bzflag icon indicating copy to clipboard operation
bzflag copied to clipboard

Consistent String packing

Open blast007 opened this issue 6 years ago • 2 comments

Currently there are no less than 6 different string packing methods inside protocol messages:

  • Fixed Size Strings
  • C style, Null Terminated variable length strings
  • C style, Non-Terminated variable length strings that use the entire buffer length
  • Pascal style variable length strings that use a byte for length
  • Pascal style variable length strings that use a unsigned short (2 bytes) for length
  • Pascal style variable length strings that use a unsigned long (4 bytes) for length

Null terminated, or Pascal Long should be the standard if it is desired for strings to be able to span multiple TCP packets (over 1020 bytes). Pascal Short is fine if every message must fit in a single packet. All strings should be UTF8 encoded.

(From @JeffM2501)

blast007 avatar May 15 '18 11:05 blast007

Here's a vote for Pascal short. :)

timriker avatar May 15 '18 15:05 timriker

The message buffer already has it's own size checking mechanism, so null terminated is viable. there is no additional error checking features provided by a separate string length.

The protocol supports messages over the size of a single packet, so short may be limiting. This may be more important if Unicode is eventually supported.

JeffM2501 avatar May 15 '18 17:05 JeffM2501