void Loop_RunTics(void) { double elapsedTime, ticLength, nowTime; // Do a network update first. N_Update(); Net_Update(); // Check the clock. if(firstTic) { // On the first tic, no time actually passes. firstTic = false; lastRunTicsTime = Timer_Seconds(); return; } // Let's see how much time has passed. This is affected by "settics". nowTime = Timer_Seconds(); elapsedTime = nowTime - lastRunTicsTime; // Remember when this frame started. lastRunTicsTime = nowTime; // Tic until all the elapsed time has been processed. while(elapsedTime > 0) { ticLength = MIN_OF(MAX_FRAME_TIME, elapsedTime); elapsedTime -= ticLength; // Will this be a sharp tick? DD_CheckSharpTick(ticLength); #ifdef __CLIENT__ // Process input events. DD_ProcessEvents(ticLength); if(!processSharpEventsAfterTickers) { // We are allowed to process sharp events before tickers. DD_ProcessSharpEvents(ticLength); } #endif // Call all the tickers. baseTicker(ticLength); #ifdef __CLIENT__ if(processSharpEventsAfterTickers) { // This is done after tickers for compatibility with ye olde game logic. DD_ProcessSharpEvents(ticLength); } #endif // Various global variables are used for counting time. advanceTime(ticLength); } }
/** * The busy loop callback function. Called periodically in the main (UI) thread * while the busy worker is running. */ void BusyMode_Loop(void) { if(!busyTask || !BusyMode_Active()) return; dd_bool canUpload = !(busyTask->mode & BUSYF_NO_UPLOADS); timespan_t oldTime; // Post and discard all input events. DD_ProcessEvents(0); DD_ProcessSharpEvents(0); if(canUpload) { ClientWindowSystem::main().glActivate(); // Any deferred content needs to get uploaded. GL_ProcessDeferredTasks(15); } // We accumulate time in the busy loop so that the animation of a task // sequence doesn't jump around but remains continuous. oldTime = busyTime; busyTime = Timer_RealSeconds() - busyTask->_startTime; if(busyTime > oldTime) { accumulatedBusyTime += busyTime - oldTime; } Sys_Lock(busy_Mutex); busyDoneCopy = busyDone; Sys_Unlock(busy_Mutex); if(!busyDoneCopy || (canUpload && GL_DeferredTaskCount() > 0) || !Con_IsProgressAnimationCompleted()) { // Let's keep running the busy loop. ClientWindowSystem::main().draw(); return; } // Stop the loop. BusyMode_Exit(); }