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

Old "Handle Timers" Error

Level 10
Joined
May 25, 2021
Messages
344
Excuse me! Anyone have the up-to-date and functional version of "Handle Timers" Trigger vJass?
The one I just get from a custom spell (from HIVE) is 2009 and it has some errors when I'm trying to save a map by WC3 Reforged Editor.

//TESH.scrollpos=0
//TESH.alwaysfold=0
//Functions used to handle timers. Credits to Vexorian and Captain Griffen
//Check http://www.wc3c.net/showthread.php?t=89072 for more informations
library HandleTimers

globals
private timer array timers
private integer N = 0
endglobals

function NewTimer takes nothing returns timer
if (N==0) then
return CreateTimer()
endif
set N=N-1
return timers[N]
endfunction

function ReleaseTimer takes timer t returns nothing
call PauseTimer(t)
if (N==8191) then
debug call BJDebugMsg("Warning: Timer stack is full, destroying timer!!")
//stack is full, the map already has much more troubles than the chance of bug
call DestroyTimer(t)
else
set timers[N]=t
set N=N+1
endif
endfunction

function TimerAttach takes timer t, real time, real value, code func returns nothing
call TimerStart(t, value, false, null)
call PauseTimer(t)
call TimerStart(t, time, false, func)
endfunction

// ONLY call on an expired timer.
function GetTimerInt takes timer t returns integer
return R2I(TimerGetRemaining(t) + 0.5)
endfunction
endlibrary

If do, sharing is much appreciated!
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,015
It’s entirely deprecated and you should use any of the timer allocation/attaching systems that have succeeded it.

However, you can still make it work with a little effort. Somewhere in the code for HandleTimers (which you didn’t show all of, some is still in the map header I’d assume) you will find a function that looks like this:
JASS:
function H2I takes handle h returns integer
   return h
    return 0
endfunction
You will need to replace the text of that function so it looks like this:
JASS:
function H2I takes handle h returns integer
    return GetHandleId(h)
endfunction
There may be an I2T function that exists somewhere in there and that will be more annoying to fix. I would honestly just try to replace the timer attachment/allocation outright. It’s also possible that there are more things in the spell that uses deprecated methods which will require more workarounds.

Finally, don’t forget to enable JASSHelper and vJASS from the trigger editor JH drop-down menu. Without that enabled you will always get errors and can’t save (and it’s off by default for every map now… thanks Blizzard).
 
Top