Handle Stack Question

Darius34

New Member
Reaction score
30
JASS:
private function Init takes nothing returns nothing
    local timer t
    
    set t = CreateTimer()
    call BJDebugMsg(I2S(H2I(t)))
    call DestroyTimer(t)
    
    set t = CreateTimer()
    call BJDebugMsg(I2S(H2I(t)))
endfunction

When I do this, I get two different handle indices. It's as if the first timer was never removed from the handle stack. Why? The variable t is also reused, so there's no leak (at least, I don't think so).

I've a feeling I'm just missing something. >.>
 

Darius34

New Member
Reaction score
30
(That was fast.) But aren't handle indices recycled? That's the reason for nulling/reassigning locals, isn't it?
 

chobibo

Level 1 Crypt Lord
Reaction score
48
the handle recyling isn't as fast as the handle allocator, try adding a sleep 1 second long
 

Viikuna

No Marlo no game.
Reaction score
265
I tried with 1 sec timer, and it displayed same handle IDs for both groups ( I used groups, not timers ).
 

SFilip

Gone but not forgotten
Reaction score
634
Handles aren't recycled until a function finishes running.
 

DioD

New Member
Reaction score
57
JASS:
globals
   integer LAST = 0
   real    TICK = 0.01
   real   INC = 0.001
   timer COUNT = null
endglobals



function Echo takes string String returns nothing
   call DisplayTextToPlayer(GetLocalPlayer(),0.0,0.0,String)
endfunction

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

function CALLBACK takes nothing returns nothing

local location Loc = Location(0.0,0.0)
local integer Int = H2I(Loc)
//call Echo(I2S(Int))

call RemoveLocation(Loc)
set Loc = null

if LAST == 0 then
   set LAST = Int
endif

if Int == LAST then
set TICK = TICK - INC
call TimerStart(COUNT,TICK,false, function CALLBACK)
else
call Echo("Hit at " + R2S(TICK))
endif

endfunction

function Trig_Recycle_Delay_test_Actions takes nothing returns nothing

set COUNT = CreateTimer()
call TimerStart(COUNT,TICK,false, function CALLBACK)


endfunction


You can detect "true" delay.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top