mirror of
https://github.com/Milxnor/Project-Reboot-3.0.git
synced 2026-01-13 02:42:22 +01:00
crashfix: prevent division by zero when spawning too many bots
This commit is contained in:
@@ -69,4 +69,6 @@ static inline void InitBotNames()
|
||||
PlayerBotNames.push_back(L"AllyJax");
|
||||
PlayerBotNames.push_back(L"secret_pommes");
|
||||
PlayerBotNames.push_back(L"Twin1");
|
||||
|
||||
std::shuffle(PlayerBotNames.begin(), PlayerBotNames.end(), std::default_random_engine((unsigned int)time(0)));
|
||||
}
|
||||
|
||||
@@ -232,21 +232,15 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Fortnite_Version < 11)
|
||||
if (Fortnite_Version < 11 || PlayerBotNames.empty())
|
||||
{
|
||||
BotNumWStr = std::to_wstring(CurrentBotNum++ + 200);
|
||||
NewName = (std::format(L"Anonymous[{}]", BotNumWStr)).c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!PlayerBotNames.empty())
|
||||
{
|
||||
// std::shuffle(PlayerBotNames.begin(), PlayerBotNames.end(), std::default_random_engine((unsigned int)time(0)));
|
||||
|
||||
int RandomIndex = std::rand() % (PlayerBotNames.size() - 1);
|
||||
NewName = PlayerBotNames[RandomIndex];
|
||||
PlayerBotNames.erase(PlayerBotNames.begin() + RandomIndex);
|
||||
}
|
||||
NewName = PlayerBotNames.back();
|
||||
PlayerBotNames.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user