• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

The shit is all on for me (Locaiton Leaks)

Status
Not open for further replies.

hdm

hdm

Level 9
Joined
Nov 19, 2011
Messages
384
I'm having problems with a Location Leak. I know how to fix them, but, let me explain:

I made a map with a lot of... "Stages". These stages have regions (for the spawn for the hero, for the respawn when he dies, etc). At the beginning of the game, the Player must chose the Stage to start. So "what did I do ?" you may ask. I just created a single Trigger that the event is the stage selection and, in the actions, a Variable for a Location, called Region_Start and, depending on the Stage selected, this variable would turn into the region associated with the Stage. For example: "Ice Stage" has the region 001 for spawn/respawn. When you select "Ice Stage", the "Region_Start" is set to region 001 (the region in the Ice Stage for spawn/respawn).
  • Ice Stage
    • Events
      • Dialog - A dialog button is clicked for Dialogue_Box
    • Conditions
      • (Clicked dialog button) Equal to Dialogue_buttons[1]
    • Actions
      • Set Region_Start = Random Point in Region 001 <gen>
Another example, select "Fire Stage" the "Region_Start" is set to region 002 (the Region in the Fire Stage for spawn/respawn).

  • Fire Stage
    • Events
      • Dialog - A dialog button is clicked for Dialogue_Box
    • Conditions
      • (Clicked dialog button) Equal to Dialogue_buttons[2]
    • Actions
      • Set Region_Start = Random Point in Region 002 <gen>
Till there, Ok. I have 2 systems in my map, one for Spawn (once you select the hero in the hero tarven you're moved to the current Region_Start) and other for respawn (you die, respawn in the current Region_Start), both in different Triggers. The question now, how to remove this Location (for prevent leaks) ? I mean, if I remove it in one trigger, all the others are fucked because there will be no more Region_Start, and If I remove it in all triggers, man, it's all damned. Any way I can fix this ? The leaks are in the Spawn/Respawn triggers, because there is

"Unit is sold, move unit to Region_Start" - Spawn
"Revive Hero Insantly at Region_Start" - Respawn

How can I destroy them ? RemoveLocation in any of the triggers will mess with everything, the game wont know anymore which Location is the Region_Start and the hero will, possibly, not respawn or not spawn. Wont it ?
 

hdm

hdm

Level 9
Joined
Nov 19, 2011
Messages
384
But anyway, if I remove the Location they wont respawn anymore. The Locations are only set once in the game, when the player selects the stage. Commonly these locations are created in one trigger and removed in the same trigger, there is a kind of cycle, create and destroy. My location is only created when the Button in the Box is selected.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
It's not a leak then, you don't need to remove it since you re-use it. Don't worry about referencing/using (reference leaks) it on another trigger, it doesn't leak since GUI uses global variables.
 
  • Like
Reactions: hdm

hdm

hdm

Level 9
Joined
Nov 19, 2011
Messages
384
U sure ? The Leak tester (hivework) says that the only two leaks in the map are these.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
I don't know anything about the leak tester, but I am sure that it isn't a leak, taking into consideration the description you have provided.
 
Level 17
Joined
Mar 21, 2011
Messages
1,597
you shouldnt use the leak tester.
look:
you use a variable just like TempPoint (location variable) in your trigger
TempPoint = Position of Unit
now, if you use that TempPoint again (in the same trigger or another), you cannot remove the "old" TempPoint anymore, its lost and is a leak. thats why you do that:
Trigger1:
TempPoint = Position of Unit
call RemoveLocation (udg_TempPoint)
....
Trigger2:
TempPoint = Position of Unit
call RemoveLocation (udg_TempPoint)

if you set a point like you did:
Point1 = Center of Map
as you wont change the variable to something else, you do not need to remove it.

i know my explanation sucks a bit but well, i tried :D
just remember:
variables where you change its value --> Remove it
variables that have a static value --> dont remove it
 
  • Like
Reactions: hdm
Level 25
Joined
Sep 26, 2009
Messages
2,378
memory leak is a piece of memory that has no more use to you and you lost all reference to it.
You hold reference to locations via variables (there's no better way how to catch them than when you create them).

Since those two locations are useful to you the whole time, they cannot be considered memory leaks.
They would become memory leaks only if you saved something else in those variables and didn't remove those locations first.
 
Status
Not open for further replies.
Top