Can conditions leak?

sevensc

New Member
Reaction score
8
Can a trigger condition leak?

function Trig_Left_Regions_Conditions takes nothing returns boolean
return GetUnitTypeId( GetTriggerUnit() ) != ( 'u000' )
endfunction

Should I be setting GetUnitTypeId and GetTriggerUnit to local variables, or is it fine this way since I am not manipulating them in anyway?

Any help with this would be fantastic.
 

Sooda

Diversity enchants
Reaction score
318
If you use in comparison GetTriggerUnit(), GetEnumUnit() or GetFilterUnit() it dosn' t leak. It starts to leak when you store returned unit into variable but don' t null it after you are done.
Though if you are using many times GetTriggerUnit() or similar function in condition I prefer to store unit first into local. Though it gets a bit more complicated then because you have to null thing(s) and return value.
Also boolexpr what your example is dosn' t need to be destroyed.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Nope, yours doesn't leak. Conditions don't leak. :D

GetUnitTypeId doesn't leak because it is a function, so you couldn't set it anyways... Unless you mean something like:
JASS:
local integer i = GetUnitTypeId(...)


But integers don't leak. Only local handles and certain handles leak. Everything is a handle except strings, reals, integers, codes, and booleans. Some exceptions, are for handles such as players or boolexprs.

GetTriggerUnit() doesn't leak unless it is set to a local handle variable because it needs to be cleared, or in other words, nulled.

The main leaks to worry about are from locations and groups. Also, forces and lightning and other stuff that must be destroyed leak also, but they are more rare in some cases. :D
 

Jazradel

Helping people do more by doing less.
Reaction score
102
Actually, Conditions do leak. However, they are saved in a table so when the condition is reused, the one in the table is used instead of a new one. If your only going to use a condition once, then you can destroy it.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Actually, Conditions do leak. However, they are saved in a table so when the condition is reused, the one in the table is used instead of a new one. If your only going to use a condition once, then you can destroy it.

Well, of course. I just meant that it isn't a leak to worry about because it won't harm your game that much.

Really, I see no use in destroying Boolexpr conditions. Vexorian confirmed it a long time ago saying that it may be hazardous to destroy the boolexpr. I guess, if you use it only once; it may be alright in the way you put it. Are you very, extremely sure of yourself?
 

sevensc

New Member
Reaction score
8
The condition I posted, as well as many of my other trigger conditions are run repeatedly throughout my game so from what you guys are saying, I should have no issues.

As far as the other leaks go, all my triggers null locals and destroy anything that needs to be destroyed (such as locations). I was only unsure about conditions.

Thanks very much guys - I hope you don't mind a bit of rep :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top