![]() |
#1 |
requires vJass
Code Moderator
|
![]() Optional add-on library: AutoEvents
AutoIndex is a very simple script to utilize. Just call GetUnitId(unit) to get get the unique value assigned to a particular unit. The GetUnitId function is extremely fast because it inlines directly to a GetUnitUserData call. AutoIndex automatically assigns an ID to each unit as it enters the map, and instantly frees that ID as the unit leaves the map. Detection of leaving units is accomplished in constant time without a periodic scan. AutoIndex uses UnitUserData by default. If something else in your map would conflict with that, you can set the UseUnitUserData configuration constant to false, and a hashtable will be used instead. Note that hashtables are about 60% slower. If you turn on debug mode, AutoIndex will be able to display several helpful error messages. The following issues will be detected:
AutoIndex provides events upon indexing or deindexing units. This effectively allows you to notice when units enter or leave the game. Also included are the AutoData, AutoCreate, and AutoDestroy modules, which allow you to fully utilize AutoIndex's enter/leave detection capabilities in conjunction with your structs. ![]() Last edited by grim001 : 02-06-2010 at 01:58 PM. |
![]() |
![]() |
Sponsored Links - Login to hide this ad! |
|
![]() |
#3 |
In Flames
Join Date: Jan 2006
Posts: 1,153
![]() |
![]() CON: you can only have 8190 units totally in your map, with regular unit-indexing, you can have 8190 indexed units in your map.
__________________This will for example index dummy units aswell, and if you got really many triggered spells in a 12 player map with lots of units/heros/whatsoever this might hit the limit... maybe this system shouldnt index dummy units (+= one dummy unitid constant ..), dunno... I would add this as an optional condition ... |
![]() |
![]() |
![]() |
#4 |
requires vJass
Code Moderator
|
![]() CON: Warcraft 3 crashed a long time before you had 8000 units in your map.
|
![]() |
![]() |
![]() |
#5 |
User
Join Date: Mar 2009
Posts: 72
![]() |
![]() In this map (look attachments)
A trigger spawn 8000 footmans, my computer don't crashed, just had some strange polys' that go away So the game don't crash before 8000 units please |
![]() |
![]() |
![]() |
#6 |
In Flames
Join Date: Jan 2006
Posts: 1,153
![]() |
![]() no problem to have 8000 dummy units ...
|
![]() |
![]() |
![]() |
#7 |
requires vJass
Code Moderator
|
![]() The answer is: no.
|
![]() |
![]() |
![]() |
#8 | |
User
Join Date: Jun 2008
Posts: 72
![]() |
![]() ^ His point was that most maps don't reach the limit so easily. In any case, couldn't struct storage space simply be increased to handle more than 8190 units? (Edit: Oops, posted a bit late. I was responding to Magissia.)
Amazingly concise for something so elaborate - great job. Quote:
Last edited by dead_or_alivex : 04-25-2009 at 03:14 AM. |
|
![]() |
![]() |
![]() |
#9 |
requires vJass
Code Moderator
|
![]() Increasing storage space would have no effect on performance except when allocating or freeing an ID. All you would have to do is add [size] next to the AutoIndex struct declaration. So it would be a great idea, except that no real map has ever, or will ever, be created that uses more than 8000 units at the same time. I'm not going to respond to any more stuff about that since it is so outlandish that it doesn't warrant discussion.
dead_or_alivex, before this I used H2I(u)-0x100000 all the time, so I think it is the next best option. But here are the downsides compared to automatic unit indexing: 1.) It is slower. 2.) It is possible to break it if handles get too high (rarely a problem in practice) 3.) It forces you to type a lot of code in every system (arrays, set/get functions, MaxHandles constant). 4.) It generates even mode code once compiled because of bigarrays. 5.) You are obligated to include a note explaining how the user should deal with the MaxHandles constant in every system. |
![]() |
![]() |
![]() |
#10 |
Dread Lord of the Cookies
Content Director
|
![]() If you're using 8000 units in a map, you're doing it wrong.
__________________Anyway...I think you should have a GetUnitId function. It'll get inlined, but it'll make it far more implementation independant, and make systems much more interoperable (which, given you can only have one unit indexing system in a map using GetUnitUserData...is incredibly important). Not using a wrapper function because you think it's cooler really doesn't cut it now that they have no performance hit and provide potentially important forward/backward compatability. |
![]() |
![]() |
![]() |
#11 | ||
Free Software Terrorist
Technical Director
|
![]() Quote:
It requires a very messed up map, but for some reason those maps are not rare. Like Griffen said, Make a GetUnit**** function thingy. Guys wanting speed can make it dependent on the UserData implementation (Err, not really, it'll get inlined) but if there was a GetUnit*** function you wouldn't have to make it dependent. You can make an AutoIndex that uses handle table, Table's only problem was the lack of auto destruction, this effectively fixes it . People that already use UserData in one of those zillion other systems could just use the Table version if they had to implement a system/spell requiring it. The rest, would still see the UserData native inlined anyway. Sounds like win-win to me... Quote:
Could just have an exceptions list/hash for typeids - assuming this problem is actually important. |
||
![]() |
![]() |
![]() |
#12 |
User
Join Date: Apr 2008
Posts: 286
![]() |
![]() I think it could make some maps really slower.
In my map for example, I've got a spell which creates 45 units per second. If you implement this library, that spell would lag, wouldn't it. Also if you don't use this a lot, it could be slower than other systems. Anyways, I am gonna do speed tests with this. |
![]() |
![]() |
![]() |
#13 | ||
Free Software Terrorist
Technical Director
|
![]() Quote:
Quote:
??? |
||
![]() |
![]() |
![]() |
#14 |
User
Join Date: Apr 2008
Posts: 286
![]() |
![]() Ok. Then I'll test this.
This seems great. |
![]() |
![]() |
![]() |
#15 | |||
requires vJass
Code Moderator
|
![]() Quote:
Quote:
So I'll make it as soon as you make Table initialize its gamecache in a struct init, otherwise it would fail on every unit entering the map or created from a a unitEntersMap method. Quote:
Last edited by grim001 : 04-25-2009 at 07:27 PM. |
|||
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
|