Skip to content

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.

feat(gameclient): command grid rows by what a button is for

Olcay Seygan1711b694003f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 537f3de1b..4d59cf1a1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -655,7 +655,7 @@ A third pass went through the generals' powers, promotions and unit abilities.
- Both are an ordinary web page with a stylesheet, in the game's Window folder. Change the colours, the sizes or the order there and the next match you watch draws it that way, and the page opens in a browser too.
- A minimised command bar stays minimised. Changing seats, or clicking another player's unit while watching, put the whole bar back up over the battlefield you had just cleared. A new match still opens with the bar up.
- The command bar's frame is drawn new, in the same steel as the boards. Each panel holds one thing and is exactly its size, the radar, the command grid, the portrait with the experience bar, and wears a steel border outside it. Grey for America, red for China, sand for GLA. It slides and minimises with the bar, and like the boards it is a page in the Window folder; take the page away and the old painted bar comes back.
-- The command bar is laid out anew, all of it running rightwards from the bottom left corner, and it is smaller: at 1920x1080 it stands 248 pixels tall where the old bar took 312, and it ends a third of the way across, so the rest of the screen's bottom edge is battlefield but for the general's powers in the corner. The radar sits in the corner, taller than before so its top lines up with the power bar's, with your general's experience bar standing beside it, and on its top edge the under-attack light, the skills key with your rank's stars on that, and over the stars the idle worker button whenever a worker stands idle. Next to it is one grid of eighteen buttons, six across and three down, and every button is its own key: Q W E R T Y over A S D F G H over Z X C V B N. No more two-key building shortcuts and no second bars: a dozer's buildings, a factory's units, a unit's abilities and upgrades and its orders all share the grid, each a single press. The orders stay put whatever you select. For a unit, A attacks, S stops, D attack-moves, V moves, Z ejects the passengers, X guards and C holds position; for a building, N sells it, B sets its rally point and Z empties its garrison. Workers keep three of their own: N clears mines on every side's worker and dozer, H swaps a GLA worker between real and fake buildings, and B is the Demolition worker's suicide charge. Everything else packs into the top left corner, two rows at a time, Q A W Z S E X D R C and on, so the buildings you reach for most sit under your fingers; what a building makes comes first and its upgrades after. Only the buttons your selection has are drawn, and with nothing selected the grid stays as a plate of bare steel. Its buttons are a fifth bigger than the rest of the bar's, so what you build stands out. Attack, hold position and move are buttons now, where no unit ever had one, with pictures painted to sit among the game's own: a crosshair on a red plate over a burning sky, a raised palm on a blue one, an arrow on a green diamond. V, or a click on the arrow, is a move for the left button: the next click on the ground sends the selection there, and a left drag lays them out along the line you draw. Beside the grid, on the bottom edge of the screen, runs a portrait bar only as long as what it holds. Select one unit and its upgrades follow its portrait; select a group and the bar holds every kind of unit in it once, each with how many you have, the one Tab has picked lit and the rest dimmed. Point at an upgrade and its card tells you what it is and what it does; point at a group's picture and it names the unit and how many you have. The power bar lies along the top of the grid, and your money sits on its left end, so both are one glance from the buttons you spend them on. The Legacy mouse and keyboard and the W A S D camera are gone from the Options screen: there is one way to play, and an Options.ini that still names them loads as it always did.
+- The command bar is laid out anew, all of it running rightwards from the bottom left corner, and it is smaller: at 1920x1080 it stands 248 pixels tall where the old bar took 312, and it ends a third of the way across, so the rest of the screen's bottom edge is battlefield but for the general's powers in the corner. The radar sits in the corner, taller than before so its top lines up with the power bar's, with your general's experience bar standing beside it, and on its top edge the under-attack light, the skills key with your rank's stars on that, and over the stars the idle worker button whenever a worker stands idle. Next to it is one grid of eighteen buttons, six across and three down, and every button is its own key: Q W E R T Y over A S D F G H over Z X C V B N. No more two-key building shortcuts and no second bars: a dozer's buildings, a factory's units, a unit's abilities and upgrades and its orders all share the grid, each a single press. The orders stay put whatever you select. For a unit, A attacks, S stops, D attack-moves, V moves, Z ejects the passengers, X guards and C holds position; for a building, N sells it, B sets its rally point and Z empties its garrison. Workers keep three of their own: N clears mines on every side's worker and dozer, H swaps a GLA worker between real and fake buildings, and B is the Demolition worker's suicide charge. Everything else goes in rows by what it is for. A dozer or worker puts what makes your army along the top row, barracks, factories, airfield and command center; its defenses along the middle row; power, supply, tech and the superweapon along the bottom. Every side's builder files the same kind of building on the same row, so the war factory is up top whether you play USA, China or GLA, with nothing selected as well. The GLA fakes take the top row too, and H swaps between real and fake from the same place on both. A unit's abilities and upgrades share the top row, a building's upgrades sit on the row under the units it trains, and a transport's or a bunker's passengers gather in the bottom right corner, one button each. A row that runs out of room carries on in the emptiest of the others. Only the buttons your selection has are drawn, and with nothing selected the grid stays as a plate of bare steel. Its buttons are a fifth bigger than the rest of the bar's, so what you build stands out. Attack, hold position and move are buttons now, where no unit ever had one, with pictures painted to sit among the game's own: a crosshair on a red plate over a burning sky, a raised palm on a blue one, an arrow on a green diamond. V, or a click on the arrow, is a move for the left button: the next click on the ground sends the selection there, and a left drag lays them out along the line you draw. Beside the grid, on the bottom edge of the screen, runs a portrait bar only as long as what it holds. Select one unit and its upgrades follow its portrait; select a group and the bar holds every kind of unit in it once, each with how many you have, the one Tab has picked lit and the rest dimmed. Point at an upgrade and its card tells you what it is and what it does; point at a group's picture and it names the unit and how many you have. The power bar lies along the top of the grid, and your money sits on its left end, so both are one glance from the buttons you spend them on. The Legacy mouse and keyboard and the W A S D camera are gone from the Options screen: there is one way to play, and an Options.ini that still names them loads as it always did.
- HUD Size on the Gameplay page of Options draws the command bar and everything along the bottom of the screen at 115, 130 or 150 percent of the size your resolution gives it. On a big monitor at a high resolution the bar can be read from the sofa again. It changes the moment you Accept.
- Every panel of the bar is only as big as what it holds now, and stands on the bottom of the screen. The radar's border runs out to the screen's left edge. The power bar lies in a steel groove of its own along the top of the command grid, twenty cells that light up from the left with your production and fill the groove when full, the consumption marked by a white needle across it. The money stands on the power bar's left end in a steel plate of its own, the figure in a dark well that is only as wide as the figure. It widens the moment your money gains a digit and waits three seconds before it narrows again, so it keeps still while the figure bobs around 10000 as you build. The figure and your income stay on one line at every resolution; at 1280x720 the income used to drop under the money and hang out of the plate. Everything the old painting filled round them is battlefield again, and a click there lands on the battlefield.
- The bar's own buttons are drawn to match, steel caps lit gold under the pointer and pressed in when pushed. The menu is a small square with three bars in the screen's top left corner. The idle worker button is a key like the smoke signals', a hard hat on it, in a steel tab over your rank's stars, where it no longer hides the end of the power bar. While a worker stands idle it flashes amber a little faster than once a second, and goes dark the moment every worker has a job. The bar's steel is 40 percent darker than it was, so the pictures on it stand out and it sits quieter against the battlefield. Each button stands in its own dark cell with steel running between them, and the steel is laid over the edge of every picture the way a frame holds a card, the whole picture showing inside it. The production queue and the general's powers are framed the same way. The power bar is sunk into the same steel as the build grid, lying along its top, and is as long as the grid on every side, where it used to change length from one faction to the next. The build grid's panel no longer carries an empty strip down its left side. There is no chat button any more: Enter opens the chat as it always did. The beacon button is gone from the bar too; the smoke signals over the radar are how you point your team at a spot. The portrait sits in the radar's lit steel too. The experience bar beside it is ten gold rungs in a sunk groove, climbing from the bottom as you earn your way to the next rank, and your rank stands in a steel tab on the portrait's top right corner, a key sunk in it like the idle worker's with one star for every rank there is, gold up to the one you hold. A watcher has nothing to promote and no longer gets the tab, which used to hang half into the screen's corner. Its button goes with it: a watcher who clicked a unit used to find an empty patch of screen there that still showed the promotions tooltip and opened the promotion screen. The portrait's grid is steel between dark cells on every side, where America's was drawn in blue lines that matched nothing else on the bar. That key is the promotions button: point at it and it comes up with a gold rim, it blinks bright in your side's own steel while you have a promotion to spend, and a click opens the promotion screen. That screen is rebuilt in the same steel and half its old size: each rank's promotions stand in a grid of build-button cells five wide, like the command grid, an empty place a dark hole, each rank in a steel well of its own with its heading, the wells a plate's thickness apart, the grid's steel laid over the edge of every picture so the picture sits in its cell like a card in a frame, your rank and the points to spend on one line over the experience bar, and Done in the last row's spare place. A gold rim marks what you have bought and a light one what you can buy now. It comes up the way the Esc menu does, the battlefield behind it dimmed to 65% black and the screen fading in over an eighth of a second; the side's old painted screen no longer fades in over it for the first nine frames. The bar has no minimise arrow any more: it is only as big as what it holds. The radar sits sunk in a bezel of lit steel, bright along the top and shadowed down the right, and the build grid and the money wear the same steel, the figure in a dark window of its own, and the under-attack light is a long red lamp set in a steel tab on its top left corner, dark until you are hit and then blinking. No words on it, so it reads the same in any language.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
index 78a5f71a2..8ad2f2477 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
@@ -458,7 +458,7 @@ enum CommandPlace
COMMAND_PLACE_RALLY = COMMAND_PLACE_B,
COMMAND_PLACE_SELL = COMMAND_PLACE_N,
COMMAND_PLACE_CLEAR_MINES = COMMAND_PLACE_N, ///< a dozer's or worker's
- COMMAND_PLACE_FAKE_STRUCTURES = COMMAND_PLACE_H, ///< the GLA worker's switch to and from the fakes
+ COMMAND_PLACE_FAKE_STRUCTURES = COMMAND_PLACE_H, ///< the GLA worker's switch to and from the fakes, the end of the defense row
COMMAND_PLACE_EXPLOSIVE = COMMAND_PLACE_B ///< the Demolition worker's suicide charge
};
@@ -466,15 +466,29 @@ enum CommandPlace
* share a command type with things that flow. See ControlBar_commandPlaces. */
Int ControlBar_namedCommandPlace( const char *buttonName );
+/** What a command button is for, which picks its row on the grid. See ControlBar_commandPlaces. */
+enum CommandGroup
+{
+ COMMAND_GROUP_PRODUCTION = 0, ///< a unit to train, or a structure that makes units (a factory, a command center, a fake)
+ COMMAND_GROUP_DEFENSE, ///< a base defense to build
+ COMMAND_GROUP_UTILITY, ///< any other structure to build: power, supply, tech, superweapons
+ COMMAND_GROUP_ABILITY, ///< upgrades, special powers, weapon switches and the rest
+ COMMAND_GROUP_PASSENGER ///< one passenger's way out of a transport or bunker
+};
+
+/** The group of a command button; GUI_COMMAND_DOZER_CONSTRUCT reads the structure's KindOf. */
+Int ControlBar_commandGroup( const class CommandButton *command );
+
/** Where each of `count` command slots stands: `types` is what each slot holds, GUI_COMMAND_NONE for
- * an empty one, `pinned` a place a slot's button always takes by name or -1, and `places` gets a
- * CommandPlace for each or -1. Pinned buttons, stop, attack move, guard, evacuate, rally point and
- * sell go to their own places. A set with an attack move has attack, hold position and move too,
- * keys no command set has a button for, so their places are kept for them; the return is TRUE then.
- * Everything else is packed toward the top left, Q A W Z S E X D R C F T V G Y B H N, skipping the
- * places taken: what the set builds (structures, units) in slot order, then the rest - abilities,
- * upgrades, passengers - in slot order, so a building's upgrades come after its production. */
-Bool ControlBar_commandPlaces( const Int *types, const Int *pinned, Int count, Int *places );
+ * an empty one, `groups` its CommandGroup, `pinned` a place a slot's button always takes by name or
+ * -1, and `places` gets a CommandPlace for each or -1. Pinned buttons, stop, attack move, guard,
+ * evacuate, rally point and sell go to their own places. A set with an attack move has attack, hold
+ * position and move too, keys no command set has a button for, so their places are kept for them;
+ * the return is TRUE then. Passengers gather in the bottom right corner. The rest go by rows, the
+ * owner's of 2026-09-30: production along Q, defenses along A, other structures along Z, and
+ * abilities along Q, or along A under a set's production. A row fills left to right in slot order;
+ * what does not fit goes to the row with the most places left. */
+Bool ControlBar_commandPlaces( const Int *types, const Int *groups, const Int *pinned, Int count, Int *places );
enum { MAX_RIGHT_HUD_UPGRADE_CAMEOS = 5};
enum { MAX_MULTI_SELECT_GROUPS = 36 }; ///< unit types a multi-selection tells apart (6x6 grid, Tab focus)
enum {
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
index 33257835d..ef3c8d961 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
@@ -223,10 +223,29 @@ static GameWindow *contextButtonAtPlace( Int place )
}
//-------------------------------------------------------------------------------------------------
-/** What a set builds, which takes the free places before the rest of the set. */
-static Bool isProduction( Int type )
-{
- return type == GUI_COMMAND_UNIT_BUILD || type == GUI_COMMAND_DOZER_CONSTRUCT;
+Int ControlBar_commandGroup( const CommandButton *command )
+{
+ switch( command->getCommandType() )
+ {
+ case GUI_COMMAND_UNIT_BUILD: return COMMAND_GROUP_PRODUCTION;
+ case GUI_COMMAND_EXIT_CONTAINER: return COMMAND_GROUP_PASSENGER;
+ case GUI_COMMAND_DOZER_CONSTRUCT: break;
+ default: return COMMAND_GROUP_ABILITY;
+ }
+
+ const ThingTemplate *structure = command->getThingTemplate();
+ if( structure == NULL )
+ return COMMAND_GROUP_UTILITY;
+ // a fake carries FS_FAKE and nothing else; three of the five are decoys of factories, so the fake
+ // set stands on the row the real factories stand on
+ if( structure->isKindOf( KINDOF_FS_FACTORY ) || structure->isKindOf( KINDOF_FS_BARRACKS ) ||
+ structure->isKindOf( KINDOF_FS_WARFACTORY ) || structure->isKindOf( KINDOF_FS_AIRFIELD ) ||
+ structure->isKindOf( KINDOF_COMMANDCENTER ) || structure->isKindOf( KINDOF_FS_FAKE ) )
+ return COMMAND_GROUP_PRODUCTION;
+ // the demo trap is no FS_ anything, only DEMOTRAP
+ if( structure->isKindOf( KINDOF_FS_BASE_DEFENSE ) || structure->isKindOf( KINDOF_DEMOTRAP ) )
+ return COMMAND_GROUP_DEFENSE;
+ return COMMAND_GROUP_UTILITY;
}
//-------------------------------------------------------------------------------------------------
@@ -246,14 +265,25 @@ Int ControlBar_namedCommandPlace( const char *buttonName )
}
//-------------------------------------------------------------------------------------------------
-Bool ControlBar_commandPlaces( const Int *types, const Int *pinned, Int count, Int *places )
+static Int freeInRow( const Bool *taken, Int row )
+{
+ Int free = 0;
+ for( Int column = 0; column < COMMAND_PLACE_COLUMNS; column++ )
+ free += taken[ row * COMMAND_PLACE_COLUMNS + column ] ? 0 : 1;
+ return free;
+}
+
+//-------------------------------------------------------------------------------------------------
+Bool ControlBar_commandPlaces( const Int *types, const Int *groups, const Int *pinned, Int count, Int *places )
{
- // the owner's order of 2026-09-28: down the columns two rows at a time, toward the top left
- static const Int FILL[ COMMAND_PLACE_COUNT ] =
+ enum { ROWS = COMMAND_PLACE_COUNT / COMMAND_PLACE_COLUMNS };
+ // passengers from the bottom right corner outward, a column of the A and Z rows at a time, then
+ // along Q from the right. The places they get are handed out in reading order
+ static const Int CORNER[ COMMAND_PLACE_COUNT ] =
{
- COMMAND_PLACE_Q, COMMAND_PLACE_A, COMMAND_PLACE_W, COMMAND_PLACE_Z, COMMAND_PLACE_S, COMMAND_PLACE_E,
- COMMAND_PLACE_X, COMMAND_PLACE_D, COMMAND_PLACE_R, COMMAND_PLACE_C, COMMAND_PLACE_F, COMMAND_PLACE_T,
- COMMAND_PLACE_V, COMMAND_PLACE_G, COMMAND_PLACE_Y, COMMAND_PLACE_B, COMMAND_PLACE_H, COMMAND_PLACE_N
+ COMMAND_PLACE_H, COMMAND_PLACE_N, COMMAND_PLACE_G, COMMAND_PLACE_B, COMMAND_PLACE_F, COMMAND_PLACE_V,
+ COMMAND_PLACE_D, COMMAND_PLACE_C, COMMAND_PLACE_S, COMMAND_PLACE_X, COMMAND_PLACE_A, COMMAND_PLACE_Z,
+ COMMAND_PLACE_Y, COMMAND_PLACE_T, COMMAND_PLACE_R, COMMAND_PLACE_E, COMMAND_PLACE_W, COMMAND_PLACE_Q
};
Bool taken[ COMMAND_PLACE_COUNT ] = { FALSE };
@@ -275,21 +305,65 @@ Bool ControlBar_commandPlaces( const Int *types, const Int *pinned, Int count, I
}
}
- // production first, then the rest: a factory whose set opens on an upgrade still puts its units
- // on Q A W before the upgrade
- for( Int pass = 0; pass < 2; pass++ )
+ Int passengers = 0;
+ Bool builds = FALSE;
+ for( Int slot = 0; slot < count; slot++ )
+ {
+ if( places[ slot ] >= 0 || types[ slot ] == GUI_COMMAND_NONE )
+ continue;
+ passengers += groups[ slot ] == COMMAND_GROUP_PASSENGER ? 1 : 0;
+ builds = builds || groups[ slot ] == COMMAND_GROUP_PRODUCTION;
+ }
+
+ Bool corner[ COMMAND_PLACE_COUNT ] = { FALSE };
+ for( Int each = 0; each < COMMAND_PLACE_COUNT && passengers > 0; each++ )
{
- const Bool wantProduction = ( pass == 0 );
+ if( !taken[ CORNER[ each ] ] )
+ {
+ corner[ CORNER[ each ] ] = taken[ CORNER[ each ] ] = TRUE;
+ passengers--;
+ }
+ }
+ Int next = 0;
+ for( Int slot = 0; slot < count; slot++ )
+ {
+ if( places[ slot ] >= 0 || types[ slot ] == GUI_COMMAND_NONE || groups[ slot ] != COMMAND_GROUP_PASSENGER )
+ continue;
+ while( next < COMMAND_PLACE_COUNT && !corner[ next ] )
+ next++;
+ if( next < COMMAND_PLACE_COUNT )
+ places[ slot ] = next++;
+ }
+
+ // the rows, one group at a time; a group that outgrows its row goes on in the row with the most
+ // places left, the nearer to its own on a tie
+ static const Int GROUPS[] = { COMMAND_GROUP_PRODUCTION, COMMAND_GROUP_DEFENSE, COMMAND_GROUP_UTILITY, COMMAND_GROUP_ABILITY };
+ for( Int each = 0; each < (Int)ARRAY_SIZE( GROUPS ); each++ )
+ {
+ const Int group = GROUPS[ each ];
+ const Int own = group == COMMAND_GROUP_ABILITY ? ( builds ? 1 : 0 ) : group;
+ Int row = own;
for( Int slot = 0; slot < count; slot++ )
{
- if( places[ slot ] >= 0 || types[ slot ] == GUI_COMMAND_NONE || isProduction( types[ slot ] ) != wantProduction )
+ if( places[ slot ] >= 0 || types[ slot ] == GUI_COMMAND_NONE || groups[ slot ] != group )
continue;
- for( Int each = 0; each < COMMAND_PLACE_COUNT; each++ )
+ // the overflow stays in the row it went to until that row is full too
+ if( freeInRow( taken, row ) == 0 )
+ {
+ for( Int other = 0; other < ROWS; other++ )
+ {
+ const Int free = freeInRow( taken, other ), best = freeInRow( taken, row );
+ if( free > best || ( free == best && free > 0 && abs( other - own ) < abs( row - own ) ) )
+ row = other;
+ }
+ }
+ for( Int column = 0; column < COMMAND_PLACE_COLUMNS; column++ )
{
- if( !taken[ FILL[ each ] ] )
+ const Int place = row * COMMAND_PLACE_COLUMNS + column;
+ if( !taken[ place ] )
{
- places[ slot ] = FILL[ each ];
- taken[ FILL[ each ] ] = TRUE;
+ places[ slot ] = place;
+ taken[ place ] = TRUE;
break;
}
}
@@ -306,6 +380,7 @@ Bool ControlBar::getCommandPlaces( Int *places ) const
// unit put their own button on the grid in placeContextOnGrid.
const Bool groupShown = !m_contextParent[ CP_COMMAND ]->winIsHidden();
Int types[ MAX_COMMANDS_PER_SET ];
+ Int groups[ MAX_COMMANDS_PER_SET ];
Int pinned[ MAX_COMMANDS_PER_SET ];
for( Int slot = 0; slot < MAX_COMMANDS_PER_SET; slot++ )
{
@@ -313,9 +388,10 @@ Bool ControlBar::getCommandPlaces( Int *places ) const
const CommandButton *command = ( groupShown && window && !BitTest( window->winGetStatus(), WIN_STATUS_HIDDEN ) )
? (const CommandButton *)GadgetButtonGetData( window ) : NULL;
types[ slot ] = command ? command->getCommandType() : GUI_COMMAND_NONE;
+ groups[ slot ] = command ? ControlBar_commandGroup( command ) : COMMAND_GROUP_ABILITY;
pinned[ slot ] = command ? ControlBar_namedCommandPlace( command->getName().str() ) : -1;
}
- return ControlBar_commandPlaces( types, pinned, MAX_COMMANDS_PER_SET, places );
+ return ControlBar_commandPlaces( types, groups, pinned, MAX_COMMANDS_PER_SET, places );
}
//-------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index f6426c7ca..98bff9e46 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -11778,8 +11778,8 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, I
putSignalRise( values, nowMs - m_signalsRiseStartMs );
// the command grid against the radar's panel, six by three, every place its key: the orders in the
- // owner's places (ControlBar_commandPlaces) and everything else packed toward the top left, what a
- // set builds before its abilities and upgrades. Over the grid's frame the power bar lies in a
+ // owner's places (ControlBar_commandPlaces), passengers in the bottom right corner and everything
+ // else in rows by what it is for. Over the grid's frame the power bar lies in a
// groove of its own panel, and the money stands on that panel's left end
const IRegion2D commandBox = gridBox( leftBox.hi.x + border, foot, COMMAND_COLUMNS, COMMAND_ROWS,
COMMAND_CELL_WIDTH, COMMAND_CELL_HEIGHT );
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index 29bfe93f2..590087545 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -3335,90 +3335,104 @@ TEST(controlbar_promotion_columns_map_to_the_screens_three_rows)
CHECK_EQ( seen8, (1 << MAX_PURCHASE_SCIENCE_RANK_8) - 1 );
}
-TEST(controlbar_command_places_follow_the_owners_drawing)
+TEST(controlbar_command_places_go_in_rows_by_what_they_are_for)
{
enum { SLOTS = 14 };
Int places[ SLOTS ];
const Int N = GUI_COMMAND_NONE;
const Int C = GUI_COMMAND_DOZER_CONSTRUCT;
+ const Int pr = COMMAND_GROUP_PRODUCTION, de = COMMAND_GROUP_DEFENSE, ut = COMMAND_GROUP_UTILITY;
+ const Int ab = COMMAND_GROUP_ABILITY, pa = COMMAND_GROUP_PASSENGER;
const Int nothingPinned[ SLOTS ] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
+ const Int abilities[ SLOTS ] = { ab, ab, ab, ab, ab, ab, ab, ab, ab, ab, ab, ab, ab, ab };
+ const Int Q = COMMAND_PLACE_Q, W = COMMAND_PLACE_W, E = COMMAND_PLACE_E, R = COMMAND_PLACE_R, T = COMMAND_PLACE_T;
+ const Int Y = COMMAND_PLACE_Y, A = COMMAND_PLACE_A, S = COMMAND_PLACE_S, D = COMMAND_PLACE_D, F = COMMAND_PLACE_F;
+ const Int G = COMMAND_PLACE_G, H = COMMAND_PLACE_H, Z = COMMAND_PLACE_Z, X = COMMAND_PLACE_X, V = COMMAND_PLACE_V;
+ const Int B = COMMAND_PLACE_B, M = COMMAND_PLACE_N, CC = COMMAND_PLACE_C;
/* nothing on the bar, which is what getCommandPlaces hands over for a hidden command group (the
last unit deselected or dead) whatever its buttons still hold: no place taken, no page keys */
const Int empty[ SLOTS ] = { N, N, N, N, N, N, N, N, N, N, N, N, N, N };
- CHECK( !ControlBar_commandPlaces( empty, nothingPinned, SLOTS, places ) );
+ CHECK( !ControlBar_commandPlaces( empty, abilities, nothingPinned, SLOTS, places ) );
for( Int slot = 0; slot < SLOTS; slot++ )
CHECK_EQ( places[ slot ], -1 );
- /* AmericaDozerCommandSet: structures in slots 1 to 9, 11 and 13, disarm mines in 14. The disarm
- is pinned to N by its button's name; the eleven structures pack toward the top left in the
- owner's order, Q A W Z S E X D R C F */
+ /* AmericaDozerCommandSet: power, strategy center, barracks, drop zone, supply center, particle
+ cannon, patriot, command center, fire base, war factory, airfield, disarm mines pinned to N.
+ The four that make units along Q, the two defenses along A, the other five along Z */
const Int dozer[ SLOTS ] = { C, C, C, C, C, C, C, C, C, N, C, N, C, GUI_COMMAND_FIRE_WEAPON };
+ const Int dozerGroups[ SLOTS ] = { ut, ut, pr, ut, ut, ut, de, pr, de, ab, pr, ab, pr, ab };
Int dozerPinned[ SLOTS ];
memcpy( dozerPinned, nothingPinned, sizeof( dozerPinned ) );
dozerPinned[ 13 ] = ControlBar_namedCommandPlace( "Command_DisarmMinesAtPosition" );
- CHECK( !ControlBar_commandPlaces( dozer, dozerPinned, SLOTS, places ) );
- const Int dozerPlaces[ SLOTS ] = { COMMAND_PLACE_Q, COMMAND_PLACE_A, COMMAND_PLACE_W, COMMAND_PLACE_Z,
- COMMAND_PLACE_S, COMMAND_PLACE_E, COMMAND_PLACE_X, COMMAND_PLACE_D, COMMAND_PLACE_R, -1, COMMAND_PLACE_C, -1,
- COMMAND_PLACE_F, COMMAND_PLACE_N };
+ CHECK( !ControlBar_commandPlaces( dozer, dozerGroups, dozerPinned, SLOTS, places ) );
+ const Int dozerPlaces[ SLOTS ] = { Z, X, Q, CC, V, B, A, W, S, -1, E, -1, R, M };
for( Int slot = 0; slot < SLOTS; slot++ )
CHECK_EQ( places[ slot ], dozerPlaces[ slot ] );
/* AmericaVehicleHumveeCommandSet: three drones, five passengers, evacuate, attack move, guard,
stop. The orders take the owner's places whatever slot they were in - stop S, attack move D,
- eject Z, guard X - and A, C and V are kept for attack, hold position and move; the drones and
- passengers take what is left in the owner's order, Q W E R F T G Y */
+ eject Z, guard X - and A, C and V are kept for attack, hold position and move. The drones go
+ along Q and the passengers into the bottom right corner, F G H over B N */
const Int humvee[ SLOTS ] = { GUI_COMMAND_OBJECT_UPGRADE, GUI_COMMAND_OBJECT_UPGRADE, GUI_COMMAND_OBJECT_UPGRADE,
GUI_COMMAND_EXIT_CONTAINER, GUI_COMMAND_EXIT_CONTAINER, GUI_COMMAND_EXIT_CONTAINER, GUI_COMMAND_EXIT_CONTAINER,
GUI_COMMAND_EXIT_CONTAINER, GUI_COMMAND_EVACUATE, N, GUI_COMMAND_ATTACK_MOVE, N, GUI_COMMAND_GUARD, GUI_COMMAND_STOP };
- CHECK( ControlBar_commandPlaces( humvee, nothingPinned, SLOTS, places ) );
- const Int humveePlaces[ SLOTS ] = { COMMAND_PLACE_Q, COMMAND_PLACE_W, COMMAND_PLACE_E, COMMAND_PLACE_R,
- COMMAND_PLACE_F, COMMAND_PLACE_T, COMMAND_PLACE_G, COMMAND_PLACE_Y, COMMAND_PLACE_Z, -1, COMMAND_PLACE_D, -1,
- COMMAND_PLACE_X, COMMAND_PLACE_S };
+ const Int humveeGroups[ SLOTS ] = { ab, ab, ab, pa, pa, pa, pa, pa, ab, ab, ab, ab, ab, ab };
+ CHECK( ControlBar_commandPlaces( humvee, humveeGroups, nothingPinned, SLOTS, places ) );
+ const Int humveePlaces[ SLOTS ] = { Q, W, E, F, G, H, B, M, Z, -1, D, -1, X, S };
for( Int slot = 0; slot < SLOTS; slot++ )
CHECK_EQ( places[ slot ], humveePlaces[ slot ] );
- /* ChinaCommandCenterCommandSet: a dozer to build, seven powers, two upgrades, rally, sell. Rally
- stands on B and sell on N whatever slot they were in; the dozer first on Q, then the rest */
+ /* AmericaVehicleChinookCommandSet: eight passengers, unload, combat drop, stop. Nothing to attack
+ with, so A C V are free and the passengers take the right four columns of A and Z */
+ const Int chinook[ SLOTS ] = { GUI_COMMAND_EXIT_CONTAINER, GUI_COMMAND_EXIT_CONTAINER, GUI_COMMAND_EXIT_CONTAINER,
+ GUI_COMMAND_EXIT_CONTAINER, GUI_COMMAND_EXIT_CONTAINER, GUI_COMMAND_EXIT_CONTAINER, GUI_COMMAND_EXIT_CONTAINER,
+ GUI_COMMAND_EXIT_CONTAINER, GUI_COMMAND_EVACUATE, GUI_COMMAND_COMBATDROP, N, N, N, GUI_COMMAND_STOP };
+ const Int chinookGroups[ SLOTS ] = { pa, pa, pa, pa, pa, pa, pa, pa, ab, ab, ab, ab, ab, ab };
+ CHECK( !ControlBar_commandPlaces( chinook, chinookGroups, nothingPinned, SLOTS, places ) );
+ const Int chinookPlaces[ SLOTS ] = { D, F, G, H, CC, V, B, M, Z, Q, -1, -1, -1, S };
+ for( Int slot = 0; slot < SLOTS; slot++ )
+ CHECK_EQ( places[ slot ], chinookPlaces[ slot ] );
+
+ /* ChinaCommandCenterCommandSet: a dozer to build, seven powers, two upgrades, rally, sell. The
+ dozer on Q, the abilities under it along A, and the three A cannot hold on W E R, the row with
+ the most room left */
const Int centre[ SLOTS ] = { GUI_COMMAND_UNIT_BUILD, GUI_COMMAND_SPECIAL_POWER, GUI_COMMAND_SPECIAL_POWER,
GUI_COMMAND_SPECIAL_POWER, GUI_COMMAND_SPECIAL_POWER, GUI_COMMAND_SPECIAL_POWER, GUI_COMMAND_SPECIAL_POWER,
GUI_COMMAND_SPECIAL_POWER, GUI_COMMAND_OBJECT_UPGRADE, GUI_COMMAND_OBJECT_UPGRADE, N, N,
GUI_COMMAND_SET_RALLY_POINT, GUI_COMMAND_SELL };
- CHECK( !ControlBar_commandPlaces( centre, nothingPinned, SLOTS, places ) );
- const Int centrePlaces[ SLOTS ] = { COMMAND_PLACE_Q, COMMAND_PLACE_A, COMMAND_PLACE_W, COMMAND_PLACE_Z,
- COMMAND_PLACE_S, COMMAND_PLACE_E, COMMAND_PLACE_X, COMMAND_PLACE_D, COMMAND_PLACE_R, COMMAND_PLACE_C, -1, -1,
- COMMAND_PLACE_B, COMMAND_PLACE_N };
+ const Int centreGroups[ SLOTS ] = { pr, ab, ab, ab, ab, ab, ab, ab, ab, ab, ab, ab, ab, ab };
+ CHECK( !ControlBar_commandPlaces( centre, centreGroups, nothingPinned, SLOTS, places ) );
+ const Int centrePlaces[ SLOTS ] = { Q, A, S, D, F, G, H, W, E, R, -1, -1, B, M };
for( Int slot = 0; slot < SLOTS; slot++ )
CHECK_EQ( places[ slot ], centrePlaces[ slot ] );
- /* a factory whose set opens on an upgrade, nine units after it, a garrison, rally and sell: the
- units take Q A W S E X D R C, round the garrison's evacuate on Z, and the upgrade comes after
- them on F. Without production first the upgrade would have taken Q */
+ /* a factory whose set opens on an upgrade, nine units after it, a garrison, rally and sell: six
+ units fill Q, the other three go on along A, the row with the most room, and the upgrade
+ follows them. The upgrade never takes a place before the units */
const Int factory[ SLOTS ] = { GUI_COMMAND_OBJECT_UPGRADE, GUI_COMMAND_UNIT_BUILD, GUI_COMMAND_UNIT_BUILD,
GUI_COMMAND_UNIT_BUILD, GUI_COMMAND_UNIT_BUILD, GUI_COMMAND_UNIT_BUILD, GUI_COMMAND_UNIT_BUILD,
GUI_COMMAND_UNIT_BUILD, GUI_COMMAND_UNIT_BUILD, GUI_COMMAND_UNIT_BUILD, GUI_COMMAND_EVACUATE, N,
GUI_COMMAND_SET_RALLY_POINT, GUI_COMMAND_SELL };
- CHECK( !ControlBar_commandPlaces( factory, nothingPinned, SLOTS, places ) );
- const Int factoryPlaces[ SLOTS ] = { COMMAND_PLACE_F, COMMAND_PLACE_Q, COMMAND_PLACE_A, COMMAND_PLACE_W,
- COMMAND_PLACE_S, COMMAND_PLACE_E, COMMAND_PLACE_X, COMMAND_PLACE_D, COMMAND_PLACE_R, COMMAND_PLACE_C,
- COMMAND_PLACE_Z, -1, COMMAND_PLACE_B, COMMAND_PLACE_N };
+ const Int factoryGroups[ SLOTS ] = { ab, pr, pr, pr, pr, pr, pr, pr, pr, pr, ab, ab, ab, ab };
+ CHECK( !ControlBar_commandPlaces( factory, factoryGroups, nothingPinned, SLOTS, places ) );
+ const Int factoryPlaces[ SLOTS ] = { F, Q, W, E, R, T, Y, A, S, D, Z, -1, B, M };
for( Int slot = 0; slot < SLOTS; slot++ )
CHECK_EQ( places[ slot ], factoryPlaces[ slot ] );
- /* Demo_GLAWorkerCommandSet, the fullest worker: ten structures, the suicide charge, the switch to
- the fakes and disarm mines. The three are pinned by name to B, H and N, and the structures pack
- Q A W Z S E X D R C */
+ /* Demo_GLAWorkerCommandSet, the fullest worker: stash, demo trap, barracks, palace, stinger, black
+ market, tunnel, scud storm, arms dealer, command center, the suicide charge, the switch to the
+ fakes and disarm mines. The three are pinned by name to B, H and N, round which the rows fill */
const Int worker[ SLOTS ] = { C, C, C, C, C, C, C, C, C, C, GUI_COMMAND_FIRE_WEAPON, N,
GUI_COMMAND_OBJECT_UPGRADE, GUI_COMMAND_FIRE_WEAPON };
+ const Int workerGroups[ SLOTS ] = { ut, de, pr, ut, de, ut, de, ut, pr, pr, ab, ab, ab, ab };
Int workerPinned[ SLOTS ];
memcpy( workerPinned, nothingPinned, sizeof( workerPinned ) );
workerPinned[ 10 ] = ControlBar_namedCommandPlace( "Demo_Command_TertiarySuicide" );
workerPinned[ 12 ] = ControlBar_namedCommandPlace( "Command_UpgradeGLAWorkerFakeCommandSet" );
workerPinned[ 13 ] = ControlBar_namedCommandPlace( "Command_DisarmMinesAtPosition" );
- CHECK( !ControlBar_commandPlaces( worker, workerPinned, SLOTS, places ) );
- const Int workerPlaces[ SLOTS ] = { COMMAND_PLACE_Q, COMMAND_PLACE_A, COMMAND_PLACE_W, COMMAND_PLACE_Z,
- COMMAND_PLACE_S, COMMAND_PLACE_E, COMMAND_PLACE_X, COMMAND_PLACE_D, COMMAND_PLACE_R, COMMAND_PLACE_C,
- COMMAND_PLACE_B, -1, COMMAND_PLACE_H, COMMAND_PLACE_N };
+ CHECK( !ControlBar_commandPlaces( worker, workerGroups, workerPinned, SLOTS, places ) );
+ const Int workerPlaces[ SLOTS ] = { Z, A, Q, X, S, CC, D, V, W, E, B, -1, H, M };
for( Int slot = 0; slot < SLOTS; slot++ )
CHECK_EQ( places[ slot ], workerPlaces[ slot ] );
@@ -3426,15 +3440,23 @@ TEST(controlbar_command_places_follow_the_owners_drawing)
CHECK_EQ( ControlBar_namedCommandPlace( "Command_UpgradeGLAWorkerRealCommandSet" ), (Int)COMMAND_PLACE_H );
CHECK_EQ( ControlBar_namedCommandPlace( "Command_ConstructGLABarracks" ), -1 );
- /* the biggest set there is, the Boss general's dozer, fourteen structures: every one gets a place,
- no two share one, and they run the owner's order to G */
+ /* the biggest set there is, the Boss general's dozer, fourteen structures: four that make units,
+ five defenses and five others, each row its own */
const Int boss[ SLOTS ] = { C, C, C, C, C, C, C, C, C, C, C, C, C, C };
- ControlBar_commandPlaces( boss, nothingPinned, SLOTS, places );
- const Int bossPlaces[ SLOTS ] = { COMMAND_PLACE_Q, COMMAND_PLACE_A, COMMAND_PLACE_W, COMMAND_PLACE_Z,
- COMMAND_PLACE_S, COMMAND_PLACE_E, COMMAND_PLACE_X, COMMAND_PLACE_D, COMMAND_PLACE_R, COMMAND_PLACE_C,
- COMMAND_PLACE_F, COMMAND_PLACE_T, COMMAND_PLACE_V, COMMAND_PLACE_G };
+ const Int bossGroups[ SLOTS ] = { ut, de, ut, de, pr, de, pr, de, pr, de, ut, pr, ut, ut };
+ ControlBar_commandPlaces( boss, bossGroups, nothingPinned, SLOTS, places );
+ const Int bossPlaces[ SLOTS ] = { Z, A, X, S, Q, D, W, F, E, G, CC, R, V, B };
for( Int slot = 0; slot < SLOTS; slot++ )
CHECK_EQ( places[ slot ], bossPlaces[ slot ] );
+
+ /* seven structures that are neither: six along Z, the seventh on A, the emptier of the other
+ rows and the nearer on a tie with Q */
+ const Int many[ SLOTS ] = { C, C, C, C, C, C, C, N, N, N, N, N, N, N };
+ const Int manyGroups[ SLOTS ] = { ut, ut, ut, ut, ut, ut, ut, ab, ab, ab, ab, ab, ab, ab };
+ ControlBar_commandPlaces( many, manyGroups, nothingPinned, SLOTS, places );
+ const Int manyPlaces[ SLOTS ] = { Z, X, CC, V, B, M, A, -1, -1, -1, -1, -1, -1, -1 };
+ for( Int slot = 0; slot < SLOTS; slot++ )
+ CHECK_EQ( places[ slot ], manyPlaces[ slot ] );
}
/* The money plate follows its figure's width: wider at once, narrower only once the narrower figure
@@ -3514,19 +3536,20 @@ TEST(the_command_grid_keys_are_the_places_and_n_sells_and_b_rallies)
CHECK_EQ( GRID_KEYS[ ControlBar_namedCommandPlace( "Command_UpgradeGLAWorkerFakeCommandSet" ) ], 'H' );
CHECK_EQ( GRID_KEYS[ ControlBar_namedCommandPlace( "Demo_Command_TertiarySuicide" ) ], 'B' );
- // a set of nothing but flowing commands fills the grid in the owner's order of 2026-09-28
- static const char FILL_KEYS[] = "QAWZSEXDRCFTVGYBHN";
+ // a set of nothing but abilities fills the grid row by row, Q first
Int flowing[ COMMAND_PLACE_COUNT ];
Int unpinned[ COMMAND_PLACE_COUNT ];
+ Int abilities[ COMMAND_PLACE_COUNT ];
Int filled[ COMMAND_PLACE_COUNT ];
for( Int slot = 0; slot < COMMAND_PLACE_COUNT; slot++ )
{
flowing[ slot ] = GUI_COMMAND_SPECIAL_POWER;
unpinned[ slot ] = -1;
+ abilities[ slot ] = COMMAND_GROUP_ABILITY;
}
- CHECK( !ControlBar_commandPlaces( flowing, unpinned, COMMAND_PLACE_COUNT, filled ) );
+ CHECK( !ControlBar_commandPlaces( flowing, abilities, unpinned, COMMAND_PLACE_COUNT, filled ) );
for( Int slot = 0; slot < COMMAND_PLACE_COUNT; slot++ )
- CHECK_EQ( GRID_KEYS[ filled[ slot ] ], FILL_KEYS[ slot ] );
+ CHECK_EQ( GRID_KEYS[ filled[ slot ] ], GRID_KEYS[ slot ] );
// and the command types that land there, whatever slot of their set they sit in. A unit that
// attack moves keeps A, C and V for the page's attack, hold and move keys: its first flowing
@@ -3535,7 +3558,7 @@ TEST(the_command_grid_keys_are_the_places_and_n_sells_and_b_rallies)
const Int unit[ SLOTS ] = { GUI_COMMAND_STOP, GUI_COMMAND_GUARD, GUI_COMMAND_EVACUATE, GUI_COMMAND_ATTACK_MOVE,
GUI_COMMAND_SPECIAL_POWER, GUI_COMMAND_SPECIAL_POWER, GUI_COMMAND_NONE, GUI_COMMAND_NONE };
Int places[ SLOTS ];
- CHECK( ControlBar_commandPlaces( unit, unpinned, SLOTS, places ) );
+ CHECK( ControlBar_commandPlaces( unit, abilities, unpinned, SLOTS, places ) );
CHECK_EQ( GRID_KEYS[ places[ 0 ] ], 'S' );
CHECK_EQ( GRID_KEYS[ places[ 1 ] ], 'X' );
CHECK_EQ( GRID_KEYS[ places[ 2 ] ], 'Z' );
@@ -3544,12 +3567,14 @@ TEST(the_command_grid_keys_are_the_places_and_n_sells_and_b_rallies)
CHECK_EQ( GRID_KEYS[ places[ 5 ] ], 'W' );
const Int building[ SLOTS ] = { GUI_COMMAND_SELL, GUI_COMMAND_SET_RALLY_POINT, GUI_COMMAND_EVACUATE,
GUI_COMMAND_UNIT_BUILD, GUI_COMMAND_UNIT_BUILD, GUI_COMMAND_NONE, GUI_COMMAND_NONE, GUI_COMMAND_NONE };
- CHECK( !ControlBar_commandPlaces( building, unpinned, SLOTS, places ) );
+ const Int buildingGroups[ SLOTS ] = { COMMAND_GROUP_ABILITY, COMMAND_GROUP_ABILITY, COMMAND_GROUP_ABILITY,
+ COMMAND_GROUP_PRODUCTION, COMMAND_GROUP_PRODUCTION, COMMAND_GROUP_ABILITY, COMMAND_GROUP_ABILITY, COMMAND_GROUP_ABILITY };
+ CHECK( !ControlBar_commandPlaces( building, buildingGroups, unpinned, SLOTS, places ) );
CHECK_EQ( GRID_KEYS[ places[ 0 ] ], 'N' );
CHECK_EQ( GRID_KEYS[ places[ 1 ] ], 'B' );
CHECK_EQ( GRID_KEYS[ places[ 2 ] ], 'Z' );
CHECK_EQ( GRID_KEYS[ places[ 3 ] ], 'Q' );
- CHECK_EQ( GRID_KEYS[ places[ 4 ] ], 'A' );
+ CHECK_EQ( GRID_KEYS[ places[ 4 ] ], 'W' );
// every block as name, key and modifiers
Int slotsBound = 0;