• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Why does this trigger leak?

Status
Not open for further replies.
Level 2
Joined
Dec 8, 2005
Messages
8
Yo,

i try to create all my maps with no leaks at all. (yes jass would be better to do that but i seem to get it mostly to work in GUI aswell)

Its for an footiewars iam working on, i create an location in the map initilization using this trigger:

Code:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
        ((Player((Integer A))) slot status)  ==  Is unused
    Then - Actions
        Set player_units[(Integer A)] = (Units owned by (Player((Integer A))))
        Unit Group - Pick every unit in player_units[(Integer A)] and do (Actions)
            Loop - Actions
                Unit - Remove (Picked unit) from the game
        Unit Group - Destroy player_units[(Integer A)]
    Else - Actions
        Player - Add 650 to (Player((Integer A))) Current gold
        [b]Set player_main_location[(Integer A)] = (Position of (Find the first unit next to (Center of (Playable map area)) that matches (((Unit-type of (Matching unit))  ==  Basic Building (Tier 0)) and ((Owner of (Matching unit))  ==  (Player((Integer A)))))))[/b]
        Unit - Create 1 hero_types[(Random integer number between 1 and 16)] for (Player((Integer A))) at player_main_location[(Integer A)] facing Default building facing (270.0) degrees
        Hero - Give (Last created unit) a Scroll of Town Portal in slot 1
        Hero - Give (Last created unit) a Wiebbe's necklace or power in slot 0

and then mostly the bold part. Iam not sure if this would leak as it doesnt use an unitgroup but an unit.

Then every X seconds i run this trigger:

Code:
Spawn Player 1
    Events
        Time - player_spawn_timer[1] expires
    Conditions
    Actions
        Set unit_spawn_group[1] = (Units owned by Player 1 (Red))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in unit_spawn_group[1])  >  100
            Then - Actions
                Game - Display to Player Group - Player 1 (Red) the text: |cFFFF0000You have ...
            Else - Actions
               [b]Unit - Create 1 player_main_spawn[1] for Player 1 (Red) at player_main_location[1] facing Default building facing (270.0) degrees[/b]
        Unit Group - Destroy unit_spawn_group[1]

At the bold part i create my unit. Now when calling this trigger does it leak? Since i dont destroy my location i thought it might leak but doing the location creating part everyone time might be a tad slower?

(edit it seems the bold part doesnt work when i use
Code:
 so check the parts with [b] infron of them)
 
Level 2
Joined
Aug 10, 2005
Messages
29
It might be a good idea to set your locations and player groups to null after you are done with them. You are using global values so I don't think they will leak... Usually leaking comes from creating local values and not destroying them. Just null them out after you are finished to be safe.
 
Level 7
Joined
Jul 30, 2004
Messages
451
actually sven, thats not true, leaks come from reference variables (local or global) that still contain their pointer to data but have no way of being referenced anymore

**call DestroyGroup(*unitgroup variable*) once you are done with it (before you set it to a new value)
call RemoveLocation(*point varaible*) once your are done with the point (before its set to another new point)

** - i don't know if this is the exact function name



seeing as how you always keep reusing the same point for spawning, and its only set once in initialization, that is fine

and seeing as how you appear to be using a non-standard function "Unit Group - Destroy" (which i assume comes from some kinda non-vanilla editor, i prefer to stick with the basics) the unit groups should be ok
 
Status
Not open for further replies.
Top