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): no tunnel shortcut for a walker whose player has no network
Olcay Seygan604059f60d22
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 275173f62..3ef9d5971 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1735,6 +1735,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same- A graphics setup that cannot make a single texture now gets the message that Direct3D could not start, instead of "Uncaught Exception during initialization". One player met the crash three times in a row on the Direct3D 11 picture with a dxgi.dll in the game folder: even the plain stand-in the game shows for a missing texture could not be made, and the first texture loaded fell on it.- The rings the battle lays on the ground, a nuke's target circle or a Spectre gunship's, no longer crash the game now and then. Since 3.2.0 the battle runs beside the picture, and those rings were laid and lifted from the battle's side while the picture was walking the list of them, so the picture could read a ring that had just been thrown away. They are laid and lifted between pictures now.- A save that will not load now says so in a box instead of crashing the game. The load had already put half the units in when it stopped, and clearing them away again went through a list of every unit's timers that the half-done load had left out of step, so the game wrote into memory it did not own.+- A dozer whose driver was sniped no longer crashes the game. A dozer left standing looks for a damaged building of its owner's to repair, and first asks whether its owner's tunnels get it there quicker. A vehicle with no driver belongs to nobody, and nobody has no tunnels, so the question took the game down. One player met it on 3.2.0 ten minutes into a match against GLA.- Loading a save from the in-game menu no longer crashes when a paratrooper is still hanging under his chute. Clearing the old match away took the chute first, the soldier "landed" off the map, died, and his death blast tried to build its debris for players that were already gone. A paratrooper cleared away with the match now just goes.- Rewinding a replay no longer stops the game with "sleepy update module illegal index". A Cold Fusion plant with Control Rods puts its bonus power back as the rewind finishes loading, and that switched the player's buildings off or on again at a moment when the game was not ready to wake them. A rewind now finishes exactly the way loading a save does, with every building's power as it was saved.- A skirmish on a custom map whose maker left out the script list for one side no longer crashes as the match starts. The win and defeat checks go on that side, and there was no list to add them to; it gets an empty one now.diff --git a/GeneralsMD/Code/GameEngine/Include/Common/TunnelTracker.h b/GeneralsMD/Code/GameEngine/Include/Common/TunnelTracker.hindex 1c15ac8fe..b3ce1d705 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/TunnelTracker.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/TunnelTracker.h@@ -72,7 +72,7 @@ public: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 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 frame- Object *findTunnelShortcut( const Object *walker, const Coord3D *from, const Coord3D *to, Real walk ) const; ///< the mouth for `walker` to go down to get from `from` to `to` quicker than a walk `walk` long, or where no walk gets there, or NULL+ static 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 NULLObject *getCurNemesis(void);void updateNemesis(const Object *target);diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/TunnelTracker.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/TunnelTracker.cppindex e3ef675b8..ef6de504b 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/TunnelTracker.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/TunnelTracker.cpp@@ -32,6 +32,7 @@#include "Common/GameState.h"#include "Common/GlobalData.h"#include "Common/KindOf.h"+#include "Common/Player.h"#include "Common/TunnelTracker.h"#include "Common/Xfer.h"@@ -363,14 +364,19 @@ Int TunnelTracker::getResidentCount() const(AIUpdateInterface::update asks findQuietTunnelNear 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 is- one member of a group, so a mixed group is judged by that member's feet. */-Object *TunnelTracker::findTunnelShortcut( const Object *walker, const Coord3D *from, const Coord3D *to, Real walk ) const+ one member of a group, so a mixed group is judged by that member's feet.+ The network is the walker's controlling player's. The neutral player has none+ (Player::initFromDict makes it, and the neutral player never goes through that), and a vehicle+ whose driver was sniped, or a map's civilian, belongs to it: a sniped dozer picking up its+ job read a NULL network here (crash report 1367). */+Object *TunnelTracker::findTunnelShortcut( const Object *walker, const Coord3D *from, const Coord3D *to, Real walk ){- if( (Int)getContainCount() >= getContainMax() )+ const TunnelTracker *tunnels = walker->getControllingPlayer()->getTunnelSystem();+ if( tunnels == NULL || (Int)tunnels->getContainCount() >= tunnels->getContainMax() )return NULL;- Object *entrance = findQuietTunnelNear( from, walker, walker->getPosition() );- Object *exit = findQuietTunnelNear( to, walker );+ Object *entrance = tunnels->findQuietTunnelNear( from, walker, walker->getPosition() );+ Object *exit = tunnels->findQuietTunnelNear( to, walker );if( entrance == NULL || exit == NULL || exit == entrance )return NULL;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cppindex 39e976fda..4e1b37c5a 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp@@ -2449,7 +2449,7 @@ void AIGroup::groupMoveToPosition( const Coord3D *p_posIn, Bool addWaypoint, Com{const Real walkX = goalPos.x - groupCenter.x;const Real walkY = goalPos.y - groupCenter.y;- tunnelEntrance = walker->getControllingPlayer()->getTunnelSystem()->findTunnelShortcut( walker, &groupCenter, &goalPos,+ tunnelEntrance = TunnelTracker::findTunnelShortcut( walker, &groupCenter, &goalPos,(Real)sqrt( walkX * walkX + walkY * walkY ) );}@@ -3143,7 +3143,7 @@ void AIGroup::groupAttackMoveToPosition( const Coord3D *pos, Int maxShotsToFire,{const Real walkX = pos->x - center.x;const Real walkY = pos->y - center.y;- tunnelEntrance = walker->getControllingPlayer()->getTunnelSystem()->findTunnelShortcut( walker, ¢er, pos,+ tunnelEntrance = TunnelTracker::findTunnelShortcut( walker, ¢er, pos,(Real)sqrt( walkX * walkX + walkY * walkY ) );}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cppindex 625776659..5e2055229 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp@@ -11583,7 +11583,7 @@ void AIPlayer::sendWaveThroughTunnels( AIGroup *wave, const Coord3D *center, Wayconst VecObjectID members = wave->getAllIDs();const Object *walker = members.empty() ? NULL : TheGameLogic->findObjectByID( members.front() );Object *entrance = walker == NULL || walker->getAI() == NULL ? NULL- : m_player->getTunnelSystem()->findTunnelShortcut( walker, center, end->getLocation(), walk );+ : TunnelTracker::findTunnelShortcut( walker, center, end->getLocation(), walk );if( entrance == NULL )return;@@ -13759,7 +13759,7 @@ void AIPlayer::doRetreats( void )fallback.z = TheTerrainLogic->getGroundHeight( fallback.x, fallback.y );const Real homeX = m_baseCenter.x - centre.x;const Real homeY = m_baseCenter.y - centre.y;- Object *homeTunnel = shortOfHome ? NULL : m_player->getTunnelSystem()->findTunnelShortcut( walker, ¢re, &m_baseCenter,+ Object *homeTunnel = shortOfHome ? NULL : TunnelTracker::findTunnelShortcut( walker, ¢re, &m_baseCenter,(Real)sqrt( homeX * homeX + homeY * homeY ) );if( homeTunnel )DEBUG_LOG(("AI RETREAT frame %d player %d falls back through tunnel %d\n", TheGameLogic->getFrame(),diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cppindex 98194b3e6..d3c1b6464 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp@@ -1302,7 +1302,7 @@ UpdateSleepTime AIUpdateInterface::update( void )// a rally point across the map is reached through the tunnels when they are shorterconst Real walkX = rallyPoint.x - getObject()->getPosition()->x;const Real walkY = rallyPoint.y - getObject()->getPosition()->y;- Object *entrance = getObject()->getControllingPlayer()->getTunnelSystem()->findTunnelShortcut( getObject(), getObject()->getPosition(),+ Object *entrance = TunnelTracker::findTunnelShortcut( getObject(), getObject()->getPosition(),&rallyPoint, (Real)sqrt( walkX * walkX + walkY * walkY ) );const Bool tunnelled = entrance != NULL&& takeTunnelTrip( entrance, &rallyPoint, fights ? TUNNEL_TRIP_ATTACK_MOVE : TUNNEL_TRIP_MOVE, CMD_FROM_AI );diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cppindex 9ce646309..94e05cf72 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp@@ -263,8 +263,7 @@ StateReturnType DozerActionPickActionPosState::update( void )//const Real walkX = goalPos.x - dozer->getPosition()->x;const Real walkY = goalPos.y - dozer->getPosition()->y;- const TunnelTracker *tunnels = dozer->getControllingPlayer()->getTunnelSystem();- Object *entrance = tunnels->findTunnelShortcut( dozer, dozer->getPosition(), &goalPos,+ Object *entrance = TunnelTracker::findTunnelShortcut( dozer, dozer->getPosition(), &goalPos,(Real)sqrt( walkX * walkX + walkY * walkY ) );if( entrance != NULL && ai->takeTunnelTrip( entrance, &goalPos, TUNNEL_TRIP_MOVE, CMD_FROM_AI ) )