• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Snippet] Trigger

Added enabled

Fixed requirements list

edit
Another update

Added 2 new methods + specified what each method does
JASS:
*           method clear takes nothing returns nothing
*               -   clears expressions
*           method clearReferences takes nothing returns nothing
*               -   clears trigger references
*           method clearBackReferences takes nothing returns nothing
*               -   removes references for all triggers referencing this trigger
 
Trigger may have nulls in it and creates more malformed trees than BooleanExpression by itself does (due to refs etc). Or(null) performs more slowly than TriggerAddCondition(null).

If you compare BoolanExpression to a trigger, then u'll see the dif ;).

edit
Even in the case of having nulls, this still performs close to a trigger with trigger conditions of nulls. The pros of being able to reference triggers and remove trigger conditions = awesome. Furthermore, it still always performs faster than TriggerExecute.
 
Level 14
Joined
Dec 12, 2012
Messages
1,007
Alright, I managed to set up an appropriate Benchmark. I measured a difference of ~10 fps in advantage to this system.
This seems to be really awesome in terms of performance.

One drawback is you can't register more than 4096 callback functions in total. You should catch that with ErrorMessage.

EDIT:
It seems that this is bugged if the amount of registered events gets close to 4096. I registered 4050 onDamage handlers
but only 4033 got fired. It seems some handlers got lost.
 
Updated map to have latest Boolean Expression library.

The updates to BooleanExpression reduce operations when building triggers and increase performance when running triggers.

I highly recommend that you get the update.


Trigger registers null boolean expressions in order to hold positions. The new BooleanExpression library will not include these null expressions in the final output. A null expression does reduce trigger speed. As these null expressions are no longer included in the final output, Trigger will get a speed boost.
 
Ok everyone, sorry about this, but the BooleanExpression update wrecked Trigger, lol.

I'll be updating Trigger to work with the new behavior of BooleanExpression.

edit
Fixed BooleanExpression (the new builder was bugged), but Trigger is still having problems >.<.

Where t1 is empty, t2 has a function, and t3 has a function

t1.reference(t2)
t2.reference(t3)

that only runs t2

edit
I managed to reproduce the problem exactly only using BooleanExpression and the shifting algorithm from Trigger. It appears that the shifting algorithm in Trigger is bad. I'll work on a fix. Not sure what's wrong with it, but I'll try to figure it out. It's only 3 lines, lolz.

edit
And fixed!! : D

Wow, that was crazy to debug

edit
*rage*

I put in a fail-safe way to stop these boolean expressions from destroying themselves!! >;o, rawr

Added new methods to TriggerCondition and TriggerReference

edit
yet another update, included a couple of debug checks
 
Last edited:
Level 19
Joined
Mar 18, 2012
Messages
1,716
This worked without throwing an error. But I'm not sure if I double destroy the BooleanExpression here:
call myTrigger.clear() call myExpr[this].destroy()


JASS:
private struct myStruct extends array
        implement Alloc
        
        private static Table table
        readonly static Trigger myTrigger
        readonly static BooleanExpression array myExpr

    private static method run takes nothing returns boolean
        local integer id = //1, 2, Get any Integer used in method xy
        local thistype this
        set this = table[id]
        call myTrigger.register(expr[this].expression)
        call myTrigger.fire()
        call myTrigger.clear()
        call myExpr[this].destroy()
        //call this.deallocate()
        return false
    endmethod

    private static method xy takes integer id, boolexpr expr returns nothing
        local thistype this = allocate()
        set table[id] = this
        set myExpr[this] = BooleanExpression.create()
        call myExpr[this].register(expr)
    endmethod
    
    private static method onInit takes nothing returns nothing
        set table = Table.create()
        set myTrigger = Trigger.create()
        call xy(1, Condition(function anyStruct.fire))
        call xy(2, Condition(function anyStruct.fire2))
    endmethod
    
endstruct
 
Level 19
Joined
Mar 18, 2012
Messages
1,716
Ok I got it. Then I will store the boolexpr in table and register it to one BooleanExpression instead of using an array and clear it afterwards.

Looks like this now, and throws no error and is working.

EDIT:
JASS:
call myExpr.register(tb.boolexpr[id])
call myTrigger.register(myExpr.expression)
call myTrigger.fire()
call myExpr.clear()
call myTrigger.clear()
 
Top