Gillius's Programming Forums

Programming => GNE Library => Topic started by: Holomorph on February 04, 2005, 09:54:32 PM

Title: GNE::setGameInformation
Post by: Holomorph 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.
Title: GNE::setGameInformation
Post by: Gillius 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.
Title: GNE::setGameInformation
Post by: Holomorph on February 08, 2005, 07:19:09 PM
ah, good, thanks for clarifying, and for the hint.