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(gamelogic): a deploying unit fires on a target parked at its reach
Olcay Seygan184fab8fc384
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0dc0960e3..a61d1f24e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1364,7 +1364,7 @@ A third pass went through the generals' powers, promotions and unit abilities.- A Supply Drop Zone's cargo plane shot down on its way off the map no longer says "unit lost". Nor does a paradrop plane, an A-10, a B-52 or any other plane a general's power sends over, nor a single member of an angry mob. None of them is a unit you command, and the score never counted them as lost; only the announcer did, so with six drop zones up a "unit lost" could come every twenty seconds for planes that had already delivered.- A match no longer freezes when a unit attacking or hunting with its team changes its orders at the wrong moment. Switching targets could throw away the unit's order logic while it was still being used; the log then filled with "no state 0, in state 10" and the game stopped on one frame until Windows closed it. The order logic now lives until the switch is done.- A Nuke Cannon on guard stays deployed between targets. After every kill it packed up to drive back to the spot it was already standing on, then set up again, so a guarding cannon spent most of a fight folding and unfolding: four Technicals driven into its range one after another cost it four pack-ups and four set-ups, and now cost it none. It still packs up for a move order or a target out of reach. The Sentry Drone guards the same way. Replays recorded before this change play out differently.-- A Nuke Cannon no longer sets up for something that is about to leave. It took 3.3 seconds to unpack for any target in reach that instant, so a Humvee driving through was gone when it finished, and it packed again without a shot: 6.7 seconds with the barrel in the air for nothing. It now looks at where the target is headed and unpacks only if that target will still be in reach. Over three Hard matches the median time a cannon stayed set up rose from 75 to 140 frames in the middle one, and the set-ups that lasted under a second fell from 15 to 10. Replays recorded before this change play out differently.+- A Nuke Cannon no longer sets up for something that is about to leave. It took 3.3 seconds to unpack for any target in reach that instant, so a Humvee driving through was gone when it finished, and it packed again without a shot: 6.7 seconds with the barrel in the air for nothing. It now looks at where a moving target is headed, at the speed it has that moment, and unpacks only if that target will still be in reach. A target that stands still in reach always gets the unpack. One that set off a moment ago is still slow, so the cannon can still misjudge it and unpack. The Sentry Drone takes the same look over its one second of unpacking. Replays recorded before this change play out differently.- Pressing Continue after a campaign mission goes straight to the next one. The main menu used to wake up behind the score screen on the way out, show its buttons and start loading its own background battle, so the menu sat on screen over the next mission's load.- The main menu no longer opens with a man screaming. The battle behind it is staged the way EA laid it out: Jarmen Kell sits on the cliff over the GLA infantry as scenery, and the extra reach high ground gives in a match let his rifle hit them from nearly twice its range a quarter of a second after the menu came up. High ground adds nothing behind the menu now, so the first soldier falls about six seconds in, under the battleship's shells, as he always did. Soldiers' death cries on the battlefield also sit back at their own volume; the boost that lifts your units' replies over the guns had been catching them too.- A civilian car no longer drives into your base in the first minute of every game. A map's civilians are owned by a computer player like any other, and the scouting pass looks for anything of that player's that can drive - so it was picking a parked car out of the scenery and sending it to a start position. A side with no faction and no build list has nothing to learn from the map and does not scout.diff --git a/GeneralsMD/Code/BuildFingerprint.manifest b/GeneralsMD/Code/BuildFingerprint.manifestindex 95a9eec8f..50d874483 100644--- a/GeneralsMD/Code/BuildFingerprint.manifest+++ b/GeneralsMD/Code/BuildFingerprint.manifest@@ -280,6 +280,7 @@ Data/Scenarios/debristrails.txtData/Scenarios/debristrails3.txtData/Scenarios/defencereach.txtData/Scenarios/deployguard.txt+Data/Scenarios/deploystall.txtData/Scenarios/dozerloss.txtData/Scenarios/dragonfirewall.txtData/Scenarios/dragonflame.txtdiff --git a/GeneralsMD/Code/Data/Scenarios/deploystall.txt b/GeneralsMD/Code/Data/Scenarios/deploystall.txtnew file mode 100644index 000000000..f2079df7d--- /dev/null+++ b/GeneralsMD/Code/Data/Scenarios/deploystall.txt@@ -0,0 +1,21 @@+# Does a Nuke Cannon fire on what parked at the far end of its reach?+#+# Two Humvees drive off and park, the cannon chases and stops with them 341 from its edge against a+# reach of 356. A cannon that tested the target's centre against that reach saw 357, so it stood+# there undeployed for good and both Humvees lived. Pass is the EXPECT line:+#+# HEADLESS EXPECT: PASS: frame 1500 slot 1 'AmericaVehicleHumvee': 0 alive, wanted 0+#+# generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit+# -randommap 1 2 small -autoskirmish 2 -takeover+# -side 0 FactionChina -side 1 FactionAmerica -seed 1 -maxframes 3100+# -scenario deploystall -logPrefix deploystall_+#+# See mobstress.txt for the line grammar.++30 spawn 0 ChinaVehicleNukeLauncher 1 700 500+30 spawn 1 AmericaVehicleHumvee 2 950 500 20+60 move 1 AmericaVehicleHumvee 1150 510+64 attack 0 ChinaVehicleNukeLauncher 1 AmericaVehicleHumvee++1500 tally 1 AmericaVehicleHumvee 0diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.hindex 122317112..e0a0e8864 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h@@ -131,7 +131,7 @@ struct ScenarioActionAsciiString selector; ///< a template name, or "*" for everything that seat ownsCoord2D at; ///< spawn, move, attackmove and arrive target, or the offset from atStartInt atStart; ///< the start position at is measured from, SCENARIO_NO_START for none- Int count; ///< how many to spawn+ Int count; ///< how many to spawn; for tally, how many should be standing, -1 for no opinionReal spacing; ///< how far apart to spawn them, in world unitsReal radius; ///< how close to the target counts as arrivedInt targetSlot; ///< whose units to attackdiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DeployStyleAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DeployStyleAIUpdate.cppindex bf45340fd..95c850813 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DeployStyleAIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DeployStyleAIUpdate.cpp@@ -101,7 +101,12 @@ void DeployStyleAIUpdate::aiDoCommand( const AICommandParms* parms )/** Setting up takes as long as the data says, and a Nuke Cannon's is 3.3 seconds, then as long again* to pack. One that unpacked for anything in reach this instant finished just as a Humvee drove out* of reach and packed again without a shot, 6.7 seconds gone. So it unpacks only for a target still- * in reach by the time it is ready, if the target keeps on going the way it is going. */+ * in reach by the time it is ready, if the target keeps on going the way it is going.+ *+ * This moves us back along the target's travel rather than the target forward, because a target+ * that is an Object and not a point keeps its bounding circle in the sum. Reach is measured edge to+ * edge, so the test against a bare point came up short by the target's radius: a parked target in+ * that last stretch was in reach and would never stay in reach, and nothing moved or fired. *///-------------------------------------------------------------------------------------------------Bool DeployStyleAIUpdate::willTargetStayInRange( const Weapon *weapon ) const{@@ -111,10 +116,10 @@ Bool DeployStyleAIUpdate::willTargetStayInRange( const Weapon *weapon ) constconst Coord3D *velocity = victim->getPhysics()->getVelocity();const Real frames = (Real)getUnpackTime();- Coord3D then = *victim->getPosition();- then.x += velocity->x * frames;- then.y += velocity->y * frames;- return weapon->isWithinAttackRange( getObject(), &then );+ Coord3D from = *getObject()->getPosition();+ from.x -= velocity->x * frames;+ from.y -= velocity->y * frames;+ return weapon->isSourceObjectWithGoalPositionWithinAttackRange( getObject(), &from, victim, NULL );}//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cppindex 61e01a649..2cf93fb07 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp@@ -543,9 +543,14 @@ ScenarioParseResult ScenarioDrill_parseLine( const char *line, ScenarioAction *areturn SCENARIO_PARSE_BAD_COUNT;break;+ case SCENARIO_ACTION_TALLY:+ action->count = -1; // nothing wanted, unless the file names a count+ if (count > SCENARIO_TOKENS_STOP && !parseWholeNumber( tokens[ SCENARIO_TOKENS_STOP ], &action->count ))+ return SCENARIO_PARSE_BAD_COUNT;+ break;+case SCENARIO_ACTION_STOP:case SCENARIO_ACTION_CLICKSTOP:- case SCENARIO_ACTION_TALLY:case SCENARIO_ACTION_PURCHASE:break;}@@ -1538,6 +1543,10 @@ static Bool executeTally( const ScenarioAction &action, Player *player )DEBUG_LOG(("HEADLESS TALLY: frame %d slot %d '%s': %d alive, health %.0f of %.0f, worth %d, %d inside, money %d\n",action.frame, action.slot, action.selector.str(), alive, health, maxHealth, worth, inside,player->getMoney()->countMoney()));+ if (action.count >= 0)+ DEBUG_LOG(("HEADLESS EXPECT: %s: frame %d slot %d '%s': %d alive, wanted %d\n",+ alive == action.count ? "PASS" : "FAIL",+ action.frame, action.slot, action.selector.str(), alive, action.count));return TRUE;}diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex e914781a9..b909def41 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -19286,6 +19286,10 @@ TEST(scenario_parses_the_order_lines)CHECK_EQ( (Int)ScenarioDrill_parseLine( "1800 tally 1 ChinaGattlingCannon", &action ), (Int)SCENARIO_PARSE_OK );CHECK_EQ( (Int)action.action, (Int)SCENARIO_ACTION_TALLY );CHECK_STR( action.selector.str(), "ChinaGattlingCannon" );+ CHECK_EQ( action.count, -1 );+ CHECK_EQ( (Int)ScenarioDrill_parseLine( "1800 tally 1 ChinaGattlingCannon 0", &action ), (Int)SCENARIO_PARSE_OK );+ CHECK_EQ( action.count, 0 );+ CHECK_EQ( (Int)ScenarioDrill_parseLine( "1800 tally 1 ChinaGattlingCannon some", &action ), (Int)SCENARIO_PARSE_BAD_COUNT );CHECK_EQ( (Int)ScenarioDrill_parseLine( "1800 tally 1", &action ), (Int)SCENARIO_PARSE_MISSING_ARGS );// the stance key