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): remove grid keys, every button keeps its own letter
Olcay Seyganf318e24149c5
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex b68e4c715..cafc07e8e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -58,9 +58,9 @@ found and fixed — EA's own, not port damage.**- 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.- 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. 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.+- 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.- 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, 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. Every key on the bar sits in the 18-key block under your left hand, Q W E R T Y over A S D F G H over Z X C V B N. Attack move, stop, guard, rally point, evacuate and combat drop keep A, S, G, Y, V and C wherever they stand; the other twelve letters are places, Q W E R T along the top with Z X D F B under them, H in the sixth column and N, still sell, in the last. The places attack move and rally point usually hold have no letter of their own. On a bar without those orders they borrow the free ones: a building has no attack move, so the American War Factory's TOW upgrade at the top of the sixth column is A, and any other button at the top of the seventh column, where a rally point usually stands, is G. A unit's attack move and guard keep A and G as before. A button that still finds no letter there moves to the leftmost free place that has one, so every button on the bar has a key whenever a keyed place is free. The letter on each button changes to match, and type select, select all, scatter and the rest that sat on those letters step aside to P and the keys right of the letters, with the page showing where each went.+- 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.## The command bar moves to the middlediff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.hindex 59eec562c..4ae3f2136 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h@@ -523,11 +523,6 @@ Int ControlBar_forceAttackSlot( const Int *types, Int count, Bool forceFires );* reads KindOf the same way. */Bool ControlBar_forceFires( const Object *obj );-/** Grid keys' second pass over ControlBar_fitCommandSlots' `shown`: a button in window w with no key- * there (`unkeyed[ w ]`) moves to the first empty window, leftmost first, whose place has a key- * (`keyed`), so a set that leaves the keyless top of the last two columns busy and a keyed window- * free gets a key for every button. A button with nowhere to go stays put. */-void ControlBar_packKeyedSlots( const Bool *keyed, const Bool *unkeyed, Int count, Int *shown );/** The page's keys past attack, hold position and move, which no command set has a button for either. */enum OrderKeyExtradiff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/HotKey.h b/GeneralsMD/Code/GameEngine/Include/GameClient/HotKey.hindex 7cf21b548..7c0a6f97e 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/HotKey.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/HotKey.h@@ -115,24 +115,8 @@ public:* button alone; upper case. Attack move, stop, guard, rally point, evacuate and sell have their* fixed letters; another button gets one only from the player, and loses it to the fixed order* on a bar holding both (addHotKey). Force Attack is 0: it is Ctrl, painted on the- * cameo, never a letter. With grid keys on (INI::parseCommandBarGridDefinition) a button on the command bar,- * barSlot its ButtonCommand number less one, gets its place's key instead, except attack move, stop, guard, rally point, evacuate and combat drop, and any other button- * (barSlot -1) loses a letter the grid uses. */- static WideChar playerButtonKey( const AsciiString& button, WideChar labelKey, Int barSlot,- Int commandType );-- /** The key command bar slot barSlot gives a button with grid keys on, 0 for a slot without one or- * with grid keys off. The two keyless places take what lendFixedKeys lent them. */- static WideChar gridSlotKey( Int barSlot );-- /** The bar about to show these `count` buttons (an empty name for none) lends the keyless places- * the fixed letters it has no order for: 11 attack move's A, 13 guard's G or the rally point's Y,- * then any of A S G Y V C still free, so a building's bar keys those places too. NULL buttons,- * which reset() passes, takes them back. */- static void lendFixedKeys( const AsciiString *buttons, const Int *types, Int count );-- /** lendFixedKeys' choice into lent, one letter or 0 per grid place. */- static void gridLentKeys( const AsciiString *buttons, const Int *types, Int count, WideChar *lent );+ * cameo, never a letter. */+ static WideChar playerButtonKey( const AsciiString& button, WideChar labelKey, Int commandType );private:typedef std::map<AsciiString, HotKey> HotKeyMap;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex 602e79647..ee1b8d5d2 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -440,25 +440,6 @@ Bool ControlBar_forceFires( const Object *obj )return obj->isKindOf( KINDOF_TRANSPORT ) && obj->isKindOf( KINDOF_CAN_ATTACK );}-//--------------------------------------------------------------------------------------------------void ControlBar_packKeyedSlots( const Bool *keyed, const Bool *unkeyed, Int count, Int *shown )-{- for( Int from = 0; from < count; from++ )- {- if( !unkeyed[ from ] || shown[ from ] < 0 )- continue;- for( Int to = 0; to < count; to++ )- {- if( keyed[ to ] && shown[ to ] < 0 )- {- shown[ to ] = shown[ from ];- shown[ from ] = -1;- break;- }- }- }-}-//-------------------------------------------------------------------------------------------------void ControlBar_orderKeyPlaces( const Int *places, Int count, Bool fights, Int *keys ){@@ -4622,20 +4603,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. With grid keys on, a command bar button's key is its place.+ // wears it in its top left corner.if( TheHotKeyManager ){- Int barSlot = -1;- for( Int slot = 0; slot < MAX_COMMANDS_PER_SET; slot++ )- if( m_commandWindows[ slot ] == button )- barSlot = slot;// 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,+ TheGameText ? TheGameText->fetchEnglishHotKey( commandButton->getTextLabel() ) : 0,commandButton->getCommandType() );if( forceAttack ){diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cppindex ca920774d..226bd583c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp@@ -379,29 +379,6 @@ void ControlBar::populateCommand( Object *obj )} // end if- // with grid keys on, the fixed letters this bar has no order for key its two keyless places- {- AsciiString names[ MAX_COMMANDS_PER_SET ];- Int types[ MAX_COMMANDS_PER_SET ];- for( i = 0; i < MAX_COMMANDS_PER_SET; i++ )- {- const CommandButton *button = commandSet->getCommandButton( i );- const Bool shows = button && !BitTest( button->getOptions(), SCRIPT_ONLY );- names[ i ] = shows ? button->getName() : AsciiString::TheEmptyString;- types[ i ] = shows ? button->getCommandType() : GUI_COMMAND_NONE;- }- {- const Int forceSlot = ControlBar_forceAttackSlot( types, MAX_COMMANDS_PER_SET, ControlBar_forceFires( obj ) );- const CommandButton *force = forceSlot >= 0 ? findCommandButton( AsciiString( "Command_ForceAttack" ) ) : NULL;- if( force )- {- names[ forceSlot ] = force->getName();- types[ forceSlot ] = force->getCommandType();- }- }- HotKeyManager::lendFixedKeys( names, types, MAX_COMMANDS_PER_SET );- }-// transports do extra special things with the user interface buttonsif( obj->getContain() && obj->getContain()->isDisplayedOnControlBar() )doTransportInventoryUI( obj, commandSet );@@ -431,22 +408,7 @@ void ControlBar::populateCommand( Object *obj )}ControlBar_fitCommandSlots( types, windowed, MAX_COMMANDS_PER_SET, shown );- // with grid keys on a button on a keyless place moves to a free keyed one, so the right of the- // bar does not keep buttons without a key. A passenger's way out stays where the transport- // code put it. Client side only: the bar's layout reaches no logic- Bool keyed[ MAX_COMMANDS_PER_SET ];- Bool unkeyed[ MAX_COMMANDS_PER_SET ];- for( i = 0; i < MAX_COMMANDS_PER_SET; i++ )- {- keyed[ i ] = windowed[ i ] && HotKeyManager::gridSlotKey( i ) != 0;- const CommandButton *button = shown[ i ] >= 0 ? set[ shown[ i ] ] : NULL;- unkeyed[ i ] = keyed[ i ] == FALSE && button && button->getCommandType() != GUI_COMMAND_EXIT_CONTAINER &&- HotKeyManager::playerButtonKey( button->getName(), 0, i, button->getCommandType() ) == 0;- }- ControlBar_packKeyedSlots( keyed, unkeyed, MAX_COMMANDS_PER_SET, shown );-- // a window nothing is fitted to stays empty: its own slot is empty or script only, or its- // button was just packed away+ // a window nothing is fitted to stays empty: its own slot is empty or script onlyfor( i = 0; i < MAX_COMMANDS_PER_SET; i++ )slot[ i ] = shown[ i ] >= 0 ? set[ shown[ i ] ] : NULL;}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cppindex c353e6fef..1acd50114 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp@@ -185,7 +185,6 @@ void HotKeyManager::init( void )void HotKeyManager::reset( void ){m_hotKeyMap.clear();- lendFixedKeys( NULL, NULL, 0 );}static Bool ownsFixedKey( GameWindow *win, const AsciiString& key );@@ -330,29 +329,13 @@ 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, and take the twelve letters of the Q W E R T- * Y / A S D F G H / Z X C V B N block that are no GRID_FIXED_KEYS. Q W E R T top the first five- * columns, Z X D F B under them, each under its own column where the fixed A, S and G leave a gap;- * the sixth column is H under attack move's place (slot 11) and the seventh N, sell's key, under- * the rally point's (slot 13). Those two places have no key of their own: a fixed order standing- * there shows its own letter, and on a bar without such an order the place borrows the free fixed- * letter (HotKeyManager::lendFixedKeys). The launcher's Hotkeys page draws the same table- * (hotkeys.js, GRID_KEYS). */-static const WideChar GRID_KEYS[] = { 'Q', 'Z', 'W', 'X', 'E', 'D', 'R', 'F', 'T', 'B', 0, 'H', 0, 'N' };-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: 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's fake* and real switches, which go by button name. No button keeps one of these letters from its* label; the player may give one to any button on the launcher's Hotkeys page, and on a bar where- * the fixed order stands too, the order gets the key (addHotKey).- * With grid keys on only GRID_FIXED_KEYS hold, on any bar and slot; sell and the H buttons take- * their place's key. The launcher holds the same tables (hotkeys.js, FIXED_KEYS and- * GRID_FIXED_LETTERS). */+ * the fixed order stands too, the order gets the key (addHotKey). The launcher holds the same+ * table (hotkeys.js, FIXED_KEYS). */static const WideChar FIXED_KEYS[] = { 'A', 'S', 'G', 'Y', 'V', 'N', 'C', 'H' };-static const WideChar GRID_FIXED_KEYS[] = { 'A', 'S', 'G', 'Y', 'V', 'C' };static const char *const FIXED_H_BUTTONS[] ={"command_upgradechinamines", "command_upgradeempmines", "command_upgradecamonetting", "command_upgradeglacamonetting",@@ -461,11 +444,9 @@ static Bool isOneOf( WideChar letter, const WideChar *letters, Int count )}//------------------------------------------------------------------------------WideChar HotKeyManager::playerButtonKey( const AsciiString& button, WideChar labelKey, Int barSlot,- Int commandType )+WideChar HotKeyManager::playerButtonKey( const AsciiString& button, WideChar labelKey, Int commandType ){- // Force Attack is Ctrl. Slot 12's grid letter is H, the English label's is F; neither is- // the key, and neither may bind the button.+ // Force Attack is Ctrl. The English label's F is not the key and may not bind the button.if( commandType == GUI_COMMAND_FORCE_ATTACK )return 0;AsciiString lower = button;@@ -473,12 +454,6 @@ WideChar HotKeyManager::playerButtonKey( const AsciiString& button, WideChar labInt ownMod = -1;const std::string bare = withoutModPrefix( lower.str(), &ownMod );const WideChar fixed = fixedButtonKey( AsciiString( bare.c_str() ), commandType );- if( s_commandGrid && barSlot >= 0 )- {- if( fixed != 0 && isOneOf( fixed, GRID_FIXED_KEYS, (Int)( sizeof( GRID_FIXED_KEYS ) / sizeof( GRID_FIXED_KEYS[ 0 ] ) ) ) )- return fixed;- return gridSlotKey( barSlot );- }if( fixed != 0 )return fixed;@@ -490,76 +465,12 @@ WideChar HotKeyManager::playerButtonKey( const AsciiString& button, WideChar lab// still takes it first (addHotKey)if( !chosen && 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;}//------------------------------------------------------------------------------/** What the bar on show lends the two keyless places, see lendFixedKeys. */-static WideChar s_lentKeys[ GRID_KEY_COUNT ] = { 0 };--WideChar HotKeyManager::gridSlotKey( Int barSlot )-{- if( !s_commandGrid || barSlot < 0 || barSlot >= GRID_KEY_COUNT )- return 0;- return GRID_KEYS[ barSlot ] != 0 ? GRID_KEYS[ barSlot ] : s_lentKeys[ barSlot ];-}--//------------------------------------------------------------------------------void HotKeyManager::gridLentKeys( const AsciiString *buttons, const Int *types, Int count, WideChar *lent )-{- const Int fixedCount = (Int)( sizeof( GRID_FIXED_KEYS ) / sizeof( GRID_FIXED_KEYS[ 0 ] ) );- WideChar used[ MAX_COMMANDS_PER_SET + GRID_KEY_COUNT ];- Int usedCount = 0;- for( Int each = 0; each < count; each++ )- {- if( buttons[ each ].isEmpty() )- continue;- AsciiString lower = buttons[ each ];- lower.toLower();- Int mod = -1;- const WideChar fixed = fixedButtonKey( AsciiString( withoutModPrefix( lower.str(), &mod ).c_str() ), types[ each ] );- if( isOneOf( fixed, GRID_FIXED_KEYS, fixedCount ) )- used[ usedCount++ ] = fixed;- }-- for( Int slot = 0; slot < GRID_KEY_COUNT; slot++ )- lent[ slot ] = 0;- // a place takes the order's letter that usually stands there first: attack move's A, then guard's- // G or the rally point's Y; then any fixed letter still free, in GRID_FIXED_KEYS' order- static const struct { Int slot; WideChar letter; } OWN[] = { { 10, 'A' }, { 12, 'G' }, { 12, 'Y' } };- for( Int pass = 0; pass < 2; pass++ )- {- const Int choices = pass == 0 ? (Int)( sizeof( OWN ) / sizeof( OWN[ 0 ] ) ) : GRID_KEY_COUNT * fixedCount;- for( Int each = 0; each < choices; each++ )- {- const Int slot = pass == 0 ? OWN[ each ].slot : each / fixedCount;- const WideChar letter = pass == 0 ? OWN[ each ].letter : GRID_FIXED_KEYS[ each % fixedCount ];- if( GRID_KEYS[ slot ] != 0 || lent[ slot ] != 0 || isOneOf( letter, used, usedCount ) )- continue;- lent[ slot ] = letter;- used[ usedCount++ ] = letter;- }- }-}--//------------------------------------------------------------------------------void HotKeyManager::lendFixedKeys( const AsciiString *buttons, const Int *types, Int count )-{- if( buttons == NULL )- {- for( Int slot = 0; slot < GRID_KEY_COUNT; slot++ )- s_lentKeys[ slot ] = 0;- return;- }- gridLentKeys( buttons, types, count, s_lentKeys );-}--//------------------------------------------------------------------------------/** CommandBarGrid, Enabled = Yes or No, End. Only the player's own Hotkeys.ini carries it, and- * nothing in it reaches the INI CRC. */+/** CommandBarGrid, Enabled = Yes or No, End: the grid keys a launcher before 2026-10-15 wrote into+ * Hotkeys.ini. Grid keys are gone, so the block is read and ignored. *//*static*/ void INI::parseCommandBarGridDefinition( INI *ini ){static const FieldParse fields[] =@@ -567,8 +478,8 @@ void HotKeyManager::lendFixedKeys( const AsciiString *buttons, const Int *types,{ "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" ));+ Bool ignored = FALSE;+ ini->initFromINI( &ignored, fields );}//-----------------------------------------------------------------------------diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 1bb48a477..394ef754d 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -4181,8 +4181,8 @@ TEST(controlbar_force_attack_slot_is_under_attack_move)CHECK_EQ( shown[ 12 ], 16 );CHECK_EQ( shown[ 13 ], 17 );- /* Force Attack is Ctrl: slot 12's grid H and the English label's F both stay off the button */- CHECK_EQ( HotKeyManager::playerButtonKey( AsciiString( "Command_ForceAttack" ), 'F', 11,+ /* Force Attack is Ctrl: the English label's F stays off the button */+ CHECK_EQ( HotKeyManager::playerButtonKey( AsciiString( "Command_ForceAttack" ), 'F',GUI_COMMAND_FORCE_ATTACK ), 0 );}@@ -4196,78 +4196,6 @@ TEST(metamap_format_chord_names_the_hold)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 the- first 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)-{- enum { SLOTS = MAX_COMMANDS_PER_SET, WINDOWS = 14 };- Bool keyed[ SLOTS ];- Bool unkeyed[ SLOTS ];- Int shown[ SLOTS ];- for( Int slot = 0; slot < SLOTS; slot++ )- {- keyed[ slot ] = slot < WINDOWS && slot != 10 && slot != 12;- unkeyed[ slot ] = FALSE;- shown[ slot ] = -1;- }- // eight units in 1-8, TOW in 11, rally point in 13 (its own Y), sell in 14- for( Int slot = 0; slot < 8; slot++ )- shown[ slot ] = slot;- shown[ 10 ] = 10;- shown[ 12 ] = 12;- shown[ 13 ] = 13;- unkeyed[ 10 ] = TRUE;- ControlBar_packKeyedSlots( keyed, unkeyed, SLOTS, shown );- CHECK_EQ( shown[ 8 ], 10 );- CHECK_EQ( shown[ 10 ], -1 );- CHECK_EQ( shown[ 12 ], 12 );- CHECK_EQ( shown[ 13 ], 13 );-- // a full keyed block leaves the button where it is- for( Int slot = 0; slot < WINDOWS; slot++ )- shown[ slot ] = slot;- ControlBar_packKeyedSlots( keyed, unkeyed, SLOTS, shown );- for( Int slot = 0; slot < WINDOWS; slot++ )- CHECK_EQ( shown[ slot ], slot );-}--/* A bar without attack move, guard or rally point lends their letters to the keyless places 11 and- 13; a unit's bar, which has them, keeps A and G on its own orders */-TEST(grid_keyless_places_borrow_the_fixed_letters_a_bar_has_no_order_for)-{- enum { SLOTS = MAX_COMMANDS_PER_SET, PLACES = 14 };- AsciiString names[ SLOTS ];- Int types[ SLOTS ];- WideChar lent[ PLACES ];- for( Int slot = 0; slot < SLOTS; slot++ )- types[ slot ] = GUI_COMMAND_NONE;-- // War Factory: units, TOW, rally point, sell- names[ 0 ] = "Command_ConstructAmericaTankCrusader"; types[ 0 ] = GUI_COMMAND_UNIT_BUILD;- names[ 10 ] = "Command_UpgradeAmericaTOWMissile"; types[ 10 ] = GUI_COMMAND_OBJECT_UPGRADE;- names[ 12 ] = "Command_SetRallyPoint"; types[ 12 ] = GUI_COMMAND_SET_RALLY_POINT;- names[ 13 ] = "Command_Sell"; types[ 13 ] = GUI_COMMAND_SELL;- HotKeyManager::gridLentKeys( names, types, SLOTS, lent );- CHECK_EQ( (Int)lent[ 10 ], (Int)'A' );- CHECK_EQ( (Int)lent[ 12 ], (Int)'G' );- for( Int slot = 0; slot < PLACES; slot++ )- if( slot != 10 && slot != 12 )- CHECK_EQ( (Int)lent[ slot ], 0 );-- // a unit with attack move, guard and stop: A and G are its own, the places borrow what is left- for( Int slot = 0; slot < SLOTS; slot++ )- {- names[ slot ].clear();- types[ slot ] = GUI_COMMAND_NONE;- }- names[ 10 ] = "Command_AttackMove"; types[ 10 ] = GUI_COMMAND_ATTACK_MOVE;- names[ 12 ] = "Command_Guard"; types[ 12 ] = GUI_COMMAND_GUARD;- names[ 13 ] = "Command_Stop"; types[ 13 ] = GUI_COMMAND_STOP;- HotKeyManager::gridLentKeys( names, types, SLOTS, lent );- CHECK_EQ( (Int)lent[ 12 ], (Int)'Y' );- CHECK_EQ( (Int)lent[ 10 ], (Int)'V' );-}-TEST(controlbar_stance_key_takes_what_the_buttons_leave){enum { SLOTS = 14 };