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): fixed order keys and grid keys from hotkeys.ini
Olcay Seygan67feda4dd0f8
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex cffcad38b..69fc41aa6 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -33,6 +33,8 @@ found and fixed — EA's own, not port damage.**- 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.- 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.+- Some keys now mean one thing on every bar: A attack move, S stop, G guard, R rally point, V evacuate or sell, C combat drop, and F for land mines, camo netting and the GLA worker's switch to fake buildings. Where a bunker, fire base, palace or tunnel has both evacuate and sell, V empties it and sell moves to O, so a slipped finger never sells a full bunker. The 182 buttons Zero Hour had put on one of those letters take another from their own name (the Avenger is E now), and no bar gained a clash doing it.+- Grid keys, one switch on the Hotkeys page: a button's key is its place on the bar, so the first button of a Command Center is Q and so is the first of a Barracks, a War Factory or a dozer. The keyboard's Q W E R over A S D F covers the first four columns and Z X over C V the next two, with the fixed keys' places stepping one key along the row to J, K, T, L, N and B. The letter on each button changes to match, and type select, select all, scatter and the rest that sat on those letters step aside, with the page showing where each went.## The command bar moves to the middlediff --git a/GeneralsMD/Code/GameEngine/Include/Common/INI.h b/GeneralsMD/Code/GameEngine/Include/Common/INI.hindex 560fea9b3..91cbdf839 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/INI.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/INI.h@@ -281,6 +281,7 @@ public:static void parseTerrainBridgeDefinition( INI *ini );static void parseMetaMapDefinition( INI *ini );static void parseCommandButtonHotKeyDefinition( INI *ini );+ static void parseCommandBarGridDefinition( INI *ini );static void parseFXListDefinition( INI *ini );static void parseObjectCreationListDefinition( INI* ini );static void parseMultiplayerSettingsDefinition( INI* ini );diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.hindex 322d1a1b2..de423ec04 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h@@ -1255,6 +1255,7 @@ protected:GameWindow *m_specialPowerShortcutParent;GameWindow *m_commandWindows[ MAX_COMMANDS_PER_SET ]; ///< command window controls for easy access+ Bool m_barHasEvacuate; ///< the command set populateCommand is laying out has an evacuate, which takes sell's V/** A player upgrade is researched once, so it goes to exactly one of the selected buildings -diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/HotKey.h b/GeneralsMD/Code/GameEngine/Include/GameClient/HotKey.hindex 200b37671..cac383305 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/HotKey.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/HotKey.h@@ -112,8 +112,13 @@ public:/** The key a command button gets: the one the player gave it in Hotkeys.ini (the launcher's* Hotkeys page writes it, INI::parseCommandButtonHotKeyDefinition reads it), 0 where the player* took the key away, and labelKey, the letter after the label's '&', where the player left the- * button alone. */- static WideChar playerButtonKey( const AsciiString& button, WideChar labelKey );+ * button alone; upper case. Attack move, stop, guard, rally point, evacuate and sell always have+ * their fixed letters (evacuateOnBar: sell shares the bar with an evacuate) and no other button+ * gets one. With grid keys on (INI::parseCommandBarGridDefinition) a button on the command bar,+ * barSlot its ButtonCommand number less one, gets its place's key instead, and any other button+ * (barSlot -1) loses a letter the grid uses. */+ static WideChar playerButtonKey( const AsciiString& button, WideChar labelKey, Int barSlot,+ Int commandType, Bool evacuateOnBar );private:typedef std::map<AsciiString, HotKey> HotKeyMap;diff --git a/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp b/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cppindex 882697791..542574683 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp@@ -99,6 +99,7 @@ static const BlockParse theTypeTable[] ={ "ChallengeGenerals", INI::parseChallengeModeDefinition },{ "CommandButton", INI::parseCommandButtonDefinition },{ "CommandButtonHotKey", INI::parseCommandButtonHotKeyDefinition },+ { "CommandBarGrid", INI::parseCommandBarGridDefinition },{ "CommandMap", INI::parseMetaMapDefinition },{ "CommandSet", INI::parseCommandSetDefinition },{ "ControlBarScheme", INI::parseControlBarSchemeDefinition },diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex 2952d01b1..b836ab67e 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -1387,6 +1387,7 @@ ControlBar::ControlBar( void ){Int i;m_commandButtons = NULL;+ m_barHasEvacuate = FALSE;m_commandSets = NULL;m_controlBarSchemeManager = NULL;m_isObserverCommandBar = FALSE;@@ -4482,13 +4483,16 @@ void ControlBar::setControlCommand( GameWindow *button, const CommandButton *com// the key is the one the player gave the button on the launcher's Hotkeys page, or else the// game's own, the letter after the '&' in the button's label - the English label's in every// language, so a Turkish or German player presses what an English one does - and the button- // wears it in its top left corner+ // wears it in its top left corner. With grid keys on, a command bar button's key is its place.if( TheHotKeyManager ){- WideChar letter = HotKeyManager::playerButtonKey( commandButton->getName(),- TheGameText ? TheGameText->fetchEnglishHotKey( commandButton->getTextLabel() ) : 0 );- if( letter >= u'a' && letter <= u'z' )- letter -= ( u'a' - u'A' );+ Int barSlot = -1;+ for( Int slot = 0; slot < MAX_COMMANDS_PER_SET; slot++ )+ if( m_commandWindows[ slot ] == button )+ barSlot = slot;+ const WideChar letter = HotKeyManager::playerButtonKey( commandButton->getName(),+ TheGameText ? TheGameText->fetchEnglishHotKey( commandButton->getTextLabel() ) : 0, barSlot,+ commandButton->getCommandType(), barSlot >= 0 && m_barHasEvacuate );if( letter != 0 ){TheHotKeyManager->addHotKey( button, HotKeyManager::nameOf( letter ) );diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cppindex fc6f1e162..dd87e6f5c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp@@ -384,8 +384,13 @@ void ControlBar::populateCommand( Object *obj )// what goes in each slot: the command set, slot for slotconst CommandButton *slot[ MAX_COMMANDS_PER_SET ];- for( i = 0; i < MAX_COMMANDS_PER_SET; i++ )+ m_barHasEvacuate = FALSE;+ for( i = 0; i < MAX_COMMANDS_PER_SET; i++ ) // sell gives V up to an evacuate on the same bar+ {slot[ i ] = commandSet->getCommandButton( i );+ if( slot[ i ] && slot[ i ]->getCommandType() == GUI_COMMAND_EVACUATE )+ m_barHasEvacuate = TRUE;+ }// populate the button with commands definedconst CommandButton *commandButton;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cppindex 2a153c05e..9eaaadcce 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp@@ -230,6 +230,8 @@ Bool HotKeyManager::executeHotKey( const AsciiString& keyIn )return TRUE;}+ const CommandButton *disabled = (const CommandButton *)GadgetButtonGetData( win );+ DEBUG_LOG(( "HOTKEYS: %s found %s disabled\n", key.str(), disabled ? disabled->getName().str() : "a window" ));AudioEventRTS disabledClick( "GUIClickDisabled" );if( TheAudio ){@@ -302,13 +304,94 @@ AsciiString HotKeyManager::searchHotKey( const UnicodeString& uStr )* kept for the whole run, so it lives outside the manager, which every game client rebuilds. */static std::map< std::string, WideChar > s_playerButtonKeys;+/** Grid keys (Hotkeys.ini's CommandBarGrid), by command bar slot: ControlBar.wnd's ButtonCommand01+ * to 14 stand two rows of seven read down the columns, so Q W E R over A S D F take the first+ * four columns and Z X C V the next two. A, S, R, F, C and V belong to the fixed orders+ * (FIXED_KEYS), so their places take the next free key along the keyboard row instead: J, K, T, L,+ * N and B. Slots 13 and 14, the last column, get no key. The launcher's Hotkeys page draws the+ * same table (hotkeys.js, GRID_KEYS). */+static const WideChar GRID_KEYS[] = { 'Q', 'J', 'W', 'K', 'E', 'D', 'T', 'L', 'Z', 'N', 'X', 'B' };+static const Int GRID_KEY_COUNT = sizeof( GRID_KEYS ) / sizeof( GRID_KEYS[ 0 ] );+static Bool s_commandGrid = FALSE;++/** The owner's fixed keys, 2026-10-12, on every bar and in both modes: A attack move, S stop,+ * G guard, R rally point, V evacuate and sell, C combat drop, and F for land mines, camo netting+ * and the GLA's fake and real switches, which go by button name. Where a bar has both evacuate and+ * sell, evacuate keeps V and sell takes O. No other button may have one of these letters. The+ * launcher holds the same tables (hotkeys.js, FIXED_KEYS). */+static const WideChar FIXED_KEYS[] = { 'A', 'S', 'G', 'R', 'V', 'C', 'F' };+static const WideChar SELL_BESIDE_EVACUATE_KEY = 'O';+static const char *const FIXED_F_BUTTONS[] =+{+ "command_upgradechinamines", "command_upgradeempmines", "command_upgradecamonetting", "command_upgradeglacamonetting",+ "command_upgradeglaworkerfakecommandset", "command_upgradeglaworkerrealcommandset"+};+static const char FIXED_F_PREFIX[] = "command_becomerealgla"; ///< a fake building's switch to the real one++static WideChar fixedButtonKey( const AsciiString& lowerName, Int commandType, Bool evacuateOnBar )+{+ if( strncmp( lowerName.str(), FIXED_F_PREFIX, sizeof( FIXED_F_PREFIX ) - 1 ) == 0 )+ return 'F';+ for( Int each = 0; each < (Int)( sizeof( FIXED_F_BUTTONS ) / sizeof( FIXED_F_BUTTONS[ 0 ] ) ); each++ )+ if( lowerName.compare( FIXED_F_BUTTONS[ each ] ) == 0 )+ return 'F';+ switch( commandType )+ {+ case GUI_COMMAND_ATTACK_MOVE: return 'A';+ case GUI_COMMAND_STOP: return 'S';+ case GUI_COMMAND_GUARD: return 'G';+ case GUI_COMMAND_SET_RALLY_POINT: return 'R';+ case GUI_COMMAND_EVACUATE: return 'V';+ case GUI_COMMAND_SELL: return evacuateOnBar ? SELL_BESIDE_EVACUATE_KEY : 'V';+ case GUI_COMMAND_COMBATDROP: return 'C';+ }+ return 0;+}++static Bool isOneOf( WideChar letter, const WideChar *letters, Int count )+{+ for( Int each = 0; each < count; each++ )+ if( letters[ each ] == letter )+ return TRUE;+ return FALSE;+}+//------------------------------------------------------------------------------WideChar HotKeyManager::playerButtonKey( const AsciiString& button, WideChar labelKey )+WideChar HotKeyManager::playerButtonKey( const AsciiString& button, WideChar labelKey, Int barSlot,+ Int commandType, Bool evacuateOnBar ){AsciiString name = button;name.toLower();+ const WideChar fixed = fixedButtonKey( name, commandType, evacuateOnBar );+ if( fixed != 0 )+ return fixed;+ if( s_commandGrid && barSlot >= 0 )+ return barSlot < GRID_KEY_COUNT ? GRID_KEYS[ barSlot ] : 0;+std::map< std::string, WideChar >::const_iterator it = s_playerButtonKeys.find( name.str() );- return it == s_playerButtonKeys.end() ? labelKey : it->second;+ WideChar letter = it == s_playerButtonKeys.end() ? labelKey : it->second;+ if( letter >= 'a' && letter <= 'z' )+ letter -= 'a' - 'A';+ if( isOneOf( letter, FIXED_KEYS, (Int)( sizeof( FIXED_KEYS ) / sizeof( FIXED_KEYS[ 0 ] ) ) ) )+ return 0;+ // a button off the bar gives a grid letter up to the bar+ if( s_commandGrid && isOneOf( letter, GRID_KEYS, GRID_KEY_COUNT ) )+ return 0;+ return letter;+}++//-----------------------------------------------------------------------------+/** CommandBarGrid, Enabled = Yes or No, End. Only the player's own Hotkeys.ini carries it, and+ * nothing in it reaches the INI CRC. */+/*static*/ void INI::parseCommandBarGridDefinition( INI *ini )+{+ static const FieldParse fields[] =+ {+ { "Enabled", INI::parseBool, NULL, 0 },+ { NULL, NULL, NULL, 0 }+ };+ ini->initFromINI( &s_commandGrid, fields );+ DEBUG_LOG(( "HOTKEYS: grid keys %s\n", s_commandGrid ? "on" : "off" ));}//-----------------------------------------------------------------------------