• 🏆 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!

Do locals leak

Status
Not open for further replies.
Level 19
Joined
Aug 8, 2007
Messages
2,765
title.

e/ sorry if im being vague, but i mean it in both instances (using a plain local and not nulling it and assigning a leaking function to a local and not destroying/nulling it)
 
Oh, one other thing:

JASS:
function temp takes nothing returns nothing
    local location l
    if (boolean expression) then
        set l = something
        // do stuff with l
        call RemoveLocation(l)
        set l = null
    endif
    // we don't null l here because it won't be equal to anything, and thus it won't leak
endfunction

Handles would only leak if they actually have a value
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Non-agent handles are local-only relevant objects and constants.

JASS:
local image i = CreateImage(...)

call DestroyImage(i)

call CreateImage(...)

After the last line, the variable i will contain the new, lower image because you do not need to nullify the variable here. The id will still be returned and it keeps pointing on the address.

JASS:
local image b
local image i = CreateImage(...)

call DestroyImage(i)

set b = CreateImage(...)

if (b == i) then
    call BJDebugMsg("that's the case")
endif
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Okay, i understand, but i dont understand something else.

JASS:
    call TriggerAddCondition( gg_trg_Respawn_Copy, Condition( IsNeutralHostile ) )

Is a line of the code. but when i save, it says

Cannot convert integer to boolean

JASS:
    call TriggerAddCondition(gg_trg_Respawn_Copy, Condition((1)))

Why is it compiling to 1? Yes theres a trigger above thats called isNeutralHostile

i also have a second problem

JASS:
local unit group GetUnits = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function IsNeutralHostile))

(these errors might have something to do with that function)

converts to

JASS:
local unit group  = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function IsNeutralHostile))

and than yells at em because theres no name for the variable...
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
vJass gives each function a number. Write

call TriggerAddCondition( gg_trg_Respawn_Copy, Condition( function IsNeutralHostile ) )

instead or vJass also allows

call TriggerAddCondition( gg_trg_Respawn_Copy, function IsNeutralHostile )

by automatically converting it to the above.
 
Status
Not open for further replies.
Top