HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

War3err doesn't like this trigger.

03-27-2007, 03:13 AM#1
Moss
Why does this trigger cause "double free of group" and "double free of location" errors?

Trigger:
Waypoint Reached
Events
Collapse Conditions
((Triggering unit) is in Units) Equal to True
Collapse Actions
Set u = (Triggering unit)
Set p = (Position of u)
Set ug = (Units within 512.00 of p matching (((Unit-type of (Matching unit)) Equal to Power Node) and (((Owner of (Matching unit)) Not equal to Neutral Hostile) and (((Matching unit) belongs to an enemy of (Owner of u)) Equal to True))))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Number of units in ug) Equal to 1
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Random unit from ug) is in rootnodes) Equal to True
(Mana of (Random unit from ug)) Less than or equal to 15.00
Collapse Then - Actions
Unit - Set mana of (Random unit from ug) to 10.00
Custom script: call RemoveLocation( GetAttachedLoc(udg_u, "dest") )
Custom script: call CleanAttachedVars(udg_u)
Unit - Remove u from the game
Collapse Else - Actions
Trigger - Run Detonate <gen> (checking conditions)
Collapse Else - Actions
Trigger - Run Set Next Waypoint <gen> (ignoring conditions)
Custom script: call RemoveLocation( udg_p )
Custom script: call DestroyGroup( udg_ug )
03-27-2007, 03:19 AM#2
Vexorian
If it was just double free of location then you could blame the handle var stuff

But of group? The only explanation would be that something is really messed up in your map.
03-28-2007, 09:07 PM#3
Moss
In hindsight it is obvious but I am still not so smart in understanding the way triggers get executed and I had to stare at this for awhile.

The problem is that the "Set Next Waypoint" and "Detonate" triggers that get called by this function use the ug and p global variables themselves so those triggers get called, execute, overwrite the variables causing the other ones to leak and then remove the new group and location then come back to the original trigger and try removing the location and group again. Correct me if I am wrong in this understanding but I don't get those error messages anymore when I made sure to remove the location after the group is made and remove the group inside the if statement just before the triggers get called.

I should really just convert all my spawned creep triggers to jass functions and use local variables I suppose.
03-28-2007, 11:10 PM#4
Vexorian
That's a good point, many guys think they can just use global variables like that when it is not the case, things like running another trigger may cause conflicts, but also some times if you do something to trigger another trigger.