From 5f50b6fddc3481fc403cb818587317ebc4d30e3c Mon Sep 17 00:00:00 2001 From: Revision Date: Fri, 4 Oct 2024 21:17:19 +0200 Subject: [PATCH] Add check to make sure there are races available for a class --- src/RandomPlayerbotFactory.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/RandomPlayerbotFactory.cpp b/src/RandomPlayerbotFactory.cpp index 8c350130..ea6c55dd 100644 --- a/src/RandomPlayerbotFactory.cpp +++ b/src/RandomPlayerbotFactory.cpp @@ -165,6 +165,13 @@ Player* RandomPlayerbotFactory::CreateRandomBot(WorldSession* session, uint8 cls raceOptions.push_back(race); } } + + if (raceOptions.size() == 0) + { + LOG_ERROR("playerbots", "No race available for class: {}", cls); + return nullptr; + } + uint8 race = raceOptions[urand(0, raceOptions.size() - 1)]; const auto raceAndGender = CombineRaceAndGender(gender, race);