void GlobalTimer::Freeze() { unsigned long thisTime; unsigned long advance; thisTime = GetTickCount(); advance = thisTime - startTime; if ( advance < interval) { return; } startTime = thisTime; Game* game = core->GetGame(); if (!game) { return; } game->RealTime++; ieDword count = advance/interval; // pst/bg2 do this, if you fix it for another game, wrap it in a check DoFadeStep(count); // show scrolling cursor while paused GameControl* gc = core->GetGameControl(); if (gc) gc->UpdateScrolling(); }
bool GlobalTimer::Update() { Map *map; Game *game; GameControl* gc; unsigned long thisTime; unsigned long advance; gc = core->GetGameControl(); if (gc) gc->UpdateScrolling(); UpdateAnimations(); thisTime = GetTickCount(); if (!startTime) { startTime = thisTime; return false; } advance = thisTime - startTime; if ( advance < interval) { return false; } ieDword count = advance/interval; DoStep(count); DoFadeStep(count); if (!gc) { goto end; } game = core->GetGame(); if (!game) { goto end; } map = game->GetCurrentArea(); if (!map) { goto end; } //do spell effects expire in dialogs? //if yes, then we should remove this condition if (!(gc->GetDialogueFlags()&DF_IN_DIALOG) ) { map->UpdateFog(); map->UpdateEffects(); if (thisTime) { //this measures in-world time (affected by effects, actions, etc) game->AdvanceTime(1); } } //this measures time spent in the game (including pauses) if (thisTime) { game->RealTime++; } end: startTime = thisTime; return true; }