- Joined
- Jul 6, 2009
- Messages
- 1,885
function Question takes title t returns question
call AskQuestion(t)
Would this function leak local unit u2?
call AskQuestion(t)
JASS:
function Closest_Unit takes group g,location l returns unit
local real r
local real dx
local real dy
local unit u1
local unit u2
set r = 1000
loop
set u1 = FirstOfGroup(g)
exitwhen u1 == null
set dx = GetUnitX(u1) - GetLocationX(l)
set dy = GetUnitY(u1) - GetLocationY(l)
if r > SquareRoot(dx * dx + dy * dy) then
set u2 = u1
set r = SquareRoot(dx * dx + dy * dy)
endif
call GroupRemoveUnit(g,u1)
set u1 = null
endloop
return u2
endfunction