View Single Post
  #8  
Old December 16th, 2007, 03:07 PM
Agrajag's Avatar

Agrajag Agrajag is offline
Lieutenant Colonel
 
Join Date: Jul 2004
Location: Israel
Posts: 1,449
Thanks: 4
Thanked 8 Times in 2 Posts
Agrajag is on a distinguished road
Default Re: Unit Limit / Save the Megagame

Quote:
capnq said:
Quote:
Agrajag said:
Quote:
All possible unit nbrs are cycled through every turn I think.
As a hobbyist programmer:
That sounds unlikely, why would you need to access a unit number for a unit that doesn't yet exist?
I can take a guess at that.

At minimum, you have to check every unit number up to the highest one assigned so far, even if thousands of lower numbered units have already been destroyed. Renumbering the units to account for casualties would be even more time consuming than just cycling through the range.
That's almost what I said - at most you have to check every unit number up to the highest one assigned so far, so there's no reason to go beyond that and reach all the way to the unit limit.
Furthermore, I don't think there could ever be any renumbering going on because IIRC the game intentionally keeps track of dead units.
But if it didn't, renumbering would actually be a piece of cake:
When unit dies:
1) Replace unit number between current one and last one.
2) "Kill" the dead unit that's now at the end.
And if renumbering is impossible due to engine constraints (for example, if a global spell remembers that it has been cast by unit #n and not the other way around), you could still reuse old numbers by merely making dead units "inactive" and whenever a new unit is created it can "steal" the dead unit's number.
__________________
I'm in the IDF. (So any new reply by me is a very rare event.)
Reply With Quote