| 06-23-2009, 06:22 AM | #1 |
I know destroying a trigger during its run will cause bugs. However, if the trigger to be destoryed has no waits or other stuff in it, can I safely destroy it in another trigger? Or should I turn it off and start an X second timer that destroys it later? How can I avoid those bugs? |
| 06-23-2009, 07:24 AM | #2 |
To be safe, just have a stack of triggers which are deleted every x seconds. (AoM and DotA do this without bugs) |
| 06-23-2009, 12:01 PM | #3 | |
We Don't Know (tm). Quote:
Probably. |
| 06-23-2009, 02:06 PM | #4 |
i think triggers bug out in association with destroys only if they are destroyed while their stuff arent completed. soooooo just wait a duration X > execution time for any trigger and destroy trigger. you would likely not be using (Polled) waits so X would prob just be 0.0; if you do use them they would likely be for low durations only so X would be ----low. JASS://uses TimerUtils globals private constant real X = 1.00 // greater than all trigger execution durations endglobals private keyword ResumeDestroyTriggerSafe function DestroyTriggerSafe takes trigger t returns nothing local timer TIM = NewTimer() call DisableTrigger(t) // so it doesnt run, anymore, as it is not meant to call SetTimerData(TIM, StoreTheTrigger(t)) //<-- i dont know: H2I() or its 1.23 equivalent or //w/e or some struct call TimerStart(TIM, X, false, function ResumeDestroyTriggerSafe) set TIM = null endfunction private function ResumeDestroyTriggerSafe takes nothing returns nothing local timer TIM = GetExpiredTimer() call DestroyTrigger(GetTheTrigger(GetTimerData(TIM))) call ReleaseTimer(TIM) set TIM = null endfunction i dont know if this is the best method or if it is even good. maybe you shouldnt be destroying triggers at all. |
| 06-23-2009, 03:35 PM | #5 | |
Quote:
I know ;) But sometimes there is just no other way to get rid of registered events. I guess I will use the timer solution. Or maybe the stack to save timer executions (less computation time ;) ) |
| 06-23-2009, 03:50 PM | #6 |
wait 60 seconds and kill it another option is not to use triggersleepaction, ever, and you don't need to worry (shouldn't) |
| 06-23-2009, 04:50 PM | #7 |
To sum common knowledge, and the content of this thread until now, you should try to do following things to be sure your dynamic triggers wont cause any bugs, most probably: - dont use any triggersleepaction (esp in the dynamic triggers, and triggers related to them) - use triggerconditions instead of triggeractions (automatically prevent the usage of triggersleepaction, and are faster) - wait some time (>60secs minimum) before you destroy them |
| 06-23-2009, 05:04 PM | #8 |
> wait 60 seconds and kill it > - wait some time (>60secs minimum) before you destroy them Why wait so much? War3 has some delayed handle recycling or what? |
| 06-23-2009, 05:05 PM | #9 | |
Do all of them and you still won't be completely sure. Quote:
You can bug triggers with just conditions fired by them. |
| 06-23-2009, 06:09 PM | #10 | |
Quote:
|
| 06-24-2009, 08:17 PM | #11 | |
Quote:
|
| 06-24-2009, 08:34 PM | #12 |
I still haven't seen any proof that DestroyTrigger related bugs actually happen if you code competently. |
| 06-25-2009, 07:15 AM | #13 | |
Quote:
I mean a trigger with just conditions fired by it can still bug when destroyed. |
