diff --git a/src/Bot/PlayerbotMgr.cpp b/src/Bot/PlayerbotMgr.cpp index a6d4a3b79..d38e7720e 100644 --- a/src/Bot/PlayerbotMgr.cpp +++ b/src/Bot/PlayerbotMgr.cpp @@ -22,6 +22,7 @@ #include "GuildMgr.h" #include "ObjectAccessor.h" #include "ObjectGuid.h" +#include "ObjectMgr.h" #include "PlayerbotAIConfig.h" #include "PlayerbotRepository.h" #include "PlayerbotFactory.h" @@ -1240,7 +1241,7 @@ std::vector PlayerbotHolder::HandlePlayerbotCommand(char const* arg std::vector chars = split(charnameStr, ','); for (std::vector::iterator i = chars.begin(); i != chars.end(); i++) { - std::string const s = *i; + std::string s = *i; if (!strcmp(cmd, "addaccount")) { @@ -1249,7 +1250,13 @@ std::vector PlayerbotHolder::HandlePlayerbotCommand(char const* arg if (!accountId) { // If not found, try to get account ID from character name - ObjectGuid charGuid = sCharacterCache->GetCharacterGuidByName(s); + std::string charName = s; + if (!normalizePlayerName(charName)) + { + messages.push_back("Neither account nor character '" + s + "' found"); + continue; + } + ObjectGuid charGuid = sCharacterCache->GetCharacterGuidByName(charName); if (!charGuid) { messages.push_back("Neither account nor character '" + s + "' found"); @@ -1277,6 +1284,11 @@ std::vector PlayerbotHolder::HandlePlayerbotCommand(char const* arg else { // For regular add command, only add the specific character + if (!normalizePlayerName(s)) + { + messages.push_back("Character '" + *i + "' not found"); + continue; + } ObjectGuid charGuid = sCharacterCache->GetCharacterGuidByName(s); if (!charGuid) {