How to deal with unsigned data with GDScript?

RexxarRexxar Posts: 1Member

Beginner godot user, but not beginner programmer.

Long story short;
The game I'm making will be an online multiplayer, where the client connects to a dedicated server.
I've finished most of the basic client logic and asset handling, but now I'm stuck on the networking part.

How do I go about reading byte streams that contain a mixture of signed and unsigned data of varying types (bytes, shorts, etc)?
And how would I go about ensuring that the unsigned data received from the sever and then sent back isn't mangled?

The server already have a set protocol which I sadly cannot change to just use signed ints.

Is this within the capability of GDScript?


Tags :

Answers

  • wombatstampedewombatstampede Posts: 72Member

    I didn't tinker with networked gaming in Godot yet. So only some general info:

    GDScript is usually dynamically typed. If you look at the StreamPeer (see also PacketPeerStream and StreamPeerBuffer) class you'll see that this also includes unsigned ints up until 64bit.

    If you don't trust StreamPeer(Buffer) then you can also use a PoolByteArray for Data Structures and modify/build them byte by byte with own methods. Although it might be a bit tedious dealing with byte order (MSB/LSB) and it might also be a bit sub optimal performance wise.

Sign In or Register to comment.