From 7164890d15616dddd9e83c24487fe335dc28931f Mon Sep 17 00:00:00 2001 From: qudzy <102037134+qudzy@users.noreply.github.com> Date: Wed, 1 Jun 2022 21:31:22 +0200 Subject: [PATCH] Restrict Death Knight random bot creation by expansion --- src/RandomPlayerbotFactory.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/RandomPlayerbotFactory.cpp b/src/RandomPlayerbotFactory.cpp index db74849b..f009fc5d 100644 --- a/src/RandomPlayerbotFactory.cpp +++ b/src/RandomPlayerbotFactory.cpp @@ -14,6 +14,8 @@ std::map> RandomPlayerbotFactory::availableRaces; RandomPlayerbotFactory::RandomPlayerbotFactory(uint32 accountId) : accountId(accountId) { + uint32 const expansion = sWorld->getIntConfig(CONFIG_EXPANSION); + availableRaces[CLASS_WARRIOR].push_back(RACE_HUMAN); availableRaces[CLASS_WARRIOR].push_back(RACE_NIGHTELF); availableRaces[CLASS_WARRIOR].push_back(RACE_GNOME); @@ -92,7 +94,8 @@ Player* RandomPlayerbotFactory::CreateRandomBot(WorldSession* session, uint8 cls uint8 gender = rand() % 2 ? GENDER_MALE : GENDER_FEMALE; - uint8 race = availableRaces[cls][urand(0, availableRaces[cls].size() - 1)]; + uint32 const randomRaceIndex = urand(0, availableRaces[cls].size() - 1); + uint8 race = availableRaces[cls][randomRaceIndex]; std::string name; if (names.empty()) @@ -411,6 +414,14 @@ void RandomPlayerbotFactory::CreateRandomBots() if (!((1 << (cls - 1)) & CLASSMASK_ALL_PLAYABLE) || !sChrClassesStore.LookupEntry(cls)) continue; + if (bool const isClassDeathKnight = cls == CLASS_DEATH_KNIGHT; + isClassDeathKnight && + sWorld->getIntConfig(CONFIG_EXPANSION) != + EXPANSION_WRATH_OF_THE_LICH_KING) + { + continue; + } + if (cls != 10) if (Player* playerBot = factory.CreateRandomBot(session, cls, names)) playerBots.emplace_back(playerBot, accountId);