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): ai replaces spotters killed in the field
Olcay Seygan7052ef260cd8
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a95a0d73b..f6a8a1029 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -157,7 +157,7 @@ found and fixed — EA's own, not port damage.**- Turkish ranks carry more than numbers. A Çavuş sees 10% further, an Uzman Çavuş takes 10% less damage standing still, and from the sixth grade a unit patches itself up out of a fight at 1% a second. Sight grows to 20% and 30% further at the astsubay and general ranks. A Teğmen spots for the Firtina and the Sakarya the way the spotter team does, a Binbaşı's own guns spread 15% less, and a Tümgeneral finds stealthed enemies within 100 of it. Officers lead: the Astsubay Kıdemli Başçavuş makes every friendly unit within 150 fire 5% faster and the Albay 10%, the Yüzbaşı lets them see 10% further, the Korgeneral cuts the damage they take by 10% and the Orgeneral puts 5% on the artillery's range. A Tuğgeneral who falls leaves the men around him taking 15% less damage for ten seconds, and a Mareşal's leadership reaches 300. Two officers of the same kind never add up: a tank between an Albay and a Başçavuş fires 10% faster, the Albay's figure alone. Select or hover a leader and what it gives the men around it shows on the ground as one quiet dial at the edge of its reach, each gift in its own band and its own pattern: short ticks round the rim for fire, a dotted line for sight, a notched line for armour, a graduated scale for the guns' reach and a faint wash inside for the last stand, so an Albay draws two bands and a Mareşal the whole dial; the portrait's tooltip lists what the rank carries. Only you and your allies see the rings. Making those colours work fixed a mistake in how the game tints glowing ground marks, which had drawn every one of them in pure blue. The grid a spy satellite or a radar scan lays over what it reveals is now the dim grey-blue EA's data asks for, and about half as bright as before.- The units still borrow American and other sides' models, voices and cameos.- The computer plays Turkiye too. A Turkish AI puts up a full base with radar towers, Hisar batteries and Siper bunkers it fills with its own infantry, sends supply trucks, fields the new army, artillery included, fires its own powers and attacks.-- The Turkish computer brings its guns and the eyes to aim them. A Firtina or Sakarya that comes out for one of its attack groups now sends for spotter teams, one on Easy and Medium and two on Hard, and the group waits for them before it leaves; until now the guns walked out blind and the spotters it did buy sat in its bunkers. The American battle plans it plays never put a Firtina in an Easy attack and only reach one after a quarter of an hour on Medium, so it adds a gun of its own to every Easy attack group, every second Medium one and every fourth on Hard. In three fifteen-minute matches a difficulty on Twilight Flame against America, Easy fielded 21 guns, Medium 48 and Hard 27, and all 41 that came out for an attack group sent for their spotters. The computer pays the Turkish price for them now. A Firtina used to cost it the American 1200 whenever that was all it had in the bank.+- The Turkish computer brings its guns and the eyes to aim them. A Firtina or Sakarya that comes out for one of its attack groups now sends for spotter teams, one on Easy and Medium and two on Hard, and the group waits for them before it leaves; until now the guns walked out blind and the spotters it did buy sat in its bunkers. The American battle plans it plays never put a Firtina in an Easy attack and only reach one after a quarter of an hour on Medium, so it adds a gun of its own to every Easy attack group, every second Medium one and every fourth on Hard. In three fifteen-minute matches a difficulty on Twilight Flame against America, Easy fielded 21 guns, Medium 48 and Hard 27, and all 41 that came out for an attack group sent for their spotters. The computer pays the Turkish price for them now. A Firtina used to cost it the American 1200 whenever that was all it had in the bank. A spotter team killed in the field is replaced for any group that still has a gun and none left to see for it, the men it trains for the seats of a Humvee or a bunker are no longer spotter teams, and a group whose spotters are late leaves without them instead of breaking up when its build time runs out.## Zero Hour on a Mac, on Linux and on the Steam Deckdiff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.hindex 210e6bab7..243a4fdb7 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h@@ -537,6 +537,7 @@ protected:void computeCenterAndRadiusOfBase(Coord3D *center, Real *radius);Object *findFactory(const ThingTemplate *thing, Bool busyOK); ///< Find a factory to build a unit. If force is true, may return a busy factory.void sendForSpotters( TeamInQueue *team, const Object *gun ); ///< a gun that fires past its own sight came out for this team: train its spotters+ Bool replaceSpotter( void ); ///< a team in the field has a gun that fires past its own sight and no spotter left: train it onevoid queueUnits( void ); ///< Check the team build list, & queue up units at any idle factories.void checkForSupplyCenter( BuildListInfo *info, Object *bldg);void queueSupplyTruck(void);diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cppindex acb342cf7..fd4123a5e 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp@@ -2764,7 +2764,7 @@ void AIPlayer::sendForSpotters( TeamInQueue *team, const Object *gun )order->m_thing = spotter;order->m_factoryID = INVALID_ID;order->m_numRequired = spotters;- order->m_required = true;+ order->m_required = false; // a team whose spotters are late goes out without them rather than disbanding at the build timeoutorder->m_next = team->m_workOrders;team->m_workOrders = order;}@@ -2926,11 +2926,80 @@ Bool AIPlayer::isAGoodIdeaToBuildTeam( TeamPrototype *proto )return true;}+// ------------------------------------------------------------------------------------------------+/** A spotter killed in the field was never replaced: the team's guns kept walking with nobody to see+ * for them. An attack team that still has a gun firing past its own sight and none of the side's+ * spotter left on its list trains one as a reinforcement, which joins it where it stands. One order at+ * a time, and not for a team still being built, whose spotters sendForSpotters has in hand. */+Bool AIPlayer::replaceSpotter( void )+{+ if( !isSkirmishAI() || getSkillProfile()->m_artillerySpotters <= 0 )+ return false;+ for( Player::PlayerTeamList::const_iterator t = m_player->getPlayerTeams()->begin(); t != m_player->getPlayerTeams()->end(); ++t )+ {+ TeamPrototype *proto = (*t);+ const ThingTemplate *spotter = missingSpotterFor( m_player, proto );+ if( spotter == NULL )+ continue;+ Bool busy = false;+ for( DLINK_ITERATOR<TeamInQueue> iter = iterate_TeamBuildQueue(); !iter.done(); iter.advance() )+ if( iter.cur()->m_team->getPrototype() == proto )+ busy = true;+ if( busy )+ continue;+ for( DLINK_ITERATOR<Team> iter = proto->iterate_TeamInstanceList(); !iter.done(); iter.advance() )+ {+ Team *team = iter.cur();+ Bool blindGun = false;+ Bool sighted = false;+ for( DLINK_ITERATOR<Object> m = team->iterate_TeamMemberList(); !m.done(); m.advance() )+ {+ if( m.cur()->isEffectivelyDead() )+ continue;+ blindGun |= m.cur()->getTemplate()->acquiresBeyondVision();+ sighted |= m.cur()->getTemplate()->isEquivalentTo( spotter );+ }+ if( !blindGun || sighted )+ continue;++ const Bool canBuildUnits = m_player->getCanBuildUnits();+ m_player->setCanBuildUnits( TRUE );+ Object *factory = findFactory( spotter, TRUE );+ m_player->setCanBuildUnits( canBuildUnits );+ if( factory == NULL )+ return false;++ WorkOrder *order = newInstance(WorkOrder);+ order->m_thing = spotter;+ order->m_factoryID = INVALID_ID;+ order->m_numRequired = 1;+ order->m_required = false;+ order->m_next = NULL;+ TeamInQueue *teamQ = newInstance(TeamInQueue);+ prependTo_TeamBuildQueue( teamQ );+ teamQ->m_priorityBuild = false;+ teamQ->m_reinforcement = true;+ teamQ->m_workOrders = order;+ teamQ->m_frameStarted = TheGameLogic->getFrame();+ teamQ->m_team = team;+ DEBUG_LOG(("AI ARTILLERY frame %d player %d replaces the spotter of team '%s'\n", TheGameLogic->getFrame(),+ m_player->getPlayerIndex(), team->getName().str()));+ m_teamDelay = 0;+ startTraining( order, teamQ->m_priorityBuild, teamQ->m_team->getName() );+ return true;+ }+ }+ return false;+}+// ------------------------------------------------------------------------------------------------/** See if any existing teams need reinforcements, and have higher priority. */// ------------------------------------------------------------------------------------------------Bool AIPlayer::selectTeamToReinforce( Int minPriority ){+ if( replaceSpotter() )+ return true;+// Find a high production priority team that needs reinforcements.Player::PlayerTeamList::const_iterator t;Team *curTeam = NULL;@@ -10503,7 +10572,7 @@ Bool AIPlayer::isGunshipRider( const Object *obj ) const{return obj->isKindOf( KINDOF_INFANTRY ) && !obj->isKindOf( KINDOF_HERO ) && obj->isSelectable() && !obj->isContained() &&!obj->isEffectivelyDead() && obj->getAI() && leavesToFinish( obj ) && !isMassUnit( obj->getID() ) && !isSlaved( obj ) &&- !obj->isKindOf( KINDOF_MOB_NEXUS );+ !obj->isKindOf( KINDOF_MOB_NEXUS ) && !obj->getTemplate()->hasSpotterSight(); // a spotter is the eyes of a gun team, not a seat filler}/** An infantryman who rides out with the army, where loadGunships puts him. */@@ -10946,7 +11015,7 @@ static const ThingTemplate *gunshipRiderTemplate( Object *factory, const ThingTecontinue;const ThingTemplate *tmpl = button->getThingTemplate();if( tmpl == NULL || !tmpl->isKindOf( KINDOF_INFANTRY ) || !tmpl->canPossiblyHaveAnyWeapon() || tmpl->isKindOf( KINDOF_DOZER ) ||- tmpl->isKindOf( KINDOF_MONEY_HACKER ) || tmpl->isKindOf( KINDOF_HERO ) ||+ tmpl->isKindOf( KINDOF_MONEY_HACKER ) || tmpl->isKindOf( KINDOF_HERO ) || tmpl->hasSpotterSight() ||tmpl->calcCostToBuild( factory->getControllingPlayer() ) <= 0 ||TheBuildAssistant->canMakeUnit( factory, tmpl ) != CANMAKE_OK )continue;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cppindex 26fdd9fb5..3a31985a9 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp@@ -2815,7 +2815,7 @@ void JetAIUpdate::aiDoCommand(const AICommandParms* parms)if (!isAllowedToRespondToAiCommands(parms))return;-+// note that we always store this, even if nothing will be "pending".m_mostRecentCommand.store(*parms);