Adding safety check to all branches

This commit is contained in:
Dustin Hendrickson
2025-05-26 15:11:44 -07:00
parent 949226d203
commit 14e4519566

View File

@@ -976,6 +976,11 @@ public:
while (allianceActualCounts[i] > allianceDesiredCounts[i] && !safeBots.empty()) while (allianceActualCounts[i] > allianceDesiredCounts[i] && !safeBots.empty())
{ {
Player* bot = safeBots.back(); Player* bot = safeBots.back();
if (!bot || !bot->IsInWorld())
{
it = safeBots.erase(it);
break;
}
safeBots.pop_back(); safeBots.pop_back();
if (g_BotDistFullDebugMode) if (g_BotDistFullDebugMode)
{ {
@@ -1041,6 +1046,11 @@ public:
while (allianceActualCounts[i] > allianceDesiredCounts[i] && !flaggedBots.empty()) while (allianceActualCounts[i] > allianceDesiredCounts[i] && !flaggedBots.empty())
{ {
Player* bot = flaggedBots.back(); Player* bot = flaggedBots.back();
if (!bot || !bot->IsInWorld())
{
it = flaggedBots.erase(it);
break;
}
flaggedBots.pop_back(); flaggedBots.pop_back();
if (g_BotDistFullDebugMode) if (g_BotDistFullDebugMode)
{ {
@@ -1144,6 +1154,11 @@ public:
while (hordeActualCounts[i] > hordeDesiredCounts[i] && !safeBots.empty()) while (hordeActualCounts[i] > hordeDesiredCounts[i] && !safeBots.empty())
{ {
Player* bot = safeBots.back(); Player* bot = safeBots.back();
if (!bot || !bot->IsInWorld())
{
it = safeBots.erase(it);
break;
}
safeBots.pop_back(); safeBots.pop_back();
if (g_BotDistFullDebugMode) if (g_BotDistFullDebugMode)
{ {
@@ -1209,6 +1224,11 @@ public:
while (hordeActualCounts[i] > hordeDesiredCounts[i] && !flaggedBots.empty()) while (hordeActualCounts[i] > hordeDesiredCounts[i] && !flaggedBots.empty())
{ {
Player* bot = flaggedBots.back(); Player* bot = flaggedBots.back();
if (!bot || !bot->IsInWorld())
{
it = flaggedBots.erase(it);
break;
}
flaggedBots.pop_back(); flaggedBots.pop_back();
if (g_BotDistFullDebugMode) if (g_BotDistFullDebugMode)
{ {