[Bug Fix] Fix for OOZ Group updates when removing/inviting Bots (#3159)

* [Bug Fix] Fix for Cross Zone Group updates with Bots when disbanding/joining groups.

* check for nullptr
This commit is contained in:
Aeadoin
2023-03-30 08:31:50 -04:00
committed by GitHub
parent 6960a1a682
commit e4ff76dceb
4 changed files with 21 additions and 8 deletions
+13 -6
View File
@@ -3837,6 +3837,7 @@ bool Bot::RemoveBotFromGroup(Bot* bot, Group* group) {
if (!group->IsLeader(bot)) {
bot->SetFollowID(0);
if (group->DelMember(bot)) {
group->DelMemberOOZ(bot->GetName());
database.SetGroupID(bot->GetCleanName(), 0, bot->GetBotID());
if (group->GroupCount() < 1) {
group->DisbandGroup();
@@ -3859,8 +3860,12 @@ bool Bot::RemoveBotFromGroup(Bot* bot, Group* group) {
}
bool Bot::AddBotToGroup(Bot* bot, Group* group) {
bool Result = false;
if (bot && group && group->AddMember(bot)) {
bool result = false;
if (!group || group->GroupCount() >= MAX_GROUP_MEMBERS) {
return result;
}
if (bot && group->AddMember(bot)) {
if (group->GetLeader()) {
bot->SetFollowID(group->GetLeader()->GetID());
// Need to send this only once when a group is formed with a bot so the client knows it is also the group leader
@@ -3871,9 +3876,10 @@ bool Bot::AddBotToGroup(Bot* bot, Group* group) {
}
}
group->VerifyGroup();
Result = true;
group->SendGroupJoinOOZ(bot);
result = true;
}
return Result;
return result;
}
// Completes a trade with a client bot owner
@@ -6869,8 +6875,9 @@ void Bot::ProcessBotGroupInvite(Client* c, std::string const& botName) {
delete g;
}
} else {
AddBotToGroup(invitedBot, c->GetGroup());
database.SetGroupID(invitedBot->GetCleanName(), c->GetGroup()->GetID(), invitedBot->GetBotID());
if (AddBotToGroup(invitedBot, c->GetGroup())) {
database.SetGroupID(invitedBot->GetCleanName(), c->GetGroup()->GetID(), invitedBot->GetBotID());
}
}
if (c->HasRaid() && c->HasGroup()) {
Raid* raid = entity_list.GetRaidByClient(c);