Skip to content

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.

fix(gameclient): a-move and ctrl attack always take the left click

Olcay Seygana1b4046c1d49
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 704a6c05c..ac89e3d1b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -34,6 +34,7 @@ found and fixed — EA's own, not port damage.**
## One interface
- The choice between a Classic and a Reforged interface is gone. There is one, laid out the way Zero Hour shipped, and the orders Reforged added now live on the keys you already know: A attack-moves, holding Ctrl fires on whatever is under the cursor as it did in 2003, a guard order can cover a patch of ground instead of one spot, and orders queue up one after another. Everything your base is building stands on the screen as a line of text each, the six closest to done first and "+N more" for the rest. Superweapon countdowns are listed the same way, up to eighteen. Both lists are in bold type, the build list in white and each countdown in its owner's colour. The promotion screen no longer darkens the battlefield behind it. Whether the right button gives orders, or the left as in 1.04, is a setting in the launcher.
+- An attack move and a Ctrl attack fire on the left click in every mouse setup. With the right button giving orders, A then a right click attack-moved, and Ctrl fired only on a right click, so the same hands did different things depending on one checkbox. Now A, or Ctrl held, then a left click is the attack everywhere, and a right click with A armed puts the key down without an order. Ctrl with a right click gives none. Plain orders stay on whichever button your setup gives them.
- Every key is yours to move. The launcher's Hotkeys page draws the command bar of every building and unit each general can field, cameos and letters as the game shows them, and a click and a keypress gives any button a new letter or none. Two buttons on one bar that would share a letter are marked before you play. The keyboard commands are there too, from bookmarks and team keys to the camera, along with the ones Zero Hour never bound: select every fighting unit, vehicle or aircraft, every barracks, war factory or airfield, the next idle worker or unit, pause, the general's promotions, the three signals to your allies and the general's powers. Your keys are yours alone; the other players in a match keep theirs, and a match never refuses you for them. Every mod you install brings its own generals to the page, ShockWave's fifteen next to Zero Hour's thirteen, and a key you give a ShockWave button stays with ShockWave.
- Some keys now mean one thing on every bar: A attack move, S stop, G guard, Y rally point, V evacuate, N sell, C combat drop, and H for land mines, camo netting and the GLA worker's switch to fake buildings. Sell sits on its own key, so emptying a bunker can never sell it. The 188 buttons Zero Hour had put on one of those letters take another, kept off the grid keys where the bar leaves room (the Avenger is J now), and no bar gained a clash doing it.
- Export and Import on the Hotkeys page take your keys to a file and back, for another PC or a fresh install. Before an import the page tells you how many keys it changes and how many would clash; a file with a line it cannot read changes nothing and quotes that line. Keys for a mod you have not installed come along and wait for it.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
index f98b81184..f0f129753 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
@@ -4165,7 +4165,6 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
// which LookAtXlat and SelectionXlat do, as the game shipped.
if( !TheGlobalData->rightButtonOrders() )
break;
- const Bool classic = TheGlobalData->isClassicMouse();
// A right click is an order. A right drag pans the camera (LookAtXlat), so a release that
// travelled past the drag tolerance, or was held too long, gives no order at all.
@@ -4173,11 +4172,11 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
NULL, NULL,
m_mouseRightDown, m_mouseRightUp);
- // The one exception is the move, attack, attack move or guard key. Those orders are aimed
- // with the left button, so a right click while one is armed puts the key down and gives no
- // order. A pan leaves the key armed. Classic's alternate mouse aims its attack move with
- // this click, as 1.04 did.
- if( !classic && TheInGameUI->isOrderKeyArmed() )
+ // The exceptions are the move, attack, attack move and guard keys and Ctrl's force fire.
+ // Those are aimed with the left button in every mouse, so a right click while a key is armed
+ // puts the key down and gives no order, and a right click with Ctrl held gives none either.
+ // A pan leaves the key armed.
+ if( TheInGameUI->isOrderKeyArmed() || TheInGameUI->isInForceAttackMode() )
{
if( isRightClick )
TheInGameUI->clearAttackMoveToMode();
@@ -4206,18 +4205,14 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
|| (command && command->getCommandType() == GUI_COMMAND_SPECIAL_POWER_FROM_SHORTCUT);
if (isPoint && controllable)
{
- UnsignedInt pickType = getPickTypesForContext( isForceAttackTargeting() );
- Drawable *draw = TheTacticalView->pickDrawable(&msg->getArgument(0)->pixelRegion.lo,
- isForceAttackTargeting(),
+ // force fire never reaches here: it is aimed with the left button, above
+ UnsignedInt pickType = getPickTypesForContext( FALSE );
+ Drawable *draw = TheTacticalView->pickDrawable(&msg->getArgument(0)->pixelRegion.lo,
+ FALSE,
(PickType) pickType);
- if (isForceAttackTargeting()) {
- evaluateForceAttack( draw, &pos, DO_COMMAND );
- } else {
- evaluateContextCommand( draw, &pos, DO_COMMAND );
- }
+ evaluateContextCommand( draw, &pos, DO_COMMAND );
disp = DESTROY_MESSAGE;
- TheInGameUI->clearAttackMoveToMode();
}
}
@@ -4271,15 +4266,14 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
|| command->getCommandType() == GUICOMMANDMODE_HIJACK_VEHICLE
|| command->getCommandType() == GUICOMMANDMODE_CONVERT_TO_CARBOMB));
- // The left button selects and nothing else. The exceptions are a GUI command that is
- // already armed and waiting for a target, and the attack, attack move and guard keys: all of
- // them are aimed with the left button, because the right one cancels them. In Classic the
- // left button is the order button as well, as it was in the game as shipped, unless EA's
- // Alternate Mouse Setup is on: then only a GUI command waiting for a target fires here.
+ // Where the right button gives the orders (Reforged, and Classic under EA's Alternate Mouse
+ // Setup) the left button selects and nothing else. The exceptions are a GUI command that is
+ // already armed and waiting for a target, the move, attack, attack move and guard keys, and
+ // Ctrl's force fire: every mouse aims those with the left button, because the right one
+ // cancels them. Classic's default mouse orders with the left button anyway, as it shipped.
const Bool classic = TheGlobalData->isClassicMouse();
- const Bool isOrderKey = TheInGameUI->isOrderKeyArmed();
- if( classic ? !TheGlobalData->leftButtonOrders() && !isFiringGUICommand
- : !isFiringGUICommand && !isOrderKey )
+ if( !TheGlobalData->leftButtonOrders() && !isFiringGUICommand
+ && !TheInGameUI->isOrderKeyArmed() && !TheInGameUI->isInForceAttackMode() )
break;
Bool controllable = TheInGameUI->areSelectedObjectsControllable()