| 04-22-2007, 08:55 PM | #1 |
Hello, do you know our classic dynamic trigger usage, create trigger attach added trigger action then remove the trigger action before destroying the trigger... It seems that using conditions instead of trigger actions is much better. With the limitation your dynamic trigger won't be allowed to have waits (not that it matters at all) * conditions are faster than actions since the don't have to create a new thread. * It seems that conditions don't have to be cleaned and that DestroyTrigger would already do all the dirty work: JASS:function h2i takes handle h returns integer return h return 0 endfunction function Experiment_Child takes nothing returns boolean call DestroyTrigger(GetTriggeringTrigger()) return false endfunction globals integer max=-1 endglobals function Experiment_Main takes nothing returns boolean local trigger t=CreateTrigger() local integer k set k=h2i(t) if (max<k) then call BJDebugMsg(I2S(k)) set max=k endif call TriggerRegisterTimerEvent(t,.01,false) set k= h2i( TriggerAddCondition(t,Condition(function Experiment_Child)) ) if (max<k) then call BJDebugMsg(I2S(k)) set max=k endif set t=null return false endfunction //========================================================================== function InitTrig_Experiment takes nothing returns nothing local trigger t=CreateTrigger() call TriggerRegisterTimerEvent(t,0.015,true) call TriggerRegisterTimerEvent(t,0.02,true) call TriggerRegisterTimerEvent(t,0.035,true) call TriggerRegisterTimerEvent(t,0.04,true) call TriggerAddCondition(t,Condition(function Experiment_Main)) set t=null endfunction After 7 minutes this test won't show the expected massive increase in memory nor any increase of handle ids... ... * Theorically, conditions being implemented in a different way than actions could have a chance of not being vulnerable to our beloved chance of bug caused by DestroyTrigger() but this is just speculation and not tested. |
| 04-22-2007, 10:52 PM | #2 | |||||
It looks very interesting but I don't understand all :/. What does h2i do, to return the position in the memory, of the object handled by the parameter ? Why do you put return 0 after return h ? Can this be executed sometimes ? edit : I just read it : Quote:
Quote:
Why, when i try it, the trigger is executed only 4 times ? edit : oops sry, I checked by adding this in the main function and saw that it is executed periodicly: JASS:call BJDebugMsg(I2S(i)) //i has been added to the global variables ofc set i = i+1 On the screen is displayed : 1048673 1048676 1048677 1048679 1048680 1048682 1048683 1048685 Are these numbers the position in memory of the created triggers and their added condition ? If yes, what is the unit of these values (if there is one) and from which point of the memory does it begin ? Quote:
Quote:
Is it the same problem that causes memory leak with my monsters spawn trigger ? (cf. monster spawn leak topic) Whats does "ids" mean ? Quote:
Sorry for all these questions, but I am a noob and I don't want to stay one all my life :( |
| 04-23-2007, 02:41 AM | #3 | ||||
Quote:
Quote:
Quote:
Quote:
|
| 04-23-2007, 03:47 AM | #4 |
have similar tests been conducted with ta's? regardless, does the boolexpr added in the trigger condition not leak? even if the triggercondition itself does not |
| 04-23-2007, 03:49 AM | #5 |
Yes, and the results were the opposite |
| 04-23-2007, 08:17 AM | #6 |
Vexorian idea stealer... =) (once again) no the word "stealer" have no place here but i have/do allready use this... PS yes it does not leak ! conditions like events... |
| 04-23-2007, 01:41 PM | #7 |
I had the idea then I contacted IceFrog and it happens that he also had the same idea then he told me it seemed that conditions didn't leak then I tested and they didn't I then tested for handle ids because grim told me to. |
| 04-23-2007, 05:11 PM | #8 |
Ok, sounds good. Which ways are you planning on using this in vJass? |
| 04-23-2007, 05:13 PM | #9 |
since it doesn't rely on dynamic triggers I would say none. |
| 04-23-2007, 05:14 PM | #10 |
Thought as much. Ah well, nice find though. |
| 04-23-2007, 05:19 PM | #11 |
neat find, I will try to incorporate this into my triggering now |
| 05-12-2007, 01:40 PM | #12 |
> With the limitation your dynamic trigger won't be allowed to have waits (not that it matters at all) What are you keeping in mind ? When I use triggerSleepAction in condition function it should cause something bad or not ? I have used wait in condition function and haven' t saw nothing odd. If it causes bugs or something can we just call new function what has waits ? Example would be: JASS:function TriggerMainActions takes nothing returns nothing call TriggerSleepAction(30.) call DisplayTextToPlayer(Player(0),0.,0., "Are waits allowed when used like this ?") endfunction function ConditionFunc takes nothing returns boolean call TriggerMainActions return false endfunctin |
| 05-12-2007, 01:45 PM | #13 |
I think you may be suffering hallucinations, cause last time I checked a wait in a condition halts the thread... |
| 05-12-2007, 01:57 PM | #14 |
Maybe I'm just blunt, but I really don't see (from your example anyways) how conditions are able to replace actions. Your example confused me more than it did explain how using conditions replaces actions... |
| 05-12-2007, 01:59 PM | #15 |
You want to run code when an event is triggered, right? both conditions and actions have that skill. |
