Valhalla Legends Forums Archive | Battle.net Bot Development | Warcraft 3 Object IDs

AuthorMessageTime
Strilanc
When communicating in multiplayer, or saving to a replay, the objects (units, destructibles, items, etc) in a wc3 game are referred to by an id number. Duh. It seems to be allocated and freed, pretty simple. You can see it in any of the order or selection actions.

The mystery is that the id is always followed by a second value, which I'll just call id2 (since it seems to be unique per object). All objects created at game init have id = id2. id2 seems to increase with time and with the number of ids. Late in the game a typical id2 for new units is in the hundred thousands whereas the id stays relatively stable due to units dying and such. id2 also seems to increase as more ids are allocated. But, most confusing of all, it doesn't strictly increase. It goes up and down over the short term.

So, the question is: what is this value? What information is the primary id not specifying that this weird secondary one specifies? Why does it increase over the long term? Is it just there to screw with my mind?
September 1, 2009, 3:51 PM
Myndfyr
In what conditions does it decrease?  For instance, if I respawn a hero, does it really decrease, or are we seeing the recycling of a unit ID?
September 1, 2009, 7:40 PM
Strilanc
I created a test map which created 5 peasants, waited 5 seconds, removed the peasants, waited 5 seconds, repeat.

I selected the peasants to get their IDs from the selection action data, and noted how the IDs change.

The primary id stayed between 900 and 1000, even after I let the map run for 20 minutes or so. The secondary id started less than 10 away from the primary id, but after 20 minutes it was in the tens of thousands. But during each create-5-peasants cycle it was not strictly increasing.

...

unless

...

Maybe it *was* strictly increasing, but it simply ordered the peasants by primary id and so it only looked like it was decreasing.

...

I need to test something.
September 1, 2009, 8:01 PM
Strilanc
Alright, now it looks like id2 is a strictly increasing index while id1 is an allocated index. Any ideas why they would use both?
September 1, 2009, 8:08 PM
Myndfyr
[quote author=Strilanc link=topic=18051.msg183320#msg183320 date=1251835700]
Alright, now it looks like id2 is a strictly increasing index while id1 is an allocated index. Any ideas why they would use both?
[/quote]

id1 could be something related to the unit ID relative to the player, or the unit prototype ID (e.g. "human peasant")?
September 1, 2009, 8:25 PM
Strilanc
No, the ids are unique to each instance of an object. Also, the type would presumably be part of the information the primary id points to.
September 1, 2009, 8:40 PM
Strilanc
My current theory:
- The allocated id is for fast-access (eg. array storage). The counter id would require a tree or other non-constant-time structure.
- The counter id is for uniqueness. The allocated id could be reassigned between the time a player issues an order and the host receives the order.
September 1, 2009, 10:35 PM

Search