diff --git a/Generals/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp b/Generals/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp index 9960f68f093..86c2617e0b6 100644 --- a/Generals/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp @@ -381,10 +381,8 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage // rotate the view up/down if (m_isPitching) { - const Real FACTOR = 0.01f; - - Real angle = FACTOR * (m_currentPos.y - m_anchor.y); - + constexpr const Real Scale = 0.01f; + const Real angle = Scale * (m_currentPos.y - m_anchor.y); TheTacticalView->setPitch( TheTacticalView->getPitch() + angle ); m_anchor = msg->getArgument( 0 )->pixel; } @@ -393,10 +391,8 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage // adjust the field of view if (m_isChangingFOV) { - const Real FACTOR = 0.01f; - - Real angle = FACTOR * (m_currentPos.y - m_anchor.y); - + constexpr const Real Scale = 0.01f; + const Real angle = Scale * (m_currentPos.y - m_anchor.y); TheTacticalView->setFieldOfView( TheTacticalView->getFieldOfView() + angle ); m_anchor = msg->getArgument( 0 )->pixel; } @@ -409,18 +405,9 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage { m_lastMouseMoveTimeMsec = timeGetTime(); - Int spin = msg->getArgument( 1 )->integer; - - if (spin > 0) - { - for ( ; spin > 0; spin--) - TheTacticalView->zoom( -View::ZoomHeightPerSecond ); - } - else - { - for ( ;spin < 0; spin++ ) - TheTacticalView->zoom( +View::ZoomHeightPerSecond ); - } + const Int spin = msg->getArgument( 1 )->integer; + const Real zoom = -spin * View::ZoomHeightPerSecond; + TheTacticalView->zoom(zoom); break; } @@ -440,17 +427,15 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage { Coord2D offset = {0, 0}; - // If we've been forced to stop scrolling (script action?) then stop if (m_isScrolling && !TheInGameUI->isScrolling()) { + // If we've been forced to stop scrolling (script action?) TheInGameUI->setScrollAmount(offset); stopScrolling(); } - else - // scroll the view - if (m_isScrolling) + else if (m_isScrolling) { - + // Scroll the view // TheSuperHackers @bugfix Mauller 07/06/2025 The camera scrolling is now decoupled from the render update. const Real fpsRatio = TheFramePacer->getBaseOverUpdateFpsRatio(); @@ -532,8 +517,11 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage TheInGameUI->setScrollAmount(offset); TheTacticalView->scrollBy( &offset ); } - else //not scrolling so reset amount + else + { + //not scrolling so reset amount TheInGameUI->setScrollAmount(offset); + } //if (TheGlobalData->m_saveCameraInReplay /*&& TheRecorder->getMode() != RECORDERMODETYPE_PLAYBACK *//**/&& (TheGameLogic->isInSinglePlayerGame() || TheGameLogic->isInSkirmishGame())/**/) //if (TheGlobalData->m_saveCameraInReplay && (TheGameLogic->isInMultiplayerGame() || TheGameLogic->isInSinglePlayerGame() || TheGameLogic->isInSkirmishGame())) diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp index f1de5c5e586..552755702b1 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp @@ -380,10 +380,8 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage // rotate the view up/down if (m_isPitching) { - const Real FACTOR = 0.01f; - - Real angle = FACTOR * (m_currentPos.y - m_anchor.y); - + constexpr const Real Scale = 0.01f; + const Real angle = Scale * (m_currentPos.y - m_anchor.y); TheTacticalView->setPitch( TheTacticalView->getPitch() + angle ); m_anchor = msg->getArgument( 0 )->pixel; } @@ -392,10 +390,8 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage // adjust the field of view if (m_isChangingFOV) { - const Real FACTOR = 0.01f; - - Real angle = FACTOR * (m_currentPos.y - m_anchor.y); - + constexpr const Real Scale = 0.01f; + const Real angle = Scale * (m_currentPos.y - m_anchor.y); TheTacticalView->setFieldOfView( TheTacticalView->getFieldOfView() + angle ); m_anchor = msg->getArgument( 0 )->pixel; } @@ -408,18 +404,9 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage { m_lastMouseMoveTimeMsec = timeGetTime(); - Int spin = msg->getArgument( 1 )->integer; - - if (spin > 0) - { - for ( ; spin > 0; spin--) - TheTacticalView->zoom( -View::ZoomHeightPerSecond ); - } - else - { - for ( ;spin < 0; spin++ ) - TheTacticalView->zoom( +View::ZoomHeightPerSecond ); - } + const Int spin = msg->getArgument( 1 )->integer; + const Real zoom = -spin * View::ZoomHeightPerSecond; + TheTacticalView->zoom(zoom); break; } @@ -439,17 +426,15 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage { Coord2D offset = {0, 0}; - // If we've been forced to stop scrolling (script action?) then stop if (m_isScrolling && !TheInGameUI->isScrolling()) { + // If we've been forced to stop scrolling (script action?) TheInGameUI->setScrollAmount(offset); stopScrolling(); } - else - // scroll the view - if (m_isScrolling) + else if (m_isScrolling) { - + // Scroll the view // TheSuperHackers @bugfix Mauller 07/06/2025 The camera scrolling is now decoupled from the render update. const Real fpsRatio = TheFramePacer->getBaseOverUpdateFpsRatio(); @@ -531,8 +516,11 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage TheInGameUI->setScrollAmount(offset); TheTacticalView->scrollBy( &offset ); } - else //not scrolling so reset amount + else + { + //not scrolling so reset amount TheInGameUI->setScrollAmount(offset); + } //if (TheGlobalData->m_saveCameraInReplay /*&& TheRecorder->getMode() != RECORDERMODETYPE_PLAYBACK *//**/&& (TheGameLogic->isInSinglePlayerGame() || TheGameLogic->isInSkirmishGame())/**/) //if (TheGlobalData->m_saveCameraInReplay && (TheGameLogic->isInMultiplayerGame() || TheGameLogic->isInSinglePlayerGame() || TheGameLogic->isInSkirmishGame()))