Jass Vault WC3Jass.com
"The Jass Vault"
 
 FAQ   Search   Memberlist   Usergroups   Register 
 Profile   Log in to check your private messages   Log in  
 Forum   Scripts   Files   Chat   Pastebin   Function finder  
Affiliates
The HIVE Workshop Games Modding
The Hubb Wc3Campaigns
WC3-Mapping.net

PolledWait

 
Post new topic   Reply to topic    Jass Vault -> blizzard.j
View previous script :: View next script  

Script code
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 we have a bit of time left, skip past 10% of the remaining
            // duration instead of checking every interval, to minimize the
            // polling on long waits.
            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
Script info
Description

Author
danny760311


Joined: 07 Apr 2005
Comments: 26
Back to top
Message
CommentPosted: Sat Jul 16, 2005 11:54 pm    Post subject: Reply with quote

I cannot see why bliz make it loop so many times...
Would there be any bug if I write it like this Question :

Code:
function PolledWait takes real duration returns nothing
    local timer t = CreateTimer()
    local real  timeRemaining
    call TimerStart(t, duration, false, null)
    loop
        set timeRemaining = TimerGetRemaining(t)
        exitwhen timeRemaining <= 0
        call TriggerSleepAction(timeRemaining)
    endloop
    call DestroyTimer(t)
endfunction
View user's profile Send private message

Author
KaTTaNa
Site Admin

Joined: 04 Apr 2005
Comments: 655
Back to top
Message
CommentPosted: Sun Jul 17, 2005 10:46 am    Post subject: Reply with quote

It would be less accurate because game time is usually much faster than real time (depends on game speed), so your TriggerSleepAction would simply wait for too long.
View user's profile Send private message Send e-mail Visit poster's website

Display posts from previous:   
Post new topic   Reply to topic    Jass Vault -> blizzard.j All times are GMT
Page 1 of 1

 
Jump to:  
You cannot submit new scripts in this section
You can comment on scripts in this section
You cannot edit your scripts in this section
You cannot delete your scripts in this forum



FSDark by SkaidonDesigns
Powered by phpBB © 2001, 2002 phpBB Group