HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Could you check some triggers for leak please?

08-19-2006, 08:10 AM#1
Soultaker
Hey guys!

I'm making a TD atm. And as you know the major triggers has to be completely leak free because they will run a thousand times..

So I would like to hear if some of you could just help me out with 2-4 triggers in my map. I can properly fix the leaks myself, I just don't know all of them.

Of course I'll give rep.

Trigger:
Move ALL
Collapse Events
Unit - A unit enters Move A 1 <gen>
Unit - A unit enters Move A 2 <gen>
Unit - A unit enters Move A 3 <gen>
Unit - A unit enters Move A 4 <gen>
Unit - A unit enters Move A 5 <gen>
Unit - A unit enters Move A 6 <gen>
Unit - A unit enters Move A 7 <gen>
Unit - A unit enters Move A 8 <gen>
Unit - A unit enters Move A 9 <gen>
Unit - A unit enters Move A 10 <gen>
Unit - A unit enters Move A 11 <gen>
Unit - A unit enters Move A 12 <gen>
Unit - A unit enters Move A 13 <gen>
Unit - A unit enters Move A 14 <gen>
Unit - A unit enters Move B 1 <gen>
Unit - A unit enters Move B 2 <gen>
Unit - A unit enters Move B 3 <gen>
Unit - A unit enters Move B 4 <gen>
Unit - A unit enters Move B 5 <gen>
Unit - A unit enters Move B 6 <gen>
Unit - A unit enters Move B 7 <gen>
Unit - A unit enters Move B 8 <gen>
Unit - A unit enters Move B 9 <gen>
Unit - A unit enters Move B 10 <gen>
Unit - A unit enters Move B 11 <gen>
Unit - A unit enters Move B 12 <gen>
Unit - A unit enters Move B 13 <gen>
Unit - A unit enters Move B 14 <gen>
Unit - A unit enters Move C 1 <gen>
Unit - A unit enters Move C 2 <gen>
Unit - A unit enters Move C 3 <gen>
Unit - A unit enters Move C 4 <gen>
Unit - A unit enters Move C 5 <gen>
Unit - A unit enters Move C 6 <gen>
Unit - A unit enters Move C 7 <gen>
Unit - A unit enters Move C 8 <gen>
Unit - A unit enters Move C 9 <gen>
Unit - A unit enters Move C 10 <gen>
Unit - A unit enters Move C 11 <gen>
Unit - A unit enters Move C 12 <gen>
Unit - A unit enters Move C 13 <gen>
Unit - A unit enters Move C 14 <gen>
Unit - A unit enters Move D 1 <gen>
Unit - A unit enters Move D 2 <gen>
Unit - A unit enters Move D 3 <gen>
Unit - A unit enters Move D 4 <gen>
Unit - A unit enters Move D 5 <gen>
Unit - A unit enters Move D 6 <gen>
Unit - A unit enters Move D 7 <gen>
Unit - A unit enters Move D 8 <gen>
Unit - A unit enters Move D 9 <gen>
Unit - A unit enters Move D 10 <gen>
Unit - A unit enters Move D 11 <gen>
Unit - A unit enters Move D 12 <gen>
Unit - A unit enters Move D 13 <gen>
Unit - A unit enters Move D 14 <gen>
Unit - A unit enters Move E 1 <gen>
Unit - A unit enters Move E 2 <gen>
Unit - A unit enters Move E 3 <gen>
Unit - A unit enters Move E 4 <gen>
Unit - A unit enters Move E 5 <gen>
Unit - A unit enters Move E 6 <gen>
Unit - A unit enters Move E 7 <gen>
Unit - A unit enters Move E 8 <gen>
Unit - A unit enters Move E 9 <gen>
Unit - A unit enters Move E 10 <gen>
Unit - A unit enters Move E 11 <gen>
Unit - A unit enters Move E 12 <gen>
Unit - A unit enters Move E 13 <gen>
Unit - A unit enters Move E 14 <gen>
Unit - A unit enters Move F 1 <gen>
Unit - A unit enters Move F 2 <gen>
Unit - A unit enters Move F 3 <gen>
Unit - A unit enters Move F 4 <gen>
Unit - A unit enters Move F 5 <gen>
Unit - A unit enters Move F 6 <gen>
Unit - A unit enters Move F 7 <gen>
Unit - A unit enters Move F 8 <gen>
Unit - A unit enters Move F 9 <gen>
Unit - A unit enters Move F 10 <gen>
Unit - A unit enters Move F 11 <gen>
Unit - A unit enters Move F 12 <gen>
Unit - A unit enters Move F 13 <gen>
Unit - A unit enters Move F 14 <gen>
Collapse Conditions
(Owner of (Triggering unit)) Equal to Player 12 (Brown)
Collapse Actions
Unit - Set the custom value of (Triggering unit) to ((Custom value of (Triggering unit)) + 1)
Set temp_point = (Point((X of Units_Move_Positions[(Custom value of (Triggering unit))]), (Y of Units_Move_Positions[(Custom value of (Triggering unit))])))
Unit - Order (Triggering unit) to Move To temp_point
Custom script: call RemoveLocation(udg_temp_point)

That's my move trigger.. I'm not sure whether the Set temp_point function leaks..

I know this next trigger might be hard to look through, but it's the same for me, so I would be very grateful if you helped me out with this.

It creates the 32 towers that you need for my map.

Trigger:
Create Setup Units
Events
Conditions
Collapse Actions
If (Player_SetUp[(Player number of System_StartUpPlayer)] Equal to 1) then do (Set temp_integer = 11) else do (Do nothing)
If (Player_SetUp[(Player number of System_StartUpPlayer)] Equal to 2) then do (Set temp_integer = 111) else do (Do nothing)
If (Player_SetUp[(Player number of System_StartUpPlayer)] Equal to 3) then do (Set temp_integer = 211) else do (Do nothing)
If (Player_SetUp[(Player number of System_StartUpPlayer)] Equal to 4) then do (Set temp_integer = 311) else do (Do nothing)
Collapse For each (Integer A) from temp_integer to (temp_integer + 77), do (Actions)
Collapse Loop - Actions
If (temp_integer Equal to 11) then do (Set temp_string = (String((Integer A)))) else do (Do nothing)
If (temp_integer Equal to 111) then do (Set temp_string = (String(((Integer A) - 100)))) else do (Do nothing)
If (temp_integer Equal to 211) then do (Set temp_string = (String(((Integer A) - 200)))) else do (Do nothing)
If (temp_integer Equal to 311) then do (Set temp_string = (String(((Integer A) - 300)))) else do (Do nothing)
Set temp_point = (Units_SpawnPoints[(6 + (Player number of System_StartUpPlayer))] offset by (((Real((Substring(temp_string, 1, 1)))) x 128.00) - 64.00) towards 90.00 degrees)
Set temp_integer2 = (Integer((Substring((Entered chat string), 2, 2))))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
temp_integer2 Less than 2
Collapse Then - Actions
Set temp_point2 = (temp_point offset by (((Real((Substring(temp_string, 2, 2)))) x 128.00) - 64.00) towards 0.00 degrees)
Collapse Else - Actions
Set temp_point2 = (temp_point offset by (((Real((Substring(temp_string, 2, 2)))) x 128.00) - 128.00) towards 0.00 degrees)
Unit - Create 1 Setup_TowerTypes[Setup_Towers[(Integer A)]] for System_StartUpPlayer at temp_point2 facing Default building facing degrees
Unit - Change color of (Last created unit) to Setup_TowerColors[Setup_Towers[(Integer A)]]
Unit - Set the custom value of (Last created unit) to (Integer A)
Custom script: call RemoveLocation(udg_temp_point)
Custom script: call RemoveLocation(udg_temp_point2)
If (Player_HasStartup[(Player number of System_StartUpPlayer)] Equal to True) then do (Skip remaining actions) else do (Do nothing)
Set Player_HasStartup[(Player number of System_StartUpPlayer)] = True
Set temp_point = (Units_SpawnPoints[(6 + (Player number of System_StartUpPlayer))] offset by (Real(Player_CC_Length[((Player number of System_StartUpPlayer) + 6)])) towards 90.00 degrees)
Set temp_point2 = (temp_point offset by (Real(Player_CC_Length[(Player number of System_StartUpPlayer)])) towards 0.00 degrees)
Unit - Create 1 Control Center for System_StartUpPlayer at temp_point2 facing 235.00 degrees
Neutral Building - Add Upgrade Aura 1 to (Last created unit) with 1 in stock and a max stock of 1
Custom script: call RemoveLocation(udg_temp_point)
Custom script: call RemoveLocation(udg_temp_point2)

Thanks you for looking through such a long post !!

- Soultaker
08-19-2006, 01:58 PM#2
Alevice
Quote:
That's my move trigger.. I'm not sure whether the Set temp_point function leaks..

Not at all. That's the point of it: The point that is about to be generated by the next function (that Point(blablah) thing) will be stored within temp-point, and not just float in the air taking valuable space.

I think many people don't really understand where do leaks come from. Someone should really write a much newbie friendly explanation of it.

Your second trigger doesn't seem to leak either. How often would that run though? Is there any chance it can run more than once at the same time? I say this because of your loop using Integer A, which is a global, and if the same trigger runs more than once in parallel, your loop will conflict a lot. It will also conflict with any other trigger running in parallel and using Integer A
08-19-2006, 02:16 PM#3
blu_da_noob
Quote:
Originally Posted by Alevice
Is there any chance it can run more than once at the same time? I say this because of your loop using Integer A, which is a global, and if the same trigger runs more than once in parallel, your loop will conflict a lot. It will also conflict with any other trigger running in parallel and using Integer A

That only applies if he uses integer A loops with waits in them.
08-19-2006, 02:20 PM#4
UnMi
Quote:
Originally Posted by Alevice
I say this because of your loop using Integer A, which is a global
You must know, Alevice, GUI is a strange thing.
The "Integer A" mentioned here is not a global integer called "A", but rather a device (Index) created by GUI to loop with. At least that's what I think, because you don't even need a global integer if you want to loop in GUI.
Collapse JASS:
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 10
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call DoSomethingWith(bj_forLoopAIndex)
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
08-19-2006, 02:24 PM#5
blu_da_noob
bj_forLoopAIndex and bj_forLoopAIndexEnd are simply globals which are defined in blizzard.j.
08-19-2006, 03:55 PM#6
Alevice
blu_da_noob is correct in both instances. I forgot about that it will truly run parallel only with waits.

Still, *I* consider it a bad practice, and would suggest using a local instead.
08-19-2006, 10:53 PM#7
Soultaker
Thank you all!

Yes, I know that the "Integer A" is global variable so all my loops with waits use my own defined globals. About the set thingy.. I wasn't sure whether it caused a leak when you use "X of point", but thanks for the explaination.

I've a lot of other triggers that needs to be checked, but they should be fine. Even if they do got a leak they will only fire about 20 times in a game anyhow..

(I repped ya Alevice)

- Soultaker