Does this leak a handle?

AdamGriffith

You can change this now in User CP.
Reaction score
69
JASS:
function H2I takes handle h returns integer
    return h
    return 0
endfunction

function Create_Trackable takes string trackableModelPath, real x, real y, real facing returns trackable
    local trackable t = CreateTrackable(trackableModelPath, x, y, facing)
    call StoreString(udg_Game_Cache, I2S(H2I(t)), "trackableModelPath", trackableModelPath)
    call StoreReal(udg_Game_Cache, I2S(H2I(t)), "x", x)
    call StoreReal(udg_Game_Cache, I2S(H2I(t)), "y", y)
    call StoreReal(udg_Game_Cache, I2S(H2I(t)), "facing", facing)
    return t
endfunction

function Trig_Trackables_Actions takes nothing returns nothing
    local string trackableModelPath = "war3mapImported\\4x4Trackable.MDX"
    local real x = 0.
    local real y = 0.
    local real facing = 0.
    local trackable t = Create_Trackable(trackableModelPath, x, y, facing)
    //Actions
    set t = null
endfunction

//===========================================================================
function InitTrig_Trackables takes nothing returns nothing
    set gg_trg_Trackables = CreateTrigger(  )
    set udg_Game_Cache = InitGameCache("MapName.w3v")
    call TriggerAddAction( gg_trg_Trackables, function Trig_Trackables_Actions )
endfunction
 

Builder Bob

Live free or don't
Reaction score
249
I've never used trackables, so I don't know much about what you can do with them. What I think I've read somewhere is that you cannot remove a trackable after you've created one. If that is the case, then you cannot leak trackables.

If trackables can be created and removed, then you could leak handles in your Create_Trackable function since you're unable to null the trackable t. You could use a global variable to get around that.

I really don't think trackables can be removed though.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
JASS:
    local trackable t = Create_Trackable(trackableModelPath, x, y, facing)
    //Actions
    set t = null


Considering he's nulling it there, I guess he should be nulling it in the other function aswell.
 

Viikuna

No Marlo no game.
Reaction score
265
Why to null something, if you dont destroy it?
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
I do not even see why you need that function for it since all you do is call it with useless variables storing 0 as value.
 

AdamGriffith

You can change this now in User CP.
Reaction score
69
The point in the addition function is to store the position of the trackable for later use.

And I cannot use return CreateTrackable(...) because then I wouldnt be able to store the mission key as I2S(H2I(t)) because t wouldnt have been created... =/
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
JASS:
globals
    trackable temptrack
endglobals

function H2I takes handle h returns integer
    return h
    return 0
endfunction

function Create_Trackable takes string trackableModelPath, real x, real y, real facing returns trackable
    local trackable t = CreateTrackable(trackableModelPath, x, y, facing)
    call StoreString(udg_Game_Cache, I2S(H2I(t)), "trackableModelPath", trackableModelPath)
    call StoreReal(udg_Game_Cache, I2S(H2I(t)), "x", x)
    call StoreReal(udg_Game_Cache, I2S(H2I(t)), "y", y)
    call StoreReal(udg_Game_Cache, I2S(H2I(t)), "facing", facing)
    set temptrack = t
    set t = null
    return temptrack
endfunction

function Trig_Trackables_Actions takes nothing returns nothing
    local string trackableModelPath = "war3mapImported\\4x4Trackable.MDX"
    local real x = 0.
    local real y = 0.
    local real facing = 0.
    local trackable t = Create_Trackable(trackableModelPath, x, y, facing)
    //Actions
    set t = null
endfunction

//===========================================================================
function InitTrig_Trackables takes nothing returns nothing
    set gg_trg_Trackables = CreateTrigger(  )
    set udg_Game_Cache = InitGameCache("MapName.w3v")
    call TriggerAddAction( gg_trg_Trackables, function Trig_Trackables_Actions )
endfunction


Just do something like that with a global. If you don't have Newgen, you can use the Variable editor.
 

Viikuna

No Marlo no game.
Reaction score
265
Again: You dont need to null things if you dont destroy them, and destroying trackables in NOT possible.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top