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(controlbar): order rows on the hotkeys page, digit keys, board by click
Olcay Seygan564bbb22c554
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2141a6fa9..a21796625 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -22,6 +22,7 @@ found and fixed, EA's own, not port damage.**- Four idle buttons stand at the right end of the command grid, top to bottom: worker, infantry, vehicle and aircraft. Each picks the next unit of its kind standing with no order and turns the camera to it, as the idle worker button always did; that button has moved there from the column on the left. A button stays dark while nothing of its kind is idle, and its tooltip names the key that does the same. The worker button used to light two to five seconds after the other three, because it waited on the worker to report itself idle; all four now look at your army on the same frame, and the worker button and its key cycle through the same workers that lit it.- The general's powers stand three to a row again, on the right edge above the general's tab. When the top row is short it leaves a step on the inside, and the tray's plate follows that outline.- The promotion window's close button is your side's own now, cut to fit the window's corner. It was the last piece of the old bar's art left on any side's screen.+- On a very wide map the minimap stops at 4:3 and shows the rest with black bands.- Watching a match gets a bar of its own in dark graphite with rounded corners. Its radar takes the map's shape as a player's does, and the column of players stands against the radar's edge on a tall map instead of leaving a gap. A lamp in each player's colour sits beside his button, with a ring round the one you point at and a brighter one round the player you are watching.- While you watch, a rack of drawers hangs from the right edge under the superweapon countdowns. The top drawer holds a lever for the camera with three stops (yours, the director that goes to the biggest fight by itself, or the followed player's own screen), a switch for that player's fog of war and a switch that slides the armies drawer out. Under it every player is ranked on a dial of seven numbers: net worth, cash, income a minute, army value, kills and losses, general's rank and power. Turn it with a click, the wheel or Q, W, E, R, T, Y and A, and each row's bar shows his share of the leader's number. A tab out of each row follows that player, a second click lets him go, and the armies drawer lists the six kinds of unit he has most of, with how many. A click on the rack never reaches the battlefield.- The superweapon countdowns stand where they do in a player's game while you watch, in their tray. The observer's bar named no tray for them, so they used to sit bare and higher up.@@ -499,6 +500,9 @@ found and fixed, EA's own, not port damage.**- The arrow keys scroll the camera in the German game, as they do in English. German Zero Hour put next and previous unit and worker on the bare arrows, so the arrows picked units and only Ctrl and an arrow moved the camera; those four now sit on Ctrl and an arrow, as the English game ships them. Any language that puts a command on a bare arrow gets the same, and an arrow you gave a command yourself on the Hotkeys page stays where you put it.- Grid keys are back, keyed by the cell a button sits in. The first grid moved buttons around to give them a place's letter and still left two places without one; this one moves nothing. With the grid on, the top row of the bar is Q W E R T Y U and the bottom row A S D F G H J, column by column, so the first cell is Q on a Barracks, a War Factory and a tank alike, and the cell under it A. A mod's nine-column bar adds I O over K L. Upgrades take X C V B N in the order they stand on the bar, so the first upgrade of any building is X. The fixed keys step aside on the bar: attack move and stop take their cells' letters like every other button, while Ctrl still forces an attack. A letter you give a button still beats its cell, and a letter can now go to one cell alone, which is what a transport needs: its passengers' exit buttons are all one button, and with a key per cell the third passenger out can be M while the rest keep the grid. Accept on the in-game Hotkeys tab keeps the grid and every per-cell key, and the tab's list shows the grid's letters. On a mod's nine-column bar it now lists every cell the bar has, up to eighteen, each button on the letter the bar gives it, I O K L included. It used to squeeze the bar into fourteen, so an order the bar keeps in the last column was listed on another letter, and a key you gave one of the last four cells never showed.- W no longer starts a War Factory. The launcher had moved China's War Factory onto W, which Zero Hour already gives to Select all aircraft. With a tank selected and no aircraft on the map, W dropped the tank, the idle worker's bar took its place, and the same press let go on that bar's War Factory. The launcher now keeps the buttons it moves off every letter a keyboard command holds on its own, W, Q and the idle worker's I among them, and China's War Factory sits on D. Start the launcher once and it rewrites its part of the file. A letter you picked yourself stays where you put it. The game now settles it for any letter, yours and the grid's included: a key press does one thing. If a button on the bar wears the letter when the key goes down, the button gets it and the keyboard command on that letter waits; if none does, the command fires and the bar that comes up after it is left alone. A button that loses its letter to another, on the bar or the strip of general's powers, shows no letter instead of one that does nothing. With nothing selected, the worker's buildings that the bar shows anyway step off any letter a keyboard command uses on its own: on the grid, Q selects everything and W every aircraft again instead of putting down a Power Plant or a Barracks, and the buildings on free letters keep them.+- With a transport or bunker selected, click one of your units to send it inside.+- A unit on repeat can be switched off even when it cannot be built: a lost prerequisite, the unit cap, a full queue or an unpowered factory no longer lock the button.+- Guard, Attack Move, Force Attack, Move and Hold Position have their own rows on the Hotkeys page, and they bind under any mod. Command bar buttons take digit keys too.## The command bar moves to the middlediff --git a/GeneralsMD/Code/Data/French/Generals.str b/GeneralsMD/Code/Data/French/Generals.strindex 049102812..20ddb0eb7 100644--- a/GeneralsMD/Code/Data/French/Generals.str+++ b/GeneralsMD/Code/Data/French/Generals.str@@ -17285,6 +17285,26 @@ GUI:HotkeysCommandAUTO_REPAIR"Aller se faire réparer ou soigner"END+GUI:HotkeysCommandTOGGLE_ATTACKMOVE+"Attaquer en marche (prochain clic)"+END++GUI:HotkeysCommandTOGGLE_FORCEATTACK+"Forcer l'attaque (prochain clic)"+END++GUI:HotkeysCommandTOGGLE_GUARD+"Protéger (prochain clic)"+END++GUI:HotkeysCommandTOGGLE_MOVE+"Déplacer (prochain clic)"+END++GUI:HotkeysCommandHOLD_POSITION+"Tenir la position"+END+GUI:LoadModeSkirmish"Escarmouche"ENDdiff --git a/GeneralsMD/Code/Data/German/Generals.str b/GeneralsMD/Code/Data/German/Generals.strindex 76acd5093..9ea032c3c 100644--- a/GeneralsMD/Code/Data/German/Generals.str+++ b/GeneralsMD/Code/Data/German/Generals.str@@ -15389,6 +15389,26 @@ GUI:HotkeysCommandAUTO_REPAIR"Reparieren oder heilen lassen"END+GUI:HotkeysCommandTOGGLE_ATTACKMOVE+"Angriffsmarsch (nächster Klick)"+END++GUI:HotkeysCommandTOGGLE_FORCEATTACK+"Angriff erzwingen (nächster Klick)"+END++GUI:HotkeysCommandTOGGLE_GUARD+"Bewachen (nächster Klick)"+END++GUI:HotkeysCommandTOGGLE_MOVE+"Bewegen (nächster Klick)"+END++GUI:HotkeysCommandHOLD_POSITION+"Position halten"+END+GUI:MoneyTransferTitle"Geld senden"ENDdiff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex 6ddde25e5..5f5f56b99 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -2237,6 +2237,26 @@ GUI:HotkeysCommandAUTO_REPAIR"Go get repaired or healed"END+GUI:HotkeysCommandTOGGLE_ATTACKMOVE+"Attack move (next click)"+END++GUI:HotkeysCommandTOGGLE_FORCEATTACK+"Force Attack (next click)"+END++GUI:HotkeysCommandTOGGLE_GUARD+"Guard (next click)"+END++GUI:HotkeysCommandTOGGLE_MOVE+"Move (next click)"+END++GUI:HotkeysCommandHOLD_POSITION+"Hold position"+END+// The match load screen (LoadScreenBoard in LoadScreen.cpp)GUI:LoadModeSkirmish"Skirmish"diff --git a/GeneralsMD/Code/Data/Russian/Generals.str b/GeneralsMD/Code/Data/Russian/Generals.strindex 676625700..63eb71d99 100644--- a/GeneralsMD/Code/Data/Russian/Generals.str+++ b/GeneralsMD/Code/Data/Russian/Generals.str@@ -17237,6 +17237,26 @@ GUI:HotkeysCommandAUTO_REPAIR"Идти на ремонт или лечение"END+GUI:HotkeysCommandTOGGLE_ATTACKMOVE+"Атака на ходу (следующий щелчок)"+END++GUI:HotkeysCommandTOGGLE_FORCEATTACK+"Принудительная атака (следующий щелчок)"+END++GUI:HotkeysCommandTOGGLE_GUARD+"Охрана (следующий щелчок)"+END++GUI:HotkeysCommandTOGGLE_MOVE+"Движение (следующий щелчок)"+END++GUI:HotkeysCommandHOLD_POSITION+"Удерживать позицию"+END+GUI:LoadModeSkirmish"Схватка"ENDdiff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.strindex ab0aaf221..a257f3e9e 100644--- a/GeneralsMD/Code/Data/Turkish/Generals.str+++ b/GeneralsMD/Code/Data/Turkish/Generals.str@@ -16617,6 +16617,26 @@ GUI:HotkeysCommandAUTO_REPAIR"Tamir olmaya ya da iyileşmeye git"END+GUI:HotkeysCommandTOGGLE_ATTACKMOVE+"Saldırarak ilerle (sonraki tıklama)"+END++GUI:HotkeysCommandTOGGLE_FORCEATTACK+"Zorla saldır (sonraki tıklama)"+END++GUI:HotkeysCommandTOGGLE_GUARD+"Koru (sonraki tıklama)"+END++GUI:HotkeysCommandTOGGLE_MOVE+"Hareket et (sonraki tıklama)"+END++GUI:HotkeysCommandHOLD_POSITION+"Yerini koru"+END+// Maç yükleme ekranı (LoadScreen.cpp içindeki LoadScreenBoard)GUI:LoadModeSkirmish"Çatışma"diff --git a/GeneralsMD/Code/Data/Ukrainian/Generals.str b/GeneralsMD/Code/Data/Ukrainian/Generals.strindex fe3499b8b..be7413a68 100644--- a/GeneralsMD/Code/Data/Ukrainian/Generals.str+++ b/GeneralsMD/Code/Data/Ukrainian/Generals.str@@ -17237,6 +17237,26 @@ GUI:HotkeysCommandAUTO_REPAIR"Іти на ремонт або лікування"END+GUI:HotkeysCommandTOGGLE_ATTACKMOVE+"Атака в русі (наступний клік)"+END++GUI:HotkeysCommandTOGGLE_FORCEATTACK+"Примусова атака (наступний клік)"+END++GUI:HotkeysCommandTOGGLE_GUARD+"Охорона (наступний клік)"+END++GUI:HotkeysCommandTOGGLE_MOVE+"Рух (наступний клік)"+END++GUI:HotkeysCommandHOLD_POSITION+"Утримувати позицію"+END+GUI:LoadModeSkirmish"Сутичка"ENDdiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex b89aa6d92..9ae4f2a8d 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -2450,7 +2450,14 @@ void ControlBar::fitRadarToMap( Bool fromLayout )next->winGetScreenPosition( &at.x, &at.y );room = MAX( 0, at.x - ( observer ? box[ RADAR_FIT_INFO ].hi.x : squareOuter.hi.x ) );}- const Int insideWidth = MIN( REAL_TO_INT( insideHeight * m_radarFitWidth / m_radarFitHeight + 0.5f ),+ //+ // A wide map also stops at 4:3 of the inside height, room or not: a 2:1 map stretched the radar+ // across half the bar and pushed everything riding on its right with it. Past that the map is+ // letterboxed with black bands top and bottom, as a map wider than the room already was+ //+ static const Real RADAR_MAX_ASPECT = 4.0f / 3.0f;+ const Int insideWidth = MIN( MIN( REAL_TO_INT( insideHeight * m_radarFitWidth / m_radarFitHeight + 0.5f ),+ REAL_TO_INT( insideHeight * RADAR_MAX_ASPECT + 0.5f ) ),square.hi.x - square.lo.x - 2 * RADAR_BEZEL + room );fit.hi.x = square.lo.x + insideWidth + 2 * RADAR_BEZEL;placeWindowAt( windows[ RADAR_FIT_RADAR ], fit );diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cppindex b6892443a..dbf19219a 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp@@ -997,9 +997,12 @@ void ControlBar::updateContextCommand( void )win->winSetStatus( WIN_STATUS_ALWAYS_COLOR );}- // the same for a unit on repeat the bank cannot pay for right now: Ctrl+Alt click has to- // reach the button to stop it, and a plain click only says there is not enough money- if( repeating && availability == COMMAND_CANT_AFFORD )+ // the same for a unit on repeat that cannot be built right now, whatever the reason (money,+ // a lost prerequisite, the cap, a full queue, an unpowered factory): Ctrl+Alt click has to+ // reach the button to stop it, and a plain click is refused by the build path below with+ // the message it already has. Build buttons come back RESTRICTED far more often than+ // CANT_AFFORD (getCommandAvailability), so testing CANT_AFFORD alone left repeat stuck on.+ if( repeating && ( availability == COMMAND_CANT_AFFORD || availability == COMMAND_RESTRICTED ) )win->winEnable( TRUE );//Determine by the production type of this button, whether or not the created objectdiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cppindex 3b382317e..2b49c07ca 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp@@ -610,10 +610,17 @@ CBCommandStatus ControlBar::processCommandUI( GameWindow *control,{TheInGameUI->message( "GUI:UnitMaxedOut" );break;- }+ }+ // a unit on repeat keeps its button clickable after its prerequisite is lost or its+ // factory goes dark (ControlBar::updateContextCommand), so these reach here now. The+ // tooltip already names what is missing; the click just does nothing+ else if( cmt == CANMAKE_NO_PREREQ || cmt == CANMAKE_FACTORY_IS_DISABLED )+ {+ break;+ }else if (cmt != CANMAKE_OK){- DEBUG_ASSERTCRASH( 0, ("Cannot create '%s' because the factory object '%s' returns false for canMakeUnit\n",+ DEBUG_ASSERTCRASH( 0, ("Cannot create '%s' because the factory object '%s' returns false for canMakeUnit\n",whatToBuild->getName().str(),factory->getTemplate()->getName().str()) );break;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenuHotkeys.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenuHotkeys.cppindex 1c6070ebb..aa44ef2db 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenuHotkeys.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenuHotkeys.cpp@@ -795,8 +795,10 @@ Bool OptionsHotkeysKey( UnsignedByte key, Int state )return TRUE;if( s_capture == CAPTURE_BUTTON ){- // a button takes a letter and nothing else- if( name.size() == 5 && isalpha( (unsigned char)name[ 4 ] ) )+ // a button takes a key that types one letter or digit, bare: the bar finds its button by the+ // character the key types (HotKeyManager::nameOf), and a stroke with Ctrl or Alt is the+ // command map's (barHoldsKey). A digit on a showing button takes the stroke from that team key+ if( name.size() == 5 && isalnum( (unsigned char)name[ 4 ] ) ){const HotkeyBinding letter( name, "NONE" );applySelected( &letter, FALSE );diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cppindex 5df74f9bf..7e28447d9 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp@@ -1508,6 +1508,63 @@ GameMessage::Type CommandTranslator::createEnterMessage( Drawable *enter,} // end createEnterMessage+//-------------------------------------------------------------------------------------------------+/** Enter the other way round: with a transport, a bunker or anything else that holds units+ * selected, a click on one of your own units that would fit in it puts that unit inside. Every+ * selected object has to be yours and hold others, the clicked unit yours, not selected and not+ * inside something already, and the first selected container it has a seat in takes it. */+//-------------------------------------------------------------------------------------------------+static Drawable *boardingContainer( const Object *passenger )+{+ if( passenger == NULL || !passenger->isLocallyControlled() || passenger->isContained() )+ return NULL;+ Drawable *container = NULL;+ const DrawableList *selected = TheInGameUI->getAllSelectedDrawables();+ for( DrawableListCIt it = selected->begin(); it != selected->end(); ++it )+ {+ const Object *obj = (*it)->getObject();+ if( obj == NULL || obj == passenger || !obj->isLocallyControlled() || obj->getContain() == NULL )+ return NULL;+ // ponytail: the first container with a seat, not the nearest; pick by distance if a mixed selection of transports wants it+ if( container == NULL && TheActionManager->canEnterObject( passenger, obj, CMD_FROM_PLAYER, CHECK_CAPACITY ) )+ container = *it;+ }+ return container;+}++//-------------------------------------------------------------------------------------------------+/** MSG_ENTER orders the logic's selected group into its target (GameLogicDispatch), whatever its+ * first argument says. So the passenger is made the group for that one order and the selection+ * the player is looking at goes straight back after it, all from this player and on the same+ * frame, as any other selection change would. */+//-------------------------------------------------------------------------------------------------+static void boardIntoContainer( Drawable *passenger, Drawable *container )+{+ DrawableList rider;+ rider.push_back( passenger );+ PickAndPlayInfo info;+ info.m_drawTarget = container;+ pickAndPlayUnitVoiceResponse( &rider, GameMessage::MSG_ENTER, &info );++ GameMessage *alone = TheMessageStream->appendMessage( GameMessage::MSG_CREATE_SELECTED_GROUP_NO_SOUND );+ alone->appendBooleanArgument( TRUE );+ alone->appendObjectIDArgument( passenger->getObject()->getID() );+ // the shift mark evaluateContextCommand put down goes to the very next message the logic reads+ // (OrderQueue::takeMessage), which is the group above; the enter needs its own+ if( TheInGameUI->isInWaypointMode() )+ TheInGameUI->markNextOrderQueued( ORDER_QUEUE_APPEND );++ GameMessage *enterMsg = TheMessageStream->appendMessage( GameMessage::MSG_ENTER );+ enterMsg->appendObjectIDArgument( passenger->getObject()->getID() );+ enterMsg->appendObjectIDArgument( container->getObject()->getID() );++ GameMessage *back = TheMessageStream->appendMessage( GameMessage::MSG_CREATE_SELECTED_GROUP_NO_SOUND );+ back->appendBooleanArgument( TRUE );+ const DrawableList *selected = TheInGameUI->getAllSelectedDrawables();+ for( DrawableListCIt it = selected->begin(); it != selected->end(); ++it )+ back->appendObjectIDArgument( (*it)->getObject()->getID() );+}+//====================================================================================CommandTranslator::CommandTranslator() :m_objective(0),@@ -1829,8 +1886,9 @@ GameMessage::Type CommandTranslator::evaluateContextCommand( Drawable *draw,TheInGameUI->markNextOrderQueued( ORDER_QUEUE_APPEND );CanAttackResult result;+ Drawable *boarding = NULL;- if(command &&+ if(command &&(command->isContextCommand()|| command->getCommandType() == GUI_COMMAND_SPECIAL_POWER|| command->getCommandType() == GUI_COMMAND_SPECIAL_POWER_FROM_SHORTCUT))@@ -2325,6 +2383,22 @@ GameMessage::Type CommandTranslator::evaluateContextCommand( Drawable *draw,hintMessage->appendObjectIDArgument( obj->getID() );} // end else+ } // end else if+ // ********************************************************************************************+ // the selection is the container and the click names the passenger (boardingContainer)+ else if( draw && !isForceAttackTargeting() && ( boarding = boardingContainer( obj ) ) != NULL )+ {++ msgType = GameMessage::MSG_ENTER;+ if( type == DO_COMMAND )+ boardIntoContainer( draw, boarding );+ else if( type != EVALUATE_ONLY )+ {+ msgType = GameMessage::MSG_ENTER_HINT;+ hintMessage = TheMessageStream->appendMessage( msgType );+ hintMessage->appendObjectIDArgument( obj->getID() );+ }+} // end else if// ********************************************************************************************else if( draw && (result = TheInGameUI->getCanSelectedObjectsAttack( InGameUI::ACTIONTYPE_ATTACK_OBJECT, obj, InGameUI::SELECTION_ANY, isForceAttackTargeting() )) == ATTACKRESULT_POSSIBLE )diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cppindex 55772a287..395a790de 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp@@ -741,7 +741,7 @@ void HotKeyManager::setFixedOrderKeys( Bool fixed )}//------------------------------------------------------------------------------/** CommandButtonHotKey <button name>, Key = one letter or NONE, End. Only the player's own+/** CommandButtonHotKey <button name>, Key = one letter or digit, or NONE, End. Only the player's own* Hotkeys.ini carries these, and nothing in it reaches the INI CRC. *//*static*/ void INI::parseCommandButtonHotKeyDefinition( INI *ini ){@@ -757,7 +757,7 @@ void HotKeyManager::setFixedOrderKeys( Bool fixed )ini->initFromINI( &key, fields );WideChar letter = 0;- if( key.getLength() == 1 && isalpha( (unsigned char)key.getCharAt( 0 ) ) )+ if( key.getLength() == 1 && isalnum( (unsigned char)key.getCharAt( 0 ) ) )letter = (WideChar)toupper( (unsigned char)key.getCharAt( 0 ) );else if( key.compareNoCase( "NONE" ) != 0 )throw INI_INVALID_DATA;@@ -1003,6 +1003,12 @@ std::vector< HotkeyCommandRow > Hotkeys_commandRows( const std::string& commandMunbound.push_back( commandRow( "REQUEST_MONEY", "INFORMATION" ) );unbound.push_back( commandRow( "AUTO_GARRISON", "CONTROL" ) );unbound.push_back( commandRow( "AUTO_REPAIR", "CONTROL" ) );+ // the orders the bar's fixed places press (orderAtPlace in ControlBar.cpp). Their buttons take+ // a letter from the button's label, which a mod's CommandSet names, so without these rows a mod+ // whose guard button sat elsewhere or had no letter left guard with no key a player could set+ static const char *const ORDERS[] = { "TOGGLE_ATTACKMOVE", "TOGGLE_FORCEATTACK", "TOGGLE_GUARD", "TOGGLE_MOVE", "HOLD_POSITION" };+ for( size_t each = 0; each < sizeof( ORDERS ) / sizeof( ORDERS[ 0 ] ); each++ )+ unbound.push_back( commandRow( ORDERS[ each ], "CONTROL" ) );char name[ 32 ];for( Int slot = 1; slot <= 8; slot++ ){@@ -1071,7 +1077,7 @@ HotkeysFile Hotkeys_parse( const std::string& text, const std::vector< HotkeyComfile.commandBarGrid = lowered( block.field( "Enabled", "no" ) ) == "yes";else if( block.type == "CommandButtonHotKey" ){- const Bool letter = key.size() == 1 && isalpha( (unsigned char)key[ 0 ] );+ const Bool letter = key.size() == 1 && isalnum( (unsigned char)key[ 0 ] );file.buttons[ block.name ] = letter ? std::string( 1, (char)toupper( (unsigned char)key[ 0 ] ) ) : std::string();}else if( block.type == "CommandMap" && !startsWith( block.name, "END_" ) )@@ -1133,7 +1139,7 @@ void Hotkeys_launcherKeys( const std::string& launcherPart, std::map< std::strinconst HotkeyIniBlock& block = blocks[ each ];const std::string key = block.field( "Key", "" );if( block.type == "CommandButtonHotKey" )- ( *buttons )[ block.name ] = ( key.size() == 1 && isalpha( (unsigned char)key[ 0 ] ) ) ? key : std::string();+ ( *buttons )[ block.name ] = ( key.size() == 1 && isalnum( (unsigned char)key[ 0 ] ) ) ? key : std::string();else if( block.type == "CommandMap" && !startsWith( block.name, "END_" ) )( *commands )[ block.name ] = lowered( block.field( "UseableIn", "" ) ) == "none"? HotkeyBinding( "", "NONE" ) : HotkeyBinding( Hotkeys_isKeyName( key ) ? key : "", block.field( "Modifiers", "NONE" ) );diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 893ef89e1..b20ff757e 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -2179,10 +2179,12 @@ TEST(hotkeys_every_row_the_page_lists_is_a_command_the_game_knows){static const char *const IDLE[] = { "SELECT_NEXT_IDLE_AIRCRAFT", "SELECT_NEXT_IDLE_VEHICLE", "SELECT_NEXT_IDLE_INFANTRY","SELECT_ALL_IDLE_UNITS", "SELECT_ALL_IDLE_AIRCRAFT", "SELECT_ALL_IDLE_VEHICLES" };+ static const char *const ORDERS[] = { "TOGGLE_ATTACKMOVE", "TOGGLE_FORCEATTACK", "TOGGLE_GUARD", "TOGGLE_MOVE", "HOLD_POSITION" };const std::vector< HotkeyCommandRow > rows = Hotkeys_commandRows( HOTKEYS_COMMAND_MAP );MetaNameProbe names;Int idle = 0;Int autoOrders = 0;+ Int orders = 0;for( size_t each = 0; each < rows.size(); each++ ){CHECK( names.findGameMessageMetaType( rows[ each ].id.c_str() ) != GameMessage::MSG_INVALID );@@ -2191,9 +2193,26 @@ TEST(hotkeys_every_row_the_page_lists_is_a_command_the_game_knows)idle++;if( ( rows[ each ].id == "AUTO_GARRISON" || rows[ each ].id == "AUTO_REPAIR" ) && rows[ each ].category == "CONTROL" && rows[ each ].binding.key.empty() )autoOrders++;+ // the bar's fixed orders, guard among them, are keys a player sets whatever the mod's bar says+ for( size_t name = 0; name < sizeof( ORDERS ) / sizeof( ORDERS[ 0 ] ); name++ )+ if( rows[ each ].id == ORDERS[ name ] && rows[ each ].category == "CONTROL" && rows[ each ].binding.key.empty() && !rows[ each ].barOnly )+ orders++;}CHECK_EQ( idle, 6 );CHECK_EQ( autoOrders, 2 );+ CHECK_EQ( orders, 5 );+}++/* OptionsHotkeysKey gives a bar button a digit as well as a letter, so the file has to keep one:+ a digit read back as no key made the next write drop it. */+TEST(hotkeys_file_keeps_a_digit_on_a_button)+{+ const std::vector< HotkeyCommandRow > rows = Hotkeys_commandRows( HOTKEYS_COMMAND_MAP );+ const HotkeysFile file = Hotkeys_parse( "CommandButtonHotKey Command_Guard\r\n Key = 4\r\nEnd\r\n"+ "CommandButtonHotKey Command_Stop\r\n Key = ,\r\nEnd\r\n", rows );+ CHECK_STR( file.buttons.find( "Command_Guard" )->second.c_str(), "4" );+ CHECK_STR( file.buttons.find( "Command_Stop" )->second.c_str(), "" );+ CHECK( Hotkeys_format( file, rows ).find( "CommandButtonHotKey Command_Guard\r\n Key = 4\r\n" ) != std::string::npos );}TEST(hotkeys_file_the_launcher_wrote_comes_back_byte_for_byte)@@ -16614,25 +16633,6 @@ TEST(a_capturable_tech_building_is_income_not_a_target)}-/** C2: whether a finished wave waits at the rally point or goes now. EA sent every team the moment- it was ready, and a string of small waves is free veterancy for whoever is on the other end.- Three things override the arithmetic, and each of them is a way of getting the AI stuck if it is- missing. */-TEST(massing_waits_for_a_force_but_never_waits_for_ever)-{- const Real AGGRESSIVE = 0.8f; // commits with less- const Real DEFENSIVE = 1.3f; // wants more in hand first-- // half of what the enemy has: not enough for either role- CHECK( aiShouldMass( 500.0f, 1000.0f, AGGRESSIVE, FALSE, FALSE ) );- CHECK( aiShouldMass( 500.0f, 1000.0f, DEFENSIVE, FALSE, FALSE ) );-- // the role is the difference: at parity the aggressive one goes and the defensive one holds- CHECK( !aiShouldMass( 1000.0f, 1000.0f, AGGRESSIVE, FALSE, FALSE ) );- CHECK( aiShouldMass( 1000.0f, 1000.0f, DEFENSIVE, FALSE, FALSE ) );-- // the sixty-second valve wins over everything, so a wave can never be parked for ever- CHECK( !aiShouldMass( 1.0f, 100000.0f, DEFENSIVE, TRUE, FALSE ) );/** An Aurora guarding a circle dropped its one bomb on the nearest thing in it, usually a soldier.A guarding aircraft now takes buildings, then vehicles, then infantry, nearest within a class, andthe lower ObjectID on an exact tie so every machine picks the same one. */@@ -16659,6 +16659,25 @@ TEST(a_guarding_aircraft_bombs_buildings_then_vehicles_then_infantry)}+/** C2: whether a finished wave waits at the rally point or goes now. EA sent every team the moment+ it was ready, and a string of small waves is free veterancy for whoever is on the other end.+ Three things override the arithmetic, and each of them is a way of getting the AI stuck if it is+ missing. */+TEST(massing_waits_for_a_force_but_never_waits_for_ever)+{+ const Real AGGRESSIVE = 0.8f; // commits with less+ const Real DEFENSIVE = 1.3f; // wants more in hand first++ // half of what the enemy has: not enough for either role+ CHECK( aiShouldMass( 500.0f, 1000.0f, AGGRESSIVE, FALSE, FALSE ) );+ CHECK( aiShouldMass( 500.0f, 1000.0f, DEFENSIVE, FALSE, FALSE ) );++ // the role is the difference: at parity the aggressive one goes and the defensive one holds+ CHECK( !aiShouldMass( 1000.0f, 1000.0f, AGGRESSIVE, FALSE, FALSE ) );+ CHECK( aiShouldMass( 1000.0f, 1000.0f, DEFENSIVE, FALSE, FALSE ) );++ // the sixty-second valve wins over everything, so a wave can never be parked for ever+ CHECK( !aiShouldMass( 1.0f, 100000.0f, DEFENSIVE, TRUE, FALSE ) );// so does a fight at home: nothing sits at a rally point while the base is being hitCHECK( !aiShouldMass( 1.0f, 100000.0f, DEFENSIVE, FALSE, TRUE ) );