mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-10 19:10:25 +00:00
[Bug Fix] Check Rule "Bots Enabled" to prevent bot database calls on connect (#3154)
* [Bug Fix] Check for Rule "Bots Enabled" to prevent bot database calls if not enabled. * formatting * check if LoadBotsList failed, or is bots_list empty
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
|
||||
#include "bot.h"
|
||||
#include "bot_command.h"
|
||||
#include "client.h"
|
||||
#include "object.h"
|
||||
#include "raids.h"
|
||||
#include "doors.h"
|
||||
@@ -296,4 +298,30 @@ void Bot::ProcessBotGroupAdd(Group* group, Raid* raid, Client* client, bool new_
|
||||
raid->GroupUpdate(raid_free_group_id);
|
||||
}
|
||||
|
||||
void Client::SpawnRaidBotsOnConnect(Raid* raid) {
|
||||
std::list<BotsAvailableList> bots_list;
|
||||
if (!database.botdb.LoadBotsList(CharacterID(), bots_list) || bots_list.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<RaidMember> r_members = raid->GetMembers();
|
||||
for (const auto& m: r_members) {
|
||||
if (strlen(m.member_name) != 0) {
|
||||
|
||||
for (const auto& b: bots_list) {
|
||||
if (strcmp(m.member_name, b.Name) == 0) {
|
||||
std::string buffer = "^spawn ";
|
||||
buffer.append(m.member_name);
|
||||
bot_command_real_dispatch(this, buffer.c_str());
|
||||
auto bot = entity_list.GetBotByBotName(m.member_name);
|
||||
|
||||
if (bot) {
|
||||
bot->SetRaidGrouped(true);
|
||||
bot->p_raid_instance = raid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user