|
|
#1 |
|
User
|
To reduce the cumbersome amount of handles generated by registering a player unit event for each player, this system localizes it all and groups everything together.
This function is more than a wrapper for TriggerRegisterAnyUnitEventBJ, it is also the replacement. The API is as simple as this: JASS:call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_DEATH, function OnDeath) ... call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, function OnOrder) And the code is really this short: JASS:library RegisterPlayerUnitEvent globals private trigger array t endglobals function RegisterPlayerUnitEvent takes playerunitevent p, code c returns nothing local integer i = GetHandleId(p) if t[i] == null then set t[i] = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(t[i], p) endif call TriggerAddCondition(t[i], Filter(c)) endfunction endlibrary Last edited by Bribe : 10-26-2011 at 08:04 AM. |
|
|
|
| Sponsored Links - Login to hide this ad! |
|
|
|
|
#2 |
|
Procrastination Incarnate
Development Director
|
I'm not convinced that saving a few dozen handles is worth implementing an additional library. Sure, implementing a simple library like this is not a big deal, but neither is having a few dozen extra handles in your map. There doesn't seem to be any noticeable difference between using this library and not using it, so I don't think it meets our usefulness criterion for resources.
__________________ |
|
|
|
|
|
#3 |
|
User
|
For those who don't want the requirement but want the potential benefit could use static if's (you know those things that so many people forget even exist) and "requires optional" (something not seen nearly enough).
In terms of efficiency there is not a lot to be gained, but by saying "a few dozen" handles will be saved that is underestimating. Order events, spell events and death events are quite common among a multitude of resources, the number of handles saved can easily launch into the hundreds and larger maps even more. Surely using something like your http://www.wc3c.net/showthread.php?t=105374 is quite useful for handling that corner of the market, but this is more extensible. Last edited by Bribe : 10-08-2011 at 08:12 AM. |
|
|
|
|
|
#4 |
|
User
|
There are other things to be gained by centralizing spell events than fewer handles. It avoids running the trigger of each spell listening on that event, even if the spell has not been cast. Saving a few handles on the way is a nice bonus, but not the primary reason for such a library.
__________________ |
|
|
|
|
|
#5 |
|
User
|
Anitarf's SpellEvent could run off of this, which shows its extensibility. But the main reason to use this is to save on handle count (mostly for the RAM benefit), and I don't see how that isn't reason enough to use it.
|
|
|
|
|
|
#6 | |
|
Procrastination Incarnate
Development Director
|
Quote:
As far as other unit events go, they are not used often. "A few dozen handles" is by no means an underestimation. There is no utility in saving a few dozen handles' worth of RAM. |
|
|
|
|
|
|
#7 |
|
User
|
I am not getting your arguments, or maybe you are not getting what the community is building with their resources.
There are many playerunitevents that are not order events that are used, and used by multiple libraries like item systems, death detection, not to mention the infamous UNIT_ATTACKED that is still useful for detecting the moment the animation finishes. Hero leveling is also commonly seen lately. Saving a few dozen handles is the smallest benefit to be gained, however in many maps I've seen there is room for saving hundreds. In either case saving RAM is worth it - and I mean just for the sake of saving RAM this is worth it. Fewer handles is the lower concern although it does help if you are using something like handle ID offsetting (keeping handles as low as possible), in such a way this contributes little (but it does contribute). Last edited by Bribe : 10-10-2011 at 08:36 AM. |
|
|
|
|
|
#8 | ||||
|
Procrastination Incarnate
Development Director
|
Quote:
Quote:
Quote:
Quote:
Last edited by Anitarf : 10-11-2011 at 12:07 AM. |
||||
|
|
|
|
|
#9 |
|
User
|
Anitarf, if you were keeping up with what the wc3 community is building (I guess you won't see much action on this specific site) you wouldn't have even asked me to cough up some maps or systems.
How much RAM saving would it take to convince you of the value? Probably none at all based on your replies. If you want to talk about cost of implementation well it's the difference between typing this: JASS:local trigger t = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH) call TriggerAddAction(t, function OnDeath) set t = null JASS:call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_DEATH, function OnDeath) I'd say the cost of implementing this is in the negatives, meaning it saves time. Unless you are repairing an existing map, then you can enjoy the benefit of saving lots of bytes of text to keep the map file size down. Which is another argument all in itself. Last edited by Bribe : 10-11-2011 at 04:49 PM. |
|
|
|
|
|
#10 | ||
|
Dread Lord of the Cookies
Content Director
|
Quote:
I agree. The efficiency argument seems silly, since it isn't going to make any real difference. Not using conditions may actually make it less efficient, potentially. But this seems much more important: Quote:
I'm lazy though, and like less lines. Less lines of code is nice for readability too. Plus it cuts out a silly BJ, but I think that's just an irrational hatred of BJs (of the coding kind, anyway). |
||
|
|
|
|
|
#11 | |||
|
Procrastination Incarnate
Development Director
|
Quote:
Quote:
Quote:
JASS:static if LIBRARY_RegisterPlayerUnitEvent then call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_DEATH, function OnDeath) else local trigger t = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH) call TriggerAddAction(t, function OnDeath) endif |
|||
|
|
|
|
|
#12 |
|
User
|
Anitarf, plenty of resources use the EVENT_PLAYER_UNIT_DEATH registry (this is the most common) and I could come up with a lot of examples of many unrelated systems which have completely legitimate useage of it, and smaller numbers of various systems which use other types, however I am concerned that presenting said things is going to "do it" for you as you've made your stance pretty clear that the dozens-hundreds of saved handles implementing this does not reach your thousands-tends of thousands saved handle requirement.
That and the fact you made a pretty big point on the utility factor, which this absolutely doesn't have (offers no new functionality). I could add in some relevant functions which could enhance the features and offer more to do with it, but for now I really have other things to focus on as I completely suck at multi-tasking. You are welcome to graveyard this thing. |
|
|
|
|
|
#13 |
|
User
Join Date: May 2011
Posts: 85
![]()
|
This should be changed to use trigger conditions (just like the version on THW), as it has been show that creating boolexprs out of functions that return nothing is perfectly safe.
|
|
|
|
|
|
#14 |
|
User
|
You are right. I didn't think pJass would let that compile but I guess the "Evil Workaround" those guys were talking about is just to have a proxy take the code as an argument and then pJass is defeated.
|
|
|
|
|
|
#15 |
|
Procrastination Incarnate
Development Director
|
Well, I recently stumbled upon a similar resource that got approved in the past, so precedent says this meets our criteria for usefulness. Since this is considerably better than the old implementation I'll graveyard it and approve this.
__________________ |
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
|
Donate |