Skip to content

Commit c1903b6

Browse files
authored
[GEN][ZH] Fix up the right mouse button scrolling to properly normalize its movement and correctly apply the Scroll Speed modifier (#1244)
1 parent adf9dde commit c1903b6

File tree

2 files changed

+14
-14
lines changed
  • GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream
  • Generals/Code/GameEngine/Source/GameClient/MessageStream

2 files changed

+14
-14
lines changed

Generals/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -423,15 +423,15 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
423423
m_anchor.y = m_currentPos.y - maxY;
424424
}
425425

426-
offset.x = TheGlobalData->m_horizontalScrollSpeedFactor * logicToFpsRatio * (m_currentPos.x - m_anchor.x);
427-
offset.y = TheGlobalData->m_verticalScrollSpeedFactor * logicToFpsRatio * (m_currentPos.y - m_anchor.y);
426+
// TheSuperHackers @fix Mauller 16/06/2025 fix RMB scrolling to allow it to scale with the user adjusted scroll factor
428427
Coord2D vec;
429-
vec.x = offset.x;
430-
vec.y = offset.y;
428+
vec.x = (m_currentPos.x - m_anchor.x);
429+
vec.y = (m_currentPos.y - m_anchor.y);
430+
// TheSuperHackers @info calculate the length of the vector to obtain the movement speed before the vector is normalized
431+
float vecLength = vec.length();
431432
vec.normalize();
432-
// Add in the window scroll amount as the minimum.
433-
offset.x += TheGlobalData->m_horizontalScrollSpeedFactor * vec.x * sqr(TheGlobalData->m_keyboardScrollFactor);
434-
offset.y += TheGlobalData->m_verticalScrollSpeedFactor * vec.y * sqr(TheGlobalData->m_keyboardScrollFactor);
433+
offset.x = TheGlobalData->m_horizontalScrollSpeedFactor * logicToFpsRatio * vecLength * vec.x * TheGlobalData->m_keyboardScrollFactor;
434+
offset.y = TheGlobalData->m_verticalScrollSpeedFactor * logicToFpsRatio * vecLength * vec.y * TheGlobalData->m_keyboardScrollFactor;
435435
}
436436
break;
437437
case SCROLL_KEY:

GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,15 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
422422
m_anchor.y = m_currentPos.y - maxY;
423423
}
424424

425-
offset.x = TheGlobalData->m_horizontalScrollSpeedFactor * logicToFpsRatio * (m_currentPos.x - m_anchor.x);
426-
offset.y = TheGlobalData->m_verticalScrollSpeedFactor * logicToFpsRatio * (m_currentPos.y - m_anchor.y);
425+
// TheSuperHackers @fix Mauller 16/06/2025 fix RMB scrolling to allow it to scale with the user adjusted scroll factor
427426
Coord2D vec;
428-
vec.x = offset.x;
429-
vec.y = offset.y;
427+
vec.x = (m_currentPos.x - m_anchor.x);
428+
vec.y = (m_currentPos.y - m_anchor.y);
429+
// TheSuperHackers @info calculate the length of the vector to obtain the movement speed before the vector is normalized
430+
float vecLength = vec.length();
430431
vec.normalize();
431-
// Add in the window scroll amount as the minimum.
432-
offset.x += TheGlobalData->m_horizontalScrollSpeedFactor * vec.x * sqr(TheGlobalData->m_keyboardScrollFactor);
433-
offset.y += TheGlobalData->m_verticalScrollSpeedFactor * vec.y * sqr(TheGlobalData->m_keyboardScrollFactor);
432+
offset.x = TheGlobalData->m_horizontalScrollSpeedFactor * logicToFpsRatio * vecLength * vec.x * TheGlobalData->m_keyboardScrollFactor;
433+
offset.y = TheGlobalData->m_verticalScrollSpeedFactor * logicToFpsRatio * vecLength * vec.y * TheGlobalData->m_keyboardScrollFactor;
434434
}
435435
break;
436436
case SCROLL_KEY:

0 commit comments

Comments
 (0)