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

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);