Skip to content

Commit 78d7582

Browse files
committed
[GEN][ZH] Fix RMB scrolling to normalize movement and be adjustable by scroll speed
1 parent 9527b54 commit 78d7582

File tree

2 files changed

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

2 files changed

+18
-14
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -423,15 +423,17 @@ 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+
// TheSuperHackers @tweak Rescale the scroll factor so the default scroll speed at 50 will result in the RMB scrolling being identical to the original 30FPS retail behavior
434+
const float scrollRescalingFactor = 0.50;
435+
offset.x = TheGlobalData->m_horizontalScrollSpeedFactor * logicToFpsRatio * vecLength * vec.x * (scrollRescalingFactor + TheGlobalData->m_keyboardScrollFactor);
436+
offset.y = TheGlobalData->m_verticalScrollSpeedFactor * logicToFpsRatio * vecLength * vec.y * (scrollRescalingFactor + TheGlobalData->m_keyboardScrollFactor);
435437
}
436438
break;
437439
case SCROLL_KEY:

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,17 @@ 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+
// TheSuperHackers @tweak Rescale the scroll factor so the default scroll speed at 50 will result in the RMB scrolling being identical to the original 30FPS retail behavior
433+
const float scrollRescalingFactor = 0.50;
434+
offset.x = TheGlobalData->m_horizontalScrollSpeedFactor * logicToFpsRatio * vecLength * vec.x * (scrollRescalingFactor + TheGlobalData->m_keyboardScrollFactor);
435+
offset.y = TheGlobalData->m_verticalScrollSpeedFactor * logicToFpsRatio * vecLength * vec.y * (scrollRescalingFactor + TheGlobalData->m_keyboardScrollFactor);
434436
}
435437
break;
436438
case SCROLL_KEY:

0 commit comments

Comments
 (0)