Nulling Locals

Carl-Fredrik

New Member
Reaction score
51
Hi everyone.. I was wondering, I have this trigger that spawns units and sends them away. It runs each 30 second and has two local locations involved (Create them at loc and send them to loc)

So I was wondering, shall I (set null) / (call RemoveLocation) these to prevent leaks? Or will it only work once then?

Thanks in advance!
// Carl-Fredrik
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Hi everyone.. I was wondering, I have this trigger that spawns units and sends them away. It runs each 30 second and has two local locations involved (Create them at loc and send them to loc)

So I was wondering, shall I (set null) / (call RemoveLocation) these to prevent leaks? Or will it only work once then?

Thanks in advance!
// Carl-Fredrik
You should only remove the locations if you create them in that trigger. If you create the locations once, eg at map initialization, then you shouldn't remove them.
Posting the code is an easy way to get more specific answers :)
 

Tom Jones

N/A
Reaction score
437
You should always null your local variables, with the exception of integers, reals, booleans, strings, and static pointers. What is a static pointer? All variables point to something, and that something may exist throughout the entire game, and is thus static. Players are an example of this, and yet another example:

JASS:
globals
    timer T = CreateTimer()
endglobals

function ...
    local timer t = T //We don't have to null this local.
                             
    //We could of course simply reference the global directly, and thus make the above local obsolete.
endfunction


Whenever you create something it should be destroyed. Once again the static rule apply, no need to destroy something the exist throughout the entire game.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top