MeleeClearExcessUnit

comment
note

It is called directly by the default "Melee Initialization" trigger.

bug

Leaks handle theUnit: In Jass you must set local variables that hold agents (or any child type) to null at the end of functions to avoid reference counter leaks.

patch

1.00

Source
Blizzard.j (raise an issue to discuss on Github or submit a PR)
return type
nothing
Source code
function MeleeClearExcessUnit takes nothing returns nothing
    local unit    theUnit = GetEnumUnit()
    local integer owner   = GetPlayerId(GetOwningPlayer(theUnit))

    if (owner == PLAYER_NEUTRAL_AGGRESSIVE) then
        // Remove any Neutral Hostile units from the area.
        call RemoveUnit(GetEnumUnit())
    elseif (owner == PLAYER_NEUTRAL_PASSIVE) then
        // Remove non-structure Neutral Passive units from the area.
        if not IsUnitType(theUnit, UNIT_TYPE_STRUCTURE) then
            call RemoveUnit(GetEnumUnit())
        endif
    endif
endfunction