2021-03-17 19:07:40 +00:00
|
|
|
#include "servers/CNShardServer.hpp"
|
2020-10-04 23:54:08 +00:00
|
|
|
#include "PlayerManager.hpp"
|
2021-03-16 22:29:13 +00:00
|
|
|
#include "Groups.hpp"
|
|
|
|
#include "Nanos.hpp"
|
2021-03-13 20:22:29 +00:00
|
|
|
#include "Abilities.hpp"
|
2020-10-04 23:54:08 +00:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <chrono>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <thread>
|
|
|
|
|
2021-03-19 21:28:25 +00:00
|
|
|
/*
|
|
|
|
* NOTE: Variadic response packets that list group members are technically
|
|
|
|
* double-variadic, as they have two count members with trailing struct counts,
|
|
|
|
* and are thus incompatible with the generic sendPacket() wrapper.
|
|
|
|
* That means we still have to (carefully) use validOutVarPacket() in this
|
|
|
|
* source file.
|
|
|
|
*/
|
|
|
|
|
2021-03-16 22:29:13 +00:00
|
|
|
using namespace Groups;
|
2020-10-04 23:54:08 +00:00
|
|
|
|
2021-03-16 21:06:10 +00:00
|
|
|
static void requestGroup(CNSocket* sock, CNPacketData* data) {
|
2020-10-04 23:54:08 +00:00
|
|
|
sP_CL2FE_REQ_PC_GROUP_INVITE* recv = (sP_CL2FE_REQ_PC_GROUP_INVITE*)data->buf;
|
2020-10-05 00:03:13 +00:00
|
|
|
|
|
|
|
Player* plr = PlayerManager::getPlayer(sock);
|
2020-10-04 23:54:08 +00:00
|
|
|
Player* otherPlr = PlayerManager::getPlayerFromID(recv->iID_To);
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-12-01 19:18:01 +00:00
|
|
|
if (otherPlr == nullptr)
|
2020-10-21 05:24:51 +00:00
|
|
|
return;
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
otherPlr = PlayerManager::getPlayerFromID(otherPlr->iIDGroup);
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
if (otherPlr == nullptr)
|
2020-10-21 05:24:51 +00:00
|
|
|
return;
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
// fail if the group is full or the other player is already in a group
|
2020-12-31 03:54:48 +00:00
|
|
|
if (plr->groupCnt >= 4 || otherPlr->iIDGroup != otherPlr->iID || otherPlr->groupCnt > 1) {
|
2020-10-04 23:54:08 +00:00
|
|
|
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;
|
|
|
|
}
|
2020-10-05 00:03:13 +00:00
|
|
|
|
|
|
|
CNSocket* otherSock = PlayerManager::getSockFromID(recv->iID_To);
|
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
if (otherSock == nullptr)
|
|
|
|
return;
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
INITSTRUCT(sP_FE2CL_PC_GROUP_INVITE, resp);
|
|
|
|
|
2020-12-31 03:54:48 +00:00
|
|
|
resp.iHostID = plr->iID;
|
2020-10-04 23:54:08 +00:00
|
|
|
|
2020-10-21 05:24:51 +00:00
|
|
|
otherSock->sendPacket((void*)&resp, P_FE2CL_PC_GROUP_INVITE, sizeof(sP_FE2CL_PC_GROUP_INVITE));
|
2020-10-04 23:54:08 +00:00
|
|
|
}
|
|
|
|
|
2021-03-16 21:06:10 +00:00
|
|
|
static void refuseGroup(CNSocket* sock, CNPacketData* data) {
|
2020-10-04 23:54:08 +00:00
|
|
|
sP_CL2FE_REQ_PC_GROUP_INVITE_REFUSE* recv = (sP_CL2FE_REQ_PC_GROUP_INVITE_REFUSE*)data->buf;
|
|
|
|
|
2020-10-21 05:24:51 +00:00
|
|
|
CNSocket* otherSock = PlayerManager::getSockFromID(recv->iID_From);
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
if (otherSock == nullptr)
|
|
|
|
return;
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
Player* plr = PlayerManager::getPlayer(sock);
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
INITSTRUCT(sP_FE2CL_PC_GROUP_INVITE_REFUSE, resp);
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
resp.iID_To = plr->iID;
|
|
|
|
|
2020-10-21 05:24:51 +00:00
|
|
|
otherSock->sendPacket((void*)&resp, P_FE2CL_PC_GROUP_INVITE_REFUSE, sizeof(sP_FE2CL_PC_GROUP_INVITE_REFUSE));
|
2020-10-04 23:54:08 +00:00
|
|
|
}
|
|
|
|
|
2021-03-16 21:06:10 +00:00
|
|
|
static void joinGroup(CNSocket* sock, CNPacketData* data) {
|
2020-10-04 23:54:08 +00:00
|
|
|
sP_CL2FE_REQ_PC_GROUP_JOIN* recv = (sP_CL2FE_REQ_PC_GROUP_JOIN*)data->buf;
|
|
|
|
Player* plr = PlayerManager::getPlayer(sock);
|
|
|
|
Player* otherPlr = PlayerManager::getPlayerFromID(recv->iID_From);
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-12-01 19:18:01 +00:00
|
|
|
if (otherPlr == nullptr)
|
2020-10-21 05:24:51 +00:00
|
|
|
return;
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
otherPlr = PlayerManager::getPlayerFromID(otherPlr->iIDGroup);
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
if (otherPlr == nullptr)
|
2020-10-21 05:24:51 +00:00
|
|
|
return;
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-09 00:01:35 +00:00
|
|
|
// fail if the group is full or the other player is already in a group
|
2020-10-04 23:54:08 +00:00
|
|
|
if (plr->groupCnt > 1 || plr->iIDGroup != plr->iID || otherPlr->groupCnt >= 4) {
|
2020-10-09 16:24:16 +00:00
|
|
|
INITSTRUCT(sP_FE2CL_PC_GROUP_JOIN_FAIL, resp);
|
2020-10-04 23:54:08 +00:00
|
|
|
sock->sendPacket((void*)&resp, P_FE2CL_PC_GROUP_JOIN_FAIL, sizeof(sP_FE2CL_PC_GROUP_JOIN_FAIL));
|
|
|
|
return;
|
|
|
|
}
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
if (!validOutVarPacket(sizeof(sP_FE2CL_PC_GROUP_JOIN), otherPlr->groupCnt + 1, sizeof(sPCGroupMemberInfo))) {
|
|
|
|
std::cout << "[WARN] bad sP_FE2CL_PC_GROUP_JOIN packet size\n";
|
|
|
|
return;
|
|
|
|
}
|
2020-10-19 17:26:14 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
plr->iIDGroup = otherPlr->iID;
|
|
|
|
otherPlr->groupCnt += 1;
|
|
|
|
otherPlr->groupIDs[otherPlr->groupCnt-1] = plr->iID;
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
size_t resplen = sizeof(sP_FE2CL_PC_GROUP_JOIN) + otherPlr->groupCnt * sizeof(sPCGroupMemberInfo);
|
|
|
|
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
memset(respbuf, 0, resplen);
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
sP_FE2CL_PC_GROUP_JOIN *resp = (sP_FE2CL_PC_GROUP_JOIN*)respbuf;
|
|
|
|
sPCGroupMemberInfo *respdata = (sPCGroupMemberInfo*)(respbuf+sizeof(sP_FE2CL_PC_GROUP_JOIN));
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
resp->iID_NewMember = plr->iID;
|
|
|
|
resp->iMemberPCCnt = otherPlr->groupCnt;
|
2020-10-19 17:26:14 +00:00
|
|
|
|
2020-10-09 00:01:35 +00:00
|
|
|
int bitFlag = getGroupFlags(otherPlr);
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
for (int i = 0; i < otherPlr->groupCnt; i++) {
|
|
|
|
Player* varPlr = PlayerManager::getPlayerFromID(otherPlr->groupIDs[i]);
|
2020-10-09 00:01:35 +00:00
|
|
|
CNSocket* sockTo = PlayerManager::getSockFromID(otherPlr->groupIDs[i]);
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-09 00:01:35 +00:00
|
|
|
if (varPlr == nullptr || sockTo == nullptr)
|
2020-10-04 23:54:08 +00:00
|
|
|
continue;
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
respdata[i].iPC_ID = varPlr->iID;
|
|
|
|
respdata[i].iPCUID = varPlr->PCStyle.iPC_UID;
|
|
|
|
respdata[i].iNameCheck = varPlr->PCStyle.iNameCheck;
|
|
|
|
memcpy(respdata[i].szFirstName, varPlr->PCStyle.szFirstName, sizeof(varPlr->PCStyle.szFirstName));
|
|
|
|
memcpy(respdata[i].szLastName, varPlr->PCStyle.szLastName, sizeof(varPlr->PCStyle.szLastName));
|
|
|
|
respdata[i].iSpecialState = varPlr->iSpecialState;
|
|
|
|
respdata[i].iLv = varPlr->level;
|
|
|
|
respdata[i].iHP = varPlr->HP;
|
|
|
|
respdata[i].iMaxHP = PC_MAXHEALTH(varPlr->level);
|
|
|
|
//respdata[i].iMapType = 0;
|
|
|
|
//respdata[i].iMapNum = 0;
|
|
|
|
respdata[i].iX = varPlr->x;
|
|
|
|
respdata[i].iY = varPlr->y;
|
|
|
|
respdata[i].iZ = varPlr->z;
|
|
|
|
// client doesnt read nano data here
|
2020-10-19 17:26:14 +00:00
|
|
|
|
2020-11-23 23:42:34 +00:00
|
|
|
if (varPlr != plr) { // apply the new member's buffs to the group and the group's buffs to the new member
|
2021-06-20 17:05:10 +00:00
|
|
|
if (Abilities::SkillTable[varPlr->Nanos[varPlr->activeNano].iSkillID].targetType == 3)
|
|
|
|
Abilities::applyBuff(sock, varPlr->Nanos[varPlr->activeNano].iSkillID, 1, 1, bitFlag);
|
|
|
|
if (Abilities::SkillTable[plr->Nanos[plr->activeNano].iSkillID].targetType == 3)
|
|
|
|
Abilities::applyBuff(sockTo, plr->Nanos[plr->activeNano].iSkillID, 1, 1, bitFlag);
|
2020-11-08 00:26:44 +00:00
|
|
|
}
|
2020-10-04 23:54:08 +00:00
|
|
|
}
|
2020-10-19 17:26:14 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
sendToGroup(otherPlr, (void*)&respbuf, P_FE2CL_PC_GROUP_JOIN, resplen);
|
|
|
|
}
|
|
|
|
|
2021-03-16 21:06:10 +00:00
|
|
|
static void leaveGroup(CNSocket* sock, CNPacketData* data) {
|
2020-10-04 23:54:08 +00:00
|
|
|
Player* plr = PlayerManager::getPlayer(sock);
|
|
|
|
groupKickPlayer(plr);
|
|
|
|
}
|
|
|
|
|
2021-03-16 22:29:13 +00:00
|
|
|
void Groups::sendToGroup(Player* plr, void* buf, uint32_t type, size_t size) {
|
2020-10-04 23:54:08 +00:00
|
|
|
for (int i = 0; i < plr->groupCnt; i++) {
|
2020-10-05 00:03:13 +00:00
|
|
|
CNSocket* sock = PlayerManager::getSockFromID(plr->groupIDs[i]);
|
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
if (sock == nullptr)
|
|
|
|
continue;
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
if (type == P_FE2CL_PC_GROUP_LEAVE_SUCC) {
|
2020-10-05 00:03:13 +00:00
|
|
|
Player* leavingPlr = PlayerManager::getPlayer(sock);
|
2020-10-04 23:54:08 +00:00
|
|
|
leavingPlr->iIDGroup = leavingPlr->iID;
|
|
|
|
}
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
sock->sendPacket(buf, type, size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-16 22:29:13 +00:00
|
|
|
void Groups::groupTickInfo(Player* plr) {
|
2020-10-04 23:54:08 +00:00
|
|
|
if (!validOutVarPacket(sizeof(sP_FE2CL_PC_GROUP_MEMBER_INFO), plr->groupCnt, sizeof(sPCGroupMemberInfo))) {
|
|
|
|
std::cout << "[WARN] bad sP_FE2CL_PC_GROUP_JOIN packet size\n";
|
|
|
|
return;
|
|
|
|
}
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
size_t resplen = sizeof(sP_FE2CL_PC_GROUP_MEMBER_INFO) + plr->groupCnt * sizeof(sPCGroupMemberInfo);
|
|
|
|
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
memset(respbuf, 0, resplen);
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
sP_FE2CL_PC_GROUP_MEMBER_INFO *resp = (sP_FE2CL_PC_GROUP_MEMBER_INFO*)respbuf;
|
|
|
|
sPCGroupMemberInfo *respdata = (sPCGroupMemberInfo*)(respbuf+sizeof(sP_FE2CL_PC_GROUP_MEMBER_INFO));
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
resp->iID = plr->iID;
|
|
|
|
resp->iMemberPCCnt = plr->groupCnt;
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
for (int i = 0; i < plr->groupCnt; i++) {
|
|
|
|
Player* varPlr = PlayerManager::getPlayerFromID(plr->groupIDs[i]);
|
2020-10-19 17:26:14 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
if (varPlr == nullptr)
|
|
|
|
continue;
|
2020-10-19 17:26:14 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
respdata[i].iPC_ID = varPlr->iID;
|
|
|
|
respdata[i].iPCUID = varPlr->PCStyle.iPC_UID;
|
|
|
|
respdata[i].iNameCheck = varPlr->PCStyle.iNameCheck;
|
|
|
|
memcpy(respdata[i].szFirstName, varPlr->PCStyle.szFirstName, sizeof(varPlr->PCStyle.szFirstName));
|
|
|
|
memcpy(respdata[i].szLastName, varPlr->PCStyle.szLastName, sizeof(varPlr->PCStyle.szLastName));
|
|
|
|
respdata[i].iSpecialState = varPlr->iSpecialState;
|
|
|
|
respdata[i].iLv = varPlr->level;
|
|
|
|
respdata[i].iHP = varPlr->HP;
|
|
|
|
respdata[i].iMaxHP = PC_MAXHEALTH(varPlr->level);
|
|
|
|
//respdata[i].iMapType = 0;
|
|
|
|
//respdata[i].iMapNum = 0;
|
|
|
|
respdata[i].iX = varPlr->x;
|
|
|
|
respdata[i].iY = varPlr->y;
|
|
|
|
respdata[i].iZ = varPlr->z;
|
|
|
|
if (varPlr->activeNano > 0) {
|
|
|
|
respdata[i].bNano = 1;
|
|
|
|
respdata[i].Nano = varPlr->Nanos[varPlr->activeNano];
|
|
|
|
}
|
|
|
|
}
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
sendToGroup(plr, (void*)&respbuf, P_FE2CL_PC_GROUP_MEMBER_INFO, resplen);
|
|
|
|
}
|
|
|
|
|
2021-03-16 21:06:10 +00:00
|
|
|
static void groupUnbuff(Player* plr) {
|
|
|
|
for (int i = 0; i < plr->groupCnt; i++) {
|
|
|
|
for (int n = 0; n < plr->groupCnt; n++) {
|
|
|
|
if (i == n)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Player* otherPlr = PlayerManager::getPlayerFromID(plr->groupIDs[i]);
|
|
|
|
CNSocket* sock = PlayerManager::getSockFromID(plr->groupIDs[n]);
|
|
|
|
|
2021-06-20 17:05:10 +00:00
|
|
|
Abilities::applyBuff(sock, otherPlr->Nanos[otherPlr->activeNano].iSkillID, 2, 1, 0);
|
2021-03-16 21:06:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-16 22:29:13 +00:00
|
|
|
void Groups::groupKickPlayer(Player* plr) {
|
2020-10-04 23:54:08 +00:00
|
|
|
// if you are the group leader, destroy your own group and kick everybody
|
|
|
|
if (plr->iID == plr->iIDGroup) {
|
2020-10-09 00:01:35 +00:00
|
|
|
groupUnbuff(plr);
|
2020-10-04 23:54:08 +00:00
|
|
|
INITSTRUCT(sP_FE2CL_PC_GROUP_LEAVE_SUCC, resp1);
|
|
|
|
sendToGroup(plr, (void*)&resp1, P_FE2CL_PC_GROUP_LEAVE_SUCC, sizeof(sP_FE2CL_PC_GROUP_LEAVE_SUCC));
|
2020-10-05 00:03:13 +00:00
|
|
|
plr->groupCnt = 1;
|
2020-10-04 23:54:08 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
if (otherPlr == nullptr)
|
2020-10-21 05:24:51 +00:00
|
|
|
return;
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
if (!validOutVarPacket(sizeof(sP_FE2CL_PC_GROUP_LEAVE), otherPlr->groupCnt - 1, sizeof(sPCGroupMemberInfo))) {
|
|
|
|
std::cout << "[WARN] bad sP_FE2CL_PC_GROUP_LEAVE packet size\n";
|
|
|
|
return;
|
|
|
|
}
|
2020-10-19 17:26:14 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
size_t resplen = sizeof(sP_FE2CL_PC_GROUP_LEAVE) + (otherPlr->groupCnt - 1) * sizeof(sPCGroupMemberInfo);
|
|
|
|
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
memset(respbuf, 0, resplen);
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
sP_FE2CL_PC_GROUP_LEAVE *resp = (sP_FE2CL_PC_GROUP_LEAVE*)respbuf;
|
|
|
|
sPCGroupMemberInfo *respdata = (sPCGroupMemberInfo*)(respbuf+sizeof(sP_FE2CL_PC_GROUP_LEAVE));
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
resp->iID_LeaveMember = plr->iID;
|
|
|
|
resp->iMemberPCCnt = otherPlr->groupCnt - 1;
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-11-08 00:26:44 +00:00
|
|
|
int bitFlag = getGroupFlags(otherPlr) & ~plr->iGroupConditionBitFlag;
|
2020-10-04 23:54:08 +00:00
|
|
|
int moveDown = 0;
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-11-08 00:26:44 +00:00
|
|
|
CNSocket* sock = PlayerManager::getSockFromID(plr->iID);
|
|
|
|
|
|
|
|
if (sock == nullptr)
|
|
|
|
return;
|
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
for (int i = 0; i < otherPlr->groupCnt; i++) {
|
|
|
|
Player* varPlr = PlayerManager::getPlayerFromID(otherPlr->groupIDs[i]);
|
2020-10-09 00:01:35 +00:00
|
|
|
CNSocket* sockTo = PlayerManager::getSockFromID(otherPlr->groupIDs[i]);
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-09 00:01:35 +00:00
|
|
|
if (varPlr == nullptr || sockTo == nullptr)
|
2020-10-04 23:54:08 +00:00
|
|
|
continue;
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
if (moveDown == 1)
|
|
|
|
otherPlr->groupIDs[i-1] = otherPlr->groupIDs[i];
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
respdata[i-moveDown].iPC_ID = varPlr->iID;
|
|
|
|
respdata[i-moveDown].iPCUID = varPlr->PCStyle.iPC_UID;
|
|
|
|
respdata[i-moveDown].iNameCheck = varPlr->PCStyle.iNameCheck;
|
|
|
|
memcpy(respdata[i-moveDown].szFirstName, varPlr->PCStyle.szFirstName, sizeof(varPlr->PCStyle.szFirstName));
|
|
|
|
memcpy(respdata[i-moveDown].szLastName, varPlr->PCStyle.szLastName, sizeof(varPlr->PCStyle.szLastName));
|
|
|
|
respdata[i-moveDown].iSpecialState = varPlr->iSpecialState;
|
|
|
|
respdata[i-moveDown].iLv = varPlr->level;
|
|
|
|
respdata[i-moveDown].iHP = varPlr->HP;
|
|
|
|
respdata[i-moveDown].iMaxHP = PC_MAXHEALTH(varPlr->level);
|
2020-10-19 17:26:14 +00:00
|
|
|
// respdata[i-moveDown]].iMapType = 0;
|
|
|
|
// respdata[i-moveDown]].iMapNum = 0;
|
2020-10-04 23:54:08 +00:00
|
|
|
respdata[i-moveDown].iX = varPlr->x;
|
|
|
|
respdata[i-moveDown].iY = varPlr->y;
|
|
|
|
respdata[i-moveDown].iZ = varPlr->z;
|
|
|
|
// client doesnt read nano data here
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
if (varPlr == plr) {
|
|
|
|
moveDown = 1;
|
|
|
|
otherPlr->groupIDs[i] = 0;
|
2020-11-23 23:42:34 +00:00
|
|
|
} else { // remove the leaving member's buffs from the group and remove the group buffs from the leaving member.
|
2021-06-20 17:05:10 +00:00
|
|
|
if (Abilities::SkillTable[varPlr->Nanos[varPlr->activeNano].iSkillID].targetType == 3)
|
|
|
|
Abilities::applyBuff(sock, varPlr->Nanos[varPlr->activeNano].iSkillID, 2, 1, 0);
|
|
|
|
if (Abilities::SkillTable[plr->Nanos[varPlr->activeNano].iSkillID].targetType == 3)
|
|
|
|
Abilities::applyBuff(sockTo, plr->Nanos[plr->activeNano].iSkillID, 2, 1, bitFlag);
|
2020-11-08 00:26:44 +00:00
|
|
|
}
|
2020-10-04 23:54:08 +00:00
|
|
|
}
|
2020-10-05 00:03:13 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
plr->iIDGroup = plr->iID;
|
|
|
|
otherPlr->groupCnt -= 1;
|
2020-10-19 17:26:14 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
sendToGroup(otherPlr, (void*)&respbuf, P_FE2CL_PC_GROUP_LEAVE, resplen);
|
2020-10-19 17:26:14 +00:00
|
|
|
|
2020-10-04 23:54:08 +00:00
|
|
|
INITSTRUCT(sP_FE2CL_PC_GROUP_LEAVE_SUCC, resp1);
|
|
|
|
sock->sendPacket((void*)&resp1, P_FE2CL_PC_GROUP_LEAVE_SUCC, sizeof(sP_FE2CL_PC_GROUP_LEAVE_SUCC));
|
|
|
|
}
|
2020-10-09 00:01:35 +00:00
|
|
|
|
2021-03-16 22:29:13 +00:00
|
|
|
int Groups::getGroupFlags(Player* plr) {
|
2020-10-09 00:01:35 +00:00
|
|
|
int bitFlag = 0;
|
2020-10-19 17:26:14 +00:00
|
|
|
|
2020-10-09 00:01:35 +00:00
|
|
|
for (int i = 0; i < plr->groupCnt; i++) {
|
|
|
|
Player* otherPlr = PlayerManager::getPlayerFromID(plr->groupIDs[i]);
|
2020-10-19 17:26:14 +00:00
|
|
|
|
2020-10-09 00:01:35 +00:00
|
|
|
if (otherPlr == nullptr)
|
|
|
|
continue;
|
2020-10-19 17:26:14 +00:00
|
|
|
|
|
|
|
bitFlag |= otherPlr->iGroupConditionBitFlag;
|
2020-10-09 00:01:35 +00:00
|
|
|
}
|
2020-10-19 17:26:14 +00:00
|
|
|
|
2020-10-09 00:01:35 +00:00
|
|
|
return bitFlag;
|
2020-10-19 17:26:14 +00:00
|
|
|
}
|
2021-03-16 21:06:10 +00:00
|
|
|
|
2021-03-16 22:29:13 +00:00
|
|
|
void Groups::init() {
|
2021-03-16 21:06:10 +00:00
|
|
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GROUP_INVITE, requestGroup);
|
|
|
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GROUP_INVITE_REFUSE, refuseGroup);
|
|
|
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GROUP_JOIN, joinGroup);
|
|
|
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GROUP_LEAVE, leaveGroup);
|
|
|
|
}
|