From 6baa0c5b076074c9813bfdf9cd7631cabbf9e95e Mon Sep 17 00:00:00 2001 From: Jade Date: Thu, 31 Dec 2020 03:54:48 +0000 Subject: [PATCH] Group related fixes - Group adding is not leader only now - Group buffs work now --- src/GroupManager.cpp | 7 +++++-- src/NanoManager.cpp | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp index 9756882..592a73a 100644 --- a/src/GroupManager.cpp +++ b/src/GroupManager.cpp @@ -33,11 +33,14 @@ void GroupManager::requestGroup(CNSocket* sock, CNPacketData* data) { otherPlr = PlayerManager::getPlayerFromID(otherPlr->iIDGroup); + if (otherPlr == nullptr) + return; + if (otherPlr == nullptr) return; // fail if the group is full or the other player is already in a group - if (plr->groupCnt >= 4 || otherPlr->groupCnt > 1) { + if (plr->groupCnt >= 4 || otherPlr->iIDGroup != otherPlr->iID || otherPlr->groupCnt > 1) { INITSTRUCT(sP_FE2CL_PC_GROUP_INVITE_FAIL, resp); sock->sendPacket((void*)&resp, P_FE2CL_PC_GROUP_INVITE_FAIL, sizeof(sP_FE2CL_PC_GROUP_INVITE_FAIL)); return; @@ -50,7 +53,7 @@ void GroupManager::requestGroup(CNSocket* sock, CNPacketData* data) { INITSTRUCT(sP_FE2CL_PC_GROUP_INVITE, resp); - resp.iHostID = plr->iIDGroup; + resp.iHostID = plr->iID; otherSock->sendPacket((void*)&resp, P_FE2CL_PC_GROUP_INVITE, sizeof(sP_FE2CL_PC_GROUP_INVITE)); } diff --git a/src/NanoManager.cpp b/src/NanoManager.cpp index ad4cb3d..2525c9f 100644 --- a/src/NanoManager.cpp +++ b/src/NanoManager.cpp @@ -600,16 +600,18 @@ bool doDebuff(CNSocket *sock, sSkillResult_Buff *respdata, int i, int32_t target bool doBuff(CNSocket *sock, sSkillResult_Buff *respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) { Player *plr = nullptr; + CNSocket *sockTo = nullptr; for (auto& pair : PlayerManager::players) { if (pair.second->iID == targetID) { + sockTo = pair.first; plr = pair.second; break; } } // player not found - if (plr == nullptr) { + if (sockTo == nullptr || plr == nullptr) { std::cout << "[WARN] doBuff: player ID not found" << std::endl; return false; } @@ -631,7 +633,7 @@ bool doBuff(CNSocket *sock, sSkillResult_Buff *respdata, int i, int32_t targetID if (amount > 0) pkt.TimeBuff.iValue = amount; - sock->sendPacket((void*)&pkt, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE)); + sockTo->sendPacket((void*)&pkt, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE)); } return true;