• 🏆 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!

[Trigger] Will this variable cause leaks or big memory dump?

Status
Not open for further replies.
Level 6
Joined
Jul 25, 2019
Messages
94
So basically, i have a trigger that when the starting shop sells a hero, it stores the hero as variable for the rest of the game since this can make triggering specific events to that 1 hero very easy.
example:

  • HeroCorruptedLord
    • Events
      • Unit - Restless Soul (strength) 0138 <gen> Sells a unit
    • Conditions
      • (Unit-type of (Sold unit)) Equal to |cffff0000C|r|cfffe0601o|r|cfffe0c02r|r|cfffe1303r|r|cfffe1a04u|r|cfffe2006p|r|cfffd2607t|r|cfffd2d08e|r|cfffd3409d|r|cfffd3a0b |r|cfffd400cL|r|cfffc470do|r|cfffc4e0er|r|cfffc5410d|r|cfffc5b11|r
    • Actions
      • Set VariableSet Hero_CorruptedLord = (Sold unit)
      • Unit - Remove Restless Soul (strength) 0138 <gen> from the game
but i also want to make a trigger that stores the same unit as a variable for the rest of the game as well, which is a variable for player checking. Example is that when the unit sells a hero, it makes the sold unit a variable called Player1Hero for the rest of the game, same for Player2Hero etc, but each hero also gets the variable for its specific kind for the rest of the game. Both of these variable attaching events happen at the same time.
My question is, does this cause leaks, can 1 unit be the target of 2 variables stored for the rest of the game and will it cause any leaks or excesive memory dump that causes DC / crash??[/trigger]
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
My question is, does this cause leaks, can 1 unit be the target of 2 variables stored for the rest of the game and will it cause any leaks or excesive memory dump that causes DC / crash??
No it will not cause any leaks. I suggest you read up what a leak is about. Variables themselves do not leak.

I think what you are after is an array of units. The index would be the owning player's slot number. This makes the assigning and retrieval logic more simple than having to deal with dedicated variables for each player.
 
A unit[] array variable can be used to store all player heroes. The player number from a player makes the index.

Event:
---- Unit Sells Unit
Action
---- Set Hero[(Player Number of (Owner of (Buying unit)))] = (Sold unit)

Then it will be that
Hero[1] -> it's Player1's hero
Hero[2] -> it's Player2's hero
...

You can read some about memory leaks here: Memory Leaks
 
Status
Not open for further replies.
Top