• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] [Jass] Trying to find memory leaks

Status
Not open for further replies.
Level 5
Joined
May 15, 2008
Messages
105
Hi guys.

I am not sure if there are any memory leaks in my map but I would like to find out. I don't see them and that's why I ask you for help. Please check my code and tell me if you see (or not) any memory leaks in it (I don't care about any other measures). I would strongly appreciate your help.


JASS:
function Trig_LeavingArea_Func107 takes integer int returns boolean
    return ( int <= 107 )
endfunction

function Trig_LeavingArea_Func106 takes integer int returns boolean
    return ( int >= 106 )
endfunction

function Trig_LeavingArea_FuncShipyard takes integer int returns boolean
    return GetBooleanAnd( Trig_LeavingArea_Func106(int), Trig_LeavingArea_Func107(int) )
endfunction

function Trig_LeavingArea_FuncControl takes integer int returns nothing
    local player playerL = GetOwningPlayer(GetTriggerUnit())
    if ( Trig_LeavingArea_FuncShipyard(int) ) then
        call SetUnitOwner( udg_Area_Shipyards[int], playerL, true )
    endif
    call SetUnitOwner( udg_Area_Towns[int], playerL, true )
    call SetUnitOwner( udg_Area_Towers[int], playerL, true )
endfunction

//===========================================================================

function Trig_LeavingArea_FuncIfNotStructure takes unit u returns boolean
    return ( IsUnitType(u, UNIT_TYPE_STRUCTURE) == false )
endfunction

function Trig_LeavingArea_FuncIfNotFlying takes unit u returns boolean
    return ( IsUnitType(u, UNIT_TYPE_FLYING) == false )
endfunction

function Trig_LeavingArea_FuncIfNotDead takes unit u returns boolean
    return ( IsUnitAliveBJ(u) == true )
endfunction

function Trig_LeavingArea_FuncIfNotFlyingDeadStructure takes unit u returns boolean
    return GetBooleanAnd( Trig_LeavingArea_FuncIfNotDead(u), GetBooleanAnd( Trig_LeavingArea_FuncIfNotStructure(u), Trig_LeavingArea_FuncIfNotFlying(u) ) )
endfunction

function Trig_LeavingArea_FuncIfNotFlyingDeadStructureFilter takes nothing returns boolean
    return Trig_LeavingArea_FuncIfNotFlyingDeadStructure( GetFilterUnit() )
endfunction

function Trig_LeavingArea_FuncIfNumberOfUnitsInGroup takes integer int returns boolean
    local integer number = 0
    local group gArea = CreateGroup()
    set gArea = GetUnitsInRectMatching(udg_Area_Region[int], Condition(function Trig_LeavingArea_FuncIfNotFlyingDeadStructureFilter))
    set number = CountUnitsInGroup(gArea)
    call DestroyGroup(gArea)
    return ( number == 0 )
endfunction


function Trig_LeavingArea_FuncIfAreaContainsTriggeringUnit takes integer number returns boolean 
    if ( not ( RectContainsUnit(udg_Area_RegionPlus[number], GetTriggerUnit()) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_LeavingArea_Actions takes nothing returns nothing
    local integer j = 1
    if ( Trig_LeavingArea_FuncIfNotFlyingDeadStructure(GetTriggerUnit()) ) then
        loop
            exitwhen j > udg_NumberOfTowns
            if ( Trig_LeavingArea_FuncIfAreaContainsTriggeringUnit(j) ) then
                if ( Trig_LeavingArea_FuncIfNumberOfUnitsInGroup( j ) ) then
                    call SetUnitPositionLoc( GetTriggerUnit(), udg_Area_Center[j] )
                    call IssueImmediateOrderBJ( GetTriggerUnit(), "holdposition" )
                    call Trig_LeavingArea_FuncControl(j)
                else
                endif
                return
            else
            endif
            set j = j + 1
        endloop
    else
    endif
endfunction


//===========================================================================


function LeavingArea_onStart takes nothing returns nothing
     local integer i = 1
     call DestroyTimer(GetExpiredTimer())
     set gg_trg_LeavingArea = CreateTrigger(  )
     loop
         exitwhen i > udg_NumberOfTowns
         call TriggerRegisterLeaveRectSimple( gg_trg_LeavingArea, udg_Area_Region[i])
         set i = i + 1
     endloop
     call TriggerAddAction( gg_trg_LeavingArea, function Trig_LeavingArea_Actions )
endfunction

function InitTrig_LeavingArea takes nothing returns nothing
     call TimerStart(CreateTimer(), 0, false, function LeavingArea_onStart)
endfunction

©Kamulec 2008-2014
 
Last edited:
Status
Not open for further replies.
Top