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

View file

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

View file

@ -2370,12 +2370,16 @@ void AITAC_ClearStructureNavData()
} }
} }
void AITAC_ClearMapAIData() void AITAC_ClearMapAIData(bool bInitialMapLoad)
{ {
UTIL_ClearLocalizations(); UTIL_ClearLocalizations();
ResourceNodes.clear(); ResourceNodes.clear();
// 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)
{
AITAC_ClearHiveInfo(); AITAC_ClearHiveInfo();
AITAC_ClearStructureNavData(); AITAC_ClearStructureNavData();
@ -2384,6 +2388,11 @@ void AITAC_ClearMapAIData()
{ {
UTIL_UpdateTileCache(); UTIL_UpdateTileCache();
} }
}
else
{
Hives.clear();
}
MarineDroppedItemMap.clear(); MarineDroppedItemMap.clear();
TeamAStructureMap.clear(); TeamAStructureMap.clear();

View file

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