destroying a terraindeformation

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
How do I destroy a terraindeformation handle? (as in, remove the handle, so no leaking)

Unrelated note: do I need to null unit handles? (I've heard that they leak anyway)
 

tooltiperror

Super Moderator
Reaction score
231
The only function in common.j that takes a [LJASS]terraindeformation[/LJASS] as an argument, to my knowledge, is [LJASS]native TerrainDeformStop[/LJASS]. I'll test if it leaks and edit this post ...

Anything that extends handle needs to be nulled, including widgets, and therefore units.
 

Romek

Super Moderator
Reaction score
963
You need to null any handle that could be destroyed. This excludes players, most triggers, and most boolexprs. Units won't directly be removed through triggers, but will die and decay eventually.
Also, you usually don't need to null heroes (unless they're going to be physically removed) or any dummy units that are recycled, since they don't decay and won't be removed. Though you're better of nulling every unit rather than checking if it's a hero or not. :p

If you don't know what not to null, you're better of nulling everything that extends handle.
 

WaterKnight

Member
Reaction score
7
Anyway, [ljass]TerrainDeformStop[/ljass] does remove the leak.

It does not. Or why do the ids climb up?

JASS:
function Trig_Nahkampf_Initialisierung_Actions takes nothing returns nothing
    local terraindeformation t = TerrainDeformCrater(0, 0, 64, 100, 1000, true)

    call TerrainDeformStop(t, 100)

    call BJDebugMsg(I2S(GetHandleId(t)))

    set t = null
endfunction

//===========================================================================
function InitTrig_Nahkampf_Initialisierung takes nothing returns nothing
    set gg_trg_Nahkampf_Initialisierung = CreateTrigger(  )
    call TriggerRegisterPlayerEventEndCinematic( gg_trg_Nahkampf_Initialisierung, Player(0) )
    call TriggerAddAction( gg_trg_Nahkampf_Initialisierung, function Trig_Nahkampf_Initialisierung_Actions )
endfunction


Tested this with temporary and permanent deformations, with immediate TerrainDeformStop/fading and with putting a wait between creation and stopping, every combination.

Not every handle needs to be nulled. These with a high id have to be, which are generally agents. Do not ask me why is no agent. Most non-agent handles are static types like or local ones like
which have no reference-counter.
 

Bribe

vJass errors are legion
Reaction score
67
handle pointers consume RAM just by existing, and if there are some handles that have no reference counter it would surprise me and I would like to see proof / list.
 

WaterKnight

Member
Reaction score
7
I did not mean that local non-agent handle pointers get released at the end of their function. This, I do not know. Ok, that could be a reason to nullify them if that did help. But said objects are not reference-counted, already freeing their id upon the destroy-function.

JASS:
function Trig_Nahkampf_Initialisierung_Actions takes nothing returns nothing
    local lightning l = AddLightning("MBUR", false, 0, 0, 0, 0)

    call DestroyLightning(l)

    call AddLightning("LEAS", false, 0, 0, 0, 0)

    call MoveLightning(l, false, 0, 0, 1000, 1000)
endfunction

//===========================================================================
function InitTrig_Nahkampf_Initialisierung takes nothing returns nothing
    set gg_trg_Nahkampf_Initialisierung = CreateTrigger(  )
    call TriggerRegisterPlayerEventEndCinematic( gg_trg_Nahkampf_Initialisierung, Player(0) )
    call TriggerAddAction( gg_trg_Nahkampf_Initialisierung, function Trig_Nahkampf_Initialisierung_Actions )
endfunction


Variable l points to MBUR first, MBUR gets deleted, restores the id although l still on it, LEAS obtains the just returned id and can be accessed through l, drawing the lariat to given coordinates.

As lightnings and some other stuff are not relevant for gameplay and local-only, I guess you do not need as much security.
 

Bribe

vJass errors are legion
Reaction score
67
Then I'll run some tests and figure out if the RAM increases with more unfreed pointers to lightnings, texttags, etc. If they don't hurt RAM, don't affect the handle stack, then there is probably no reason to null them?
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
>It does not. Or why do the ids climb up?

Yeah, you're right. I accidentally was reading the id of null, so I tested it again and it seems that it does leak. =(
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
:x

So terraindeformations cannot be destroyed?
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
I'm afraid not, at least from what I see. I tried both of the stop natives, and neither worked to solve it. :(
 
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