Group related fixes

- Group adding is not leader only now
- Group buffs work now
This commit is contained in:
Jade 2020-12-31 03:54:48 +00:00 committed by dongresource
parent d4eaf83354
commit 6baa0c5b07
2 changed files with 9 additions and 4 deletions

View File

@ -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));
}

View File

@ -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;