Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(gameclient): send the mouse wheel as notches, not truncated integers
Olcay Seygan0803ee6cf718
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h b/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.hindex 92e61f795..f36f9c062 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h@@ -136,7 +136,7 @@ public:MSG_RAW_MOUSE_RIGHT_DOUBLE_CLICK, ///< (pixel, modifiers, time)MSG_RAW_MOUSE_RIGHT_BUTTON_UP, ///< (pixel, modifiers, time)MSG_RAW_MOUSE_RIGHT_DRAG, ///< drag of the mouse with a button held down- MSG_RAW_MOUSE_WHEEL, ///< (Int spin, + is away, - is toward user)+ MSG_RAW_MOUSE_WHEEL, ///< (Real spin in notches, + is away, - is toward user)MSG_RAW_MOUSE_END,MSG_RAW_KEY_DOWN, ///< (KeyDefType) the given key was pressed (uses Microsoft VK_ codes)diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Mouse.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Mouse.cppindex cdc0a997b..7bc877ec8 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Mouse.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Mouse.cpp@@ -821,7 +821,9 @@ void Mouse::createStreamMessages( void ){msg = TheMessageStream->appendMessage( GameMessage::MSG_RAW_MOUSE_WHEEL );msg->appendPixelArgument( m_currMouse.pos );- msg->appendIntegerArgument( m_currMouse.wheelPos / 120 ); // wheel delta+ // A notch is 120. A touchpad sends less than that per event, and integer division threw+ // those away: the argument came out zero and every small scroll read as a downward one.+ msg->appendRealArgument( (Real)m_currMouse.wheelPos / 120.0f ); // wheel delta, in notchesmsg->appendIntegerArgument( TheKeyboard->getModifierFlags() );} // end ifdiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cppindex 156eae4df..7fb6abc72 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp@@ -424,7 +424,8 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessageReal angle = FACTOR * (m_currentPos.y - m_anchor.y);- TheTacticalView->setPitch( TheTacticalView->getPitch() + angle );+ // Dragging down tips the camera down. The sign used to be the other way round.+ TheTacticalView->setPitch( TheTacticalView->getPitch() - angle );m_anchor = msg->getArgument( 0 )->pixel;}@@ -448,14 +449,17 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage{m_lastMouseMoveFrame = TheGameLogic->getFrame();- Int spin = msg->getArgument( 1 )->integer;+ // Notches, and a touchpad sends fractions of one.+ Real spin = msg->getArgument( 1 )->real;//// Ctrl+wheel turns the structure on the cursor by 45 degrees a notch instead of zooming.// The wheel is otherwise wasted while placing, and the drag-to-aim interface it replaces// cannot hit an exact eighth of a turn. Eaten so the same notch does not also zoom.//- if (TheKeyboard->isCtrl() && TheInGameUI->rotatePendingPlacement( spin ))+ // Whole notches only: half a touchpad swipe is not a 45 degree turn.+ const Int rotateSteps = (Int)spin;+ if (TheKeyboard->isCtrl() && rotateSteps != 0 && TheInGameUI->rotatePendingPlacement( rotateSteps ))return DESTROY_MESSAGE;//@@ -478,16 +482,10 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessagem_zoomAnchorValid = TRUE;}- if (spin > 0)- {- for ( ; spin > 0; spin--)- TheTacticalView->zoomIn();- }- else- {- for ( ;spin < 0; spin++ )- TheTacticalView->zoomOut();- }+ if (spin > 0.0f)+ TheTacticalView->zoomIn( spin );+ else if (spin < 0.0f)+ TheTacticalView->zoomOut( -spin );break; // without this the case fell into MSG_META_OPTIONS below and every wheel// notch called stopScrolling(), killing zoom-while-panning and leaving@@ -631,6 +629,9 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage{DEBUG_ASSERTCRASH(!m_isPitching, ("hmm, mismatched m_isPitching"));m_isPitching = true;+ // Anchor where the drag starts, or the first frame measures against wherever the last+ // rotate or scroll left the anchor and the camera snaps.+ m_anchor = m_currentPos;disp = DESTROY_MESSAGE;break;}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/WindowXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/WindowXlat.cppindex 8e3cdcee2..e0b912cbe 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/WindowXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/WindowXlat.cpp@@ -140,7 +140,7 @@ static GameWindowMessage rawMouseToWindowMessage( const GameMessage *msg )// ------------------------------------------------------------------------case GameMessage::MSG_RAW_MOUSE_WHEEL:- if( msg->getArgument( 1 )->integer > 0 )+ if( msg->getArgument( 1 )->real > 0.0f )gwm = GWM_WHEEL_UP;elsegwm = GWM_WHEEL_DOWN;@@ -299,7 +299,7 @@ GameMessageDisposition WindowTranslator::translateGameMessage(const GameMessageICoord2D mousePos = msg->getArgument( 0 )->pixel;// get wheel position- Int wheelPos = msg->getArgument( 1 )->integer;+ Real wheelPos = msg->getArgument( 1 )->real;// process wheel eventGameWindowMessage gwm = rawMouseToWindowMessage( msg );diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cppindex 0466dc001..72cdb6c6e 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp@@ -831,13 +831,8 @@ void ScriptActions::doPitchCamera(Real pitch, Real sec, Real easeIn, Real easeOuvoid ScriptActions::doOversizeTheTerrain(Int amount){oversizeTheTerrain(amount);- Coord2D offset;- offset.x = 0.0001f;- offset.y = 0.0001f;- TheTacticalView->scrollBy(&offset);- offset.x = -0.0001f;- offset.y = -0.0001f;- TheTacticalView->scrollBy(&offset);+ // The two cancelling scrolls were only here to make the view notice it was dirty.+ TheTacticalView->forceRedraw();}//-------------------------------------------------------------------------------------------------