- Joined
- Apr 27, 2011
- Messages
- 272
Just a simple implementation of a location stack to help prevent location leaks.
JASS:
library LocationUtils
//===========================================================================
// "LocationUtils" by Alain.Mark
//
// -Info-
// -Attempts to remove the problem of location leaks by providing a location stack.
//
// -API-
// -function NewLocationEx takes real x, real y location
// -function NewLocation takes nothing returns location
// -function DestroyLocation takes location l returns nothing
//
//===========================================================================
globals
private integer N=0
private location array Ll
endglobals
//===========================================================================
function NewLocationEx takes real x, real y returns location
if(N==0)then
return Location(x,y)
endif
set N=N-1
call MoveLocation(Ll[N],x,y)
return Ll[N]
endfunction
//===========================================================================
function NewLocation takes nothing returns location
return NewLocationEx(0.00,0.00)
endfunction
//===========================================================================
function DestroyLocation takes location l returns nothing
set Ll[N]=l
set N=N+1
endfunction
//===========================================================================
endlibrary