Triggers - Memory Leaks and Custom Scripts

emjlr3

Change can be a good thing
Reaction score
395
no need to destroy variables that never leave

for instance, playable map area

however, if you create a new rect, and point it to the playable map area, well now you have a new rect that may need to be destoroyed later
 

TheLegend

New Member
Reaction score
10
I have a big problem with this line here:
Trigger:
  • Trigger
    • set tempforce = (All Players)
    • ...
    • Custom script: call DestroyForce( udg_tempforce )

cause when I call it all the Forces I create later dont seem to work. How do I know... well first of all only the first DisplayText works while all others fail (do nothing) as like the call DestroyForce deletes the REAl force and not my Force Variable. How do i fix this so once another trigger is run this works again
 

TheLegend

New Member
Reaction score
10
...why? Oh you mean only to use this antileak on PlayerGroup(Triggering player) But wont it make the same mistake like with All Players.
I mean if it deletes it wont it delete the Triggering Player's force too (I want to use it later too...)
 

Laiev

Hey Listen!!
Reaction score
188
'cuz if you delete it, everything involving '(All Players)' will stop to work, because the (All Players) don't exist anymore
 

TheLegend

New Member
Reaction score
10
not nice... ill leave this leak in the map :)... its safer. My map is too big to allow myself to make a mistake like that, i wont be able to find it. Thanx for the info
 

Laiev

Hey Listen!!
Reaction score
188
only use [ljass]DestroyForce(force)[/ljass] if you use [ljass]CreateForce()[/ljass]
 

Bribe

vJass errors are legion
Reaction score
67
(All players) does not leak, so it is not "leaving a leak in your map". There are two main types of object to consider:

1. An object that exists perpetually; (All Players) is one of these. So is (Playable map area). Also, converting player to force (if you know the index of the player, that is) is another perpetually-existing object that should not be removed.

2. A dynamic object that gets created and destroyed throughout the game. (Enemies of (Triggering player)) is one of these. So is (Entire map). Converting player to force if you don't know the index of the player will cause a new force to be created and leaked.
 

Bobby

New Member
Reaction score
0
problem

Hi everyone!

I'm having soem troubles with a few of the triggers I made in my new map. They look like this:

Ereignisse:

Zeit - Every 1 second of game time

Bedingungen:

Aktionen:

set TempBlauRunner = (units owned by player 2 (blue) matching (((Unit-type of (matching unit)) gleich Runner) and ((custom value of (matching unit)) gleich 0)))

If (All conditions are true) then do (then actions) else do (else actions)
If: custom value of unit gleich 0​
Then do: Pick every unit in TempBlauRunner and order (picked unit) to...​
custom script call DestroyGroup(udg_TempBlauRunner)

So the trigger itself works well, but it seems to cause leaks cause when I start the map it run perfectly but after a while it starts lagging and the longer I play the worse it gets. I turned off the trigger to see if it's this trigger which is causing the leaks and the map ran perfectly.
Can you please help me? What did I do wrong?
 

Bribe

vJass errors are legion
Reaction score
67
"Pick every unit in TempBlauRunner and order (picked unit) to.."

Order them to what? Maybe you order them to do something to a point, which would cause a location leak.
 

Bobby

New Member
Reaction score
0
I used this trigger several times with different orders (for different situations in the game):

- Einheit - Order (Picked unit) to Rechtsklick (Random item in Spielfeld <gen> matching ((Item-type of (Matching item)) Gleich Bombe))

- Einheit - Order (Picked unit) to Angreifen (Random unit from (Units owned by Spieler 1 (Rot) matching ((Item-type of (Item carried by (Matching unit) in slot 1)) Gleich Bombe)))

- Einheit - Order (Picked unit) to Folgen (Random unit from (Units owned by Spieler 2 (Blau) matching ((Item-type of (Item carried by (Matching unit) in slot 1)) Gleich Bombe)))

- Einheit - Order (Picked unit) to Bewegen nach TempPunktAngriff

- Einheit - Order (Picked unit) to Angreifen/Bewegen nach TempPunktAngriff


Sorry for all the german words in between, that's how my WE displays the triggers... if you need me to translate just tell me :)

I removed the "TempPunktAngriff" variable within the "Pick every unit..." action to avoid leaks, so this is what one of them looks like right now:

If (All Conditions are True) then do (Then Actions) else do (Else Actions)
'IF'-Bedingungen
BombeBesitzer Gleich 2
'THEN'-Aktionen
Set TempBlauBall = (Units owned by Spieler 2 (Blau) matching (((Unit-type of (Matching unit)) Gleich Runner (Blau)) and ((Custom value of (Matching unit)) Gleich 2)))
Einheitengruppe - Pick every unit in TempBlauBall and do (Actions)
Schleifen - Aktionen
Set TempPunktAngriff = (Center of Endgebiet Orc <gen>)
Einheit - Order (Picked unit) to Bewegen nach TempPunktAngriff
Custom script: call RemoveLocation(udg_TempPunktAngriff)
Custom script: call DestroyGroup(udg_TempBlauBall)
'ELSE'-Aktionen
 

Bribe

vJass errors are legion
Reaction score
67
(Random unit from (Units owned by Spieler 1 (Rot) matching ((Item-type of (Item carried by (Matching unit) in slot 1)) Gleich Bombe)))

Leaks a unit group.

So does this:

Einheit - Order (Picked unit) to Folgen (Random unit from (Units owned by Spieler 2 (Blau) matching ((Item-type of (Item carried by (Matching unit) in slot 1)) Gleich Bombe)))
 

Bobby

New Member
Reaction score
0
Thanks alot! :thup: You're right, I didn't think of it as a unit group because the item "bombe" only exists once in this map. :banghead:

So what about this one:

If (All Conditions are True) then do (Then Actions) else do (Else Actions)
'IF'-Bedingungen
BombeBesitzer Gleich 0​
'THEN'-Aktionen
Set TempBlauRunner = (Units owned by Spieler 2 (Blau) matching (((Unit-type of (Matching unit)) Gleich Runner (Blau)) and ((Custom value of (Matching unit)) Gleich 0)))​
Einheitengruppe - Pick every unit in TempBlauRunner and do (Actions)
Schleifen - Aktionen
Einheit - Order (Picked unit) to Rechtsklick (Random item in Spielfeld <gen> matching ((Item-type of (Matching item)) Gleich Bombe))
Custom script: call DestroyGroup(udg_TempBlauRunner)​
'ELSE'-Aktionen

Is there such thing as an item group? And what's the custom script to remove it?
 

Bribe

vJass errors are legion
Reaction score
67
There are only unit groups. Item/destructable "groups" are not handles, unlike unit groups, but rather dynamic enumerating utilities.

In JASS, to pick all units in a unit group it requires a "group" type handle to be created. For Items/Destructables, there are no required handles.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top