From: Jason <jas...@ch...> - 2005-02-25 19:02:22
|
Ok I've been thinking this and looking into the code again. The code basicly sets the current master unit id based on when a unit loads. so when the server reboots all units in bays load up and if their id is greater then or equal to the master unit id then their id+1 gets set as the master unit id. Now with Pfiles that means we don't always get the highest unit it. So say player A has unit id 1000 the server resets the highest id in the house bays is 990 player B logs in the highest unit id he has is 999 the new master id gets set to 1000 player by buys a new unit its given unit id 1000. Then when player A logs back in he has a unit with a dup id. I be that is what has been causing alot of the problems with exp and levels not getting saved. I bet there are alot of dup unit ids out there because of this code. first thing we might want to do is add an admin command to check a player for dup unit ids this would be a bitch as it would have to go through all house queues and then all player queues. Definatley could be memory/cpu intensive. Even if we do add the vector to keep track of unused ids, we'd still have to save it to a file so when the server reboots everything is kosher, there is a chance of duplicate id's being added to a vector unless vectors weed out dup key I don't know do they? > > From: Jason <jas...@ch...> > Date: 2005/02/25 Fri AM 10:28:47 PST > To: <mek...@li...> > Subject: [mekwars-developers] Problems with Unit id's > > I was looking at the code today and found a potential problem > > There is a master unit id var which is an int. When ever a new unit id is required this master id is incremented and returned. Now a signed int, which this var is, has a max of 32k so once you get 32k unit id's out there it'll either flip to -32k flip to 0 or blow up. From what I've seen on fishes server he might just get there sooner then anyone else. I'm not sure why this never happened on LV1 > > Solutions: > > One solution would be to store all unit ids from units that where scrapped/destoyed into a vector and pull from this vector until its empty then once it is increment the master id. > > Main problem with this is what happens with users that log in and then don't play anymore they'll have unit id's trapped. Best solution is to have a purge option that would purge based on date of the Pfile. It would search the folder look at the dates of each file and any one older then the days enter would be loaded have all their units scrapped and unenrolled. > > Let me know what you think. |