Hello Hive!
Now, I thought I was pretty decent at this leak checking except I have a trigger running very often and it seems to be leaking.
I have already:
Like I said, it runs pretty often atm (will probably be reduced) so it is important it doesn't leak.
What have I missed?
P.S. It isn't correct so don't bother copying it xD
Now, I thought I was pretty decent at this leak checking except I have a trigger running very often and it seems to be leaking.
I have already:
- Nulled units
- Destroyed and nulled filters
- Destroyed and nulled groups
- There are no locs used
JASS:
function plyrFltr takes nothing returns boolean
local unit u = GetFilterUnit()
local boolean a = GetOwningPlayer(u) == Player(11)
set u = null
return a
endfunction
function zCollideUp takes unit unitSubject, real zProjected returns boolean
local unit unitTarget
local boolean InRange = false
local real zTarget
local real zActual = GetUnitFlyHeight(unitSubject)
local group tmpGrp
local filterfunc tmpFltr = Filter(function plyrFltr)
set tmpGrp = CreateGroup()
//Width of player unit global needed
call GroupEnumUnitsInRange(tmpGrp, GetUnitX(unitSubject), GetUnitY(unitSubject), 90, tmpFltr)
loop
set unitTarget = FirstOfGroup(tmpGrp)
//Height of player unit global needed
set zTarget = GetUnitFlyHeight(unitTarget) - 100
if (zTarget >= zActual and zTarget <= zProjected) then
set InRange = true
call GroupRemoveUnit(tmpGrp, unitTarget)
endif
call GroupRemoveUnit(tmpGrp, unitTarget)
exitwhen unitTarget == null
endloop
call DestroyGroup(tmpGrp)
call DestroyFilter(tmpFltr)
set unitTarget = null
set tmpGrp = null
set tmpFltr = null
return InRange
endfunction
function zCollideDown takes unit unitSubject, real zProjected returns boolean
local unit unitTarget
local boolean InRange = false
local real zTarget
local real zActual = GetUnitFlyHeight(unitSubject)
local group tmpGrp
local filterfunc tmpFltr = Filter(function plyrFltr)
set tmpGrp = CreateGroup()
//width of player unit global needed
call GroupEnumUnitsInRange(tmpGrp, GetUnitX(unitSubject), GetUnitY(unitSubject), 90, tmpFltr)
loop
set unitTarget = FirstOfGroup(tmpGrp)
set zTarget = GetUnitFlyHeight(unitTarget)
//Height of object colliding with unitSubject global needed
if (zTarget <= zActual-70 and zTarget >= zProjected-70) then
set InRange = true
call GroupRemoveUnit(tmpGrp, unitTarget)
endif
call GroupRemoveUnit(tmpGrp, unitTarget)
exitwhen unitTarget == null
endloop
call DestroyGroup(tmpGrp)
call DestroyFilter(tmpFltr)
set unitTarget = null
set tmpGrp = null
set tmpFltr = null
return InRange
endfunction
function xCollide takes unit unitSubject, real xProjected, real zProjected returns boolean
local unit unitTarget
local boolean InRange = false
local real xTarget
local group tmpGrp
local filterfunc tmpFltr = Filter(function plyrFltr)
set tmpGrp = CreateGroup()
//width of player unit global needed
call GroupEnumUnitsInRange(tmpGrp, GetUnitX(unitSubject), GetUnitY(unitSubject), 90, tmpFltr)
loop
set unitTarget = FirstOfGroup(tmpGrp)
set xTarget = GetUnitX(unitTarget)
//Width of object colliding with unitSubject global needed
//Width of player unit global needed
if (xProjected+(90/2) <= xTarget+(72/2) or xProjected+(90/2) >= xTarget-(72/2)) or (xProjected-(90/2) <= xTarget+(72/2) or xProjected-(90/2) >= xTarget-(72/2)) and (zCollideUp(unitSubject, zProjected) or zCollideDown(unitSubject, zProjected)) then
set InRange = true
call GroupRemoveUnit(tmpGrp, unitTarget)
endif
call GroupRemoveUnit(tmpGrp, unitTarget)
exitwhen unitTarget == null
endloop
call DestroyGroup(tmpGrp)
call DestroyFilter(tmpFltr)
set unitTarget = null
set tmpGrp = null
set tmpFltr = null
return InRange
endfunction
function ApplyPhysics takes nothing returns nothing
local unit unitSubject
local real xCurrent
local real zCurrent
local real xProjected
local real zProjected
set udg_index = 0
loop
set unitSubject = udg_PlayerUnit[udg_index]
set xCurrent = GetUnitX(unitSubject)
set zCurrent = GetUnitFlyHeight(unitSubject)
set xProjected = xCurrent + udg_xVelocity[udg_index]
set zProjected = zCurrent + udg_zVelocity[udg_index] + udg_zAccel
//--------------y--------------
if zCollideUp(unitSubject, zProjected) then
if udg_zVelocity[udg_index] >= 5 then // bounce threshhold when travelling up
set udg_zVelocity[udg_index] = 0 - udg_zVelocity[udg_index]
else
set udg_zVelocity[udg_index] = 0
endif
elseif zCollideDown(unitSubject, zProjected) then
set udg_zVelocity[udg_index] = 0
else
call SetUnitFlyHeight(unitSubject, zProjected, 0)
set udg_zVelocity[udg_index] = udg_zVelocity[udg_index] + udg_zAccel
endif
//-------------x-------------
if xCollide(unitSubject, xProjected, zProjected) then
// bounce threshhold when travelling horizontally
if udg_xVelocity[udg_index] >= 5 then
set udg_xVelocity[udg_index] = 0 - udg_xVelocity[udg_index]
else
set udg_xVelocity[udg_index] = 0
endif
else
call SetUnitX(unitSubject, xProjected)
set udg_xVelocity[udg_index] = udg_xVelocity[udg_index]
endif
set unitSubject = null
set udg_index = udg_index + 1
exitwhen udg_index == 13
endloop
endfunction
//===========================================================================
function InitTrig_PhysicsV2 takes nothing returns nothing
set gg_trg_PhysicsV2 = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic(gg_trg_PhysicsV2, 0.01)
call TriggerAddAction( gg_trg_PhysicsV2, function ApplyPhysics )
endfunction
Like I said, it runs pretty often atm (will probably be reduced) so it is important it doesn't leak.
What have I missed?
P.S. It isn't correct so don't bother copying it xD
Last edited: