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

Wait and Wait (Game-Time)

Status
Not open for further replies.

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
What are the different between Wait and Wait (Game-Time)? Example would be helpful as well.
Wait calls this...
JASS:
native TriggerSleepAction takes real timeout returns nothing

Wait (Game-Time) calls this...
JASS:
function PolledWait takes real duration returns nothing
    local timer t
    local real  timeRemaining
    if (duration > 0) then
        set t = CreateTimer()
        call TimerStart(t, duration, false, null)
        loop
            set timeRemaining = TimerGetRemaining(t)
            exitwhen timeRemaining <= 0
            if (timeRemaining > bj_POLLED_WAIT_SKIP_THRESHOLD) then
                call TriggerSleepAction(0.1 * timeRemaining)
            else
                call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
            endif
        endloop
        call DestroyTimer(t)
    endif
endfunction

Both use the same TriggerSleepAction to suspend the thread for a period. PolledWait uses a timer to keep timing accuracy so performs better with long delays. Both perform as badly with short delays due to the mechanics of TriggerSleepAction. PolledWait also leaks a handle index do to a JASS bug.
 
Level 2
Joined
May 18, 2013
Messages
9
In reality you should never use Wait (Game-Time) due to the leak. You can use a custom function designed like PolledWait but with the leak fixed.

For very accurate timing, use a timer.

Thanks a million Doc. That sure did clear up a lot and I shall grant you a beautiful rep :grin:

@MasterTrainer: I am still new to this. I haven’t explored with countdown timer yet, just was puzzle by wait and wait (game time).
 
Last edited:
Status
Not open for further replies.
Top