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(gameengine): draw a capture gold with its cursor, queued or running
Olcay Seygan41ad02acede6
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ae51f010e..a9b7433f2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -239,6 +239,7 @@ found and fixed — EA's own, not port damage.**- Shift queues an attack now, not only a move. A or F held down while you shift-click adds a force-attack or an attack-move to the line of orders a group is already holding, and it fires the moment the order in front of it is finished - a target dead, or nobody left chasing an attack-move point. The coloured thread that shows a queued order covers it too, so a queue of "go here, then attack that, then attack-move over there" reads as one continuous line in three colours. The game's own white waypoint markings, which used to draw over the same ground the moment shift went down, are gone - they only ever duplicated what the coloured thread already showed, and doing both left a queued attack sitting under two different pictures of itself.- The shift queue takes any mix of orders now and stays with the units you gave it to. Move, attack-move, attack a target, draw a formation line, then guard: hold shift, click them in whatever order you like, and the group works down the list by itself. Queue an army's whole route, select something else, go back to your base, and the army keeps going. Before, clicking anything else threw the list away. Each step also starts the moment the one before it is done. It used to wait for the order to travel to the other players and back, which on a 250ms connection was a quarter of a second standing still at every corner. The group keeps together: nobody starts the next order until everyone still alive has finished this one, so a column does not string out behind its fastest tank. Select part of a group and shift-click, and that part takes its own copy of the list with the new order on the end while the others carry on with theirs. Shift-click a group that is already on an ordinary move and the new point goes behind the move instead of replacing it.- Shift queues whatever a right-click orders, not just moves. Shift-right-click an enemy tank and killing it goes on the list; do it on a building with a Black Lotus selected and taking the building goes on the list. A transport to climb into, a repair bay, a hospital and a supply dock work the same way, and so does an ability armed from the command bar. "Walk here, take that supply center, walk on" is one set of clicks, and the list waits for the capture to finish before anyone sets off for the next point. Upgrades queue as well: shift-click the Overlord's Gatling cannon and it is bought when the Overlord gets there and paid for then. If the money is not in the bank by that time the upgrade is passed over and the list carries on. Each unit with more than one place to go numbers its markers in the order it will reach them, and a step the colour cannot tell apart from a move carries its own cursor next to the number, or the upgrade's picture. A shift-click on one of your own units is still a point on the path. Keep shift down after pressing F, A or G and the key stays armed, so five targets are one key and five clicks instead of five of each; it drops when shift comes up. A guard, a hold or fire on the ground ends a list for good. Nothing queues behind one, whether it was given with shift or without, until an order without shift takes the units off it. Replays recorded before this version that shift-clicked an upgrade, or gave a unit holding a list an ability without shift, play back differently.+- A capture on the list looks like a capture. Its thread is gold where a move's is green, and the capture cursor sits beside its marker even when taking the building is the only order the unit has: one queued capture used to look exactly like a walk to the building's door. The thread stays gold the whole time the capture runs, on the walk over and at the door, where it used to show a plain move and then nothing at all while the building turned. The riflemen who walk in by the door queue a capture the same way Black Lotus does, Rangers and Red Guards included, from the capture button or a shift-right-click.- Attack move stays armed for as long as shift is down, whether you pressed its key or clicked its button on the bar, so every point you queue is an attack move. Orders given on the minimap are the orders they would be on the battlefield: an armed attack move is an attack move there too, and shift adds to the queue. Passing the pointer over the minimap no longer puts an armed attack move down.- What the circle picks up is what you can see, and a stealthed unit is not that. Shroud was the only test, so a hidden tank parked in ground you had already cleared went on the list like anything else: drag a circle over open country and the group opened fire on air, one order per hidden unit, which is a stealth detector drawn with the mouse. An undetected unit is not in the circle.- Ctrl+D takes every unit of the kinds you have selected that is on the screen, and pressed twice inside half a second takes them across the whole map. One tank selected and two keystrokes is your whole armour, wherever it is standing. It was on Shift+Ctrl+E, which is three fingers for something you do in every fight, and it only ever reached across the map when the screen had nothing left to give - so the wide selection happened to you instead of being asked for.diff --git a/GeneralsMD/Code/Data/Scenarios/shiftorders.txt b/GeneralsMD/Code/Data/Scenarios/shiftorders.txtindex 6f2d4d072..452fc8b9e 100644--- a/GeneralsMD/Code/Data/Scenarios/shiftorders.txt+++ b/GeneralsMD/Code/Data/Scenarios/shiftorders.txt@@ -10,7 +10,7 @@## generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit# -map "Maps\Alpine Assault\Alpine Assault.map" -autoskirmish 2 -takeover-# -side 0 FactionChina -side 1 FactionAmerica -seed 1 -maxframes 2400+# -side 0 FactionChina -side 1 FactionAmerica -seed 1 -maxframes 4500# -scenario shiftorders -logPrefix shiftorders_## See mobstress.txt for the line grammar.@@ -37,5 +37,34 @@# post. This line has to report 0 of 1.65 arrive 0 ChinaTankOverlord 950 1750 100-2390 tally 0 AmericaSupplyCenter-2390 tally 1 AmericaSupplyCenter+4490 tally 0 AmericaSupplyCenter+4490 tally 1 AmericaSupplyCenter++# The rifleman's capture, the Red Guard's and the Ranger's, which walk up and go in by the door where+# Black Lotus hacks from range. Both stay paused until the player owns Capture Building, so the+# barracks researches it first (30 s, done at frame 930) and the lists go out once it is. Each list+# is a walk, a capture and a walk on, and a capture at the door runs about 650 frames: the arrive+# lines say each finished, the tallies whose buildings they are. The Ranger is China's here so+# nobody in this file fires on anybody else.+30 spawn 0 ChinaBarracks 1 400 700+31 shiftupgrade 0 ChinaBarracks Upgrade_InfantryCaptureBuilding+30 spawn 0 ChinaInfantryRedguard 1 600 850+30 spawn 0 AmericaInfantryRanger 1 600 1000+30 spawn 1 AmericaPowerPlant 1 1300 800+30 spawn 1 AmericaBarracks 1 1300 1450++960 shiftmove 0 ChinaInfantryRedguard 1000 950+961 shiftpower 0 ChinaInfantryRedguard 1 AmericaPowerPlant SpecialAbilityRedGuardCaptureBuilding+962 shiftmove 0 ChinaInfantryRedguard 800 1250++960 shiftmove 0 AmericaInfantryRanger 1000 1300+961 shiftpower 0 AmericaInfantryRanger 1 AmericaBarracks SpecialAbilityRangerCaptureBuilding+962 shiftmove 0 AmericaInfantryRanger 700 1500++965 arrive 0 ChinaInfantryRedguard 800 1250 150+965 arrive 0 AmericaInfantryRanger 700 1500 150++4490 tally 0 AmericaPowerPlant+4490 tally 1 AmericaPowerPlant+4490 tally 0 AmericaBarracks+4490 tally 1 AmericaBarracksdiff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialAbilityUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialAbilityUpdate.hindex 07b36c875..17b900d0f 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialAbilityUpdate.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialAbilityUpdate.h@@ -216,6 +216,7 @@ public:virtual void setSpecialPowerOverridableDestination( const Coord3D *loc ) {}virtual Bool isPowerCurrentlyInUse( const CommandButton *command = NULL ) const;virtual Bool getCaptureProgress( ObjectID *targetID, Real *progress ) const;+ virtual Bool getCaptureTarget( ObjectID *targetID ) const;// virtual Bool isBusy() const { return m_isBusy; }diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialPowerUpdateModule.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialPowerUpdateModule.hindex a35d5b953..78fcf5040 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialPowerUpdateModule.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialPowerUpdateModule.h@@ -57,6 +57,10 @@ public:* it is, nought to one. Asked by the client so the building can wear a clock. Not pure, because* taking a building is one ability out of dozens and the rest have no answer to give. */virtual Bool getCaptureProgress( ObjectID *targetID, Real *progress ) const { return FALSE; }++ /** The building this module is taking, from the moment the man sets off for the door until he has+ * packed up again - the walk and the wait included, which getCaptureProgress leaves out. */+ virtual Bool getCaptureTarget( ObjectID *targetID ) const { return FALSE; }};//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.hindex abf89ab02..43b5a03f0 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h@@ -381,6 +381,7 @@ public:SpecialAbilityUpdate* findSpecialAbilityUpdate( SpecialPowerType type ) const;SpecialPowerCompletionDie* findSpecialPowerCompletionDie() const;Bool getCaptureProgress( ObjectID *targetID, Real *progress ) const; ///< the building this one is taking, and how far through it is+ Bool getCaptureTarget( ObjectID *targetID ) const; ///< the building this one is taking, the walk to the door includedSpecialPowerUpdateInterface* findSpecialPowerWithOverridableDestinationActive( SpecialPowerType type = SPECIAL_INVALID ) const;SpecialPowerUpdateInterface* findSpecialPowerWithOverridableDestination( SpecialPowerType type = SPECIAL_INVALID ) const;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex 10a4e332c..73af20c7a 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -5255,6 +5255,15 @@ void InGameUI::collectOrderHints( void )Coord3D resolvedGoal;Bool goalResolved = FALSE;Bool legsDrawn = FALSE; // the order drew its own threads, and the shift list follows on from them++ // a capture walks its man to the door with a plain move of its own and then stands him idle+ // while the building turns, so the state machine reads as a move and then as nothing at all.+ // The ability knows better, and the thread is the capture's for as long as it runs+ ObjectID capturedID = INVALID_ID;+ const Object *captured = obj->getCaptureTarget( &capturedID ) ? TheGameLogic->findObjectByID( capturedID ) : NULL;+ if( captured && isHiddenByShroud( captured ) )+ captured = NULL;+switch( ai->getCurrentStateID() ){case AI_MOVE_TO:@@ -5372,12 +5381,19 @@ void InGameUI::collectOrderHints( void )// gave it, and that order is held out of reach of the goal until the wheels are up.// Ask for it, or an air strike shows nothing at all during the seconds the plane spends// taxiing, which is exactly when the player wants to see where it is going- if( !getHeldAircraftOrder( obj, hint.kind, resolvedGoal ) )+ if( captured == NULL && !getHeldAircraftOrder( obj, hint.kind, resolvedGoal ) )continue;goalResolved = TRUE;break;}+ if( captured )+ {+ hint.kind = ORDER_HINT_CAPTURE;+ resolvedGoal = *captured->getPosition();+ goalResolved = TRUE;+ }+if( !legsDrawn ){hint.from = *obj->getPosition();diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cppindex 806e414a6..1d8421e7e 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp@@ -6534,6 +6534,19 @@ Bool Object::getCaptureProgress( ObjectID *targetID, Real *progress ) constreturn FALSE;}+// ------------------------------------------------------------------------------------------------+Bool Object::getCaptureTarget( ObjectID *targetID ) const+{+ for( BehaviorModule** u = m_behaviors; *u; ++u )+ {+ SpecialPowerUpdateInterface *spInterface = (*u)->getSpecialPowerUpdateInterface();+ if( spInterface && spInterface->getCaptureTarget( targetID ) )+ return TRUE;+ }++ return FALSE;+}+// ------------------------------------------------------------------------------------------------SpecialPowerUpdateInterface* Object::findSpecialPowerWithOverridableDestinationActive( SpecialPowerType type ) const{diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpecialAbilityUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpecialAbilityUpdate.cppindex 193c52623..abe1c74f3 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpecialAbilityUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpecialAbilityUpdate.cpp@@ -618,22 +618,31 @@ Bool SpecialAbilityUpdate::isPowerCurrentlyInUse( const CommandButton *command )//-------------------------------------------------------------------------------------------------Bool SpecialAbilityUpdate::getCaptureProgress( ObjectID *targetID, Real *progress ) const{- if( !m_active || m_prepFrames == 0 || m_targetID == INVALID_ID )- return FALSE;-- const SpecialPowerType type = getSpecialPowerType();- if( type != SPECIAL_INFANTRY_CAPTURE_BUILDING && type != SPECIAL_BLACKLOTUS_CAPTURE_BUILDING )+ if( m_prepFrames == 0 || !getCaptureTarget( targetID ) )return FALSE;const UnsignedInt total = getSpecialAbilityUpdateModuleData()->m_preparationFrames;if( total == 0 || m_prepFrames > total )return FALSE;- *targetID = m_targetID;*progress = 1.0f - (Real)m_prepFrames / (Real)total;return TRUE;}+//-------------------------------------------------------------------------------------------------+Bool SpecialAbilityUpdate::getCaptureTarget( ObjectID *targetID ) const+{+ if( !m_active || m_targetID == INVALID_ID )+ return FALSE;++ const SpecialPowerType type = getSpecialPowerType();+ if( type != SPECIAL_INFANTRY_CAPTURE_BUILDING && type != SPECIAL_BLACKLOTUS_CAPTURE_BUILDING )+ return FALSE;++ *targetID = m_targetID;+ return TRUE;+}+//-------------------------------------------------------------------------------------------------void SpecialAbilityUpdate::onExit( Bool cleanup ){diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cppindex 5295054c6..f4b88d76c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp@@ -1234,11 +1234,23 @@ static Bool executeShiftOrder( const ScenarioAction &action, Player *player, con/** Shift on an object upgrade button, once for every unit that matches: the two messages the commandbar sends, handed to the dispatcher the way they arrive. An upgrade names the unit that buys it, so- unlike the other shift verbs this one needs nothing selected. */-static Bool executeShiftUpgrade( const ScenarioAction &action, Player *player, AIGroup *group, Int taken )+ unlike the other shift verbs this one needs nothing selected - and the buyer can be a building,+ which takes no orders: a barracks researching Capture Building is a shift-click on its button too. */+static Bool executeShiftUpgrade( const ScenarioAction &action, Player *player ){- const std::vector<ObjectID> buyers = group->getAllIDs();- TheAI->destroyGroup( group );+ std::vector<ObjectID> buyers;+ for( Object *obj = TheGameLogic->getFirstObject(); obj; obj = obj->getNextObject() )+ {+ if (obj->getControllingPlayer() == player && !obj->isEffectivelyDead() && selectorMatches( action.selector, obj ))+ buyers.push_back( obj->getID() );+ }+ const Int taken = (Int)buyers.size();+ if (taken == 0)+ {+ DEBUG_LOG(("SCENARIO: frame %d: slot %d owns nothing matching '%s'\n",+ action.frame, action.slot, action.selector.str()));+ return FALSE;+ }const UpgradeTemplate *upgrade = TheUpgradeCenter->findUpgrade( action.name );if (upgrade == NULL)@@ -1270,6 +1282,9 @@ static Bool executeShiftUpgrade( const ScenarioAction &action, Player *player, Astatic Bool executeOrder( const ScenarioAction &action, Player *player, const Coord3D &dest ){+ if (action.action == SCENARIO_ACTION_SHIFTUPGRADE)+ return executeShiftUpgrade( action, player );+AIGroup *group = TheAI->createGroup();const Int taken = gatherIntoGroup( player, action.selector, group );if (taken == 0)@@ -1346,9 +1361,6 @@ static Bool executeOrder( const ScenarioAction &action, Player *player, const Cocase SCENARIO_ACTION_SHIFTPOWER:return executeShiftOrder( action, player, dest, group, taken ); // the group is gone either way- case SCENARIO_ACTION_SHIFTUPGRADE:- return executeShiftUpgrade( action, player, group, taken );-case SCENARIO_ACTION_STOP:{group->groupIdle( CMD_FROM_SCRIPT );diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cppindex bb39163b8..540105002 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp@@ -963,9 +963,10 @@ void W3DInGameUI::drawAttackCircle( void )//-------------------------------------------------------------------------------------------------/** The thread is coloured by what it is for: anything that ends in a shot is red, an attack move- * is pink, a post to be held is blue, everything else is green. The marker on the end of it is- * the plain pointer in the same colour - one shape for every order, so the colour is the whole- * message. A dot and a ring were tried in its place and players wanted the pointer back. */+ * is pink, a post to be held is blue, a building to be taken is gold, everything else is green.+ * The marker on the end of it is the plain pointer in the same colour - one shape for every+ * order, so the colour is the whole message. A dot and a ring were tried in its place and+ * players wanted the pointer back. *///-------------------------------------------------------------------------------------------------static UnsignedInt orderHintLineColor( InGameUI::OrderHintKind kind ){@@ -979,6 +980,8 @@ static UnsignedInt orderHintLineColor( InGameUI::OrderHintKind kind )return 0x66FF5555;case InGameUI::ORDER_HINT_GUARD:return 0x6655CCFF;+ case InGameUI::ORDER_HINT_CAPTURE:+ return 0x66FFCC33;default:return 0x6655FF55;}@@ -1127,7 +1130,8 @@ static const Image *orderCursorImage( Mouse::MouseCursor cursor, ICoord2D *hotSp//-------------------------------------------------------------------------------------------------/** The cursor a kind of order is given with, for the kinds whose colour is the plain green and so- * says nothing on its own. Mouse::NONE for the rest. */+ * says nothing on its own, and for a capture, whose gold is new enough to want saying twice.+ * Mouse::NONE for the rest. *///-------------------------------------------------------------------------------------------------static Mouse::MouseCursor orderHintCursor( InGameUI::OrderHintKind kind ){@@ -1286,7 +1290,8 @@ void W3DInGameUI::drawOrderHints( void )| ( (UnsignedInt)REAL_TO_INT( 255.0f * eased ) << 24 );TheDisplay->drawImage( image, x, y, x + w, y + h, markerColor );- if( it->step > 0 || it->icon )+ // a capture carries its cursor even alone: a lone one is the case that looked like a walk+ if( it->step > 0 || it->icon || it->kind == ORDER_HINT_CAPTURE ){ICoord2D tip;tip.x = to.x + slide;