The online racing simulator
Maximum PLID and UCID values
(4 posts, started )
Maximum PLID and UCID values
Hi. In one of my tests I've come to need to track and understand a little PLIDs and UCIDs.

As I'm not going to have AI cars, I'll I have to do is keep a static array that links UCIDs and PLIDs. But I''d like to know what should be the size of that array, and that depends on the maximum UCID value.

Let's say I have this array:
byte PLIDS[47];

(Using C++)

I've used 47 thinking that UCIDs keep it at the minimum possible values, and considering there is a maximum of 47 slots (connections) including spectators.

I use the UCID as the index for the array, and assign to it the corresponding PLID value. But if I ever get an UCID greater than 46 that will produce a violation.
#2 - Stuff
Instead of making a fixed array why not use a STL container like a list, map or something else? Info here. And instead of storing UCIDs and PLIDs separate, I'd make a "player" map and store both in there. One central place to keep all people organized for lookups when a packet arrives.

But, if you have to use an array for some reason look into dynamic memory. (i.e. use a pointer to point to a resized array). Some info here.

#3 - nikka
use 255 to be on the safe side. At least previous versions could have ucid greater than 47, maybe that is fixed now, but I always use 255 just to be sure.
The memory range for the UCID and PLID allowed by the data type is 0 to 255. So it would be a safe bet to handle it that way.

Maximum PLID and UCID values
(4 posts, started )
FGED GREDG RDFGDR GSFDG