Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2000:
[Freeciv-Dev] The implementation if freeciv ID numbers
Home

[Freeciv-Dev] The implementation if freeciv ID numbers

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] The implementation if freeciv ID numbers
From: Thue Janus Kristensen <thue@xxxxxxx>
Date: Sat, 18 Mar 2000 20:10:44 +0100

Currently freeciv has an "unsigned char used_ids[8192];" bitvector with a bit
per 65536 possible id number. Every time a unit or city is
allocated/deallocated the id bit is set/reset with with alloc_id/dealloc_id.
This is potentially smart since it means you can use an unsigned short in the
packets and still be sure to not run out of ID numbers, saving some bandwith.
This allows ~65000 units+cities simultaneously. (and goes into infinete loop of
that number is reached, but I doubt it will be)

Only all the packets use ints for ID's... DUH.

So before I begin to pile more use if the current ID system on top, is there
any reason why we couldn't just use an 32-bit int counting ever upwards (well,
that would limit the number of units in the game to 4294967296 ever). My code
gets slightly ugly with the with the current implementation, as it involves the
client knowning potentially dead cities, whose ID could get reallocated(ouch).

It would of course be a problem if freeciv were compiled on a 16 bit platform
(where an int would be 16 bit). Then the current implementation makes sence. Is
this the case/is there plans to do that? The network bandwidth advantage
of actually making the ID ints unsigned shorts instead may also be worthwhile.

-Thue



[Prev in Thread] Current Thread [Next in Thread]