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(gameengine): surface at the tunnel nearest the goal under fire
Olcay Seygan9194ad1e9f11
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 227b80f08..ae216f549 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1093,10 +1093,11 @@ A third pass went through the generals' powers, promotions and unit abilities.- Circular range checks are circles now, not the square drawn around them.- A tunnel network heals at one rate, however many entrances it has.-- GLA units take the tunnels on their own. Give a move order across the map, and if the way through your network is any shorter than the walk, the whole selection goes down the tunnel nearest it and comes up at the one nearest where you sent it, then walks the rest. An attack move does the same and comes up still attack-moving, and fresh units heading for a rally point across the map take the tunnels too, fighting on the way if they would have walked there fighting. The tunnels used to have to be almost a third shorter before anybody took them, so fresh units with a tunnel beside their barracks and one beside the rally point mostly walked anyway. Passing through does not count as resting: only units you put inside yourself are healed. The group decides together: fifteen Rebels with six places already taken all go through, where a first version sent ten underground and walked the other five. The green order line shows it: one line to the tunnel they go down and one from the tunnel they come up at to where you sent them. Twelve Rebels crossing a small map with a tunnel at each end got there in 21 seconds instead of 50, four Scorpions in 9 instead of 21. A tunnel that has just been hit is skipped, so nobody surfaces into the fire. So is one still going up or being sold: a tunnel you had only just placed used to count straight away, and units sent across the map queued up at a building site. A tunnel rising again out of a GLA hole counts as going up until it is finished, and units underground when the tunnel they went down is destroyed no longer come up at one. The computer does it too: a GLA team losing a fight near one of its tunnels falls back underground and comes up at home, which happened 10 to 25 times a match in four Hard GLA mirrors on Twilight Flame, and an attack wave takes the tunnels when they come up nearer your base than its road does. And the computer now digs them on purpose: a tunnel at home, one at the expansion it holds, and one three quarters of the way down the road its next wave will take, as long as nothing it has seen there can shoot. It does not wait for a fat bank to do it: a tunnel costs 800 and pays back on the first wave. In four Hard GLA mirrors on Twilight Flame, 10 of 49 attack waves went underground, where none had before, and beaten teams fell back through a tunnel 250 times. Units you put in a tunnel yourself stay put, and a network they have filled is left alone: the order walks. With one place free, everybody still goes through it one after the other, since a unit passing through leaves the moment it arrives. Replays recorded before this change play out differently.+- GLA units take the tunnels on their own. Give a move order across the map, and if the way through your network is any shorter than the walk, the whole selection goes down the tunnel nearest it and comes up at the one nearest where you sent it, then walks the rest. An attack move does the same and comes up still attack-moving, and fresh units heading for a rally point across the map take the tunnels too, fighting on the way if they would have walked there fighting. The tunnels used to have to be almost a third shorter before anybody took them, so fresh units with a tunnel beside their barracks and one beside the rally point mostly walked anyway. Passing through does not count as resting: only units you put inside yourself are healed. The group decides together: fifteen Rebels with six places already taken all go through, where a first version sent ten underground and walked the other five. The green order line shows it: one line to the tunnel they go down and one from the tunnel they come up at to where you sent them. Twelve Rebels crossing a small map with a tunnel at each end got there in 21 seconds instead of 50, four Scorpions in 9 instead of 21. A tunnel still going up or being sold is skipped: a tunnel you had only just placed used to count straight away, and units sent across the map queued up at a building site. A tunnel rising again out of a GLA hole counts as going up until it is finished, and units underground when the tunnel they went down is destroyed no longer come up at one. The computer does it too: a GLA team losing a fight near one of its tunnels falls back underground and comes up at home, which happened 10 to 25 times a match in four Hard GLA mirrors on Twilight Flame, and an attack wave takes the tunnels when they come up nearer your base than its road does. And the computer now digs them on purpose: a tunnel at home, one at the expansion it holds, and one three quarters of the way down the road its next wave will take, as long as nothing it has seen there can shoot. It does not wait for a fat bank to do it: a tunnel costs 800 and pays back on the first wave. In four Hard GLA mirrors on Twilight Flame, 10 of 49 attack waves went underground, where none had before, and beaten teams fell back through a tunnel 250 times. Units you put in a tunnel yourself stay put, and a network they have filled is left alone: the order walks. With one place free, everybody still goes through it one after the other, since a unit passing through leaves the moment it arrives. Replays recorded before this change play out differently.- Units a move order takes through the tunnels come out still selected. Going underground took each one off your selection and nothing put it back, so a group sent across the map surfaced as nobody's and had to be picked up again by hand. A trip you order by clicking a tunnel still leaves the selection the way it always has, and picking something else while they are underground means they stay out of it.- Builders take the tunnels to work. A GLA Worker sent to build, repair or finish a structure goes through the network when that is shorter than the walk, and carries on with the job at the far end. The same holds for the builder of any side that has tunnels. Replays recorded before this change play out differently.- A move order onto ground your units cannot walk to goes through the tunnels. Up a cliff, across water with no bridge, the plateaus of the GLA campaign: with a tunnel on your side and one on theirs, the selection goes down and comes up there, where it used to walk to the foot of the cliff and stop, and you had to put them in the tunnel and empty it on the far side by hand. The tunnels picked are the nearest ones your units can actually walk to and from, so nobody comes up on an island next to where you sent them and stands there, and a tunnel across a river no longer counts as the way in for units on this bank. Four Rebels sent into a walled-off hollow on Dark Night, 700 short of it and 900 from the tunnel behind them, came up in it 49 seconds later. Replays recorded before this change play out differently.+- Units sent through the tunnels come up at the one nearest where you sent them, even while the enemy is shooting at it. A tunnel hit in the last two seconds used to be passed over, and a Sneak Attack in an enemy base is hit for as long as it stands, so a player in a 7 against 1 match watched his army surface at a quiet tunnel across the map, or at home, and walk to the fight in one long line in front of the enemy. Thirty Rebels and five Scorpions attack-moving into a base whose Rangers were shooting the Sneak Attack beside it all came up at a tunnel 300 short of it and walked; now all 35 come up at the Sneak Attack, the Rebels reach the fight in 4.7 seconds on average where they took 11.8, and the last of them in 6.3 where he took 14.8. Replays recorded before this change play out differently.## The power bar tells the truthdiff --git a/GeneralsMD/Code/BuildFingerprint.manifest b/GeneralsMD/Code/BuildFingerprint.manifestindex c66f59d4c..27e61bf3f 100644--- a/GeneralsMD/Code/BuildFingerprint.manifest+++ b/GeneralsMD/Code/BuildFingerprint.manifest@@ -124,6 +124,7 @@ Data/Cinema/minefx_scene.txtData/Cinema/minefx_scene_enemy.txtData/Cinema/missileapex_film.txtData/Cinema/mobwatch.txt+Data/Cinema/msaa_river.txtData/Cinema/ngguard.txtData/Cinema/nohud.txtData/Cinema/nukedome.txt@@ -359,6 +360,7 @@ Data/Scenarios/mobclose.txtData/Scenarios/mobopen.txtData/Scenarios/mobstress.txtData/Scenarios/mobwin.txt+Data/Scenarios/msaa_river.txtData/Scenarios/netrepeat.txtData/Scenarios/netstance.txtData/Scenarios/nukefade.txt@@ -450,6 +452,7 @@ Data/Scenarios/tunnelgap.txtData/Scenarios/tunnelqueue.txtData/Scenarios/tunnelshortcut.txtData/Scenarios/tunnelsplit.txt+Data/Scenarios/tunnelunderfire.txtData/Scenarios/tunnelwalk.txtData/Scenarios/v240_heli.txtData/Scenarios/v240_hook.txtdiff --git a/GeneralsMD/Code/Data/Scenarios/tunnelunderfire.txt b/GeneralsMD/Code/Data/Scenarios/tunnelunderfire.txtnew file mode 100644index 000000000..ab17124de--- /dev/null+++ b/GeneralsMD/Code/Data/Scenarios/tunnelunderfire.txt@@ -0,0 +1,48 @@+# Tunnel under fire: a GLA attack move across the map while enemy Rangers shoot at the tunnel nearest+# the goal, a Sneak Attack tunnel in an enemy base the way a player uses one.+#+# Three mouths: one beside the army at home (880,910), one 300 short of the goal (700,1270) and one+# 150 from it (550,1570) that the Rangers start shooting just after the order. The army goes down at+# home and should come up beside the goal, into the Rangers, and fight there. Before the fix a mouth+# hit in the last two seconds counted as no mouth at all, so everybody came up at the one 300 short+# and walked the rest.+#+# Measured 2026-10-27, seed 3, with a temporary log of the mouth each unit left by: before, all 35+# came up at the one 300 short (700,1270) and the Rebels reached the goal after 710 frames on average,+# the last after 887 (14.8 s); after, all 35 came up beside the goal and the Rebels took 280, the last+# 381 (6.3 s), Scorpions 519 to 209. HEADLESS STALL: no stop of a second or more either way, and+# every unit left the tunnel the frame after it was told to, so nothing waited at the mouth.+#+# generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit+# -randommap 3 2 small -autoskirmish 2 -takeover -side 0 FactionGLA -side 1 FactionAmerica+# -seed 3 -maxframes 4800 -scenario tunnelunderfire -logPrefix tunnelunderfire_++30 spawn 0 GLATunnelNetwork 1 start0:0:300+30 spawn 0 GLATunnelNetwork 1 start1:450:-300+30 spawn 0 GLAInfantryRebel 30 start0:0:180 15+30 spawn 0 GLATankScorpion 6 start0:-150:300 40+60 spawn 0 GLATunnelNetwork 1 start1:300:0+# the shortcut waits for the pathfinder's zones to take the new tunnels in (tunnelgap.txt)+400 playerattackmove 0 GLAInfantryRebel start1:450:0+400 playerattackmove 0 GLATankScorpion start1:450:0+400 arrive 0 GLAInfantryRebel start1:450:0 200+400 arrive 0 GLATankScorpion start1:450:0 200+# the Rangers open fire once the order has picked its tunnels, the way a Sneak Attack draws fire+430 spawn 1 AmericaInfantryRanger 8 start1:300:-130 20+440 attack 1 AmericaInfantryRanger 0 GLATunnelNetwork+# and keep firing through the whole time the army comes up, about 525 to 1040+700 spawn 1 AmericaInfantryRanger 8 start1:300:-130 20+710 attack 1 AmericaInfantryRanger 0 GLATunnelNetwork+500 tally 1 AmericaInfantryRanger+500 tally 0 GLATunnelNetwork+600 tally 1 AmericaInfantryRanger+600 tally 0 GLATunnelNetwork+700 tally 1 AmericaInfantryRanger+700 tally 0 GLATunnelNetwork+800 tally 1 AmericaInfantryRanger+800 tally 0 GLATunnelNetwork+1000 tally 1 AmericaInfantryRanger+1000 tally 0 GLATunnelNetwork+2300 tally 1 AmericaInfantryRanger+2300 tally 0 GLAInfantryRebel+2300 tally 0 GLATunnelNetworkdiff --git a/GeneralsMD/Code/GameEngine/Include/Common/TunnelTracker.h b/GeneralsMD/Code/GameEngine/Include/Common/TunnelTracker.hindex b3ce1d705..6924f3d42 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/TunnelTracker.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/TunnelTracker.h@@ -69,7 +69,7 @@ public:const std::list< ObjectID > *getContainerList() const {return &m_tunnelIDs;}- Object *findQuietTunnelNear( const Coord3D *pos, const Object *walker = NULL, const Coord3D *reachPos = NULL ) const; ///< the tunnel nearest pos that has not been shot at lately and, given a walker, that it can walk between and reachPos (pos by default), or NULL+ Object *findTunnelNear( const Coord3D *pos, const Object *walker = NULL, const Coord3D *reachPos = NULL ) const; ///< the finished tunnel nearest pos, under fire or not, and, given a walker, that it can walk between and reachPos (pos by default), or NULLBool hasTunnelTraveller() const; ///< is anybody inside only passing through, and so about to free their place?Int getResidentCount() const; ///< the ones inside to stay: what the network shows, since a traveller is gone the next framestatic Object *findTunnelShortcut( const Object *walker, const Coord3D *from, const Coord3D *to, Real walk ); ///< the mouth of its controlling player's network for `walker` to go down to get from `from` to `to` quicker than a walk `walk` long, or where no walk gets there, or NULLdiff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/TunnelTracker.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/TunnelTracker.cppindex ef6de504b..1d7de073c 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/TunnelTracker.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/TunnelTracker.cpp@@ -247,7 +247,7 @@ void TunnelTracker::onTunnelDestroyed( const Object *deadTunnel )}else{- // The mouth named here is the one a trip with nowhere quiet to surface comes out of, so a+ // The mouth named here is the one a trip with nowhere else to surface comes out of, so a// finished one wins over a foundation or a rebuild out of a hole; with nothing but building// sites left, the first of them. The loop below copes with a null tunnel.Object *validTunnel = NULL;@@ -277,19 +277,18 @@ void TunnelTracker::onTunnelDestroyed( const Object *deadTunnel )}// -------------------------------------------------------------------------// A mouth that took a hit this recently is not one to send anybody through: they would come out-// into whatever is shooting at it.-static const UnsignedInt TUNNEL_UNDER_FIRE_FRAMES = 2 * LOGICFRAMES_PER_SECOND;-// With a walker, a mouth that is on the other side of a cliff or a river from reachPos (pos when// none is given) is no mouth at all. The question is asked in terrain zones, which read a structure// as the ground under it: the mouth is one, and a base wall is not what keeps a walk from getting// somewhere.-Object *TunnelTracker::findQuietTunnelNear( const Coord3D *pos, const Object *walker, const Coord3D *reachPos ) const+// A mouth under fire counts like any other. Skipping one hit in the last two seconds was meant to+// keep anybody from surfacing into the fire, and a Sneak Attack is a mouth that is under fire for as+// long as it stands: the army came up at a quiet one across the map, or at home, and walked the+// rest in a line in front of the enemy (tunnelunderfire.txt).+Object *TunnelTracker::findTunnelNear( const Coord3D *pos, const Object *walker, const Coord3D *reachPos ) const{if( reachPos == NULL )reachPos = pos;- const UnsignedInt now = TheGameLogic->getFrame();Object *nearest = NULL;Real nearestSqr = 0.0f;for( std::list<ObjectID>::const_iterator it = m_tunnelIDs.begin(); it != m_tunnelIDs.end(); ++it )@@ -301,10 +300,6 @@ Object *TunnelTracker::findQuietTunnelNear( const Coord3D *pos, const Object *waif( !isFinishedTunnel( tunnel ) )continue;- // the stamp starts at 0xffffffff, which the sum wraps to just under the window- if( tunnel->getBodyModule()->getLastDamageTimestamp() + TUNNEL_UNDER_FIRE_FRAMES > now )- continue;-const Real distSqr = ThePartitionManager->getDistanceSquared( tunnel, pos, FROM_CENTER_2D );if( nearest != NULL && distSqr >= nearestSqr )continue;@@ -361,7 +356,7 @@ Int TunnelTracker::getResidentCount() consttunnels it was meant to use stood on both sides of it. Otherwise the legs to and from the tunnelsare straight lines, and `walk` is the caller's to measure: the straight line for a move order, thelength of the path for a wave that follows one. The trip leaves by the same far mouth- (AIUpdateInterface::update asks findQuietTunnelNear the same question).+ (AIUpdateInterface::update asks findTunnelNear the same question).ponytail: straight lines, not path lengths; a tunnel across a river the walk has to go roundlooks no better than one across open ground. A path search when that matters. The walker isone member of a group, so a mixed group is judged by that member's feet.@@ -375,8 +370,8 @@ Object *TunnelTracker::findTunnelShortcut( const Object *walker, const Coord3D *if( tunnels == NULL || (Int)tunnels->getContainCount() >= tunnels->getContainMax() )return NULL;- Object *entrance = tunnels->findQuietTunnelNear( from, walker, walker->getPosition() );- Object *exit = tunnels->findQuietTunnelNear( to, walker );+ Object *entrance = tunnels->findTunnelNear( from, walker, walker->getPosition() );+ Object *exit = tunnels->findTunnelNear( to, walker );if( entrance == NULL || exit == NULL || exit == entrance )return NULL;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex 8664f1c1c..fa64d16b1 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -3766,7 +3766,7 @@ void InGameUI::collectOrderHints( void )hint.onObject = TRUE;addOrderHint( hint, previous );- const Object *exit = local->getTunnelSystem()->findQuietTunnelNear( ai->getTunnelTripGoal(), obj );+ const Object *exit = local->getTunnelSystem()->findTunnelNear( ai->getTunnelTripGoal(), obj );hint.from = ( exit != NULL ) ? *exit->getPosition() : hint.to;hint.to = *ai->getTunnelTripGoal();hint.onObject = FALSE;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cppindex 3a19d066a..1a990623e 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp@@ -1340,7 +1340,7 @@ UpdateSleepTime AIUpdateInterface::update( void )Object *tunnel = me->getContainedBy();if (tunnel != NULL && tunnel->getContain()->isTunnelContain()){- Object *exit = me->getControllingPlayer()->getTunnelSystem()->findQuietTunnelNear( &m_tunnelTripGoal, me );+ Object *exit = me->getControllingPlayer()->getTunnelSystem()->findTunnelNear( &m_tunnelTripGoal, me );privateExit( exit != NULL ? exit : tunnel, CMD_FROM_AI );}else