Snippet Advent

Bribe

vJass errors are legion
Reaction score
67
Every one of your comments shows you just don't get how this works.

1. The first trigger is for storing static codes used by "register". It is attached to the event itself and this trigger can have many conditions attached to it.

2. The other triggers are dynamic, with just one condition each.

3. registerEx returns an integer which represents the registry that was just made.

4. unregister takes that integer and disassembles that registry.

The typecast of "Advent" specifically refers to the parent node that was made via the "create" method. It does not refer to the child-nodes returned by "registerEx".
 

Dirac

22710180
Reaction score
147
No Bribe i already knew the 4 points you stated. And i fully knew what your intentions were (about the first trigger being the one with many conditions and the other's having only one) And i knew this because i read the code, not because i'm trying to prove you wrong.
What you're missing is that it doesn't have to be that way.
My way you can make every "node" have many conditions if you want, the sole action of using registerEx tells the system that this registration fires at the same time the head does.
It's like a circular linked list of triggers.
However each node should be fully manipulable and it also should be removed from the list it belongs without mentioning the head whatsoever, because after all it would make no sense to register the head from itself ([ljass]call this.unregister(this)[/ljass])
The deallocate method should be like the one my linked list has, yes it forces to recycle triggers, but that doesn't cause that much damage. (IMO you should avoid loops whenever you can)
Conclusion, every node should be an Advent, apart from the nodes within it's range
Forcing the user to attach data himself makes thing only more complicate, you're doing this from the idea that every advent could have more than data attachment, and why should it?
Instead of letting the user know which Advent is the one firing this function (when there's no need at all) through the "reg" var, have every Advent store it's own "data" integer var.
 

Bribe

vJass errors are legion
Reaction score
67
I could add a regData member but what if the user wants to attach other things like units, other types, multiple variables, etc? I get that it can save arrays if the user wants it but if the user doesn't want it he must suffer an additional array (which I don't honestly think is enough of a problem for me to not do it).

Why would someone want to multi-register a dynamic sub-trigger of the Advent? I prefer keeping it as integers so the user doesn't do something screwy like firing a node instead of a proper Advent.

Recycling triggers is possible but in reality what's there to lose in destroying them and keeping the RAM/handle ID stack low? The two latter benefits (doing it my way) the user very nicely.

The Advent sharing identity with its nodes doesn't make sense. You create an Advent (say, unit indexed or unit damaged), then register some attachment functions to that Advent. You don't register attachment functions to attachment functions >>
 

Dirac

22710180
Reaction score
147
Just an [ljass]integer data[/ljass] would suffice instead of having to create lots of arrays for every time you want to attach data to advents (like the way you suggest on your documentation of having [ljass]integer AdvData[Advent.registerEx][/ljass] kind of stuff)
If you were using a circular list you could fire nodes and nothing would go wrong using this way
JASS:
local integer exit=this
loop
    call TriggerEvaluate(this)
    set this=next
    exitwhen this==exit
endloop

It wouldn't cause any issues and would provide even more flexibility (i need it for my damage library)
If you want to destroy triggers you might as well loop through the list using the loop above and then flush the list.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top