Author Topic: GNE::setGameInformation  (Read 5871 times)

Holomorph

  • User
  • *
  • Posts: 32
GNE::setGameInformation
« on: February 04, 2005, 09:54:32 PM »
It might be nice to have the version argument for this function be a float, or even a string, since in most cases versions are not integers.

Gillius

  • Administrator
  • User
  • *****
  • Posts: 147
    • http://www.gillius.org/
GNE::setGameInformation
« Reply #1 on: February 07, 2005, 10:55:35 AM »
I have two comments about this.  First off, the game version information is sent in the initial request packet, so it should be small -- a string would need to be bounded somehow.  Secondly, floats are bad because they are imprecise, espically if you have a Mac client connecting to a PC server or even AMD to Intel.

The user version field really is just treated as a block of binary data with a size of 4 bytes, as the protocol just simply compares the two values bitwise for equality.  It does not have to be an integer, even, so yes if you really wanted a float there, you can do it.  I believe the error exception for user version difference gives you back the bad version number so that you can convert to your format and compare numbers if you want.

Please note that the version there is for your network protocol version and not your game's version.  If you release two game versions V1.00 and V1.01 that are network compatible, there is no need to increase network number unless you don't want them to connect.

To suggest a good format, GNE's network number is also in the same packet in a 4-byte integer format.  Because I know how to interpret it, I can do less than and greater than comparisons for that version directly and encode that into the error code.  IIRC, GNE's format is such that the highest two bytes are major revision, then I have a byte for sub version and then the lowest byte is for a "build" type number, meaning the version number is in x.y.z format where x is from 0 to 65535, y and z are from 0 to 255., so that 2.3.12 is a valid version number as encoded in the 4-byte form.  You could use the same system in your program to encode program version numbers into the 4-byte integer format.  Note that the numbers are still comparable in this packed format.
Gillius
Gillius's Programming http://www.gillius.org/

Holomorph

  • User
  • *
  • Posts: 32
GNE::setGameInformation
« Reply #2 on: February 08, 2005, 07:19:09 PM »
ah, good, thanks for clarifying, and for the hint.