- Joined
- Jun 5, 2008
- Messages
- 2,573
So currently i have a system using trackables in a way that you can attach any amount of triggers in any order to a trackables hit and track event.
Once it's event fires it loops through the triggers, passes needed data and then calls TriggerExecute(trig).
Currently it looks something like this:
And in the executed trigger action:
I am using this to emulate a player firing an event for the trackable.
The system needs to be GUI friendly, that is the reason i am using lists of triggers to be executed, that way the user can just use custom scripts to load data for that trigger execution and then continue to use GUI.
The question is, does this suffer from race condition in any way, is it safe and would just setting a global be safe enough to not use the trigger execution trick with hashtable in a multiplayer enviorement (edge cases when two users click on a trackable which has the same triggers linked)
Once it's event fires it loops through the triggers, passes needed data and then calls TriggerExecute(trig).
Currently it looks something like this:
JASS:
method onHit takes nothing returns nothing
local integer i = 0
local trigger t
loop
exitwhen i >= triggerCount
set t = LoadTriggerHandle(triggerData, this, i)
call SaveInteger( dataTable, GetHandleId(t), GetTriggerExecCount(t)+1, playerId)
call TriggerExecute(t)
set i = i +1
endloop
endmethod
And in the executed trigger action:
JASS:
local trigger t = GetTriggeringTrigger()
local integer playerId = LoadInteger( dataTable, GetHandleId(t), GetTriggerExecCount(t) )
I am using this to emulate a player firing an event for the trackable.
The system needs to be GUI friendly, that is the reason i am using lists of triggers to be executed, that way the user can just use custom scripts to load data for that trigger execution and then continue to use GUI.
The question is, does this suffer from race condition in any way, is it safe and would just setting a global be safe enough to not use the trigger execution trick with hashtable in a multiplayer enviorement (edge cases when two users click on a trackable which has the same triggers linked)