Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(gameclient): command grid overflow runs on to the next row down
Olcay Seygan4da3161452ad
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4d59cf1a1..c42e13494 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 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.+- 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 row below it, so a command center's general's powers read in order from A across to Z and never end up beside the dozer. 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.hindex 8ad2f2477..d9c8964ae 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h@@ -487,7 +487,7 @@ Int ControlBar_commandGroup( const class CommandButton *command );* 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. */+ * what does not fit goes on in the next row down with room, then in the rows above. */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)diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex ef3c8d961..ebf0c4470 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -335,8 +335,9 @@ Bool ControlBar_commandPlaces( const Int *types, const Int *groups, const Int *pplaces[ 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+ // the rows, one group at a time; a group that outgrows its row goes on in the next row down with+ // room, and only then in the rows above, nearest first, so it still reads in slot order after its+ // own row: a command center's powers run on from A to Z rather than back up beside its dozerstatic 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++ ){@@ -347,14 +348,16 @@ Bool ControlBar_commandPlaces( const Int *types, const Int *groups, const Int *p{if( places[ slot ] >= 0 || types[ slot ] == GUI_COMMAND_NONE || groups[ slot ] != group )continue;- // the overflow stays in the row it went to until that row is full tooif( freeInRow( taken, row ) == 0 ){- for( Int other = 0; other < ROWS; other++ )+ for( Int step = 1; step < 2 * ROWS; step++ ){- const Int free = freeInRow( taken, other ), best = freeInRow( taken, row );- if( free > best || ( free == best && free > 0 && abs( other - own ) < abs( row - own ) ) )+ const Int other = step < ROWS ? own + step : own - ( step - ROWS + 1 );+ if( other >= 0 && other < ROWS && freeInRow( taken, other ) > 0 )+ {row = other;+ break;+ }}}for( Int column = 0; column < COMMAND_PLACE_COLUMNS; column++ )diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 590087545..15477d90c 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -3395,20 +3395,20 @@ TEST(controlbar_command_places_go_in_rows_by_what_they_are_for)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 */+ dozer on Q, the abilities under it along A, and the three A cannot hold go on along Z, so the+ nine read in order and none stands beside the dozer */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 };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 };+ const Int centrePlaces[ SLOTS ] = { Q, A, S, D, F, G, H, Z, X, CC, -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: six- units fill Q, the other three go on along A, the row with the most room, and the upgrade+ units fill Q, the other three go on along A, the next row down, and the upgradefollows 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,@@ -3449,8 +3449,8 @@ TEST(controlbar_command_places_go_in_rows_by_what_they_are_for)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 */+ /* seven structures that are neither: six along Z, and with no row under Z the+ seventh goes up to A, the nearest row above */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 );