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): fork ai on official and random maps only
Olcay Seygan39bf9f9b56e2
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9aed30ac2..c8ccdf95f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -497,6 +497,7 @@ found and fixed, EA's own, not port damage.**- Nor does it know which start position you took. It used to read that straight off the lobby, for every player, from the first second. Now it works it out: each position it has not looked at is a suspect, and the odds are simply how many opponents are still unaccounted for over how many places they could be - three of you on an eight-position map is 3 in 7 for each. Every empty position its scout crosses off makes the rest likelier, 3 in 6, then 3 in 5. When the numbers meet, it stops looking: three opponents with three places left to be is not a guess, and walking over to confirm it would waste the trip. On a two-player map that is true from the start, so nothing changed there - it never wastes a second hunting for an address it can work out by subtraction. Where it has not worked you out yet, it attacks the position you are most likely to be on, and finds out on arrival.- Nor does it read your base off the map. Where your base is, what it is worth, which supply dock to expand to and where to aim a superweapon all came off a walk of your object list, in the shroud, from the first second of the match. The computer now only counts what it can see, plus the buildings it has already found - buildings do not walk away. Before it has scouted you, all it knows is where you started, which is on the map preview anyway.- A map that scripts its own computer player, the way Art of Defense maps script their GLA waves, gets that player back. All of the above ran on top of the map's script and pulled the waves off their routes: on AOD Super V the GLA sent 13 bunches of wave units off hunting on their own in one Easy match of 30,000 frames, and it could start a base of its own beside them. Now it plays the map's script and nothing else, as it did in the original game, on every difficulty. Official and random maps leave their computer players to the game's own scripts and play exactly as before.+- Everything in this section now plays on the official maps and the random ones only, in skirmish and in LAN and online rooms with computer seats. A map you downloaded or made yourself gets Zero Hour's own computer opponent back, the one its maker built and tested the map against: EA's scripts as they shipped, EA's build pace, EA's choice of enemy and its sight of the whole map, no personality whatever the lobby says. Campaign missions and the Generals' Challenge already had it and keep it. On a copy of Tournament Desert dropped into the Maps folder, two Hard computers now play 24,000 steps without one of the 20 attack waves and 39 economy moves they make on the shipped Tournament Desert with the same seed, and both replays play back to the same world. A replay recorded on a custom map before this change plays back differently.## Superweapons that go where the damage isdiff --git a/GeneralsMD/Code/BuildFingerprint.manifest b/GeneralsMD/Code/BuildFingerprint.manifestindex 09f4df3de..7cf657e7f 100644--- a/GeneralsMD/Code/BuildFingerprint.manifest+++ b/GeneralsMD/Code/BuildFingerprint.manifest@@ -467,6 +467,7 @@ Data/Scenarios/vision.txtData/Scenarios/wallgarrison.txtData/Scenarios/wreckcheck.txtData/Scripts/SkirmishScripts.scb+Data/Scripts/SkirmishScriptsRetail.scbData/Turkish/Generals.strData/Ukrainian/Generals.strData/Window/ControlBar.wnddiff --git a/GeneralsMD/Code/Data/Scripts/SkirmishScriptsRetail.scb b/GeneralsMD/Code/Data/Scripts/SkirmishScriptsRetail.scbnew file mode 100644index 000000000..38bc6003eBinary files /dev/null and b/GeneralsMD/Code/Data/Scripts/SkirmishScriptsRetail.scb differdiff --git a/GeneralsMD/Code/GameEngine/Include/Common/Player.h b/GeneralsMD/Code/GameEngine/Include/Common/Player.hindex 7ba9fbd64..3791137b1 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/Player.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/Player.h@@ -616,6 +616,7 @@ public:/// Is this player a skirmish ai player?Bool isSkirmishAIPlayer( void );+ Bool aiRunsOwnAI( void ) const; ///< a computer player on the fork's AI (AIPlayer::runsOwnAI); FALSE for a human and for EA's AI/// Have the ai check for bridges.virtual Bool checkBridges(Object *unit, Waypoint *way);diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.hindex b000a4b6f..82dd459a3 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h@@ -230,8 +230,14 @@ public: // AIPlayer interface, may be overridden by AISkirmishPlayer. jba.virtual Bool isSkirmishAI(void) {return false;}/** A skirmish AI that plays the fork's own game beside its scripts: economy, base, army, waves and* tactics. Not one whose map wrote those scripts itself (an Art of Defense map's waves), which is- * left to them the way a Challenge or mission opponent is. */+ * left to them the way a Challenge or mission opponent is, and not one on a player's own map+ * (SidesList::forkAIMap), which plays EA's AI. Every fork AI rule keys on this, never on+ * isSkirmishAI() or the player type. */Bool runsOwnAI(void);+ /** Whose eyes this AI reads another player's estate through: its own index on the fork's AI, so+ * it knows only what it has scouted; -1 on EA's, which knew the whole map and whose map scripts+ * were written for that. Pass it as the observerNdx below. */+ Int knowledgeObserver(void);virtual Player *getAiEnemy(void) {return NULL;} ///< Solo AI attacks based on scripting. Only skirmish auto-acquires an enemy at this point. jba.virtual Bool checkBridges(Object *unit, Waypoint *way) {return false;}/** Center, Flank or Backdoor: the approach with the least enemy firepower this AI knows about.diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/AISkirmishPlayer.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/AISkirmishPlayer.hindex bed1a71e0..21913d992 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/AISkirmishPlayer.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/AISkirmishPlayer.h@@ -110,6 +110,7 @@ protected:void adjustBuildList(BuildListInfo *list);Int getMyEnemyPlayerIndex(void);void acquireEnemy(void);+ void acquireEnemyRetail(void); ///< EA's acquireEnemy, for a seat that plays EA's AI (!runsOwnAI)void doSurrender(void); ///< say GG and give up once the match is lost beyond recoveryprotected:diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/SidesList.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/SidesList.hindex 8d3bb1c5a..0d022f5b3 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/SidesList.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/SidesList.h@@ -165,6 +165,12 @@ public:/// the map wrote its own scripts for its skirmish players (an Art of Defense map's waves), so/// prepareForMP_or_Skirmish left SkirmishScripts.scb unreadBool skirmishScriptsFromMap() const { return m_skirmishScriptsFromMap; }+ /** The match is on a map the game ships, where the fork's own skirmish AI plays: one in the game's+ * Maps folder (EA's, or a mod's in its archives) or one the random map generator made. A player's+ * own map, downloaded or hand-made, gets EA's AI and EA's SkirmishScripts.scb. Decided from the+ * map's path, which every machine in the match and the replay agree on. */+ Bool forkAIMap() const { return m_forkAIMap; }+ static Bool isForkAIMapPath(const AsciiString& mapPath);/** The skirmish side a computer player on pt copies its scripts from, and in *teams (when asked) the* record its teams are in. Under -modfactions a mod faction takes its own mod's side of the same@@ -218,6 +224,7 @@ protected:TeamsInfoRec m_teamrec;TeamsInfoRec m_skirmishTeamrec;Bool m_skirmishScriptsFromMap;+ Bool m_forkAIMap;/// -modfactions: each mod's SkirmishScripts.scb players and teams; and the standard file's players for/// sides the map has none for. Kept out of m_skirmishSides, which a map's own sides nearly filldiff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cppindex 1a14f2a91..132075021 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp@@ -1863,12 +1863,14 @@ void GlobalData::computeExeCRC( void )// Add in MP scripts to the EXE CRC, since the game will go out of sync if they change// -modfactions: then each mod's own SkirmishScripts.scb, which its factions' computer players run// (SidesList::loadModSkirmishScripts)- std::vector<Int> focus( 2, FILE_FOCUS_ALL );+ // and EA's own SkirmishScripts.scb, which a player's own map runs (SidesList::prepareForMP_or_Skirmish)+ std::vector<Int> focus( 3, FILE_FOCUS_ALL );for (Int mod = 0; m_modFactions && mod < (Int)m_mods.size(); ++mod)focus.push_back( mod );for (size_t s = 0; s < focus.size(); ++s){- const char *script = s == 1 ? "Data\\Scripts\\MultiplayerScripts.scb" : "Data\\Scripts\\SkirmishScripts.scb";+ const char *script = s == 1 ? "Data\\Scripts\\MultiplayerScripts.scb"+ : s == 2 ? "Data\\Scripts\\SkirmishScriptsRetail.scb" : "Data\\Scripts\\SkirmishScripts.scb";File *fp = NULL;if (focus[s] == FILE_FOCUS_ALL){diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cppindex 2f51f51d7..4cf615c17 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp@@ -1283,7 +1283,13 @@ void Player::becomingLocalPlayer(Bool yes)//-------------------------------------------------------------------------------------------------Bool Player::isSkirmishAIPlayer( void ){- return m_ai ? m_ai->isSkirmishAI() : false;+ return m_ai ? m_ai->isSkirmishAI() : false;+}++//-------------------------------------------------------------------------------------------------+Bool Player::aiRunsOwnAI( void ) const+{+ return m_ai != NULL && m_ai->runsOwnAI();}@@ -1697,7 +1703,7 @@ void Player::onUnitLost(const Object *obj)//-------------------------------------------------------------------------------------------------Bool Player::isAIDutyAmbulance(const Object *obj) const{- return m_ai ? m_ai->isDutyAmbulance(obj) : FALSE;+ return m_ai && m_ai->runsOwnAI() ? m_ai->isDutyAmbulance(obj) : FALSE;}//-------------------------------------------------------------------------------------------------@@ -3568,11 +3574,11 @@ Bool Player::canBuildMoreOfType( const ThingTemplate *whatToBuild, Int unitsPerOmaxSimultaneousOfType = (UnsignedInt)cap;}- // the defence allowance binds computer players in skirmish and network matches and their replays;- // humans, and a campaign or Generals Challenge mission, keep EA's rules+ // the defence allowance binds computer players on the fork's AI in skirmish and network matches and+ // their replays; humans, a campaign or Generals Challenge mission and a player's own map keep EA's rulesif ( whatToBuild->isKindOf( KINDOF_FS_SUPERWEAPON ) && TheGameLogic && !TheGameLogic->isInSinglePlayerGame()&& SuperweaponNeedsDefenses( whatToBuild->getName(), proRules, (Int)TheGameLogic->getSuperweaponRestriction(),- getPlayerType() == PLAYER_COMPUTER ) )+ aiRunsOwnAI() ) ){SuperweaponDefenseCount count = { 0, 0 };iterateObjects( countSuperweaponDefenses, &count );diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Team.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Team.cppindex d48f2c49a..18d5a6382 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Team.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Team.cpp@@ -1545,11 +1545,11 @@ void Team::setTeamTargetObject(const Object *target)// Whether a team fires together is a rung of the ladder now, not one of the three script// tiers: the ladder has six steps and this is one of the capabilities that separates them// (AI-ROADMAP.md D6). The bottom two rungs still do not do it, which is what the old- // DIFFICULTY_EASY test said. A script-driven opponent keeps that test itself, so the ladder's- // tuning never reaches a Challenge or mission.+ // DIFFICULTY_EASY test said. A script-driven opponent, or one on a player's own map, keeps that+ // test itself, so the ladder's tuning never reaches a Challenge, a mission or a custom map.//Player *player = getControllingPlayer();- const Bool focusFire = player->isSkirmishAIPlayer()+ const Bool focusFire = player->aiRunsOwnAI()? TheAI->getDifficultyProfile(player->getAISkillLevel())->m_focusFire: player->getPlayerDifficulty() != DIFFICULTY_EASY;if (!focusFire) {diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cppindex 985317528..b99cfece8 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp@@ -560,6 +560,7 @@ Bool FileSystem::isForkOwnedPath(const AsciiString& filename)if (p == "data\\ini\\modernwater.ini")return TRUE;return p == "data\\patch.str"+ || p == "data\\scripts\\skirmishscriptsretail.scb" // EA's own, for a player's own map|| starts("data\\turkish\\") || starts("data\\german\\")|| starts("data\\ukrainian\\") || starts("data\\russian\\") || starts("data\\french\\")|| starts("art\\textures\\reforged")diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cppindex 28899bc3d..6a90777cb 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp@@ -1458,9 +1458,10 @@ Object *AIPlayer::buildStructureWithDozer(const ThingTemplate *bldgPlan, BuildLibuildings. No spot now means no building from this entry: giveUpOnSpot drops it orsets it aside, so the rest of the list is not held behind it. */static const Int NEIGHBOURS[8][2] = { {1,0}, {-1,0}, {0,1}, {0,-1}, {1,1}, {-1,1}, {1,-1}, {-1,-1} };- const Int searchRadius = runsOwnAI() ? SKIRMISH_BUILD_SEARCH_CELLS : BUILD_SEARCH_CELLS;+ // EA's reach and stride, keyed as EA keyed them: any skirmish AI searched wide, its own map or not+ const Int searchRadius = isSkirmishAI() ? SKIRMISH_BUILD_SEARCH_CELLS : BUILD_SEARCH_CELLS;const Int searchWidth = 2*searchRadius + 1;- const Int probeStride = runsOwnAI() ? 2 : 1; // the rings tried every other cell for a skirmish AI too+ const Int probeStride = isSkirmishAI() ? 2 : 1; // the rings tried every other cell for a skirmish AI too// A home building the skirmish AI asked for stays within the base's edge and away from an// enemy. The flood only tested that the building fits.const Bool home = runsOwnAI() && info->isPriorityBuild() && m_baseCenterSet && staysHome(bldgPlan);@@ -2025,6 +2026,9 @@ void AIPlayer::onUnitProduced( Object *factory, Object *unit )}order->m_factoryID = INVALID_ID; // no longer using this factory.+ // a support order the fork's AI put in for a job of its own; EA's AI never has one, and+ // a unit that came out of anything else must not land in those slots+ const Bool dutyOrder = order->m_isScout && runsOwnAI();if (ai) {// tell it to start gathering resources.// Here is the special bit for this exit style, force wanting on SupplyTruck types@@ -2059,7 +2063,7 @@ void AIPlayer::onUnitProduced( Object *factory, Object *unit )// a Chinook buyGunshipChinook ordered (a support-unit order, m_isScout): the supply// center's exit put it to gathering, which the line above has just switched off, and// it stays on our books as a gunship. A script team's transport Chinook is not one- else if (order->m_isScout && unit->isKindOf(KINDOF_AIRCRAFT) && unit->isKindOf(KINDOF_HARVESTER) &&+ else if (dutyOrder && unit->isKindOf(KINDOF_AIRCRAFT) && unit->isKindOf(KINDOF_HARVESTER) &&passengersFireFrom(unit->getTemplate())) {for (Int chinook = 0; chinook < MAX_GUNSHIP_CHINOOKS; ++chinook) {if (m_gunshipChinook[chinook] == INVALID_ID) {@@ -2071,7 +2075,7 @@ void AIPlayer::onUnitProduced( Object *factory, Object *unit )}}// ... and a plain one buyTransportChinook ordered, which flies the wave's units- else if (order->m_isScout && unit->isKindOf(KINDOF_AIRCRAFT) && unit->isKindOf(KINDOF_HARVESTER) &&+ else if (dutyOrder && unit->isKindOf(KINDOF_AIRCRAFT) && unit->isKindOf(KINDOF_HARVESTER) &&transportContainOf(unit->getTemplate())) {for (Int shuttle = 0; shuttle < MAX_TRANSPORT_CHINOOKS; ++shuttle) {if (m_shuttle[shuttle].id == INVALID_ID) {@@ -2089,10 +2093,10 @@ void AIPlayer::onUnitProduced( Object *factory, Object *unit )}}// a Helix buyDutyHelix ordered; a team's Helix comes out of a team order, not a support one- if (order->m_isScout && isHelicopter(unit))+ if (dutyOrder && isHelicopter(unit))takeDutyHelix(unit);// ... and an Ambulance doAmbulances ordered- if (order->m_isScout && isAmbulanceTemplate(unit->getTemplate())) {+ if (dutyOrder && isAmbulanceTemplate(unit->getTemplate())) {for (Int slot = 0; slot < MAX_DUTY_AMBULANCES; ++slot) {if (m_ambulance[slot].id == INVALID_ID) {m_ambulance[slot].id = unit->getID();@@ -2203,7 +2207,7 @@ static void summarizeStrike( const Coord3D *at, Int playerNdx, Real radius, Int//----------------------------------------------------------------------------------------------------------Int AIPlayer::superweaponScore( Coord3D *center, Int playerNdx, Real radius, Bool targetMilitaryUnits ){- const Int value = getPlayerSuperweaponValue( center, playerNdx, radius, targetMilitaryUnits, m_player->getPlayerIndex(),+ const Int value = getPlayerSuperweaponValue( center, playerNdx, radius, targetMilitaryUnits, knowledgeObserver(),strikeEconomyWeight(), strikeThreatWeight() );if( value <= 0 || !runsOwnAI() )return value;@@ -2453,7 +2457,7 @@ Bool AIPlayer::computeSuperweaponTarget(const SpecialPowerTemplate *power, Coordif( success ){StrikeSummary summary;- summarizeStrike( &veryBestPos, playerNdx, weaponRadius, m_player->getPlayerIndex(), &summary );+ summarizeStrike( &veryBestPos, playerNdx, weaponRadius, knowledgeObserver(), &summary );DEBUG_LOG(("AI SUPERWEAPON frame %d player %d skill %d aims '%s' at (%.0f,%.0f), worth %d: structures %d units %d, top '%s'\n",TheGameLogic->getFrame(), m_player->getPlayerIndex(), (Int)m_skillLevel, power->getName().str(), veryBestPos.x,veryBestPos.y, cash, summary.structures, summary.units, summary.top ? summary.top->getTemplate()->getName().str() : "none"));@@ -2890,7 +2894,8 @@ Bool AIPlayer::isAGoodIdeaToBuildTeam( TeamPrototype *proto )return false;}- if (hasEnoughMoneyUnitsFor(proto)) {+ // the cap on hackers and other money units is the fork's; EA's AI trains what its script asks for+ if (runsOwnAI() && hasEnoughMoneyUnitsFor(proto)) {return false;}// check build limit@@ -4138,8 +4143,9 @@ void AIPlayer::buildBySupplies(Int minimumCash, const AsciiString& thingName, Bo}// Every call aims at the same spot beside the warehouse and the wiggle below takes the nearest// free ground to it, so each defense the scripts asked for went up against the last one: a- // Hard China stood nine Gattling cannons shoulder to shoulder at one pile.- if (bestSupplyWarehouse && countOwnedNear(m_player, tTemplate, bestSupplyWarehouse->getPosition(),+ // Hard China stood nine Gattling cannons shoulder to shoulder at one pile. EA's AI builds+ // every defense its script asks for, as the mission was balanced against.+ if (bestSupplyWarehouse && runsOwnAI() && countOwnedNear(m_player, tTemplate, bestSupplyWarehouse->getPosition(),SUPPLY_CENTER_CLOSE_DIST + bestSupplyWarehouse->getGeometryInfo().getBoundingCircleRadius()) >= MAX_DEFENSES_PER_WAREHOUSE) {return;}@@ -4488,6 +4494,7 @@ Object *AIPlayer::findSupplyCenter(Int minimumCash, Bool holdableOnly)Coord3D enemyCenter;enemyCenter.zero();Region2D bounds;+ const Bool ownAI = runsOwnAI();Player *enemy = getAiEnemy();if (enemy) {getPlayerStructureBounds(&bounds, enemy->getPlayerIndex(), FALSE, m_player->getPlayerIndex());@@ -4500,8 +4507,9 @@ Object *AIPlayer::findSupplyCenter(Int minimumCash, Bool holdableOnly)if (!obj->isKindOf(KINDOF_STRUCTURE)) continue;if (!obj->isKindOf(KINDOF_SUPPLY_SOURCE)) continue;// ... and one this AI has laid eyes on. This loop walks every object on the map, so- // without the test the AI expands to docks in shroud it has never been near.- if (!observerKnowsAbout(obj, m_player->getPlayerIndex())) continue;+ // without the test the AI expands to docks in shroud it has never been near. EA's AI knew+ // every dock, and a mission's script picks from all of them.+ if (!observerKnowsAbout(obj, knowledgeObserver())) continue;static const NameKeyType key_warehouseUpdate = NAMEKEY("SupplyWarehouseDockUpdate");SupplyWarehouseDockUpdate *warehouseModule = (SupplyWarehouseDockUpdate*)obj->findUpdateModule( key_warehouseUpdate );if( warehouseModule ) {@@ -4528,12 +4536,12 @@ Object *AIPlayer::findSupplyCenter(Int minimumCash, Bool holdableOnly)// Another side's pile: its supply center works it, or its base stands round it. Only// our own center was looked for (an ally's too, for a supportive AI), so a dock inside// an ally's base or a second enemy's read as free and the AI put a center, then guns- // and factories, against theirs.- if (otherSideStructureNear(m_player, obj)) {+ // and factories, against theirs. EA's AI takes the dock its script asks for, as it did.+ if (ownAI && otherSideStructureNear(m_player, obj)) {continue;}// a site given up at this dock lately (watchSite): not straight back into the same trap- if (aiSpotCooling(m_cooledSpots, obj->getPosition(), AI_COOLED_DOCK_RADIUS, TheGameLogic->getFrame())) {+ if (ownAI && aiSpotCooling(m_cooledSpots, obj->getPosition(), AI_COOLED_DOCK_RADIUS, TheGameLogic->getFrame())) {continue;}@@ -4571,7 +4579,7 @@ Object *AIPlayer::findSupplyCenter(Int minimumCash, Bool holdableOnly)// Hard AI's expansion for ten minutes with a free pile one valley over. A safe dock// is preferred, the nearest of them, and the unsafe nearest only when none is safe.// A mission's script picked its piles by hand and keeps EA's nearest.- if (!holdableOnly && runsOwnAI() && (bestSafeWarehouse==NULL || bestSafeDistSqr>distSqr) &&+ if (!holdableOnly && ownAI && (bestSafeWarehouse==NULL || bestSafeDistSqr>distSqr) &&isLocationSafe(obj->getPosition(), obj->getTemplate())) {bestSafeWarehouse = obj;bestSafeDistSqr = distSqr;@@ -5096,7 +5104,12 @@ Int AIPlayer::computeStructureDelay( void )//----------------------------------------------------------------------------------------------------------Bool AIPlayer::runsOwnAI( void ){- return isSkirmishAI() && !TheSidesList->skirmishScriptsFromMap();+ return isSkirmishAI() && TheSidesList->forkAIMap() && !TheSidesList->skirmishScriptsFromMap();+}++Int AIPlayer::knowledgeObserver( void )+{+ return runsOwnAI() ? m_player->getPlayerIndex() : -1;}//----------------------------------------------------------------------------------------------------------@@ -5502,7 +5515,9 @@ void AIPlayer::doUpgradesAndSkills( void )}}}- if (isSkirmishAI()) {+ if (isSkirmishAI() && !runsOwnAI()) {+ m_skillsetSelector = GameLogicRandomValue(0, limit); // EA's roll, across every set+ } else if (isSkirmishAI()) {//// Split the designers' skill sets between the two roles rather than rolling across all// of them (D8). This makes no claim about which set is which - only that an aggressive@@ -16331,6 +16346,10 @@ const AIPersonaWeights &AIPlayer::personaWeights( void ) constvoid AIPlayer::setAIPersonality( AIPersonality persona ){+ // EA's AI has no personality: a seat on a map that plays it is Normal whatever the lobby said,+ // draws nothing and keeps the role it rolled (SidesList's flags are set before players are)+ if( !runsOwnAI() )+ persona = AIPERSONA_NORMAL;// only a Random seat draws, so a Normal seat's random stream is the one it always wasm_personaFromRandom = persona == AIPERSONA_RANDOM;if( m_personaFromRandom )@@ -17961,6 +17980,10 @@ void AIPlayer::getPlayerStructureBounds( Region2D *bounds, Int playerNdx, Bool cbounds->hi.x = bounds->lo.x = bounds->hi.y = bounds->lo.y = 0;Region2D objBounds;objBounds.hi.x = objBounds.lo.x = objBounds.hi.y = objBounds.lo.y = 0;+ // EA's AI saw every building on the map, and the map scripts it runs were written for that: a+ // player's own index only limits the fork's AI, whichever caller passed it+ if (!runsOwnAI())+ observerNdx = -1;Player* pPlayer = ThePlayerList->getNthPlayer(playerNdx);if (pPlayer == NULL)diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cppindex b583e8d69..8187b9069 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp@@ -100,8 +100,13 @@ m_surrenderFrame(0)// GameLogicRandomValue, so a replay rolls the same one. Rolled here rather than in AIPlayer's// constructor so a Challenge or mission opponent leaves the logic random stream as retail did;// nothing between the two constructors draws, so a skirmish rolls on the same draw as before.+ // A seat that plays EA's AI (a player's own map, or one that scripts its seats) does not roll at+ // all: retail had no role and drew nothing here. The sides list is read before the players are+ // made, so runsOwnAI() already knows, and in this body isSkirmishAI() is this class's.//- m_role = (GameLogicRandomValue( 0, AIROLE_COUNT - 1 ) == 0) ? AIROLE_AGGRESSIVE : AIROLE_DEFENSIVE;+ if (runsOwnAI()) {+ m_role = (GameLogicRandomValue( 0, AIROLE_COUNT - 1 ) == 0) ? AIROLE_AGGRESSIVE : AIROLE_DEFENSIVE;+ }}AISkirmishPlayer::~AISkirmishPlayer()@@ -192,8 +197,9 @@ void AISkirmishPlayer::processBaseBuilding( void )// Check for built or dozer missing.if( bldg->getStatusBits().test( OBJECT_STATUS_UNDER_CONSTRUCTION ) ){- // a site its dozers cannot reach, or die on the way to, is cancelled for the money- if (watchSite(info, bldg)) {+ // a site its dozers cannot reach, or die on the way to, is cancelled for the money;+ // EA's AI waits on it for ever, as retail did+ if (runsOwnAI() && watchSite(info, bldg)) {continue;}if (bldg->isKindOf(KINDOF_FS_POWER) && !bldg->isKindOf(KINDOF_CASH_GENERATOR))@@ -244,8 +250,9 @@ void AISkirmishPlayer::processBaseBuilding( void )continue; // already built.}// A second war factory, barracks or airfield of the plan's waits until the ones standing- // fall behind their queues, as an extra one would.- if (holdsExtraFactory(curPlan)) {+ // fall behind their queues, as an extra one would. Only for the fork's AI: the queues are+ // sampled by its doSpending, so EA's would wait on a sample that never comes.+ if (runsOwnAI() && holdsExtraFactory(curPlan)) {continue;}// The safety check below is a range query over everything near the spot, most of a@@ -271,7 +278,10 @@ void AISkirmishPlayer::processBaseBuilding( void )// The rest of the plan, unasked: a seat its map scripts builds what the scripts ask and the// power, as retail's did, or an Art of Defense GLA puts up a base and leaves its waves.const Bool couldBeBuilt = runsOwnAI() && bldgPlan==NULL && info->isAutomaticBuild() && info->isBuildable();- if (!couldBePriority && !couldBePower && !couldBeBuilt) {+ // EA's AI walked every entry on, and short of power an automatic one with no free dozer+ // queues one below; that entry keeps going for it, so the dozer comes when retail's did.+ const Bool retailDozerAsk = !runsOwnAI() && isUnderPowered && info->isAutomaticBuild();+ if (!couldBePriority && !couldBePower && !couldBeBuilt && !retailDozerAsk) {continue;}// Make sure it is safe to build here.@@ -324,9 +334,10 @@ void AISkirmishPlayer::processBaseBuilding( void )}continue;}- // check if this building has any "rebuilds" left- if (info->isBuildable())- {+ // check if this building has any "rebuilds" left. EA's test above read bldgPlan, so this+ // never took anything for retail; EA's AI still builds only what is asked and the power.+ if (info->isBuildable() && runsOwnAI())+ {if (bldgPlan == NULL) {bldgPlan = curPlan;bldgInfo = info;@@ -445,7 +456,8 @@ Bool AISkirmishPlayer::isAGoodIdeaToBuildTeam( TeamPrototype *proto )return false;}- if (hasEnoughMoneyUnitsFor(proto)) {+ // the hacker cap and the hoard are the fork's AI; EA's builds what its scripts ask, as many as the data says+ if (runsOwnAI() && hasEnoughMoneyUnitsFor(proto)) {return false;}// check build limit, which a hoard raises for attack teams; defence teams keep the data's, and so do@@ -454,7 +466,7 @@ Bool AISkirmishPlayer::isAGoodIdeaToBuildTeam( TeamPrototype *proto )Int allowedInstances = info->m_maxInstances;if (!info->m_isBaseDefense && !info->m_isPerimeterDefense && aiTeamAttacks(info)) {allowedInstances = aiHoardAllowedTeamInstances( allowedInstances, m_player->getMoney()->countMoney(),- getSkillProfile()->m_cashHoardThreshold );+ hoardThreshold() );}if (proto->countTeamInstances() >= allowedInstances){if (TheGlobalData->m_debugAI) {@@ -594,7 +606,8 @@ Int AISkirmishPlayer::getMyEnemyPlayerIndex(void) {//----------------------------------------------------------------------------------------------------------Bool AISkirmishPlayer::influenceMapAttackGoal( Coord3D *goal ){- if( !getSkillProfile()->m_useInfluenceMapForAttackLane )+ // EA's AI aims at the middle of the buildings, as retail did+ if( !runsOwnAI() || !getSkillProfile()->m_useInfluenceMapForAttackLane )return FALSE;if( ThePartitionManager == NULL || goal == NULL )return FALSE;@@ -610,8 +623,82 @@ Bool AISkirmishPlayer::influenceMapAttackGoal( Coord3D *goal )return TRUE;}+//----------------------------------------------------------------------------------------------------------+/** EA's acquireEnemy as it shipped, for a seat that plays EA's AI. Its quirks are the point: the+ * crippled enemy pushed to half the map, the gang-up penalty counting this AI's own pick, the+ * "attacking me" nudge going to whoever else is targeted, and the bounds read through the fog. */+//----------------------------------------------------------------------------------------------------------+void AISkirmishPlayer::acquireEnemyRetail(void)+{+ Player *bestEnemy = NULL;+ Real bestDistanceSqr = HUGE_DIST*HUGE_DIST;++ if (m_currentEnemy) {+ Bool inBadShape = !m_currentEnemy->hasAnyUnits() || !m_currentEnemy->hasAnyBuildFacility();+ if (!inBadShape) return;+ }++ // look for the closest enemy.+ Int i;+ for (i=0; i<ThePlayerList->getPlayerCount(); i++) {+ Player *curPlayer = ThePlayerList->getNthPlayer(i);+ if (m_player->getRelationship(curPlayer->getDefaultTeam()) == ENEMIES) {+ if (curPlayer->hasAnyObjects()==false) continue; // not much of an enemy.+ // ok, we got an enemy;+ // If a player is out of units, or out of build facilities, we can lower his priority.+ Bool inBadShape = !curPlayer->hasAnyUnits() || !curPlayer->hasAnyBuildFacility();++ Coord3D enemyPos = m_baseCenter;+ Region2D bounds;+ getPlayerStructureBounds(&bounds, i);+ enemyPos.x = bounds.lo.x + bounds.width()/2;+ enemyPos.y = bounds.lo.y + bounds.height()/2;+ Real curDistSqr = sqr(enemyPos.x-m_baseCenter.x) + sqr(enemyPos.y-m_baseCenter.y);++ //Fudge for in bad shape. If an enemy is crippled, concentrate on the other ones.+ if (inBadShape) {+ curDistSqr = HUGE_DIST*HUGE_DIST*0.5f;+ }+ // See if other ai's are attacking this target.+ // We don't want the ai's to gang up on one enemy.+ Int k;+ for (k=0; k<ThePlayerList->getPlayerCount(); k++) {+ if (k==i) continue; // don't count self.+ Player *somePlayer = ThePlayerList->getNthPlayer(k);+ if (somePlayer->isSkirmishAIPlayer() && (somePlayer->getCurrentEnemy()==curPlayer)) {+ // Some ai is already targeting this guy. Add a distance penalty.+ curDistSqr += (500*500);+ }+ if (somePlayer->isSkirmishAIPlayer() && (somePlayer->getCurrentEnemy()==m_player)) {+ // he is attacking me. So I will (gently) prefer to attack him.+ curDistSqr -= (25*25);+ if (curDistSqr<0) curDistSqr = 0;+ }+ }++ // Ai enemy - will take if we don't get a better offer.+ if (curDistSqr<bestDistanceSqr) {+ bestEnemy = curPlayer;+ bestDistanceSqr = curDistSqr;+ }+ }+ }+ if (bestEnemy!=NULL && (bestEnemy!=m_currentEnemy)) {+ m_currentEnemy = bestEnemy;+ AsciiString msg = TheNameKeyGenerator->keyToName(m_player->getPlayerNameKey());+ msg.concat(" acquiring target enemy player: ");+ msg.concat(TheNameKeyGenerator->keyToName(m_currentEnemy->getPlayerNameKey()));+ TheScriptEngine->AppendDebugMessage( msg, false);+ }+}+void AISkirmishPlayer::acquireEnemy(void){+ if (!runsOwnAI()) {+ acquireEnemyRetail();+ return;+ }+Player *bestEnemy = NULL;Real bestDistanceSqr = HUGE_DIST*HUGE_DIST;@@ -754,8 +841,9 @@ void AISkirmishPlayer::buildAIBaseDefense(Bool flank)defenseTemplateName = resInfo->m_baseDefenseStructure1;}// the data names one defence per side, so a script asking for ten got ten of it: the side's mix- // comes off a dozer's buttons instead, and the data's choice stands in when no dozer is left- Object *dozer = findNearestDozer(&m_baseCenter);+ // comes off a dozer's buttons instead, and the data's choice stands in when no dozer is left.+ // EA's AI builds the data's one, on the approach-path ring, as retail did.+ Object *dozer = runsOwnAI() ? findNearestDozer(&m_baseCenter) : NULL;const ThingTemplate *mix = dozer ? nextBaseDefense(dozer) : NULL;if (mix) {// the spot with the widest field of fire first; the approach-path ring when none scores@@ -815,7 +903,8 @@ void AISkirmishPlayer::buildAIBaseDefenseStructure(const AsciiString &thingName,if (flank) return;if (!influenceMapAttackGoal(&goalPos)) {Region2D bounds;- getPlayerStructureBounds(&bounds, getMyEnemyPlayerIndex(), FALSE, m_player->getPlayerIndex());+ // what this AI has seen of him; EA's sees every building, as retail did+ getPlayerStructureBounds(&bounds, getMyEnemyPlayerIndex(), FALSE, runsOwnAI() ? m_player->getPlayerIndex() : -1);goalPos.x = bounds.lo.x + bounds.width()/2;goalPos.y = bounds.lo.y + bounds.height()/2;}@@ -890,8 +979,9 @@ void AISkirmishPlayer::buildAIBaseDefenseStructure(const AsciiString &thingName,/* See if we can build there. */Bool canBuild;Real placeAngle = tTemplate->getPlacementViewAngle();- // a spot the base cannot drive to guards nothing: a ledge, or across a valley the path runs beside- canBuild = reachableFromBase(&buildPos) && LBC_OK == TheBuildAssistant->isLocationLegalToBuild(&buildPos, tTemplate, placeAngle,+ // a spot the base cannot drive to guards nothing: a ledge, or across a valley the path runs beside.+ // EA's AI takes the first legal spot, as retail did.+ canBuild = (!runsOwnAI() || reachableFromBase(&buildPos)) && LBC_OK == TheBuildAssistant->isLocationLegalToBuild(&buildPos, tTemplate, placeAngle,BuildAssistant::TERRAIN_RESTRICTIONS|BuildAssistant::NO_OBJECT_OVERLAP, NULL, m_player);TheTerrainVisual->removeAllBibs(); // isLocationLegalToBuild adds bib feedback, turn it off. jba.if (flank) {@@ -1074,10 +1164,12 @@ void AISkirmishPlayer::processTeamBuilding( void )* instead, the shipped values land on the same 3 seconds they do today, and the modifiers* work again around it: a wealthy skirmish AI presses at 1.5 seconds, a poor one drops to 5.* See FINDINGS.md 4.+ *+ * A seat that plays EA's AI keeps the data's delays and EA's clamp (doBaseBuilding, doTeamBuilding).*/Real AISkirmishPlayer::getBuildRateScale( void ){- return 10.0f/3.0f;+ return runsOwnAI() ? 10.0f/3.0f : 1.0f;}//----------------------------------------------------------------------------------------------------------@@ -1094,6 +1186,10 @@ void AISkirmishPlayer::doBaseBuilding( void )m_readyToBuildStructure = true;m_buildDelay = 0;}+ // EA's flat 3 seconds, for a seat that plays EA's AI; the fork's works off getBuildRateScale+ if (!runsOwnAI() && m_structureTimer > 3*LOGICFRAMES_PER_SECOND) {+ m_structureTimer = 3*LOGICFRAMES_PER_SECOND;+ }}// This timer is to keep from banging on the logic each frame. If something interesting// happens, like a building is added or a unit finished, the timers are shortcut.@@ -1143,6 +1239,10 @@ void AISkirmishPlayer::doTeamBuilding( void )m_readyToBuildTeam = true;m_teamDelay = 0;}+ // EA's flat 3 seconds, as for the structure timer above+ if (!runsOwnAI() && m_teamTimer > 3*LOGICFRAMES_PER_SECOND) {+ m_teamTimer = 3*LOGICFRAMES_PER_SECOND;+ }}// This timer is to keep from banging on the logic each frame. If something interesting@@ -1482,8 +1582,10 @@ Object * AISkirmishPlayer::findDozer( const Coord3D *pos )Bool AISkirmishPlayer::computeSuperweaponTarget(const SpecialPowerTemplate *power, Coord3D *retPos, Int playerNdx, Real weaponRadius){+ // what this AI has seen of the target; EA's sees every building, as retail did+ const Int observer = runsOwnAI() ? m_player->getPlayerIndex() : -1;Region2D bounds;- getPlayerStructureBounds(&bounds, playerNdx, FALSE, m_player->getPlayerIndex());+ getPlayerStructureBounds(&bounds, playerNdx, FALSE, observer);if( power->getSpecialPowerType() == SPECIAL_CLUSTER_MINES || power->getSpecialPowerType() == NUKE_SPECIAL_CLUSTER_MINES ){@@ -1505,7 +1607,7 @@ Bool AISkirmishPlayer::computeSuperweaponTarget(const SpecialPowerTemplate *powe} else {if (!influenceMapAttackGoal(&goalPos)) {Region2D bounds;- getPlayerStructureBounds(&bounds, getMyEnemyPlayerIndex(), FALSE, m_player->getPlayerIndex());+ getPlayerStructureBounds(&bounds, getMyEnemyPlayerIndex(), FALSE, observer);goalPos.x = bounds.lo.x + bounds.width()/2;goalPos.y = bounds.lo.y + bounds.height()/2;}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/SidesList.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/SidesList.cppindex 0c54a90ca..80198c77a 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/SidesList.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/SidesList.cpp@@ -51,7 +51,9 @@#include "Common/DataChunk.h"#include "Common/FileSystem.h"#include "Common/GameState.h"+#include "Common/GlobalData.h"#include "Common/PlayerTemplate.h"+#include "Common/RandomMapGenerator.h"#include "Common/WellKnownKeys.h"#include "Common/Xfer.h"#include "GameLogic/AI.h"@@ -207,7 +209,7 @@ Int SidesInfo::removeFromBuildList(BuildListInfo *pBuildList)/**SidesList - Constructor.*/-SidesList::SidesList(void) : m_numSides(0), m_numSkirmishSides(0), m_skirmishScriptsFromMap(false)+SidesList::SidesList(void) : m_numSides(0), m_numSkirmishSides(0), m_skirmishScriptsFromMap(false), m_forkAIMap(false){}@@ -234,6 +236,7 @@ void SidesList::clear(void)emptySides();emptyTeams();m_skirmishScriptsFromMap = false;+ m_forkAIMap = false;}@@ -692,8 +695,25 @@ SidesInfo *SidesList::findSkirmishSideNamed(const AsciiString& side, Int mod, Tereturn best;}+/*static*/ Bool SidesList::isForkAIMapPath(const AsciiString& mapPath)+{+ AsciiString path = mapPath;+ // a loaded save plays its own copy of the map from the save folder; the map it was started on decides+ if (TheGameState && TheGameState->isInSaveDirectory(path))+ path = TheGameState->getPristineMapName();+ if (path.isEmpty())+ return false;+ // the generator's maps sit in the player's own Maps folder, but the game made them+ if (isGeneratedMapPath(path))+ return true;+ // "maps\..." is the game's folder and its archives, "userdata\maps\..." the player's: the same+ // portable name the lobby sends and the replay records, so every machine reads the same answer+ return TheGameState && TheGameState->realMapPathToPortableMapPath(path).startsWithNoCase("maps\\");+}+void SidesList::prepareForMP_or_Skirmish(void){+ m_forkAIMap = isForkAIMapPath(TheGlobalData->m_mapName);m_skirmishTeamrec.clear();Int i;for (i = 0; i < getNumTeams(); i++)@@ -733,10 +753,21 @@ void SidesList::prepareForMP_or_Skirmish(void)}}m_skirmishScriptsFromMap = gotScripts;+ if (gotScripts)+ DEBUG_LOG(("Skirmish map brings its own scripts: fork AI off, map %s\n", TheGlobalData->m_mapName.str()));loadModSkirmishScripts();if (!gotScripts) {AsciiString path = "data\\Scripts\\SkirmishScripts.scb";- DEBUG_LOG(("Skirmish map using standard scripts\n"));+ // A player's own map gets EA's scripts as EA shipped them: the fork's file carries its own+ // openings and its Hard without the free cash. A -mod brings its own skirmish AI and keeps it.+ // ponytail: any -mod keeps the resolved file, even one that ships no .scb; check the mod's+ // archives for one if that ever matters.+ // (GlobalData::computeExeCRC hashes this file too, under the same name)+ const char *retail = "data\\Scripts\\SkirmishScriptsRetail.scb";+ if (!m_forkAIMap && TheGlobalData->m_mods.empty() && TheFileSystem->doesFileExist(retail))+ path = retail;+ DEBUG_LOG(("Skirmish map using standard scripts %s: fork AI %s, map %s\n", path.str(),+ m_forkAIMap ? "on" : "off", TheGlobalData->m_mapName.str()));m_skirmishTeamrec.clear();CachedFileInputStream theInputStream;if (theInputStream.open(path)) {diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cppindex e95f70ff3..a043a1ee6 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp@@ -6057,7 +6057,7 @@ Bool PartitionFilterPossibleToAttack::allow(Object *objOther)// picking its own target, so an explicit order to level one still goes through, and a tech// building that shoots back is still shot back at.//- if (m_obj->getControllingPlayer() && m_obj->getControllingPlayer()->getPlayerType() == PLAYER_COMPUTER &&+ if (m_obj->getControllingPlayer() && m_obj->getControllingPlayer()->aiRunsOwnAI() &&aiIsIncomeNotATarget(objOther->isKindOf(KINDOF_TECH_BUILDING),objOther->isKindOf(KINDOF_CAPTURABLE),objOther->isKindOf(KINDOF_TECH_BASE_DEFENSE)))diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cppindex 1fbd1b584..c26c32c57 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp@@ -7079,7 +7079,11 @@ Object* AIUpdateInterface::getNextMoodTarget( Bool calledByAI, Bool calledDuring// members and base defence turrets all route through here - so the exemption covered every one// of them. The AI now sees what a player sees, which is also what makes stealth work against it.//- if( (calledByAI || beyondVision) && obj->getControllingPlayer() )+ // A computer player on EA's AI (a mission, a Challenge, a player's own map) keeps EA's exemption:+ // those maps and their scripts were made for an opponent whose units see into the fog.+ const Player *controller = obj->getControllingPlayer();+ if( controller && ( beyondVision ||+ ( calledByAI && ( controller->getPlayerType() == PLAYER_HUMAN || controller->aiRunsOwnAI() ) ) ) ){flags |= AI::UNFOGGED;}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cppindex 1f0d01bf0..12a36f71a 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp@@ -4756,8 +4756,9 @@ static void salvageCrateTick( void )const Player *owner = them->getControllingPlayer();if( owner == NULL || crate->getShroudedStatus( owner->getPlayerIndex() ) >= OBJECTSHROUD_FOGGED )continue;- // a human's units go where the human sends them; only the computer's are sent for salvage- if( owner->getPlayerType() != PLAYER_COMPUTER )+ // a human's units go where the human sends them; only the computer's are sent for salvage,+ // and only on the fork's AI: EA's never went for a crate on its own+ if( owner->getPlayerType() != PLAYER_COMPUTER || !owner->aiRunsOwnAI() )continue;const Bool upgrades = wantsSalvageUpgrade( them );