From 03df274450e5f50eea2942e3f8c05a28ac9fee1f Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sat, 13 May 2023 00:15:48 +0300 Subject: [PATCH] Framerate manager is now in a separate file and private member of GH --- client/CMT.cpp | 4 +- client/CMakeLists.txt | 2 + client/CVideoHandler.cpp | 16 ++-- client/adventureMap/AdventureMapInterface.cpp | 12 +-- client/adventureMap/AdventureMapInterface.h | 3 +- client/battle/BattleAnimationClasses.cpp | 6 +- client/battle/BattleInterfaceClasses.cpp | 2 +- client/battle/BattleObstacleController.cpp | 2 +- client/battle/BattleProjectileController.cpp | 10 +-- client/battle/BattleStacksController.cpp | 2 +- client/gui/CGuiHandler.cpp | 74 ++++--------------- client/gui/CGuiHandler.h | 28 ++----- client/gui/CursorHandler.cpp | 2 +- client/gui/FramerateManager.cpp | 65 ++++++++++++++++ client/gui/FramerateManager.h | 31 ++++++++ client/mapView/MapView.cpp | 4 +- client/widgets/Images.cpp | 2 +- client/windows/CCastleInterface.cpp | 2 +- 18 files changed, 156 insertions(+), 111 deletions(-) create mode 100644 client/gui/FramerateManager.cpp create mode 100644 client/gui/FramerateManager.h diff --git a/client/CMT.cpp b/client/CMT.cpp index 7ade1be02..853c15aef 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -16,6 +16,7 @@ #include "mainmenu/CMainMenu.h" #include "mainmenu/CPrologEpilogVideo.h" #include "gui/CursorHandler.h" +#include "gui/FramerateManager.h" #include "CPlayerInterface.h" #include "CVideoHandler.h" #include "CMusicHandler.h" @@ -599,8 +600,7 @@ static void mainLoop() fsChanged([](const JsonNode &newState){ CGuiHandler::pushUserEvent(EUserEvent::FULLSCREEN_TOGGLED); }); inGuiThread.reset(new bool(true)); - assert(GH.mainFPSmng); - GH.mainFPSmng->init(settings["video"]["targetfps"].Integer()); + GH.framerateManager().init(settings["video"]["targetfps"].Integer()); while(1) //main SDL events loop { diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index b3aea160a..75b375240 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -31,6 +31,7 @@ set(client_SRCS gui/CIntObject.cpp gui/CursorHandler.cpp gui/InterfaceObjectConfigurable.cpp + gui/FramerateManager.cpp gui/NotificationHandler.cpp gui/ShortcutHandler.cpp @@ -162,6 +163,7 @@ set(client_HEADERS gui/CIntObject.h gui/CursorHandler.h gui/InterfaceObjectConfigurable.h + gui/FramerateManager.h gui/MouseButton.h gui/NotificationHandler.h gui/Shortcut.h diff --git a/client/CVideoHandler.cpp b/client/CVideoHandler.cpp index 4979b7ac0..b3e5817d4 100644 --- a/client/CVideoHandler.cpp +++ b/client/CVideoHandler.cpp @@ -370,7 +370,7 @@ void CVideoPlayer::update( int x, int y, SDL_Surface *dst, bool forceRedraw, boo auto packet_duration = frame->duration; #endif double frameEndTime = (frame->pts + packet_duration) * av_q2d(format->streams[stream]->time_base); - frameTime += GH.mainFPSmng->getElapsedMilliseconds() / 1000.0; + frameTime += GH.getFrameDeltaMilliseconds() / 1000.0; if (frameTime >= frameEndTime ) { @@ -450,6 +450,7 @@ bool CVideoPlayer::playVideo(int x, int y, bool stopOnKey) pos.x = x; pos.y = y; + frameTime = 0.0; while(nextFrame()) { @@ -461,10 +462,15 @@ bool CVideoPlayer::playVideo(int x, int y, bool stopOnKey) SDL_RenderCopy(mainRenderer, texture, nullptr, &rect); SDL_RenderPresent(mainRenderer); - // Wait 3 frames - GH.mainFPSmng->framerateDelay(); - GH.mainFPSmng->framerateDelay(); - GH.mainFPSmng->framerateDelay(); +#if (LIBAVUTIL_VERSION_MAJOR < 58) + auto packet_duration = frame->pkt_duration; +#else + auto packet_duration = frame->duration; +#endif + double frameDurationSec = packet_duration * av_q2d(format->streams[stream]->time_base); + uint32_t timeToSleepMillisec = 1000 * (frameDurationSec); + + boost::this_thread::sleep(boost::posix_time::millisec(timeToSleepMillisec)); } return true; diff --git a/client/adventureMap/AdventureMapInterface.cpp b/client/adventureMap/AdventureMapInterface.cpp index c874630a8..3d5d5c933 100644 --- a/client/adventureMap/AdventureMapInterface.cpp +++ b/client/adventureMap/AdventureMapInterface.cpp @@ -59,7 +59,7 @@ AdventureMapInterface::AdventureMapInterface(): shortcuts->setState(EAdventureState::MAKING_TURN); widget->getMapView()->onViewMapActivated(); - addUsedEvents(KEYBOARD); + addUsedEvents(KEYBOARD | TIME); } void AdventureMapInterface::onMapViewMoved(const Rect & visibleArea, int mapLevel) @@ -139,18 +139,20 @@ void AdventureMapInterface::showAll(SDL_Surface * to) void AdventureMapInterface::show(SDL_Surface * to) { - handleMapScrollingUpdate(); - CIntObject::show(to); LOCPLINT->cingconsole->show(to); } -void AdventureMapInterface::handleMapScrollingUpdate() +void AdventureMapInterface::tick(uint32_t msPassed) +{ + handleMapScrollingUpdate(msPassed); +} + +void AdventureMapInterface::handleMapScrollingUpdate(uint32_t timePassed) { /// Width of window border, in pixels, that triggers map scrolling static constexpr uint32_t borderScrollWidth = 15; - uint32_t timePassed = GH.mainFPSmng->getElapsedMilliseconds(); uint32_t scrollSpeedPixels = settings["adventure"]["scrollSpeedPixels"].Float(); uint32_t scrollDistance = scrollSpeedPixels * timePassed / 1000; diff --git a/client/adventureMap/AdventureMapInterface.h b/client/adventureMap/AdventureMapInterface.h index d5d9dfd0f..2c07c1550 100644 --- a/client/adventureMap/AdventureMapInterface.h +++ b/client/adventureMap/AdventureMapInterface.h @@ -75,7 +75,7 @@ private: const IShipyard * ourInaccessibleShipyard(const CGObjectInstance *obj) const; /// check and if necessary reacts on scrolling by moving cursor to screen edge - void handleMapScrollingUpdate(); + void handleMapScrollingUpdate(uint32_t msPassed); void showMoveDetailsInStatusbar(const CGHeroInstance & hero, const CGPathNode & pathNode); @@ -93,6 +93,7 @@ protected: void activate() override; void deactivate() override; + void tick(uint32_t msPassed) override; void show(SDL_Surface * to) override; void showAll(SDL_Surface * to) override; diff --git a/client/battle/BattleAnimationClasses.cpp b/client/battle/BattleAnimationClasses.cpp index abf3282bf..4f0e8498e 100644 --- a/client/battle/BattleAnimationClasses.cpp +++ b/client/battle/BattleAnimationClasses.cpp @@ -381,7 +381,7 @@ bool MovementAnimation::init() void MovementAnimation::nextFrame() { - progress += float(GH.mainFPSmng->getElapsedMilliseconds()) / 1000 * progressPerSecond; + progress += float(GH.getFrameDeltaMilliseconds()) / 1000 * progressPerSecond; //moving instructions myAnim->pos.x = static_cast(begX + distanceX * progress ); @@ -579,7 +579,7 @@ bool ColorTransformAnimation::init() void ColorTransformAnimation::nextFrame() { - float elapsed = GH.mainFPSmng->getElapsedMilliseconds() / 1000.f; + float elapsed = GH.getFrameDeltaMilliseconds() / 1000.f; float fullTime = AnimationControls::getFadeInDuration(); float delta = elapsed / fullTime; totalProgress += delta; @@ -1029,7 +1029,7 @@ void EffectAnimation::playEffect() { if(elem.effectID == ID) { - elem.currentFrame += AnimationControls::getSpellEffectSpeed() * GH.mainFPSmng->getElapsedMilliseconds() / 1000; + elem.currentFrame += AnimationControls::getSpellEffectSpeed() * GH.getFrameDeltaMilliseconds() / 1000; if(elem.currentFrame >= elem.animation->size()) { diff --git a/client/battle/BattleInterfaceClasses.cpp b/client/battle/BattleInterfaceClasses.cpp index 42262df8d..d46901c07 100644 --- a/client/battle/BattleInterfaceClasses.cpp +++ b/client/battle/BattleInterfaceClasses.cpp @@ -220,7 +220,7 @@ void BattleHero::render(Canvas & canvas) canvas.draw(flagFrame, flagPosition); canvas.draw(heroFrame, heroPosition); - float timePassed = float(GH.mainFPSmng->getElapsedMilliseconds()) / 1000.f; + float timePassed = float(GH.getFrameDeltaMilliseconds()) / 1000.f; flagCurrentFrame += currentSpeed * timePassed; currentFrame += currentSpeed * timePassed; diff --git a/client/battle/BattleObstacleController.cpp b/client/battle/BattleObstacleController.cpp index d0f32cdf9..c0966b475 100644 --- a/client/battle/BattleObstacleController.cpp +++ b/client/battle/BattleObstacleController.cpp @@ -161,7 +161,7 @@ void BattleObstacleController::collectRenderableObjects(BattleRenderer & rendere void BattleObstacleController::update() { - timePassed += GH.mainFPSmng->getElapsedMilliseconds() / 1000.f; + timePassed += GH.getFrameDeltaMilliseconds() / 1000.f; } std::shared_ptr BattleObstacleController::getObstacleImage(const CObstacleInstance & oi) diff --git a/client/battle/BattleProjectileController.cpp b/client/battle/BattleProjectileController.cpp index a52060661..476920e3d 100644 --- a/client/battle/BattleProjectileController.cpp +++ b/client/battle/BattleProjectileController.cpp @@ -59,14 +59,14 @@ void ProjectileMissile::show(Canvas & canvas) canvas.draw(image, pos); } - float timePassed = GH.mainFPSmng->getElapsedMilliseconds() / 1000.f; + float timePassed = GH.getFrameDeltaMilliseconds() / 1000.f; progress += timePassed * speed; } void ProjectileAnimatedMissile::show(Canvas & canvas) { ProjectileMissile::show(canvas); - frameProgress += AnimationControls::getSpellEffectSpeed() * GH.mainFPSmng->getElapsedMilliseconds() / 1000; + frameProgress += AnimationControls::getSpellEffectSpeed() * GH.getFrameDeltaMilliseconds() / 1000; size_t animationSize = animation->size(reverse ? 1 : 0); while (frameProgress > animationSize) frameProgress -= animationSize; @@ -76,7 +76,7 @@ void ProjectileAnimatedMissile::show(Canvas & canvas) void ProjectileCatapult::show(Canvas & canvas) { - frameProgress += AnimationControls::getSpellEffectSpeed() * GH.mainFPSmng->getElapsedMilliseconds() / 1000; + frameProgress += AnimationControls::getSpellEffectSpeed() * GH.getFrameDeltaMilliseconds() / 1000; int frameCounter = std::floor(frameProgress); int frameIndex = (frameCounter + 1) % animation->size(0); @@ -91,7 +91,7 @@ void ProjectileCatapult::show(Canvas & canvas) canvas.draw(image, pos); } - float timePassed = GH.mainFPSmng->getElapsedMilliseconds() / 1000.f; + float timePassed = GH.getFrameDeltaMilliseconds() / 1000.f; progress += timePassed * speed; } @@ -136,7 +136,7 @@ void ProjectileRay::show(Canvas & canvas) } } - float timePassed = GH.mainFPSmng->getElapsedMilliseconds() / 1000.f; + float timePassed = GH.getFrameDeltaMilliseconds() / 1000.f; progress += timePassed * speed; } diff --git a/client/battle/BattleStacksController.cpp b/client/battle/BattleStacksController.cpp index 5d3823344..a9ba0f3ff 100644 --- a/client/battle/BattleStacksController.cpp +++ b/client/battle/BattleStacksController.cpp @@ -335,7 +335,7 @@ void BattleStacksController::showStack(Canvas & canvas, const CStack * stack) } stackAnimation[stack->unitId()]->nextFrame(canvas, fullFilter, facingRight(stack)); // do actual blit - stackAnimation[stack->unitId()]->incrementFrame(float(GH.mainFPSmng->getElapsedMilliseconds()) / 1000); + stackAnimation[stack->unitId()]->incrementFrame(float(GH.getFrameDeltaMilliseconds()) / 1000); } void BattleStacksController::update() diff --git a/client/gui/CGuiHandler.cpp b/client/gui/CGuiHandler.cpp index 23db3f839..f21f3e32c 100644 --- a/client/gui/CGuiHandler.cpp +++ b/client/gui/CGuiHandler.cpp @@ -14,6 +14,7 @@ #include "CIntObject.h" #include "CursorHandler.h" #include "ShortcutHandler.h" +#include "FramerateManager.h" #include "../CGameInfo.h" #include "../render/Colors.h" @@ -100,7 +101,7 @@ void CGuiHandler::init() { screenHandlerInstance = std::make_unique(); shortcutsHandlerInstance = std::make_unique(); - mainFPSmng = new CFramerateManager(settings["video"]["targetfps"].Integer()); + framerateManagerInstance = std::make_unique(settings["video"]["targetfps"].Integer()); isPointerRelativeMode = settings["general"]["userRelativePointer"].Bool(); pointerSpeedMultiplier = settings["general"]["relativePointerSpeedMultiplier"].Float(); @@ -193,7 +194,7 @@ void CGuiHandler::totalRedraw() void CGuiHandler::updateTime() { - int ms = mainFPSmng->getElapsedMilliseconds(); + int ms = framerateManagerInstance->getElapsedMilliseconds(); std::list hlp = timeinterested; for (auto & elem : hlp) { @@ -692,10 +693,9 @@ void CGuiHandler::renderFrame() disposed.clear(); } - mainFPSmng->framerateDelay(); // holds a constant FPS + framerateManagerInstance->framerateDelay(); // holds a constant FPS } - CGuiHandler::CGuiHandler() : lastClick(-500, -500) , lastClickTime(0) @@ -705,7 +705,6 @@ CGuiHandler::CGuiHandler() , mouseButtonsMask(0) , continueEventHandling(true) , curInt(nullptr) - , mainFPSmng(nullptr) , statusbar(nullptr) { terminate_cond = new CondSh(false); @@ -713,7 +712,6 @@ CGuiHandler::CGuiHandler() CGuiHandler::~CGuiHandler() { - delete mainFPSmng; delete terminate_cond; } @@ -722,6 +720,11 @@ ShortcutHandler & CGuiHandler::shortcutsHandler() return *shortcutsHandlerInstance; } +FramerateManager & CGuiHandler::framerateManager() +{ + return *framerateManagerInstance; +} + void CGuiHandler::moveCursorToPosition(const Point & position) { SDL_WarpMouseInWindow(mainWindow, position.x, position.y); @@ -756,6 +759,11 @@ const Point & CGuiHandler::getCursorPosition() const return cursorPosition; } +uint32_t CGuiHandler::getFrameDeltaMilliseconds() const +{ + return framerateManagerInstance->getElapsedMilliseconds(); +} + Point CGuiHandler::screenDimensions() const { return Point(screen->w, screen->h); @@ -783,7 +791,7 @@ void CGuiHandler::drawFPSCounter() static SDL_Rect overlay = { 0, 0, 64, 32}; uint32_t black = SDL_MapRGB(screen->format, 10, 10, 10); SDL_FillRect(screen, &overlay, black); - std::string fps = std::to_string(mainFPSmng->getFramerate()); + std::string fps = std::to_string(framerateManagerInstance->getFramerate()); graphics->fonts[FONT_BIG]->renderTextLeft(screen, fps, Colors::YELLOW, Point(10, 10)); } @@ -823,55 +831,3 @@ void CGuiHandler::onScreenResize() totalRedraw(); } - - -CFramerateManager::CFramerateManager(int newRate) - : rate(0) - , rateticks(0) - , fps(0) - , accumulatedFrames(0) - , accumulatedTime(0) - , lastticks(0) - , timeElapsed(0) -{ - init(newRate); -} - -void CFramerateManager::init(int newRate) -{ - rate = newRate; - rateticks = 1000.0 / rate; - this->lastticks = SDL_GetTicks(); -} - -void CFramerateManager::framerateDelay() -{ - ui32 currentTicks = SDL_GetTicks(); - - timeElapsed = currentTicks - lastticks; - accumulatedFrames++; - - // FPS is higher than it should be, then wait some time - if(timeElapsed < rateticks) - { - int timeToSleep = (uint32_t)ceil(this->rateticks) - timeElapsed; - boost::this_thread::sleep(boost::posix_time::milliseconds(timeToSleep)); - } - - currentTicks = SDL_GetTicks(); - // recalculate timeElapsed for external calls via getElapsed() - // limit it to 100 ms to avoid breaking animation in case of huge lag (e.g. triggered breakpoint) - timeElapsed = std::min(currentTicks - lastticks, 100); - - lastticks = SDL_GetTicks(); - - accumulatedTime += timeElapsed; - - if(accumulatedFrames >= 100) - { - //about 2 second should be passed - fps = static_cast(ceil(1000.0 / (accumulatedTime / accumulatedFrames))); - accumulatedTime = 0; - accumulatedFrames = 0; - } -} diff --git a/client/gui/CGuiHandler.h b/client/gui/CGuiHandler.h index 8b8033404..8535c48d4 100644 --- a/client/gui/CGuiHandler.h +++ b/client/gui/CGuiHandler.h @@ -23,7 +23,7 @@ union SDL_Event; struct SDL_MouseMotionEvent; class ShortcutHandler; -class CFramerateManager; +class FramerateManager; class IStatusBar; class CIntObject; class IUpdateable; @@ -44,32 +44,11 @@ enum class EUserEvent FORCE_QUIT, //quit client without question }; -// A fps manager which holds game updates at a constant rate -class CFramerateManager -{ -private: - double rateticks; - ui32 lastticks; - ui32 timeElapsed; - int rate; - int fps; // the actual fps value - ui32 accumulatedTime; - ui32 accumulatedFrames; - -public: - CFramerateManager(int newRate); // initializes the manager with a given fps rate - void init(int newRate); // needs to be called directly before the main game loop to reset the internal timer - void framerateDelay(); // needs to be called every game update cycle - ui32 getElapsedMilliseconds() const {return this->timeElapsed;} - ui32 getFrameNumber() const { return accumulatedFrames; } - ui32 getFramerate() const { return fps; }; -}; - // Handles GUI logic and drawing class CGuiHandler { public: - CFramerateManager * mainFPSmng; //to keep const framerate + std::list> listInt; //list of interfaces - front=foreground; back = background (includes adventure map, window interfaces, all kind of active dialogs, and so on) std::shared_ptr statusbar; @@ -97,6 +76,7 @@ private: CIntObjectList textInterested; std::unique_ptr screenHandlerInstance; + std::unique_ptr framerateManagerInstance; void handleMouseButtonClick(CIntObjectList & interestedObjs, MouseButton btn, bool isPressed); void processLists(const ui16 activityFlag, std::function *)> cb); @@ -117,7 +97,9 @@ public: const Point & getCursorPosition() const; ShortcutHandler & shortcutsHandler(); + FramerateManager & framerateManager(); + uint32_t getFrameDeltaMilliseconds() const; Point screenDimensions() const; /// returns true if at least one mouse button is pressed diff --git a/client/gui/CursorHandler.cpp b/client/gui/CursorHandler.cpp index acc49d1c1..ff7a4f0de 100644 --- a/client/gui/CursorHandler.cpp +++ b/client/gui/CursorHandler.cpp @@ -250,7 +250,7 @@ void CursorHandler::updateSpellcastCursor() { static const float frameDisplayDuration = 0.1f; // H3 uses 100 ms per frame - frameTime += GH.mainFPSmng->getElapsedMilliseconds() / 1000.f; + frameTime += GH.getFrameDeltaMilliseconds() / 1000.f; size_t newFrame = frame; while (frameTime >= frameDisplayDuration) diff --git a/client/gui/FramerateManager.cpp b/client/gui/FramerateManager.cpp new file mode 100644 index 000000000..b210c2237 --- /dev/null +++ b/client/gui/FramerateManager.cpp @@ -0,0 +1,65 @@ +/* + * FramerateManager.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +#include "StdInc.h" +#include "FramerateManager.h" + +#include + +FramerateManager::FramerateManager(int newRate) + : rate(0) + , rateticks(0) + , fps(0) + , accumulatedFrames(0) + , accumulatedTime(0) + , lastticks(0) + , timeElapsed(0) +{ + init(newRate); +} + +void FramerateManager::init(int newRate) +{ + rate = newRate; + rateticks = 1000.0 / rate; + this->lastticks = SDL_GetTicks(); +} + +void FramerateManager::framerateDelay() +{ + ui32 currentTicks = SDL_GetTicks(); + + timeElapsed = currentTicks - lastticks; + accumulatedFrames++; + + // FPS is higher than it should be, then wait some time + if(timeElapsed < rateticks) + { + int timeToSleep = (uint32_t)ceil(this->rateticks) - timeElapsed; + boost::this_thread::sleep(boost::posix_time::milliseconds(timeToSleep)); + } + + currentTicks = SDL_GetTicks(); + // recalculate timeElapsed for external calls via getElapsed() + // limit it to 100 ms to avoid breaking animation in case of huge lag (e.g. triggered breakpoint) + timeElapsed = std::min(currentTicks - lastticks, 100); + + lastticks = SDL_GetTicks(); + + accumulatedTime += timeElapsed; + + if(accumulatedFrames >= 100) + { + //about 2 second should be passed + fps = static_cast(ceil(1000.0 / (accumulatedTime / accumulatedFrames))); + accumulatedTime = 0; + accumulatedFrames = 0; + } +} diff --git a/client/gui/FramerateManager.h b/client/gui/FramerateManager.h new file mode 100644 index 000000000..c1db41190 --- /dev/null +++ b/client/gui/FramerateManager.h @@ -0,0 +1,31 @@ +/* + * FramerateManager.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ +#pragma once + +// A fps manager which holds game updates at a constant rate +class FramerateManager +{ +private: + double rateticks; + ui32 lastticks; + ui32 timeElapsed; + int rate; + int fps; // the actual fps value + ui32 accumulatedTime; + ui32 accumulatedFrames; + +public: + FramerateManager(int newRate); // initializes the manager with a given fps rate + void init(int newRate); // needs to be called directly before the main game loop to reset the internal timer + void framerateDelay(); // needs to be called every game update cycle + ui32 getElapsedMilliseconds() const {return this->timeElapsed;} + ui32 getFrameNumber() const { return accumulatedFrames; } + ui32 getFramerate() const { return fps; }; +}; diff --git a/client/mapView/MapView.cpp b/client/mapView/MapView.cpp index 94e483ad6..e576fc9e1 100644 --- a/client/mapView/MapView.cpp +++ b/client/mapView/MapView.cpp @@ -66,13 +66,13 @@ void BasicMapView::render(Canvas & target, bool fullUpdate) void BasicMapView::show(SDL_Surface * to) { - controller->updateBefore(GH.mainFPSmng->getElapsedMilliseconds()); + controller->updateBefore(GH.getFrameDeltaMilliseconds()); Canvas target(to); CSDL_Ext::CClipRectGuard guard(to, pos); render(target, false); - controller->updateAfter(GH.mainFPSmng->getElapsedMilliseconds()); + controller->updateAfter(GH.getFrameDeltaMilliseconds()); } void BasicMapView::showAll(SDL_Surface * to) diff --git a/client/widgets/Images.cpp b/client/widgets/Images.cpp index 6b79633ef..485cc161b 100644 --- a/client/widgets/Images.cpp +++ b/client/widgets/Images.cpp @@ -395,7 +395,7 @@ void CShowableAnim::show(SDL_Surface * to) if ((flags & PLAY_ONCE) && frame + 1 == last) return; - frameTimePassed += GH.mainFPSmng->getElapsedMilliseconds(); + frameTimePassed += GH.getFrameDeltaMilliseconds(); if(frameTimePassed >= frameTimeTotal) { diff --git a/client/windows/CCastleInterface.cpp b/client/windows/CCastleInterface.cpp index 1501065de..7329b4882 100644 --- a/client/windows/CCastleInterface.cpp +++ b/client/windows/CCastleInterface.cpp @@ -215,7 +215,7 @@ void CBuildingRect::show(SDL_Surface * to) } if(stateTimeCounter < BUILD_ANIMATION_FINISHED_TIMEPOINT) - stateTimeCounter += GH.mainFPSmng->getElapsedMilliseconds(); + stateTimeCounter += GH.getFrameDeltaMilliseconds(); } void CBuildingRect::showAll(SDL_Surface * to)