Merge pull request #577 from noisiver/fix-null-check

Add check to make sure there are races available for a class before generation
This commit is contained in:
Yunfan Li 2024-10-05 22:13:30 +08:00 committed by GitHub
commit 4fc9bca5ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -165,6 +165,13 @@ Player* RandomPlayerbotFactory::CreateRandomBot(WorldSession* session, uint8 cls
raceOptions.push_back(race);
}
}
if (raceOptions.empty())
{
LOG_ERROR("playerbots", "No races available for class: {}", cls);
return nullptr;
}
uint8 race = raceOptions[urand(0, raceOptions.size() - 1)];
const auto raceAndGender = CombineRaceAndGender(gender, race);