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): playing production strip as a row in a steel tray
Olcay Seygan894c78c899df
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3cac0287c..2b581f681 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -461,7 +461,7 @@ found and fixed — EA's own, not port damage.**- A superweapon's wait is written in plain seconds - 200, not 3:20 - so it compares with every other countdown on the screen at a glance. Once it is charged the number goes away entirely and the picture itself breathes in your colour, which is the one thing you want to catch out of the corner of your eye.- The countdown inside a strip picture moved down into its bottom left corner and carries the unit with it - 45s, 200s - on a translucent plate. In the middle of the picture it sat on the one thing the picture is there to show, and the plate it lost when it was in the middle earns its place down in the corner, where a pale cameo was swallowing the digits and their shadow together. This applies to the superweapon countdowns in the top right as well.- Every picture in the row stands in a tray - the same tray your general's powers stand in down in the corner, your own side's copy of it, so the American, Chinese and GLA strips each carry their own metal. The tray is turned back to front, because that bar grows out of the right hand corner and the strip grows out of the left, so its heavy rail leads the row instead of standing between every pair of pictures. It is never stretched to fit, and side by side the trays close up behind each other by exactly what that bar closes its own up by, so a row of them reads as one run of metal rather than a line of loose boxes. Stacked they stand clear of each other instead: a picture in a column carries its whole tray, with none of the one above it cutting across its top edge. The strip is flush against the left edge, and a black rectangle laid over the battlefield is gone.-- The queue stands up out of the corner instead of lying across the bottom of the screen. It is a column now, five pictures high, growing upward from just above the command bar with the next thing to arrive at the bottom of it - so the one picture you actually read is always in the same place, a thumb's width above the buttons, and it does not move when six more tanks are ordered. What is left over closes the column as a sixth cell wearing a "+N". A busy base used to lay its whole queue across the battlefield; now it costs one picture's width of screen, whatever it has coming. Watching a match it goes back to rows, because there the up and down belongs to the players: one row each, piled off the bottom left corner, each row reading left to right.+- The queue stands up out of the corner instead of lying across the bottom of the screen. It is a column now, five pictures high, growing upward from just above the command bar with the next thing to arrive at the bottom of it - so the one picture you actually read is always in the same place, a thumb's width above the buttons, and it does not move when six more tanks are ordered. What is left over closes the column as a sixth cell wearing a "+N". A busy base used to lay its whole queue across the battlefield; now it costs one picture's width of screen, whatever it has coming. Watching a match it goes back to rows, because there the up and down belongs to the players: one row each, piled off the bottom left corner, each row reading left to right. Playing under the new steel command bar it lies down again, as a row: a steel tray on the radar's side standing just over the under-attack light, the twin of the general's powers on the other side, the next thing to arrive against the screen's left edge and the rest running right. Each picture sits in a framed cell the size of a power's, so the two trays read as a pair.- A slot in it is a slot of that bar to the pixel, at every resolution - the size is measured off the bar itself rather than guessed - so the queue is read at a glance instead of squinted at: these were postage stamps a third of that size. Ten tanks ordered back to back are one picture with an x10 in its corner rather than ten copies of the same tank eating the row, so what is left of the row still says what else is coming.- The buildings your workers are raising stand in that same column, not in one of their own: a war factory going up is a picture in the queue at the point its time puts it, between the tank that lands before it and the one that lands after. One column is the whole answer to what your base has coming, read bottom to top in the order it arrives, and it no longer takes a second strip of screen to say the slower half of it. Each site carries its own sweep and the seconds it still needs. Click one and the camera goes there - a half-finished building under fire on the far side of the map is one click away instead of a hunt across the minimap - and none of them can be cancelled by mistake: a building already standing is sold or lost, never cancelled, so Ctrl over it does nothing.- The superweapon strip in the top right stands in the same metal, the right way round this time: it is anchored to the right hand edge and grows leftwards, which is the way that bar in the corner grows, so its rail closes the row against the edge of the screen. The black rectangle behind those pictures is gone with it, and the countdowns are the size of the ones down in the corner rather than half of it.diff --git a/GeneralsMD/Code/Data/Window/Html/Queue.html b/GeneralsMD/Code/Data/Window/Html/Queue.htmlnew file mode 100644index 000000000..ca3c8abc8--- /dev/null+++ b/GeneralsMD/Code/Data/Window/Html/Queue.html@@ -0,0 +1,73 @@+<!DOCTYPE html>+<!--+ Everything the player has coming, playing: one cameo for each item queued in any factory or going+ up on the ground, the soonest first, in a row of cells growing right from the screen's left edge+ over the radar's under-attack light. The tray is the general's powers' tray on the other side of+ the bar, mirrored. The cameos, their clocks, their countdowns and the "+N" are the game's own and+ draw between the page's two layers. Same materials as Window/Html/ControlBar.html.++ The game fills in, twice every frame the row is up (InGameUI::drawQueueTray):+ {{layer}} "back" under the cameos, "front" over them: the cells' frames again, so+ the steel lies over each picture's edge+ {{side}} "america", "china" or "gla"+ {{tray.x}} .y .w .h the tray, a panel as ControlBar.html's {{right.x}} is: .x and .y the+ border's outer corner, .w and .h the cells it holds, .bt .br .bb .bl its+ border's four widths+ data-each="cells" a cell behind each cameo and the "+N", each {{cell.x}} .y .w .h+ All in the page's pixels, a pixel of an 800x600 screen. Without this page the strip draws its+ column of the power bar's trays.+-->+<html>+<head>+<meta charset="utf-8">+<title>Queue</title>+<style>+ html, body { margin: 0; padding: 0; }+ body { background-color: #3b4a36; }+ .piece { position: absolute; }+ .front .under, .back .over { display: none; }++ /* the tray: a steel plate lit from above, a light line along its top, dark down its right, which+ faces the battlefield, and along its bottom, which stands over it; the cells in a two pixel+ well. The border's widths are written into each piece, since the page cannot add a width to a+ width */+ .tray { border-style: solid; border-color: transparent; }+ .tray .steel { position: absolute; background: linear-gradient(to bottom, #9aa3ad, #5a626c 30%, #353c45); }+ .tray .shine { position: absolute; height: 1px; background-color: #dde4ea; }+ .tray .shade { position: absolute; width: 1px; background-color: #0c1114; }+ .tray .base { position: absolute; height: 1px; background-color: #0c1114; }+ .tray .sunk { position: absolute; left: -2px; top: -2px; border: 2px solid #06090b;+ border-bottom-color: #b4bec8; border-right-color: #b4bec8; background-color: #3a414a; }+ .china .tray .steel { background: linear-gradient(to bottom, #c06a52, #7a3120 30%, #3f160f); }+ .china .tray .shine { background-color: #f0b8a4; }+ .china .tray .sunk { border-bottom-color: #d98a72; border-right-color: #d98a72; background-color: #45190f; }+ .gla .tray .steel { background: linear-gradient(to bottom, #b8ab6e, #766a3a 30%, #3c3519); }+ .gla .tray .shine { background-color: #ebe2b4; }+ .gla .tray .sunk { border-bottom-color: #cbbf82; border-right-color: #cbbf82; background-color: #423a1c; }++ /* a cell as the command grid's: dark, the well's steel laid over its edge and a bevel inside */+ .cell { background-color: #020405; }+ .cell.over { background: none; }+ .cell .edge { position: absolute; left: -1px; top: -1px; right: -1px; bottom: -1px; border: 3px solid #3a414a; }+ .china .cell .edge { border-color: #45190f; }+ .gla .cell .edge { border-color: #423a1c; }+ .cell .bevel { position: absolute; left: 2px; top: 2px; right: 2px; bottom: 2px; border: 1px solid #06090b;+ border-bottom-color: #9aa4ae; border-right-color: #9aa4ae; }+ .china .cell .bevel { border-bottom-color: #d98a72; border-right-color: #d98a72; }+ .gla .cell .bevel { border-bottom-color: #cbbf82; border-right-color: #cbbf82; }+</style>+</head>+<body>+<div class="{{layer}} {{side}}">+ <div class="piece tray under" style="left: {{tray.x}}px; top: {{tray.y}}px; width: {{tray.w}}px; height: {{tray.h}}px; border-width: {{tray.bt}}px {{tray.br}}px {{tray.bb}}px {{tray.bl}}px">+ <div class="steel" style="left: -{{tray.bl}}px; right: -{{tray.br}}px; top: -{{tray.bt}}px; bottom: -{{tray.bb}}px"></div>+ <div class="shine" style="left: -{{tray.bl}}px; right: -{{tray.br}}px; top: -{{tray.bt}}px"></div>+ <div class="shade" style="right: -{{tray.br}}px; top: -{{tray.bt}}px; bottom: -{{tray.bb}}px"></div>+ <div class="base" style="left: -{{tray.bl}}px; right: -{{tray.br}}px; bottom: -{{tray.bb}}px"></div>+ <div class="sunk" style="width: {{tray.w}}px; height: {{tray.h}}px"></div>+ </div>+ <div class="piece cell under" data-each="cells" style="left: {{cell.x}}px; top: {{cell.y}}px; width: {{cell.w}}px; height: {{cell.h}}px"><div class="edge"></div><div class="bevel"></div></div>+ <div class="piece cell over" data-each="cells" style="left: {{cell.x}}px; top: {{cell.y}}px; width: {{cell.w}}px; height: {{cell.h}}px"><div class="edge"></div><div class="bevel"></div></div>+</div>+</body>+</html>diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex 445b2b885..5d7376dff 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -1205,6 +1205,7 @@ protected:///< one run of cells - a column while playing, a player's row while watching - with its left///< edge at 'left' and its first cell's top edge at 'bottomY'void drawProductionStripColumn( Int row, Int left, Int bottomY );+ void drawQueueTray( Int row ); ///< the playing strip as a row in Window/Html/Queue.html's trayconst Image *productionStripTray( void ); ///< the bar's tray, mirrored, kept until the bar changes sidevoid stripTrayMetrics( ICoord2D *tray, ICoord2D *cameo, ICoord2D *hole, Int *step ); ///< that tray's size, its cameo hole, and the column stepvoid drawStripSeconds( Int which, Int x, Int y, Int w, Int h, Int seconds ); ///< countdown written inside a cameo@@ -1311,6 +1312,12 @@ protected:Bool m_productionStripWatching; ///< the rows are every player's, not oursInt m_productionStripCameoW; ///< cameo size this frame, in the control bar's aspectInt m_productionStripCameoH;+ Bool m_productionStripThemed; ///< playing under the bar's page: a row in Queue.html's steel tray+ Int m_productionStripStep; ///< from one themed cameo to the next, across+ HtmlOverlay * m_queueOverlay; ///< Window/Html/Queue.html under the cameos+ HtmlOverlay * m_queueFrontOverlay; ///< and its frames over them+ Bool m_queuePageLoaded;+ std::string m_queuePage;//// The strip's cameos face the other way from the power bar's, so the tray behind them is adiff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.hindex 96a9b0f64..08701d262 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h@@ -68,7 +68,8 @@ enum ScenarioActionTypeSCENARIO_ACTION_ENTER, ///< enter <slot> <selector> <targetSlot> <targetSelector>SCENARIO_ACTION_PLAYERMOVE, ///< playermove <slot> <selector> <position>; a right click, not a script orderSCENARIO_ACTION_POWER, ///< power <slot> <building> <position> [powerName]; fire its special powers (or the one named) there now, charged or not- SCENARIO_ACTION_PLAYERATTACKMOVE ///< playerattackmove <slot> <selector> <position>; the player's attack move, not a script's+ SCENARIO_ACTION_PLAYERATTACKMOVE, ///< playerattackmove <slot> <selector> <position>; the player's attack move, not a script's+ SCENARIO_ACTION_PRODUCE ///< produce <slot> <building> <template> <count>; queue that many in its first matching building};/// ScenarioAction::atStart when the position is plain numbersdiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex 71bffc3c3..20ed2100e 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -1190,6 +1190,11 @@ InGameUI::InGameUI()m_productionStripWatching = FALSE;m_productionStripCameoW = PRODUCTION_STRIP_CAMEO;m_productionStripCameoH = PRODUCTION_STRIP_CAMEO;+ m_productionStripThemed = FALSE;+ m_productionStripStep = 0;+ m_queueOverlay = NULL;+ m_queueFrontOverlay = NULL;+ m_queuePageLoaded = FALSE;m_productionStripTray = NULL;m_productionStripTraySource = NULL;for( Int stripString = 0; stripString < STRIP_OVERFLOW_STRINGS; stripString++ )@@ -1347,6 +1352,10 @@ InGameUI::~InGameUI()delete m_cellFrontOverlay[ grid ];m_cellFrontOverlay[ grid ] = NULL;}+ delete m_queueOverlay;+ m_queueOverlay = NULL;+ delete m_queueFrontOverlay;+ m_queueFrontOverlay = NULL;delete m_tooltipOverlay;m_tooltipOverlay = NULL;}@@ -10190,6 +10199,7 @@ void InGameUI::drawScoreboard( void )static const char *const CONTROL_BAR_PAGE = "Window\\Html\\ControlBar.html";static const char *const PROMOTION_PAGE = "Window\\Html\\Promotion.html";+static const char *const QUEUE_PAGE = "Window\\Html\\Queue.html";static void standDownPromotionScreen( void );/** The command bar's windows the page is told the place of, by their name in ControlBar.wnd. */@@ -11417,21 +11427,23 @@ void InGameUI::drawProductionStripColumn( Int row, Int left, Int bottomY )const Int trayW = traySize.x;const Int trayH = traySize.y;- const Int cameoW = cameoSize.x;- const Int cameoH = cameoSize.y;+ // under the bar's page the cameos stand in Queue.html's cells instead, in a row: `left` and+ // `bottomY` are then the first cameo's own corner+ const Int cameoW = m_productionStripThemed ? m_productionStripCameoW : cameoSize.x;+ const Int cameoH = m_productionStripThemed ? m_productionStripCameoH : cameoSize.y;// the tray is drawn mirrored, so its hole is mirrored with it: what that bar measures in from// the left is the same distance in from the right hereconst Int trayInsetX = trayW - trayHole.x - cameoW;const Int trayInsetY = trayHole.y;const Int trayX = left;- const Int x = left + trayInsetX; ///< where the first cameo starts+ const Int x = m_productionStripThemed ? left : left + trayInsetX; ///< where the first cameo starts//// Which way the cells run. Either way they step a whole tray, so no cameo has a neighbouring// tray lying over its edge.//- const Int cellStepX = m_productionStripWatching ? trayStep : 0;- const Int cellStepY = m_productionStripWatching ? 0 : trayH;+ const Int cellStepX = m_productionStripThemed ? m_productionStripStep : m_productionStripWatching ? trayStep : 0;+ const Int cellStepY = m_productionStripThemed || m_productionStripWatching ? 0 : trayH;const Image *tray = productionStripTray();@@ -11453,7 +11465,7 @@ void InGameUI::drawProductionStripColumn( Int row, Int left, Int bottomY )// Without the art - a mod that ships no shortcut bar - a slot keeps the flat plate it used to// have rather than losing its backing.//- for( Int back = cells - 1; back >= 0; back-- )+ for( Int back = cells - 1; back >= 0 && !m_productionStripThemed; back-- ){const Int backX = trayX + back * cellStepX;const Int backY = bottomY - back * cellStepY - trayInsetY;@@ -11638,8 +11650,9 @@ void InGameUI::drawProductionStripColumn( Int row, Int left, Int bottomY )draw->x, draw->y, cameoW, draw->quantity );}- // and the borders round them, a team border heavy enough to read as the row's whole label- for( Int borderSlot = 0; borderSlot < count; borderSlot++ )+ // and the borders round them, a team border heavy enough to read as the row's whole label; the+ // themed row's frames are Queue.html's+ for( Int borderSlot = 0; borderSlot < count && !m_productionStripThemed; borderSlot++ ){const StripSlotDraw *draw = &slots[ borderSlot ];TheDisplay->drawOpenRect( draw->x, draw->y, cameoW, cameoH,@@ -11699,6 +11712,87 @@ void InGameUI::drawProductionStripColumn( Int row, Int left, Int bottomY )}}+//-------------------------------------------------------------------------------------------------+/** Playing under the bar's page, the strip is a row in the page's steel, Window/Html/Queue.html: a+ * tray on the radar's side as the general's powers' is on the portrait's, standing over the+ * under-attack light's tab with its first cell against the screen's left edge and the row growing+ * right. Each cell is a power's size, the soonest first, the "+N" in a cell of its own at the end,+ * and the page's frames are drawn again over the cameos' edges the way the command grid's are. */+//-------------------------------------------------------------------------------------------------+void InGameUI::drawQueueTray( Int row )+{+ const Real scale = ControlBarUniformScale();+ const IRegion2D button = commandButtonRect( 1 );+ ICoord2D cell;+ cell.x = ( button.hi.x - button.lo.x ) * SKILL_CELL_PERCENT / 100;+ cell.y = ( button.hi.y - button.lo.y ) * SKILL_CELL_PERCENT / 100;+ const Int gap = REAL_TO_INT( SKILL_CELL_GAP * scale );+ const Int frame = REAL_TO_INT( CELL_FRAME * scale );+ const Int reach = min( frame, gap / 2 );+ const Int inset = frame - reach;+ const Int trayBorder = REAL_TO_INT( SKILL_TRAY_BORDER * scale );++ IRegion2D content;+ controlBarUnion( CONTROL_BAR_LEFT, content );+ const IRegion2D alertTab = tabOn( framed( content, REAL_TO_INT( PANEL_BORDER * scale ), TRUE, FALSE ),+ ALERT_TAB_WIDTH, PANEL_TAB_HEIGHT, FALSE );++ // a cameo wearing an "x5" stands for five, and the "+N" is what none of them shows+ Int shown = 0;+ for( Int slot = 0; slot < m_productionStripCount[ row ]; slot++ )+ shown += m_productionStrip[ row ][ slot ].quantity;+ const Int cells = m_productionStripCount[ row ] + ( m_productionStripTotal[ row ] > shown ? 1 : 0 );++ IRegion2D cellsBox;+ cellsBox.lo.x = trayBorder;+ cellsBox.hi.y = alertTab.lo.y - REAL_TO_INT( SKILL_GRID_GAP * scale ) - trayBorder;+ cellsBox.lo.y = cellsBox.hi.y - cell.y;+ cellsBox.hi.x = cellsBox.lo.x + cells * cell.x + ( cells - 1 ) * gap;+ IRegion2D tray = cellsBox;+ tray.lo.x = 0;+ tray.lo.y -= trayBorder;+ tray.hi.x += trayBorder;+ tray.hi.y += trayBorder;++ m_productionStripCameoW = cell.x - 2 * inset;+ m_productionStripCameoH = cell.y - 2 * inset;+ m_productionStripStep = cell.x + gap;++ HtmlValues values;+ HtmlLists lists;+ values[ "side" ] = spectatorSide();+ putFrame( values, "tray", cellsBox, tray, TRUE );+ std::vector< HtmlValues > &cellList = lists[ "cells" ];+ for( Int each = 0; each < cells; each++ )+ {+ IRegion2D place;+ place.lo.x = cellsBox.lo.x + each * m_productionStripStep;+ place.lo.y = cellsBox.lo.y;+ place.hi.x = place.lo.x + cell.x;+ place.hi.y = cellsBox.hi.y;+ HtmlValues entry;+ putPageRect( entry, "cell", reachedBy( place, reach ), TRUE );+ cellList.push_back( entry );+ }++ if( m_queueOverlay == NULL )+ {+ m_queueOverlay = new HtmlOverlay( m_superweaponNormalFont );+ m_queueFrontOverlay = new HtmlOverlay( m_superweaponNormalFont );+ }+ values[ "layer" ] = "back";+ m_queueOverlay->setPage( HtmlTemplate_expand( m_queuePage, values, lists, lookupGameText ) );+ m_queueOverlay->draw();++ TheDisplay->beginBatch2D();+ drawProductionStripColumn( row, cellsBox.lo.x + inset, cellsBox.lo.y + inset );+ TheDisplay->endBatch2D();++ values[ "layer" ] = "front";+ m_queueFrontOverlay->setPage( HtmlTemplate_expand( m_queuePage, values, lists, lookupGameText ) );+ m_queueFrontOverlay->draw();+}+#ifdef DEBUG_LOGGINGextern Real TheStripGatherMS;extern Real TheStripDrawMS;@@ -11882,28 +11976,40 @@ void InGameUI::drawProductionStrip( void )const Int trayBelow = traySize.y - trayHole.y;const Int lowerY = barTop - trayBelow - stripPixels( PRODUCTION_STRIP_LIFT );- //- // The strip is the busiest thing on the screen that is drawn a quad at a time, so it is drawn- // as a batch: the columns hand the display their pieces in an order that lets it gather the ones- // asking for the same state into single draw calls. See Display::beginBatch2D.- //- TheDisplay->beginBatch2D();-- //- // Playing there is the one run and it stands on the edge. Watching, each player is a row of his- // own and the rows are piled up from the bar, the first of them lowest, so the vertical says who- // and the horizontal says what - a queue that grew upward as well would have nowhere to put the- // next player.- //- for( Int at = 0; at < rowsUsed; at++ )+ // playing under the bar's page, the one run is a row in the page's steel instead+ if( !m_queuePageLoaded ){- const Int y = lowerY - at * traySize.y;- if( y - traySize.y < 0 )- continue;- drawProductionStripColumn( used[ at ], 0, y );+ m_queuePageLoaded = TRUE;+ readHtmlPage( QUEUE_PAGE, m_queuePage );}+ m_productionStripThemed = !m_productionStripWatching && m_controlBarPageShown && !m_queuePage.empty();+ if( m_productionStripThemed )+ drawQueueTray( used[ 0 ] );+ else+ {+ //+ // The strip is the busiest thing on the screen that is drawn a quad at a time, so it is drawn+ // as a batch: the columns hand the display their pieces in an order that lets it gather the+ // ones asking for the same state into single draw calls. See Display::beginBatch2D.+ //+ TheDisplay->beginBatch2D();- TheDisplay->endBatch2D();+ //+ // Playing there is the one run and it stands on the edge. Watching, each player is a row of+ // his own and the rows are piled up from the bar, the first of them lowest, so the vertical+ // says who and the horizontal says what - a queue that grew upward as well would have nowhere+ // to put the next player.+ //+ for( Int at = 0; at < rowsUsed; at++ )+ {+ const Int y = lowerY - at * traySize.y;+ if( y - traySize.y < 0 )+ continue;+ drawProductionStripColumn( used[ at ], 0, y );+ }++ TheDisplay->endBatch2D();+ }#ifdef DEBUG_LOGGINGQueryPerformanceCounter( (LARGE_INTEGER *)&tDrawEnd );diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cppindex 9187ddfdd..810dc36a9 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp@@ -25,6 +25,7 @@#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine+#include "Common/BuildAssistant.h"#include "Common/file.h"#include "Common/FileSystem.h"#include "Common/GlobalData.h"@@ -39,6 +40,7 @@#include "GameLogic/Module/AIUpdate.h"#include "GameLogic/Module/BehaviorModule.h"#include "GameLogic/Module/CreateModule.h"+#include "GameLogic/Module/ProductionUpdate.h"#include "GameLogic/Module/SpecialPowerModule.h"#include "GameLogic/Object.h"#include "GameLogic/ScenarioDrill.h"@@ -175,6 +177,8 @@ static Bool parseActionType( const AsciiString &token, ScenarioActionType *actio*action = SCENARIO_ACTION_PARTICLES;else if (token == "power")*action = SCENARIO_ACTION_POWER;+ else if (token == "produce")+ *action = SCENARIO_ACTION_PRODUCE;elsereturn FALSE;@@ -255,6 +259,7 @@ static Int tokensNeededFor( ScenarioActionType action )case SCENARIO_ACTION_ATTACKMOVE: return SCENARIO_TOKENS_MOVE;case SCENARIO_ACTION_ATTACK: return SCENARIO_TOKENS_ATTACK;case SCENARIO_ACTION_ENTER: return SCENARIO_TOKENS_ATTACK;+ case SCENARIO_ACTION_PRODUCE: return SCENARIO_TOKENS_ATTACK;case SCENARIO_ACTION_STOP: return SCENARIO_TOKENS_STOP;case SCENARIO_ACTION_ARRIVE: return SCENARIO_TOKENS_ARRIVE;}@@ -343,6 +348,14 @@ ScenarioParseResult ScenarioDrill_parseLine( const char *line, ScenarioAction *abreak;}+ case SCENARIO_ACTION_PRODUCE:+ {+ action->targetSelector = tokens[ 4 ]; // what to make+ if (!parseWholeNumber( tokens[ 5 ], &action->count ) || action->count < 1)+ return SCENARIO_PARSE_BAD_COUNT;+ break;+ }+case SCENARIO_ACTION_STOP:break;}@@ -914,6 +927,33 @@ static Bool executePower( const ScenarioAction &action, Player *player, const Coreturn fired > 0;}+/** Queue `count` of the template in the first matching building of this seat, the way a click on+ its build button would, money and prerequisites checked by the building's own queue. What a+ queue refuses is counted and reported, not forced. */+static Bool executeProduce( const ScenarioAction &action, Player *player )+{+ Object *building = findFirstMatching( player, action.selector );+ ProductionUpdateInterface *queue = building ? building->getProductionUpdateInterface() : NULL;+ const ThingTemplate *made = TheThingFactory->findTemplate( action.targetSelector );+ if (queue == NULL || made == NULL)+ {+ DEBUG_LOG(("SCENARIO: frame %d produce: slot %d has no producing '%s', or '%s' is no template\n",+ action.frame, action.slot, action.selector.str(), action.targetSelector.str()));+ return FALSE;+ }++ Int queued = 0;+ for (Int each = 0; each < action.count; ++each)+ {+ if (queue->canQueueCreateUnit( made ) == CANMAKE_OK && queue->queueCreateUnit( made, queue->requestUniqueUnitID() ))+ ++queued;+ }++ DEBUG_LOG(("SCENARIO: frame %d produce slot %d '%s' queued %d of %d '%s'\n",+ action.frame, action.slot, action.selector.str(), queued, action.count, action.targetSelector.str()));+ return queued > 0;+}+static Bool executeOrder( const ScenarioAction &action, Player *player, const Coord3D &dest ){AIGroup *group = TheAI->createGroup();@@ -993,6 +1033,7 @@ static Bool executeOrder( const ScenarioAction &action, Player *player, const Cocase SCENARIO_ACTION_ARRIVE:case SCENARIO_ACTION_PARTICLES:case SCENARIO_ACTION_POWER:+ case SCENARIO_ACTION_PRODUCE:ordered = FALSE; // handled before the group is builtbreak;}@@ -1026,6 +1067,9 @@ Bool ScenarioDrill_execute( const ScenarioAction &action )if (action.action == SCENARIO_ACTION_POWER)return executePower( action, player, position );+ if (action.action == SCENARIO_ACTION_PRODUCE)+ return executeProduce( action, player );+return executeOrder( action, player, position );}