Skip to content

Commit

Permalink
Merge pull request liyunfan1223#577 from noisiver/fix-null-check
Browse files Browse the repository at this point in the history
Add check to make sure there are races available for a class before generation
  • Loading branch information
liyunfan1223 authored Oct 5, 2024
2 parents 269deaf + 8f1f79a commit 4fc9bca
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/RandomPlayerbotFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4fc9bca

Please sign in to comment.