• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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