Warcraft III resources & community, 2003–2006 · archived

Why does/doesn't Polar Projection leak?

7 posts
#1

Why does/doesn't Polar Projection leak?

Ok, I'm already confused. Some people tell me that PolarProjectionBJ leaks, other say that it doesn't. Just curious, if it leaks why and where.

~Daelin
#2
and the answer is "It depends on the way you use polar projection"


if you say


call SetUnitPositionLoc ( u , PolarProjectionBJ ( GetUnitLoc ( u ) , 600 , 0 ) )


it will lag a hell,because GetUnitLoc () will return a location that will not be removed , and PolarProjection will return another one that is not removed , so we have 2 location leaks.

but if you say

local location l = GetUnitLoc ( u )
local location p = PolarProjectionBJ ( l , 600 , 0 )

call SetUnitPositionLoc ( u , p )


call RemoveLocation ( l )
call RemoveLocation ( p )
set l = null
set p = null



wont leak now ,but locations suck so the best way of using polar projections is



local real x = GetUnitX ( u ) + dist * Cos(angle * bj_DEGTORAD)
local real y = GetUnitY ( u ) + dist * Sin(angle * bj_DEGTORAD)

call SetUnitPosition ( u , x , y )



doesnt use locations and is way faster
#3
So practically it's not the function itself that leaks, it's the locations... But that sounds ridiculous. Why wouldn't anyone use locations when you have them at hand? Strange...

~Daelin
#4
why not using locations ?

because they seem to leak even after calling RemoveLocation () , if you use coordinates it will be much more better , as ints/reals dont leak.
#5
It also seems that most of the functions using units position uses coordinates instead of locations. Like many BJ functions that calls the real native function which uses coordinates. I also used locations before but Vexorian told me that it is better to use coordinates and I saw that he use coordinates in all his spells when ever possible. Leave the locations. :)
#6
What if I make 2 functions PolarProjectionX and PolarProjectionY returning X and Y using Sin/Cos? Will that leak too?
#7
JacekWhat if I make 2 functions PolarProjectionX and PolarProjectionY returning X and Y using Sin/Cos? Will that leak too?

Why should it? Only objects leak. The functions here uses numeric vaules so no leak here.