Skip to content

Commit bf8d5be

Browse files
authored
bugfix(gameengine): Fix logic in GameEngine::canUpdateRegularGameLogic() (TheSuperHackers#2707)
1 parent 842c7a5 commit bf8d5be

4 files changed

Lines changed: 18 additions & 20 deletions

File tree

Generals/Code/GameEngine/Include/Common/GameEngine.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ class GameEngine : public SubsystemInterface
8080

8181
virtual void resetSubsystems();
8282

83-
Bool canUpdateGameLogic();
83+
Bool canUpdateGameLogic(UnsignedInt logicTimeQueryFlags);
8484
Bool canUpdateNetworkGameLogic();
85-
Bool canUpdateRegularGameLogic();
85+
Bool canUpdateRegularGameLogic(UnsignedInt logicTimeQueryFlags);
8686

8787
virtual FileSystem *createFileSystem(); ///< Factory for FileSystem classes
8888
virtual LocalFileSystem *createLocalFileSystem() = 0; ///< Factory for LocalFileSystem classes

Generals/Code/GameEngine/Source/Common/GameEngine.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ void GameEngine::resetSubsystems()
649649
}
650650

651651
/// -----------------------------------------------------------------------------------------------
652-
Bool GameEngine::canUpdateGameLogic()
652+
Bool GameEngine::canUpdateGameLogic(UnsignedInt logicTimeQueryFlags)
653653
{
654654
// Must be first.
655655
TheGameLogic->preUpdate();
@@ -663,7 +663,7 @@ Bool GameEngine::canUpdateGameLogic()
663663
}
664664
else
665665
{
666-
return canUpdateRegularGameLogic();
666+
return canUpdateRegularGameLogic(logicTimeQueryFlags);
667667
}
668668
}
669669

@@ -684,19 +684,18 @@ Bool GameEngine::canUpdateNetworkGameLogic()
684684
}
685685

686686
/// -----------------------------------------------------------------------------------------------
687-
Bool GameEngine::canUpdateRegularGameLogic()
687+
Bool GameEngine::canUpdateRegularGameLogic(UnsignedInt logicTimeQueryFlags)
688688
{
689-
const Bool enabled = TheFramePacer->isLogicTimeScaleEnabled();
690-
const Int logicTimeScaleFps = TheFramePacer->getLogicTimeScaleFps();
691-
const Int maxRenderFps = TheFramePacer->getFramesPerSecondLimit();
689+
const Int logicTimeScaleFps = TheFramePacer->getActualLogicTimeScaleFps(logicTimeQueryFlags);
690+
const Int maxRenderFps = TheFramePacer->getActualFramesPerSecondLimit();
692691

693692
#if defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE)
694693
const Bool useFastMode = TheGlobalData->m_TiVOFastMode;
695694
#else //always allow this cheat key if we're in a replay game.
696695
const Bool useFastMode = TheGlobalData->m_TiVOFastMode && TheGameLogic->isInReplayGame();
697696
#endif
698697

699-
if (useFastMode || !enabled || logicTimeScaleFps >= maxRenderFps)
698+
if (useFastMode || logicTimeScaleFps >= maxRenderFps)
700699
{
701700
// Logic time scale is uncapped or larger equal Render FPS. Update straight away.
702701
return true;
@@ -746,7 +745,7 @@ void GameEngine::update()
746745
}
747746
}
748747

749-
const Bool canUpdate = canUpdateGameLogic();
748+
const Bool canUpdate = canUpdateGameLogic(FramePacer::IgnoreFrozenTime | FramePacer::IgnoreHaltedGame);
750749
const Bool canUpdateLogic = canUpdate && !TheFramePacer->isGameHalted() && !TheFramePacer->isTimeFrozen();
751750
const Bool canUpdateScript = canUpdate && !TheFramePacer->isGameHalted();
752751

GeneralsMD/Code/GameEngine/Include/Common/GameEngine.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ class GameEngine : public SubsystemInterface
7979

8080
virtual void resetSubsystems();
8181

82-
Bool canUpdateGameLogic();
82+
Bool canUpdateGameLogic(UnsignedInt logicTimeQueryFlags);
8383
Bool canUpdateNetworkGameLogic();
84-
Bool canUpdateRegularGameLogic();
84+
Bool canUpdateRegularGameLogic(UnsignedInt logicTimeQueryFlags);
8585

8686
virtual FileSystem *createFileSystem(); ///< Factory for FileSystem classes
8787
virtual LocalFileSystem *createLocalFileSystem() = 0; ///< Factory for LocalFileSystem classes

GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ void GameEngine::resetSubsystems()
813813
}
814814

815815
/// -----------------------------------------------------------------------------------------------
816-
Bool GameEngine::canUpdateGameLogic()
816+
Bool GameEngine::canUpdateGameLogic(UnsignedInt logicTimeQueryFlags)
817817
{
818818
// Must be first.
819819
TheGameLogic->preUpdate();
@@ -827,7 +827,7 @@ Bool GameEngine::canUpdateGameLogic()
827827
}
828828
else
829829
{
830-
return canUpdateRegularGameLogic();
830+
return canUpdateRegularGameLogic(logicTimeQueryFlags);
831831
}
832832
}
833833

@@ -848,19 +848,18 @@ Bool GameEngine::canUpdateNetworkGameLogic()
848848
}
849849

850850
/// -----------------------------------------------------------------------------------------------
851-
Bool GameEngine::canUpdateRegularGameLogic()
851+
Bool GameEngine::canUpdateRegularGameLogic(UnsignedInt logicTimeQueryFlags)
852852
{
853-
const Bool enabled = TheFramePacer->isLogicTimeScaleEnabled();
854-
const Int logicTimeScaleFps = TheFramePacer->getLogicTimeScaleFps();
855-
const Int maxRenderFps = TheFramePacer->getFramesPerSecondLimit();
853+
const Int logicTimeScaleFps = TheFramePacer->getActualLogicTimeScaleFps(logicTimeQueryFlags);
854+
const Int maxRenderFps = TheFramePacer->getActualFramesPerSecondLimit();
856855

857856
#if defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE)
858857
const Bool useFastMode = TheGlobalData->m_TiVOFastMode;
859858
#else //always allow this cheat key if we're in a replay game.
860859
const Bool useFastMode = TheGlobalData->m_TiVOFastMode && TheGameLogic->isInReplayGame();
861860
#endif
862861

863-
if (useFastMode || !enabled || logicTimeScaleFps >= maxRenderFps)
862+
if (useFastMode || logicTimeScaleFps >= maxRenderFps)
864863
{
865864
// Logic time scale is uncapped or larger equal Render FPS. Update straight away.
866865
return true;
@@ -910,7 +909,7 @@ void GameEngine::update()
910909
}
911910
}
912911

913-
const Bool canUpdate = canUpdateGameLogic();
912+
const Bool canUpdate = canUpdateGameLogic(FramePacer::IgnoreFrozenTime | FramePacer::IgnoreHaltedGame);
914913
const Bool canUpdateLogic = canUpdate && !TheFramePacer->isGameHalted() && !TheFramePacer->isTimeFrozen();
915914
const Bool canUpdateScript = canUpdate && !TheFramePacer->isGameHalted();
916915

0 commit comments

Comments
 (0)