Fixed crash on new map start with bots

This commit is contained in:
RGreenlees 2024-03-09 22:58:24 +00:00 committed by pierow
parent b3a1c7a6be
commit 14d3e2c54a
4 changed files with 21 additions and 10 deletions

View File

@ -3457,6 +3457,7 @@ void AIPlayerSetWantsAndNeedsCOMarineTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Ta
NearestArmouryFilter.DeployableTeam = pBot->Player->GetTeam();
NearestArmouryFilter.ReachabilityTeam = pBot->Player->GetTeam();
NearestArmouryFilter.ReachabilityFlags = pBot->BotNavInfo.NavProfile.ReachabilityFlag;
NearestArmouryFilter.IncludeStatusFlags = STRUCTURE_STATUS_COMPLETED;
NearestArmouryFilter.ExcludeStatusFlags = STRUCTURE_STATUS_RECYCLING;
NearestArmouryFilter.MaxSearchRadius = SearchRadius;
@ -3515,6 +3516,7 @@ void AIPlayerSetWantsAndNeedsMarineTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Task
NearestArmouryFilter.DeployableTeam = pBot->Player->GetTeam();
NearestArmouryFilter.ReachabilityTeam = pBot->Player->GetTeam();
NearestArmouryFilter.ReachabilityFlags = pBot->BotNavInfo.NavProfile.ReachabilityFlag;
NearestArmouryFilter.IncludeStatusFlags = STRUCTURE_STATUS_COMPLETED;
NearestArmouryFilter.ExcludeStatusFlags = STRUCTURE_STATUS_RECYCLING;
NearestArmouryFilter.MaxSearchRadius = (bTaskIsUrgent) ? UTIL_MetresToGoldSrcUnits(20.0f) : UTIL_MetresToGoldSrcUnits(5.0f);

View File

@ -931,7 +931,7 @@ void AIMGR_ResetRound()
LastAIPlayerCountUpdate = 0.0f;
AITAC_ClearMapAIData();
AITAC_ClearMapAIData(false);
UTIL_PopulateDoors();
UTIL_PopulateWeldableObstacles();
@ -1035,7 +1035,7 @@ void AIMGR_NewMap()
LastAIPlayerCountUpdate = 0.0f;
ALERT(at_console, "AI Manager New Map\n");
AITAC_ClearMapAIData();
AITAC_ClearMapAIData(true);
if (NavmeshLoaded())
{

View File

@ -2370,19 +2370,28 @@ void AITAC_ClearStructureNavData()
}
}
void AITAC_ClearMapAIData()
void AITAC_ClearMapAIData(bool bInitialMapLoad)
{
UTIL_ClearLocalizations();
ResourceNodes.clear();
AITAC_ClearHiveInfo();
AITAC_ClearStructureNavData();
while (!bTileCacheUpToDate)
// If we're clearing AI data due to a map load, then we just clear the hive data immediately since we've reloaded the nav mesh
// If we're clearing AI data due to a round restart, then ensure we properly clear all temp obstacles and connections since we're not reloading the mesh
if (!bInitialMapLoad)
{
UTIL_UpdateTileCache();
AITAC_ClearHiveInfo();
AITAC_ClearStructureNavData();
while (!bTileCacheUpToDate)
{
UTIL_UpdateTileCache();
}
}
else
{
Hives.clear();
}
MarineDroppedItemMap.clear();

View File

@ -84,7 +84,7 @@ vector<AvHPlayer*> AITAC_GetAllPlayersOnTeamWithLOS(AvHTeamNumber Team, const Ve
bool AITAC_ShouldBotBeCautious(AvHAIPlayer* pBot);
// Clears out the marine and alien buildable structure maps, resource node and hive lists, and the marine item list
void AITAC_ClearMapAIData();
void AITAC_ClearMapAIData(bool bInitialMapLoad = false);
// Clear out all the hive information
void AITAC_ClearHiveInfo();