Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GeneralsMD/Code/GameEngine/Include/Common/GameEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class GameEngine : public SubsystemInterface
virtual Int getFramesPerSecondLimit( void ); ///< Get the max render and engine update fps.
Real getUpdateTime(); ///< Get the last engine update delta time in seconds.
Real getUpdateFps(); ///< Get the last engine update fps.
Real getBaseOverUpdateFpsRatio(Real minUpdateFps = 5.0f); ///< Get the last engine base over update fps ratio. Used to scale user inputs to a frame rate independent speed.

static Bool isTimeFrozen(); ///< Returns true if a script has frozen time.
static Bool isGameHalted(); ///< Returns true if the game is paused or the network is stalling.
Expand Down
8 changes: 8 additions & 0 deletions GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,14 @@ Real GameEngine::getUpdateFps()
return 1.0f / m_updateTime;
}

//-------------------------------------------------------------------------------------------------
Real GameEngine::getBaseOverUpdateFpsRatio(Real minUpdateFps)
{
// TheSuperHackers @info Update fps is floored to default 5 fps, 200 ms.
// Useful to prevent insane ratios on frame spikes/stalls.
return (Real)BaseFps / std::max(getUpdateFps(), minUpdateFps);
}

//-------------------------------------------------------------------------------------------------
Bool GameEngine::isTimeFrozen()
{
Expand Down
4 changes: 2 additions & 2 deletions GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
////////////////////////////////////////////////////////////////////////////////

// InGameUI.cpp ///////////////////////////////////////////////////////////////////////////////////
// Implementation of in-game user interface singleton inteface
// Implementation of in-game user interface singleton
// Author: Michael S. Booth, March 2001
///////////////////////////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -1945,7 +1945,7 @@ void InGameUI::update( void )
if (m_cameraRotatingLeft || m_cameraRotatingRight || m_cameraZoomingIn || m_cameraZoomingOut)
{
// TheSuperHackers @tweak The camera rotation and zoom are now decoupled from the render update.
const Real fpsRatio = (Real)BaseFps / TheGameEngine->getUpdateFps();
const Real fpsRatio = TheGameEngine->getBaseOverUpdateFpsRatio();
const Real rotateAngle = TheGlobalData->m_keyboardCameraRotateSpeed * fpsRatio;
const Real zoomHeight = (Real)View::ZoomHeightPerSecond * fpsRatio;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
{

// TheSuperHackers @bugfix Mauller 07/06/2025 The camera scrolling is now decoupled from the render update.
const Real fpsRatio = (Real)BaseFps / TheGameEngine->getUpdateFps();
const Real fpsRatio = TheGameEngine->getBaseOverUpdateFpsRatio();

switch (m_scrollType)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ void W3DView::update(void)
// if scrolling, only adjust if we're too close or too far
if (m_scrollAmount.length() < m_scrollAmountCutoff || (m_currentHeightAboveGround < m_minHeightAboveGround) || (TheGlobalData->m_enforceMaxCameraHeight && m_currentHeightAboveGround > m_maxHeightAboveGround))
{
const Real fpsRatio = (Real)BaseFps / TheGameEngine->getUpdateFps();
const Real fpsRatio = TheGameEngine->getBaseOverUpdateFpsRatio();
const Real zoomAdj = (desiredZoom - m_zoom) * TheGlobalData->m_cameraAdjustSpeed * fpsRatio;
if (fabs(zoomAdj) >= 0.0001f) // only do positive
{
Expand All @@ -1367,7 +1367,7 @@ void W3DView::update(void)
else if (!didScriptedMovement)
{
// we're not scrolling; settle toward desired height above ground
const Real fpsRatio = (Real)BaseFps / TheGameEngine->getUpdateFps();
const Real fpsRatio = TheGameEngine->getBaseOverUpdateFpsRatio();
const Real zoomAdj = (m_zoom - desiredZoom) * TheGlobalData->m_cameraAdjustSpeed * fpsRatio;
if (fabs(zoomAdj) >= 0.0001f)
{
Expand Down
Loading