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
feat(gameclient): rebind Force Attack hold from the command bar
Olcay Seygan336e8787f8bf
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 6c5ba7e0f..76501207e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -51,9 +51,9 @@ 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.+- 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 (that hold is yours to move on the launcher's Command bar page), 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.-- Combat units that attack-move now have a Force Attack button on the command bar, under Attack Move and left of Stop. It arms the same fire-on-whatever-is-under-the-pointer mode holding Ctrl has always given, and the button wears Ctrl. This version's data checksum differs, so it cannot join a game hosted on an older one.+- Combat units that attack-move now have a Force Attack button on the command bar, under Attack Move and left of Stop. It arms the same fire-on-whatever-is-under-the-pointer mode the hold key has always given. The hold is Ctrl until you change it on the launcher's Hotkeys page, Command bar tab, and the button wears whatever you bound. Shift plus that hold still draws a selection box. This version's data checksum differs, so it cannot join a game hosted on an older one.- The dark plate behind Exit, Restart and the options screen in a match covers the whole picture. It used to sit in a 4:3 frame in the middle, so a widescreen left the battlefield bright down both sides. The box itself keeps the shape it was drawn in.- Buildings select together again, which the one interface had taken away. Shift-click them, drag a box over them, or double-click one for every building of its kind on the screen; select four War Factories and each tank you click goes to whichever has the shortest queue. Double-click a unit and every one of that kind whose feet sit in the picture is taken, including the ones sitting past the camera's far clip that used to be skipped. A building and a unit still never share a selection.- Formation lines are back for everyone. With move, attack move or guard armed, a left drag spreads the selection along the line you draw again; since the one interface it drew a selection box instead, because the line was switched off for the Classic mouse that every player now runs. A drag with no order armed is still the selection box.diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/MetaEvent.h b/GeneralsMD/Code/GameEngine/Include/GameClient/MetaEvent.hindex 594ebe6aa..768c69697 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/MetaEvent.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/MetaEvent.h@@ -388,4 +388,11 @@ public:extern MetaMap *TheMetaMap;+/** The words a command bar button wears for this meta command's key plus modifiers, English, the+ * same shape as the launcher's chord ("Ctrl", "Alt", "F", "Ctrl + F"). Empty when the command is+ * off the keyboard (UseableIn NONE). "Ctrl" when the map is missing, so Force Attack still names+ * its shipped hold. */+UnicodeString MetaMap_formatChord( MappableKeyType key, MappableKeyModState mods, CommandUsableInType usable );+UnicodeString MetaMap_chordLabel( GameMessage::Type meta );+#endifdiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex e96dd7658..6a189ea93 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -4616,17 +4616,22 @@ void ControlBar::setControlCommand( GameWindow *button, const CommandButton *comfor( Int slot = 0; slot < MAX_COMMANDS_PER_SET; slot++ )if( m_commandWindows[ slot ] == button )barSlot = slot;- // Force Attack is Ctrl, the hold that force-fires. Showing H or F on the cameo would- // steal that letter and lie about the key. Do not addHotKey it: Ctrl is already- // MSG_META_BEGIN_FORCEATTACK, and binding the button to Ctrl would toggle on every press.+ // Force Attack wears the BEGIN_FORCEATTACK hold from MetaMap (Ctrl until the player+ // rebinds it on the launcher's Command bar tab). Showing H or F on the cameo would+ // steal that letter and lie about the key. Do not addHotKey it: the hold is already+ // MSG_META_BEGIN_FORCEATTACK, and binding the button to that key would toggle on every press.const Bool forceAttack = commandButton->getCommandType() == GUI_COMMAND_FORCE_ATTACK;const WideChar letter = forceAttack ? 0 : HotKeyManager::playerButtonKey( commandButton->getName(),TheGameText ? TheGameText->fetchEnglishHotKey( commandButton->getTextLabel() ) : 0, barSlot,commandButton->getCommandType() );if( forceAttack ){- GadgetButtonSetText( button, UnicodeString( u"Ctrl" ) );- button->winSetStatus( WIN_STATUS_SHORTCUT_BUTTON );+ const UnicodeString chord = MetaMap_chordLabel( GameMessage::MSG_META_BEGIN_FORCEATTACK );+ GadgetButtonSetText( button, chord );+ if( chord.isEmpty() )+ button->winClearStatus( WIN_STATUS_SHORTCUT_BUTTON );+ else+ button->winSetStatus( WIN_STATUS_SHORTCUT_BUTTON );}else if( letter != 0 ){diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cppindex 2a8b2c7fe..731f4dd63 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp@@ -852,6 +852,81 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t)return m;}+//-------------------------------------------------------------------------------------------------+UnicodeString MetaMap_formatChord( MappableKeyType key, MappableKeyModState mods, CommandUsableInType usable )+{+ if( usable == COMMANDUSABLE_NONE )+ return UnicodeString::TheEmptyString;++ UnicodeString text;+ if( ( mods & CTRL ) != 0 )+ text.concat( UnicodeString( u"Ctrl" ) );+ if( ( mods & ALT ) != 0 )+ {+ if( !text.isEmpty() )+ text.concat( UnicodeString( u" + " ) );+ text.concat( UnicodeString( u"Alt" ) );+ }+ if( ( mods & SHIFT ) != 0 )+ {+ if( !text.isEmpty() )+ text.concat( UnicodeString( u" + " ) );+ text.concat( UnicodeString( u"Shift" ) );+ }+ if( key != MK_NONE )+ {+ const char *token = NULL;+ for( const LookupListRec *rec = KeyNames; rec->name != NULL; ++rec )+ {+ if( rec->value == (Int)key )+ {+ token = rec->name;+ break;+ }+ }+ UnicodeString keyText;+ if( token != NULL && strncmp( token, "KEY_", 4 ) == 0 )+ {+ const char *rest = token + 4;+ if( strcmp( rest, "ESC" ) == 0 )+ keyText = UnicodeString( u"Esc" );+ else if( strcmp( rest, "SPACE" ) == 0 )+ keyText = UnicodeString( u"Space" );+ else if( strcmp( rest, "ENTER" ) == 0 )+ keyText = UnicodeString( u"Enter" );+ else if( strcmp( rest, "BACKSPACE" ) == 0 )+ keyText = UnicodeString( u"Backspace" );+ else if( strcmp( rest, "TAB" ) == 0 )+ keyText = UnicodeString( u"Tab" );+ else if( strcmp( rest, "PGUP" ) == 0 )+ keyText = UnicodeString( u"Page Up" );+ else if( strcmp( rest, "PGDN" ) == 0 )+ keyText = UnicodeString( u"Page Down" );+ else+ keyText.translate( AsciiString( rest ) );+ }+ else+ keyText = UnicodeString( u"Key" );+ if( !text.isEmpty() )+ text.concat( UnicodeString( u" + " ) );+ text.concat( keyText );+ }+ return text;+}++//-------------------------------------------------------------------------------------------------+UnicodeString MetaMap_chordLabel( GameMessage::Type meta )+{+ if( TheMetaMap == NULL )+ return UnicodeString( u"Ctrl" );+ for( const MetaMapRec *rec = TheMetaMap->getFirstMetaMapRec(); rec; rec = rec->m_next )+ {+ if( rec->m_meta == meta )+ return MetaMap_formatChord( rec->m_key, rec->m_modState, rec->m_usableIn );+ }+ return UnicodeString( u"Ctrl" );+}+//-------------------------------------------------------------------------------------------------/*static */ void MetaMap::parseMetaMap(INI* ini){diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cppindex 0ece0fd94..8bc59fa32 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp@@ -1102,14 +1102,14 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessam_leftMouseButtonIsDown = true;m_selectFeedbackAnchor = msg->getArgument( 0 )->pixel;- // with the attack key armed or Ctrl held the left button draws a circle instead of a- // selection box, and everything hostile inside it becomes a target list. An armed line key- // (move, attack move, guard) keeps its line under Ctrl. Ctrl+Shift is the box: you can- // pick units without dropping force-fire. Shift with the attack key armed still queues a- // circle.+ // with the attack key armed or the Force Attack hold down the left button draws a circle+ // instead of a selection box, and everything hostile inside it becomes a target list. An+ // armed line key (move, attack move, guard) keeps its line under the hold. Hold+Shift is+ // the box: you can pick units without dropping force-fire. Shift with the attack key+ // armed still queues a circle.if( TheInGameUI->isForceFireOn() && !TheInGameUI->isLineOrderArmed() && TheInGameUI->getSelectCount() > 0&& TheInGameUI->getGUICommand() == NULL && TheInGameUI->getPendingPlaceType() == NULL- && !( TheKeyboard->isCtrl() && TheKeyboard->isShift() ) )+ && !( TheInGameUI->isInForceAttackMode() && TheKeyboard->isShift() ) )TheInGameUI->beginAttackCircle( m_selectFeedbackAnchor );break;}diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex c9836b7ce..f34457463 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -4174,6 +4174,16 @@ TEST(controlbar_force_attack_slot_is_under_attack_move)GUI_COMMAND_FORCE_ATTACK ), 0 );}+TEST(metamap_format_chord_names_the_hold)+{+ CHECK( MetaMap_formatChord( MK_NONE, CTRL, COMMANDUSABLE_GAME ) == UnicodeString( u"Ctrl" ) );+ CHECK( MetaMap_formatChord( MK_F, NONE, COMMANDUSABLE_GAME ) == UnicodeString( u"F" ) );+ CHECK( MetaMap_formatChord( MK_F, CTRL, COMMANDUSABLE_GAME ) == UnicodeString( u"Ctrl + F" ) );+ CHECK( MetaMap_formatChord( MK_NONE, ALT, COMMANDUSABLE_GAME ) == UnicodeString( u"Alt" ) );+ CHECK( MetaMap_formatChord( MK_NONE, CTRL, COMMANDUSABLE_NONE ).isEmpty() );+ CHECK( MetaMap_chordLabel( GameMessage::MSG_META_BEGIN_FORCEATTACK ) == UnicodeString( u"Ctrl" ) );+}+/* Grid keys leave windows 11 and 13 keyless. The USA War Factory's TOW upgrade in 11 moves to thefirst free keyed window, leftmost first; attack move in 11 has its own A and is never unkeyed */TEST(controlbar_grid_packs_keyless_buttons_into_keyed_windows)