1. Head to the 33rd Modeling Contest Poll and drink to your heart's desire.
    Dismiss Notice
  2. Choose your means of doom in the 17th Mini Mapping Contest Poll.
    Dismiss Notice
  3. A slave to two rhythms, the 22nd Terraining Contest is here.
    Dismiss Notice
  4. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  5. The die is cast - the 6th Melee Mapping Contest results have been announced. Onward to the Hive Cup!
    Dismiss Notice
  6. The glory of the 20th Icon Contest is yours for the taking!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[JASS] What to do with triggers?

Discussion in 'Triggers & Scripts' started by Marcelo Hossomi, Feb 18, 2009.

  1. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,104
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    The problem with trigger destruction is a handle index recycle bug which can lead to 2 objects having the same hande (and a crash). Although one really should not fear it, it is advisable to keep the ammount of trigger destruction to a minimal. In damage detection systems, for example, you can reuse one trigger for multiple units before destruction instead of 1 trigger per unit.

    This bug does exist, and it mostly causes crashes. However I would say the failed displacement bug is a much more common cause of crashes.
     
  2. Dynasti

    Dynasti

    Joined:
    Oct 18, 2007
    Messages:
    871
    Resources:
    4
    Maps:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    4
    If you cannot reset a trigger, what does this native then?

    Code (vJASS):
    native ResetTrigger takes trigger trg returns nothing
     
  3. RolePlaynGamer

    RolePlaynGamer

    Joined:
    Apr 5, 2008
    Messages:
    473
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Nothing. It sucks, as it's a very useful function.
     
  4. Eccho

    Eccho

    Joined:
    Nov 29, 2006
    Messages:
    2,297
    Resources:
    2
    Spells:
    2
    Resources:
    2
    ResetTrigger is a combination of removing the actions and conditions from the trigger. It does not remove the events :7
     
  5. RolePlaynGamer

    RolePlaynGamer

    Joined:
    Apr 5, 2008
    Messages:
    473
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Are you sure? I tried playing with it a while back, and I remeber it didn't do anything. It was more than a year ago, so perhaps my memory is not correct. I'll test it again in a moment...
     
  6. Eccho

    Eccho

    Joined:
    Nov 29, 2006
    Messages:
    2,297
    Resources:
    2
    Spells:
    2
    Resources:
    2
    Well, I found a thread on wc3c where it has been discussed. You can read about it here
     
  7. RolePlaynGamer

    RolePlaynGamer

    Joined:
    Apr 5, 2008
    Messages:
    473
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    I just tested, and it seems that ResetTrigger doesn't do anything. I tried with both triggercondition's and triggeraction's. TriggerClearConditions and TriggerClearActions worked fine, but from reading the thread you linked, it seems that they still leak when cleared.
    Perhaps ResetTrigger resets evaluate/execute count?

    Test Code
    Code (vJASS):

    scope ResetTriggerTest
       
        globals
            public trigger CheckTrig
           
            public trigger TestTrig
        endglobals

    private function check takes nothing returns boolean
      call BJDebugMsg("Trigger is running")
      return false
    endfunction

    private function test takes nothing returns boolean
      call ResetTrigger(CheckTrig)
      //call TriggerClearActions(CheckTrig)
      //call TriggerClearConditions(CheckTrig)
      call BJDebugMsg("Trigger reset")
      return false
    endfunction

    public function InitTrig takes nothing returns nothing
      set CheckTrig = CreateTrigger()
      call TriggerRegisterPlayerEvent(CheckTrig, Player(0), EVENT_PLAYER_END_CINEMATIC)
      call TriggerAddCondition(CheckTrig, Condition(function check))
      //call TriggerAddAction(CheckTrig, function check)
     
      set TestTrig = CreateTrigger()
      call TriggerRegisterPlayerChatEvent(TestTrig, Player(0), "test", false)
      call TriggerAddCondition(TestTrig, Condition(function test))
    endfunction
    endscope
     
  8. Eccho

    Eccho

    Joined:
    Nov 29, 2006
    Messages:
    2,297
    Resources:
    2
    Spells:
    2
    Resources:
    2
    yes, someone was saying that in the link I pasted to you. That was what I meant actually.