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(gameengine): hold rows for waypoints and selection, no stand-in orders
Olcay Seygan69a387e34fcc
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 57014f780..3ee6258c5 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -146,7 +146,7 @@ found and fixed — EA's own, not port damage.**- A box round your soldiers leaves the worker among them behind again. The rule that a box holding anything military drops the dozers, workers, supply trucks, Chinooks and hackers from it was switched off for the Classic mouse, which is the one every player now runs, so the dozer came along with the tanks. It holds for every box now, a Shift box added to a selection included. A box of workers alone still takes the workers, and a click or a double click on one still takes it.- 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 all your infantry, vehicles 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 18 letters under your left hand where the bar leaves room (the Avenger is J now), and no bar gained a clash doing it. Those letters are still yours to hand out: the Hotkeys page gives A or H to any other button you pick, and marks the clash. On a bar that has the order as well, the order keeps its key: a Barracks button on A fires from A, and a tank's A is still attack move.-- Those orders move too. Sell, attack move, stop, guard, rally point, evacuate, combat drop, the mines, camo netting and the fake building switch were locked to their letters: the Hotkeys tab refused to wait for a key on them, and a letter given to one in the file was ignored in the match. Each one now takes the letter you give it, or none, on the Hotkeys tab like any other button, and keeps it after a restart; the letters above are only where they start. A letter you set also beats the one a button had from the game: Sell moved to K on the GLA Command Center used to lose K to the Worker button, and now sells.+- Those orders move too. Sell, attack move, stop, guard, rally point, evacuate, combat drop, the mines, camo netting and the fake building switch were locked to their letters: the Hotkeys tab refused to wait for a key on them, and a letter given to one in the file was ignored in the match. Each one now takes the letter you give it, or none, on the Hotkeys tab like any other button, and keeps it after a restart; the letters above are only where they start. A letter you set also beats the one a button had from the game: Sell moved to K on the GLA Command Center used to lose K to the Worker button, and now sells. The launcher's Hotkeys page lets them go as well; it used to show the fixed letter whatever you had set and refuse to change it. Two holds Zero Hour put on a modifier alone are on the list of commands now, in the game and the launcher: Alt queues orders and Shift adds to the selection, and either can move to a key or another modifier. With nothing selected and a worker lending you his bar, only his buildings answer a key. H used to throw a GLA worker over to his fake buildings, and S stopped him, though nobody had picked him.- The Hotkeys page is in the game as well, as the last tab of the options screen, so a key can move without quitting to the launcher: from the main menu, or from Esc in the middle of a match. Every command sits on the left with its key. On the right you pick a general and one of his buildings or units, and its command bar is listed button by button, each with its cameo and its letter. Double-click a line, or press Enter or Change, and then the key; Esc lets go. Two buttons of one bar on one letter, or two commands on one key, turn red, and the line under the lists names them. Accept writes the file the launcher writes, so a key set in either place is there in the other, and a key changed in a match works from the next press.- 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.- Grid keys are gone. The switch that made a button's key its place on the bar, Q for the first button of every building, is off the Hotkeys page, and the game no longer moves buttons around to give them a place's letter. Each button wears the letter you gave it or the game's own, and the fixed keys above still hold. A hotkeys file saved with grid keys on loads as before, with the switch ignored, so a player who had them on finds the letters of their own buttons back on the bar.diff --git a/GeneralsMD/Code/Data/German/Generals.str b/GeneralsMD/Code/Data/German/Generals.strindex bf0bec6d0..9542591a7 100644--- a/GeneralsMD/Code/Data/German/Generals.str+++ b/GeneralsMD/Code/Data/German/Generals.str@@ -15069,6 +15069,10 @@ GUI:HotkeysPressForceAttack"Drücke eine Taste, oder Strg oder Alt allein. Umschalt kann nicht die Haltetaste sein. Esc bricht ab."END+GUI:HotkeysPressHold+"Drücke eine Taste, oder Strg, Alt oder Umschalt allein. Esc bricht ab."+END+GUI:HotkeysClash"%s: %s teilen sich diese Taste. Im Spiel bekommt sie nur einer davon: ein fester Befehl behält seine eigene, und ein Buchstabe von dir schlägt den des Spiels."END@@ -15297,6 +15301,14 @@ GUI:HotkeysCommandSIGNAL_ATTENTION"Signal: hierher schauen"END+GUI:HotkeysCommandBEGIN_WAYPOINTS+"Befehle einreihen (halten)"+END++GUI:HotkeysCommandBEGIN_PREFER_SELECTION+"Zur Auswahl hinzufügen (halten)"+END+GUI:MoneyTransferTitle"Geld senden"ENDdiff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex 94037bbbb..0e433b33f 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -1428,6 +1428,10 @@ GUI:HotkeysPressForceAttack"Press a key, or Ctrl or Alt alone. Shift cannot be the hold. Esc cancels."END+GUI:HotkeysPressHold+"Press a key, or Ctrl, Alt or Shift alone. Esc cancels."+END+GUI:HotkeysClash"%s: %s share this key. Only one of them gets it in the game: a fixed order keeps its own, and a letter you set beats the game's."END@@ -1656,6 +1660,14 @@ GUI:HotkeysCommandSIGNAL_ATTENTION"Signal: look here"END+GUI:HotkeysCommandBEGIN_WAYPOINTS+"Queue orders (hold)"+END++GUI:HotkeysCommandBEGIN_PREFER_SELECTION+"Add to selection (hold)"+END+// Computer player personalities, picked per seat in the lobby (AIPersonality)GUI:AIPersonaNormal"Normal"diff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.strindex 64e77ac37..ac458ba2f 100644--- a/GeneralsMD/Code/Data/Turkish/Generals.str+++ b/GeneralsMD/Code/Data/Turkish/Generals.str@@ -15825,6 +15825,10 @@ GUI:HotkeysPressForceAttack"Bir tuşa ya da tek başına Ctrl veya Alt tuşuna basın. Shift basılı tutma tuşu olamaz. Esc vazgeçer."END+GUI:HotkeysPressHold+"Bir tuşa ya da tek başına Ctrl, Alt veya Shift tuşuna basın. Esc vazgeçer."+END+GUI:HotkeysClash"%s: %s aynı tuşu kullanıyor. Oyunda tuş yalnızca birinde çalışır: sabit emir kendi tuşunu korur, senin verdiğin harf oyununkinden önce gelir."END@@ -16053,6 +16057,14 @@ GUI:HotkeysCommandSIGNAL_ATTENTION"İşaret: buraya bak"END+GUI:HotkeysCommandBEGIN_WAYPOINTS+"Emirleri sıraya koy (basılı tut)"+END++GUI:HotkeysCommandBEGIN_PREFER_SELECTION+"Seçime ekle (basılı tut)"+END+// Bilgisayar oyuncusu kişilikleri, lobide koltuk başına seçilir (AIPersonality)GUI:AIPersonaNormal"Normal"diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/HotKey.h b/GeneralsMD/Code/GameEngine/Include/GameClient/HotKey.hindex 8c7c951f6..9e7941f39 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/HotKey.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/HotKey.h@@ -171,6 +171,7 @@ struct HotkeyCommandRowstd::string label; ///< DisplayName, empty for nonestd::string pair; ///< END_ of a BEGIN_, empty otherwiseBool barOnly; ///< Force Attack's hold, set on the command bar page only+ Bool hold; ///< a BEGIN_ the shipped file puts on a modifier alone, which a modifier alone may take againBool launcherDefault; ///< a key the launcher gives a command the game leaves unbound};@@ -182,7 +183,8 @@ struct HotkeysFile};/** The rows of the shipped Data\<language>\CommandMap.ini text, then the commands it leaves unbound- * and Force Attack's hold (loadCommands in hotkeys.js). */+ * and the holds it puts on a modifier alone: Force Attack, waypoints and prefer selection+ * (loadCommands in hotkeys.js). */std::vector< HotkeyCommandRow > Hotkeys_commandRows( const std::string& commandMapText );/** The player's part of a Hotkeys.ini text, and the launcher's part as it stands (parseOverrides). */HotkeysFile Hotkeys_parse( const std::string& text, const std::vector< HotkeyCommandRow >& rows );diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex 034263041..b9f27956d 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -4397,13 +4397,23 @@ void ControlBar::setControlCommand( GameWindow *button, const CommandButton *comsetCommandBarBorder(button, commandButton->getCommandButtonMappedBorderType());+ // A builder standing in for an empty selection lends the keys its buildings and nothing else.+ // Nobody selected it, so its orders keep no letter: H with nothing selected is the command map's+ // (view the command center), not the GLA worker's switch to fake buildings, and S stops nothing.+ Bool standInOrder = FALSE;+ if( m_standInBuilderID != INVALID_DRAWABLE_ID && m_currentSelectedDrawable+ && m_currentSelectedDrawable->getID() == m_standInBuilderID+ && commandButton->getCommandType() != GUI_COMMAND_DOZER_CONSTRUCT )+ for( Int slot = 0; slot < MAX_COMMANDS_PER_SET; slot++ )+ standInOrder = standInOrder || m_commandWindows[ slot ] == button;+// 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.if( TheHotKeyManager ){- const WideChar letter = HotKeyManager::playerButtonKey( commandButton->getName(),+ const WideChar letter = standInOrder ? 0 : HotKeyManager::playerButtonKey( commandButton->getName(),TheGameText ? TheGameText->fetchEnglishHotKey( commandButton->getTextLabel() ) : 0,commandButton->getCommandType() );if( letter != 0 )diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenuHotkeys.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenuHotkeys.cppindex 6e41ec0ad..ff1080f6b 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenuHotkeys.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenuHotkeys.cpp@@ -98,7 +98,7 @@ Int s_active = 0; ///< the list touched last: 0 the commands, 1 the barInt s_commandRow = -1; ///< index into s_rowsconst CommandButton *s_button = NULL;CaptureKind s_capture = CAPTURE_NONE;-std::string s_holdCandidate; ///< Force Attack's hold: Ctrl or Alt pressed alone so far+std::string s_holdCandidate; ///< a hold's capture: the modifier pressed alone so far, "-" once anything else wasBool s_filling = FALSE;UnicodeString wide( const std::string& text )@@ -358,7 +358,7 @@ std::vector< UnicodeString > sameChord( const HotkeyCommandRow& row ){std::vector< UnicodeString > others;const HotkeyBinding binding = bindingOf( row );- if( binding.key.empty() )+ if( binding.key.empty() && binding.modifiers == "NONE" )return others;for( size_t each = 0; each < s_rows.size(); each++ )if( !s_rows[ each ].barOnly && s_rows[ each ].id != row.id && bindingOf( s_rows[ each ] ) == binding )@@ -508,7 +508,7 @@ void updateNote( void )changed = s_file.commands.count( row.id ) != 0;canChange = TRUE;if( s_capture == CAPTURE_COMMAND )- note = TheGameText->fetch( "GUI:HotkeysPressKey" );+ note = TheGameText->fetch( row.hold ? "GUI:HotkeysPressHold" : "GUI:HotkeysPressKey" );else{note.format( u"%s: %s.", commandName( row ).str(), chordOf( binding ).str() );@@ -766,26 +766,29 @@ Bool OptionsHotkeysKey( UnsignedByte key, Int state )const Bool ctrlKey = key == KEY_LCTRL || key == KEY_RCTRL, altKey = key == KEY_LALT || key == KEY_RALT;const Bool shiftKey = key == KEY_LSHIFT || key == KEY_RSHIFT;const Bool force = s_capture == CAPTURE_BUTTON && s_button->getCommandType() == GUI_COMMAND_FORCE_ATTACK;+ const Bool hold = force || ( s_capture == CAPTURE_COMMAND && s_rows[ s_commandRow ].hold );- if( force )+ if( hold ){- // Ctrl or Alt let go with no key between is the hold alone; Shift cannot be the hold- if( ctrlKey || altKey )+ // a modifier let go with no key between is the hold alone. Shift cannot be Force Attack's:+ // Shift on top of that hold queues the circle.+ const char *alone = ctrlKey ? "CTRL" : altKey ? "ALT" : ( shiftKey && !force ) ? "SHIFT" : NULL;+ if( alone ){if( down )- s_holdCandidate = s_holdCandidate.empty() ? ( ctrlKey ? "CTRL" : "ALT" ) : std::string( "-" );- else if( s_holdCandidate == "CTRL" || s_holdCandidate == "ALT" )+ s_holdCandidate = s_holdCandidate.empty() ? std::string( alone ) : std::string( "-" );+ else if( s_holdCandidate == alone ){- const HotkeyBinding hold( "", s_holdCandidate );- applySelected( &hold, FALSE );+ const HotkeyBinding binding( "", alone );+ applySelected( &binding, FALSE );}return TRUE;}const std::string name = keyName( key );- if( down && !shift && !name.empty() )+ if( down && !( force && shift ) && !name.empty() ){- const HotkeyBinding hold( name, modifierName( ctrl, alt, FALSE ) );- applySelected( &hold, FALSE );+ const HotkeyBinding binding( name, modifierName( ctrl, alt, !force && shift ) );+ applySelected( &binding, FALSE );}else if( down )s_holdCandidate = "-";diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cppindex e80ee18ff..be475d625 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp@@ -3972,6 +3972,7 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessagecase GameMessage::MSG_META_BEGIN_WAYPOINTS:// DEBUG_ASSERTCRASH( !TheInGameUI->isInWaypointMode(), ("Setting m_waypointMode but it's already set!") );TheInGameUI->setWaypointMode( true );+ DEBUG_LOG(( "HOTKEYS: waypoint mode on\n" )); // a rebound hold reads back from the logbreak;//-----------------------------------------------------------------------------------------@@ -3988,6 +3989,7 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessagecase GameMessage::MSG_META_END_WAYPOINTS:// DEBUG_ASSERTCRASH( TheInGameUI->isInWaypointMode(), ("Clearing m_waypointMode but it's already clear!") );TheInGameUI->setWaypointMode( false );+ DEBUG_LOG(( "HOTKEYS: waypoint mode off\n" ));break;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cppindex 135a4b1ab..616e1f8a6 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp@@ -743,6 +743,7 @@ static HotkeyCommandRow commandRow( const std::string& id, const std::string& carow.usableIn = "GAME";row.category = category;row.barOnly = FALSE;+ row.hold = FALSE;row.launcherDefault = FALSE;return row;}@@ -798,8 +799,19 @@ std::vector< HotkeyCommandRow > Hotkeys_commandRows( const std::string& commandMunbound[ each ].launcherDefault = TRUE;}+ // HOLD_COMMANDS: KEY_NONE and a modifier in the shipped file, which the rows above leave out.+ // Force Attack's is set from its command bar button, the other two on the commands list.+ static const char *const HOLDS[][ 2 ] = { { "FORCEATTACK", "CTRL" }, { "WAYPOINTS", "ALT" }, { "PREFER_SELECTION", "SHIFT" } };+ for( size_t each = 0; each < sizeof( HOLDS ) / sizeof( HOLDS[ 0 ] ); each++ )+ {+ HotkeyCommandRow hold = commandRow( std::string( "BEGIN_" ) + HOLDS[ each ][ 0 ], "CONTROL", "", HOLDS[ each ][ 1 ] );+ hold.pair = std::string( "END_" ) + HOLDS[ each ][ 0 ];+ hold.barOnly = each == 0;+ hold.hold = TRUE;+ unbound.push_back( hold );+ }+std::vector< HotkeyCommandRow > all = rows;- Bool forceAttack = FALSE;for( size_t each = 0; each < unbound.size(); each++ ){Bool known = FALSE;@@ -808,16 +820,6 @@ std::vector< HotkeyCommandRow > Hotkeys_commandRows( const std::string& commandMif( !known )all.push_back( unbound[ each ] );}- for( size_t row = 0; row < rows.size(); row++ )- forceAttack = forceAttack || rows[ row ].id == "BEGIN_FORCEATTACK";- if( !forceAttack )- {- // FORCE_ATTACK_HOLD: KEY_NONE + Ctrl in the shipped file, set from the command bar page- HotkeyCommandRow hold = commandRow( "BEGIN_FORCEATTACK", "CONTROL", "", "CTRL" );- hold.pair = "END_FORCEATTACK";- hold.barOnly = TRUE;- all.push_back( hold );- }return all;}diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex ccc5d7d6e..61f89ef68 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -1900,6 +1900,39 @@ TEST(hotkeys_names_sort_and_chords_read_as_the_launcher_has_them)CHECK( Hotkeys_isKeyName( "KEY_PGDN" ) && !Hotkeys_isKeyName( "KEY_NONE" ) && !Hotkeys_isKeyName( "KEY_LCTRL" ) );}+/* HotKey.cpp, Hotkeys_commandRows: the waypoint and prefer-selection holds are KEY_NONE and a modifier+ in the shipped file, so the rows read from it dropped them and the Hotkeys tab had no line for them.+ They are rows of their own now, and a key set on one writes the END_ half too: without it the mode+ that the press switched on stays on. */+TEST(hotkeys_waypoint_and_selection_holds_are_rows_and_keep_their_end)+{+ const std::vector< HotkeyCommandRow > rows = Hotkeys_commandRows( HOTKEYS_COMMAND_MAP );+ const HotkeyCommandRow *waypoints = NULL, *prefer = NULL, *force = NULL;+ for( size_t each = 0; each < rows.size(); each++ )+ {+ waypoints = rows[ each ].id == "BEGIN_WAYPOINTS" ? &rows[ each ] : waypoints;+ prefer = rows[ each ].id == "BEGIN_PREFER_SELECTION" ? &rows[ each ] : prefer;+ force = rows[ each ].id == "BEGIN_FORCEATTACK" ? &rows[ each ] : force;+ }+ CHECK( waypoints != NULL && waypoints->hold && !waypoints->barOnly && waypoints->binding == HotkeyBinding( "", "ALT" )+ && waypoints->pair == "END_WAYPOINTS" && waypoints->category == "CONTROL" );+ CHECK( prefer != NULL && prefer->hold && !prefer->barOnly && prefer->binding == HotkeyBinding( "", "SHIFT" )+ && prefer->pair == "END_PREFER_SELECTION" );+ CHECK( force != NULL && force->hold && force->barOnly );++ // Alt's hold moved to Q, and Shift's to Ctrl alone: both halves of each in the file+ HotkeysFile file = Hotkeys_parse( "", rows );+ file.commands[ "BEGIN_WAYPOINTS" ] = HotkeyBinding( "KEY_Q", "NONE" );+ file.commands[ "BEGIN_PREFER_SELECTION" ] = HotkeyBinding( "", "CTRL" );+ const std::string text = Hotkeys_format( file, rows );+ CHECK( text.find( "CommandMap END_WAYPOINTS\r\n Key = KEY_Q\r\n Transition = UP\r\n Modifiers = NONE\r\n UseableIn = GAME\r\n" ) != std::string::npos );+ CHECK( text.find( "CommandMap END_PREFER_SELECTION\r\n Key = KEY_NONE\r\n Transition = UP\r\n Modifiers = CTRL\r\n UseableIn = GAME\r\n" ) != std::string::npos );+ const HotkeysFile back = Hotkeys_parse( text, rows );+ CHECK( back.commands.find( "BEGIN_WAYPOINTS" )->second == HotkeyBinding( "KEY_Q", "NONE" ) );+ CHECK( back.commands.find( "BEGIN_PREFER_SELECTION" )->second == HotkeyBinding( "", "CTRL" ) );+ CHECK( back.commands.find( "END_WAYPOINTS" ) == back.commands.end() );+}+/* HotKey.cpp: a fixed order's letter is its default, not a lock. Players could not move Sell off N:the fixed letter was returned before Hotkeys.ini was asked, and the Hotkeys tab refused the capture. */TEST(hotkeys_every_fixed_order_takes_the_players_letter)