mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
bot add fix
This commit is contained in:
@@ -88,11 +88,10 @@ void PlayerbotHolder::HandlePlayerBotLoginCallback(PlayerbotLoginQueryHolder con
|
|||||||
|
|
||||||
uint32 masterAccount = holder.GetMasterAccountId();
|
uint32 masterAccount = holder.GetMasterAccountId();
|
||||||
WorldSession* masterSession = masterAccount ? sWorld->FindSession(masterAccount) : nullptr;
|
WorldSession* masterSession = masterAccount ? sWorld->FindSession(masterAccount) : nullptr;
|
||||||
|
|
||||||
bool allowed = false;
|
bool allowed = false;
|
||||||
if (botAccountId == masterAccount)
|
if (botAccountId == masterAccount)
|
||||||
allowed = true;
|
allowed = true;
|
||||||
else if (masterSession && sPlayerbotAIConfig->allowGuildBots && bot->GetGuildId() == masterSession->GetPlayer()->GetGuildId())
|
else if (masterSession && sPlayerbotAIConfig->allowGuildBots && bot->GetGuildId() != 0 && bot->GetGuildId() == masterSession->GetPlayer()->GetGuildId())
|
||||||
allowed = true;
|
allowed = true;
|
||||||
else if (sPlayerbotAIConfig->IsInRandomAccountList(botAccountId))
|
else if (sPlayerbotAIConfig->IsInRandomAccountList(botAccountId))
|
||||||
allowed = true;
|
allowed = true;
|
||||||
@@ -106,7 +105,7 @@ void PlayerbotHolder::HandlePlayerBotLoginCallback(PlayerbotLoginQueryHolder con
|
|||||||
if (masterSession)
|
if (masterSession)
|
||||||
{
|
{
|
||||||
ChatHandler ch(masterSession);
|
ChatHandler ch(masterSession);
|
||||||
ch.PSendSysMessage("You are not allowed to control bot {}", bot->GetName());
|
ch.PSendSysMessage("You are not allowed to control bot %s", bot->GetName());
|
||||||
}
|
}
|
||||||
OnBotLogin(bot);
|
OnBotLogin(bot);
|
||||||
LogoutPlayerBot(bot->GetGUID());
|
LogoutPlayerBot(bot->GetGUID());
|
||||||
@@ -780,7 +779,10 @@ std::vector<std::string> PlayerbotHolder::HandlePlayerbotCommand(char const* arg
|
|||||||
race_limit = "2, 5, 6, 8, 10";
|
race_limit = "2, 5, 6, 8, 10";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
QueryResult results = CharacterDatabase.Query("SELECT guid FROM characters WHERE name IN (SELECT name FROM playerbots_names) AND class = '{}' AND online = 0 AND race IN ({}) ORDER BY account DESC LIMIT 1", claz, race_limit);
|
// find a bot fit conditions and not in any guild
|
||||||
|
QueryResult results = CharacterDatabase.Query("SELECT guid FROM characters "
|
||||||
|
"WHERE name IN (SELECT name FROM playerbots_names) AND class = '{}' AND online = 0 AND race IN ({}) AND guid NOT IN ( SELECT guid FROM guild_member ) "
|
||||||
|
"ORDER BY account DESC LIMIT 1", claz, race_limit);
|
||||||
if (results)
|
if (results)
|
||||||
{
|
{
|
||||||
Field* fields = results->Fetch();
|
Field* fields = results->Fetch();
|
||||||
@@ -794,22 +796,24 @@ std::vector<std::string> PlayerbotHolder::HandlePlayerbotCommand(char const* arg
|
|||||||
return messages;
|
return messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string charnameStr;
|
||||||
|
|
||||||
if (!charname)
|
if (!charname)
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
bool isPlayer = sCharacterCache->GetCharacterNameByGuid(master->GetTarget(), name);
|
bool isPlayer = sCharacterCache->GetCharacterNameByGuid(master->GetTarget(), name);
|
||||||
// Player* tPlayer = ObjectAccessor::FindConnectedPlayer(master->GetTarget());
|
// Player* tPlayer = ObjectAccessor::FindConnectedPlayer(master->GetTarget());
|
||||||
if (isPlayer) {
|
if (isPlayer) {
|
||||||
charname = new char[name.size() + 1];
|
charnameStr = name;
|
||||||
strcpy(charname, name.c_str());
|
|
||||||
} else {
|
} else {
|
||||||
messages.push_back("usage: list/reload/tweak/self or add/init/remove PLAYERNAME");
|
messages.push_back("usage: list/reload/tweak/self or add/init/remove PLAYERNAME");
|
||||||
return messages;
|
return messages;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
charnameStr = charname;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string const cmdStr = cmd;
|
std::string const cmdStr = cmd;
|
||||||
std::string const charnameStr = charname;
|
|
||||||
|
|
||||||
std::set<std::string> bots;
|
std::set<std::string> bots;
|
||||||
if (charnameStr == "*" && master)
|
if (charnameStr == "*" && master)
|
||||||
|
|||||||
Reference in New Issue
Block a user