[JASS] About location leaks

Status
Not open for further replies.
Level 7
Joined
Aug 19, 2009
Messages
279
Hi guys..

Well i have a trigger where i need to use location a lot of times.
I remove the location after use like this

JASS:
        set loc1 = GetUnitLoc(rotatecenter[n])
        set z1 = GetLocationZ(loc1)
        set loc2 = GetUnitLoc(rotateunit[n])
        set z2 = GetLocationZ(loc2)
        call SetUnitFlyHeight(rotateunit[n], (150 + z1 - z2) , 0)
        call RemoveLocation(loc1)
        call RemoveLocation(loc2)

Some one said i could use a global location instead of a local location and use move location all the time it will work and i don't need to remove it

I don't think mui will be a problem. So which do you think will be more efficient.
 
It would look something like this:
JASS:
    globals
        location loc = Location(0, 0)
    endglobals
    
    function GetPointZ takes real x, real y returns real
        call MoveLocation(loc, x, y)
        return GetLocationZ(loc)
    endfunction
    
    function GetUnitZ takes unit u returns real
        return GetPointZ(GetUnitX(u), GetUnitY(u))
    endfunction
You would need to have Jasshelper to declare a global block like that and should probably make the global have a longer name to avoid conflicts.

EDIT:
@Spartipilo: He needs at least one location to get the z of stuff.
 
A good way to handle locations is not using them, but rather use X/Y coordenates :) Avoid creating / destroying the location
 
Status
Not open for further replies.
Back
Top