• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Safely unregistering dynamically created triggers

Status
Not open for further replies.
Level 3
Joined
Aug 4, 2012
Messages
22
Ok. Here's the situation. So I'm creating units and I need to attach "RegisterUnitInRange" events dynamically to these units. So I'm using a snippet from here to accomplish that.

That part is simple. These created units are removed after sometime. So I think to myself, I should probably unregister the events before removing the units from the map.

But I remembered that destroying dynamic triggers can sometime cause handle corruption which can lead to fatals etc. And UnregisterUnitInRangeEvent in the above snippet does utilize destroytrigger for cleaning up purposes.

So how should I handle this situation? do I:

  1. Let the triggers leak?
  2. Unregister the event anyway?
 
The handle stack corruption bug relates specifically to DestroyTrigger() when used alongside TriggerSleepAction().
http://www.wc3c.net/showpost.php?p=1132590&postcount=5

Otherwise, as far as we know it is safe. In this case, it would make sense to unregister the event using UnregisterUnitInRangeEvent (in that system). You don't know how many event you could be making--it could be just 1. Or it could be 10000 over the course of the map. Just to be safe (and memory efficient), you should clear them. :)
 
Status
Not open for further replies.
Top