mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18:51:29 +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:
parent
e9c63c7d94
commit
7854130a93
@ -17,6 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "bot.h"
|
#include "bot.h"
|
||||||
|
#include "bot_command.h"
|
||||||
|
#include "client.h"
|
||||||
#include "object.h"
|
#include "object.h"
|
||||||
#include "raids.h"
|
#include "raids.h"
|
||||||
#include "doors.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);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2033,6 +2033,7 @@ public:
|
|||||||
void SetBotSpawnLimit(int new_spawn_limit, uint8 class_id = NO_CLASS);
|
void SetBotSpawnLimit(int new_spawn_limit, uint8 class_id = NO_CLASS);
|
||||||
|
|
||||||
void CampAllBots(uint8 class_id = NO_CLASS);
|
void CampAllBots(uint8 class_id = NO_CLASS);
|
||||||
|
void SpawnRaidBotsOnConnect(Raid* raid);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool bot_owner_options[_booCount];
|
bool bot_owner_options[_booCount];
|
||||||
@ -2042,7 +2043,6 @@ private:
|
|||||||
bool CanTradeFVNoDropItem();
|
bool CanTradeFVNoDropItem();
|
||||||
void SendMobPositions();
|
void SendMobPositions();
|
||||||
void PlayerTradeEventLog(Trade *t, Trade *t2);
|
void PlayerTradeEventLog(Trade *t, Trade *t2);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -607,28 +607,8 @@ void Client::CompleteConnect()
|
|||||||
if (raid) {
|
if (raid) {
|
||||||
SetRaidGrouped(true);
|
SetRaidGrouped(true);
|
||||||
raid->LearnMembers();
|
raid->LearnMembers();
|
||||||
std::list<BotsAvailableList> bots_list;
|
if (RuleB(Bots, Enabled)) {
|
||||||
database.botdb.LoadBotsList(this->CharacterID(), bots_list);
|
SpawnRaidBotsOnConnect(raid);
|
||||||
std::vector<RaidMember> r_members = raid->GetMembers();
|
|
||||||
for (const RaidMember& iter : r_members) {
|
|
||||||
if (iter.member_name) {
|
|
||||||
for (const BotsAvailableList& b_iter : bots_list)
|
|
||||||
{
|
|
||||||
if (strcmp(iter.member_name, b_iter.Name) == 0)
|
|
||||||
{
|
|
||||||
char buffer[71] = "^spawn ";
|
|
||||||
strcat(buffer, iter.member_name);
|
|
||||||
bot_command_real_dispatch(this, buffer);
|
|
||||||
Bot* b = entity_list.GetBotByBotName(iter.member_name);
|
|
||||||
if (b)
|
|
||||||
{
|
|
||||||
b->SetRaidGrouped(true);
|
|
||||||
b->p_raid_instance = raid;
|
|
||||||
//b->SetFollowID(this->GetID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
raid->VerifyRaid();
|
raid->VerifyRaid();
|
||||||
raid->GetRaidDetails();
|
raid->GetRaidDetails();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user