mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-05 06:50:04 +00:00
Cleaned up whitespace.
Incantation: sed -i 's/[ \t]*$//g' src/*.[ch]pp Also switched BuddyManager from tabs to spaces using vim's :retab command.
This commit is contained in:
parent
b8f586bc10
commit
661070dc3a
@ -10,328 +10,328 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
void BuddyManager::init() {
|
void BuddyManager::init() {
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_REQUEST_MAKE_BUDDY, requestBuddy);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_REQUEST_MAKE_BUDDY, requestBuddy);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY, reqBuddyByName);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY, reqBuddyByName);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_ACCEPT_MAKE_BUDDY, reqAcceptBuddy);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_ACCEPT_MAKE_BUDDY, reqAcceptBuddy);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_FIND_NAME_ACCEPT_BUDDY, reqFindNameBuddyAccept);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_FIND_NAME_ACCEPT_BUDDY, reqFindNameBuddyAccept);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_SEND_BUDDY_FREECHAT_MESSAGE, reqBuddyFreechat);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_SEND_BUDDY_FREECHAT_MESSAGE, reqBuddyFreechat);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_SEND_BUDDY_MENUCHAT_MESSAGE, reqBuddyMenuchat);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_SEND_BUDDY_MENUCHAT_MESSAGE, reqBuddyMenuchat);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_GET_BUDDY_STATE, reqPktGetBuddyState);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_GET_BUDDY_STATE, reqPktGetBuddyState);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_SET_BUDDY_BLOCK, reqBuddyBlock);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_SET_BUDDY_BLOCK, reqBuddyBlock);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_REMOVE_BUDDY, reqBuddyDelete);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_REMOVE_BUDDY, reqBuddyDelete);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_BUDDY_WARP, reqBuddyWarp);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_BUDDY_WARP, reqBuddyWarp);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Buddy request
|
//Buddy request
|
||||||
void BuddyManager::requestBuddy(CNSocket* sock, CNPacketData* data) {
|
void BuddyManager::requestBuddy(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_REQUEST_MAKE_BUDDY))
|
if (data->size != sizeof(sP_CL2FE_REQ_REQUEST_MAKE_BUDDY))
|
||||||
return; // malformed packet
|
return; // malformed packet
|
||||||
|
|
||||||
Player* plrReq = PlayerManager::getPlayer(sock);
|
Player* plrReq = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (plrReq == nullptr)
|
if (plrReq == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sP_CL2FE_REQ_REQUEST_MAKE_BUDDY* pkt = (sP_CL2FE_REQ_REQUEST_MAKE_BUDDY*)data->buf;
|
sP_CL2FE_REQ_REQUEST_MAKE_BUDDY* pkt = (sP_CL2FE_REQ_REQUEST_MAKE_BUDDY*)data->buf;
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC, resp);
|
||||||
|
|
||||||
CNSocket* otherSock = sock;
|
CNSocket* otherSock = sock;
|
||||||
|
|
||||||
for (auto pair : PlayerManager::players) {
|
for (auto pair : PlayerManager::players) {
|
||||||
if (pair.second.plr->PCStyle.iPC_UID == pkt->iBuddyPCUID) {
|
if (pair.second.plr->PCStyle.iPC_UID == pkt->iBuddyPCUID) {
|
||||||
otherSock = pair.first;
|
otherSock = pair.first;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerView& plr = PlayerManager::players[otherSock];
|
PlayerView& plr = PlayerManager::players[otherSock];
|
||||||
|
|
||||||
resp.iRequestID = plr.plr->iID;
|
resp.iRequestID = plr.plr->iID;
|
||||||
resp.iBuddyID = plr.plr->iID;
|
resp.iBuddyID = plr.plr->iID;
|
||||||
resp.iBuddyPCUID = plr.plr->PCStyle.iPC_UID;
|
resp.iBuddyPCUID = plr.plr->PCStyle.iPC_UID;
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC)); //informs the player that the request was sent
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC)); //informs the player that the request was sent
|
||||||
requestedBuddy(otherSock, plrReq, plr); //The other player will see the request
|
requestedBuddy(otherSock, plrReq, plr); //The other player will see the request
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Sending buddy request by player name
|
//Sending buddy request by player name
|
||||||
void BuddyManager::reqBuddyByName(CNSocket* sock, CNPacketData* data) {
|
void BuddyManager::reqBuddyByName(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY)) {
|
if (data->size != sizeof(sP_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY)) {
|
||||||
return; // malformed packet
|
return; // malformed packet
|
||||||
}
|
}
|
||||||
|
|
||||||
sP_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY* pkt = (sP_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY*)data->buf;
|
sP_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY* pkt = (sP_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY*)data->buf;
|
||||||
Player* plrReq = PlayerManager::getPlayer(sock);
|
Player* plrReq = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (plrReq == nullptr)
|
if (plrReq == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_FIND_NAME_MAKE_BUDDY_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_PC_FIND_NAME_MAKE_BUDDY_SUCC, resp);
|
||||||
|
|
||||||
CNSocket* otherSock = sock;
|
CNSocket* otherSock = sock;
|
||||||
|
|
||||||
int sizeOfRes = sizeof(pkt->szFirstName) / 9; //Maximum size of a player's first name
|
int sizeOfRes = sizeof(pkt->szFirstName) / 9; //Maximum size of a player's first name
|
||||||
int sizeOfLNRes = sizeof(pkt->szLastName) / 17; //Maximum size of a player's last name
|
int sizeOfLNRes = sizeof(pkt->szLastName) / 17; //Maximum size of a player's last name
|
||||||
|
|
||||||
for (auto pair : PlayerManager::players) {
|
for (auto pair : PlayerManager::players) {
|
||||||
int sizeOfReq = sizeof(pair.second.plr->PCStyle.szFirstName) / 9;
|
int sizeOfReq = sizeof(pair.second.plr->PCStyle.szFirstName) / 9;
|
||||||
int sizeOfLNReq = sizeof(pair.second.plr->PCStyle.szLastName) / 17;
|
int sizeOfLNReq = sizeof(pair.second.plr->PCStyle.szLastName) / 17;
|
||||||
if (BuddyManager::firstNameCheck(pair.second.plr->PCStyle.szFirstName, pkt->szFirstName, sizeOfReq, sizeOfRes) == true && BuddyManager::lastNameCheck(pair.second.plr->PCStyle.szLastName, pkt->szLastName, sizeOfLNReq, sizeOfLNRes) == true) { //This long line of gorgeous parameters is to check if the player's name matches :eyes:
|
if (BuddyManager::firstNameCheck(pair.second.plr->PCStyle.szFirstName, pkt->szFirstName, sizeOfReq, sizeOfRes) == true && BuddyManager::lastNameCheck(pair.second.plr->PCStyle.szLastName, pkt->szLastName, sizeOfLNReq, sizeOfLNRes) == true) { //This long line of gorgeous parameters is to check if the player's name matches :eyes:
|
||||||
otherSock = pair.first;
|
otherSock = pair.first;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resp.iPCUID = plrReq->PCStyle.iPC_UID;
|
resp.iPCUID = plrReq->PCStyle.iPC_UID;
|
||||||
resp.iNameCheckFlag = plrReq->PCStyle.iNameCheck;
|
resp.iNameCheckFlag = plrReq->PCStyle.iNameCheck;
|
||||||
|
|
||||||
memcpy(resp.szFirstName, plrReq->PCStyle.szFirstName, sizeof(plrReq->PCStyle.szFirstName));
|
memcpy(resp.szFirstName, plrReq->PCStyle.szFirstName, sizeof(plrReq->PCStyle.szFirstName));
|
||||||
memcpy(resp.szLastName, plrReq->PCStyle.szLastName, sizeof(plrReq->PCStyle.szLastName));
|
memcpy(resp.szLastName, plrReq->PCStyle.szLastName, sizeof(plrReq->PCStyle.szLastName));
|
||||||
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_PC_FIND_NAME_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_PC_FIND_NAME_MAKE_BUDDY_SUCC));
|
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_PC_FIND_NAME_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_PC_FIND_NAME_MAKE_BUDDY_SUCC));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Accepting buddy request
|
//Accepting buddy request
|
||||||
void BuddyManager::reqAcceptBuddy(CNSocket* sock, CNPacketData* data) {
|
void BuddyManager::reqAcceptBuddy(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_ACCEPT_MAKE_BUDDY))
|
if (data->size != sizeof(sP_CL2FE_REQ_ACCEPT_MAKE_BUDDY))
|
||||||
return; // malformed packet
|
return; // malformed packet
|
||||||
|
|
||||||
sP_CL2FE_REQ_ACCEPT_MAKE_BUDDY* pkt = (sP_CL2FE_REQ_ACCEPT_MAKE_BUDDY*)data->buf;
|
sP_CL2FE_REQ_ACCEPT_MAKE_BUDDY* pkt = (sP_CL2FE_REQ_ACCEPT_MAKE_BUDDY*)data->buf;
|
||||||
Player* plrReq = PlayerManager::getPlayer(sock);
|
Player* plrReq = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (plrReq == nullptr)
|
if (plrReq == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, resp);
|
||||||
|
|
||||||
CNSocket* otherSock = sock;
|
CNSocket* otherSock = sock;
|
||||||
|
|
||||||
for (auto pair : PlayerManager::players) {
|
for (auto pair : PlayerManager::players) {
|
||||||
if (pair.second.plr->PCStyle.iPC_UID == pkt->iBuddyPCUID) {
|
if (pair.second.plr->PCStyle.iPC_UID == pkt->iBuddyPCUID) {
|
||||||
otherSock = pair.first;
|
otherSock = pair.first;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerView& plr = PlayerManager::players[otherSock];
|
PlayerView& plr = PlayerManager::players[otherSock];
|
||||||
|
|
||||||
if (pkt->iAcceptFlag == 1) {
|
if (pkt->iAcceptFlag == 1) {
|
||||||
//resp.iBuddySlot = 0; //hard-coding this for now
|
//resp.iBuddySlot = 0; //hard-coding this for now
|
||||||
resp.BuddyInfo.iID = pkt->iBuddyID;
|
resp.BuddyInfo.iID = pkt->iBuddyID;
|
||||||
resp.BuddyInfo.iPCUID = pkt->iBuddyPCUID;
|
resp.BuddyInfo.iPCUID = pkt->iBuddyPCUID;
|
||||||
resp.BuddyInfo.iNameCheckFlag = plr.plr->PCStyle.iNameCheck;
|
resp.BuddyInfo.iNameCheckFlag = plr.plr->PCStyle.iNameCheck;
|
||||||
resp.BuddyInfo.iPCState = plr.plr->iPCState;
|
resp.BuddyInfo.iPCState = plr.plr->iPCState;
|
||||||
resp.BuddyInfo.iGender = plr.plr->PCStyle.iGender;
|
resp.BuddyInfo.iGender = plr.plr->PCStyle.iGender;
|
||||||
resp.BuddyInfo.bBlocked = 0;
|
resp.BuddyInfo.bBlocked = 0;
|
||||||
resp.BuddyInfo.bFreeChat = 1;
|
resp.BuddyInfo.bFreeChat = 1;
|
||||||
|
|
||||||
memcpy(resp.BuddyInfo.szFirstName, plr.plr->PCStyle.szFirstName, sizeof(plr.plr->PCStyle.szFirstName));
|
memcpy(resp.BuddyInfo.szFirstName, plr.plr->PCStyle.szFirstName, sizeof(plr.plr->PCStyle.szFirstName));
|
||||||
memcpy(resp.BuddyInfo.szLastName, plr.plr->PCStyle.szLastName, sizeof(plr.plr->PCStyle.szLastName));
|
memcpy(resp.BuddyInfo.szLastName, plr.plr->PCStyle.szLastName, sizeof(plr.plr->PCStyle.szLastName));
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
|
||||||
buddyList(sock, resp.BuddyInfo); //saves buddy data to player's buddylist
|
buddyList(sock, resp.BuddyInfo); //saves buddy data to player's buddylist
|
||||||
if (plr.plr->PCStyle.iPC_UID == pkt->iBuddyPCUID) {
|
if (plr.plr->PCStyle.iPC_UID == pkt->iBuddyPCUID) {
|
||||||
resp.BuddyInfo.iID = plrReq->iID;
|
resp.BuddyInfo.iID = plrReq->iID;
|
||||||
resp.BuddyInfo.iPCUID = plrReq->PCStyle.iPC_UID;
|
resp.BuddyInfo.iPCUID = plrReq->PCStyle.iPC_UID;
|
||||||
resp.BuddyInfo.iNameCheckFlag = plrReq->PCStyle.iNameCheck;
|
resp.BuddyInfo.iNameCheckFlag = plrReq->PCStyle.iNameCheck;
|
||||||
resp.BuddyInfo.iPCState = plrReq->iPCState;
|
resp.BuddyInfo.iPCState = plrReq->iPCState;
|
||||||
resp.BuddyInfo.iGender = plrReq->PCStyle.iGender;
|
resp.BuddyInfo.iGender = plrReq->PCStyle.iGender;
|
||||||
resp.BuddyInfo.bBlocked = 0;
|
resp.BuddyInfo.bBlocked = 0;
|
||||||
resp.BuddyInfo.bFreeChat = 1;
|
resp.BuddyInfo.bFreeChat = 1;
|
||||||
memcpy(resp.BuddyInfo.szFirstName, plrReq->PCStyle.szFirstName, sizeof(plrReq->PCStyle.szFirstName));
|
memcpy(resp.BuddyInfo.szFirstName, plrReq->PCStyle.szFirstName, sizeof(plrReq->PCStyle.szFirstName));
|
||||||
memcpy(resp.BuddyInfo.szLastName, plrReq->PCStyle.szLastName, sizeof(plrReq->PCStyle.szLastName));
|
memcpy(resp.BuddyInfo.szLastName, plrReq->PCStyle.szLastName, sizeof(plrReq->PCStyle.szLastName));
|
||||||
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
|
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
|
||||||
buddyList(otherSock, resp.BuddyInfo); //saves requester's data to this player's buddylist
|
buddyList(otherSock, resp.BuddyInfo); //saves requester's data to this player's buddylist
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, declineResp);
|
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, declineResp);
|
||||||
|
|
||||||
declineResp.iErrorCode = 6; //Buddy declined notification
|
declineResp.iErrorCode = 6; //Buddy declined notification
|
||||||
declineResp.iBuddyID = pkt->iBuddyID;
|
declineResp.iBuddyID = pkt->iBuddyID;
|
||||||
declineResp.iBuddyPCUID = pkt->iBuddyPCUID;
|
declineResp.iBuddyPCUID = pkt->iBuddyPCUID;
|
||||||
|
|
||||||
otherSock->sendPacket((void*)&declineResp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL)); //tells the requester that the player declined
|
otherSock->sendPacket((void*)&declineResp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL)); //tells the requester that the player declined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Accepting buddy request from the find name request
|
//Accepting buddy request from the find name request
|
||||||
void BuddyManager::reqFindNameBuddyAccept(CNSocket* sock, CNPacketData* data) {
|
void BuddyManager::reqFindNameBuddyAccept(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_FIND_NAME_ACCEPT_BUDDY)) {
|
if (data->size != sizeof(sP_CL2FE_REQ_PC_FIND_NAME_ACCEPT_BUDDY)) {
|
||||||
return; // malformed packet
|
return; // malformed packet
|
||||||
}
|
}
|
||||||
|
|
||||||
sP_CL2FE_REQ_PC_FIND_NAME_ACCEPT_BUDDY* pkt = (sP_CL2FE_REQ_PC_FIND_NAME_ACCEPT_BUDDY*)data->buf;
|
sP_CL2FE_REQ_PC_FIND_NAME_ACCEPT_BUDDY* pkt = (sP_CL2FE_REQ_PC_FIND_NAME_ACCEPT_BUDDY*)data->buf;
|
||||||
Player* plrReq = PlayerManager::getPlayer(sock);
|
Player* plrReq = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (plrReq == nullptr)
|
if (plrReq == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, resp);
|
||||||
|
|
||||||
CNSocket* otherSock = sock;
|
CNSocket* otherSock = sock;
|
||||||
|
|
||||||
int sizeOfRes = sizeof(pkt->szFirstName) / 9;
|
int sizeOfRes = sizeof(pkt->szFirstName) / 9;
|
||||||
int sizeOfLNRes = sizeof(pkt->szLastName) / 17;
|
int sizeOfLNRes = sizeof(pkt->szLastName) / 17;
|
||||||
|
|
||||||
for (auto pair : PlayerManager::players) {
|
for (auto pair : PlayerManager::players) {
|
||||||
int sizeOfReq = sizeof(pair.second.plr->PCStyle.szFirstName) / 9;
|
int sizeOfReq = sizeof(pair.second.plr->PCStyle.szFirstName) / 9;
|
||||||
int sizeOfLNReq = sizeof(pair.second.plr->PCStyle.szLastName) / 17;
|
int sizeOfLNReq = sizeof(pair.second.plr->PCStyle.szLastName) / 17;
|
||||||
if (BuddyManager::firstNameCheck(pair.second.plr->PCStyle.szFirstName, pkt->szFirstName, sizeOfReq, sizeOfRes) == true && BuddyManager::lastNameCheck(pair.second.plr->PCStyle.szLastName, pkt->szLastName, sizeOfLNReq, sizeOfLNRes) == true) {
|
if (BuddyManager::firstNameCheck(pair.second.plr->PCStyle.szFirstName, pkt->szFirstName, sizeOfReq, sizeOfRes) == true && BuddyManager::lastNameCheck(pair.second.plr->PCStyle.szLastName, pkt->szLastName, sizeOfLNReq, sizeOfLNRes) == true) {
|
||||||
otherSock = pair.first;
|
otherSock = pair.first;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerView& plr = PlayerManager::players[otherSock];
|
PlayerView& plr = PlayerManager::players[otherSock];
|
||||||
|
|
||||||
if (pkt->iAcceptFlag == 1) {
|
if (pkt->iAcceptFlag == 1) {
|
||||||
//resp.iBuddySlot = 0; //hard-coding this for now
|
//resp.iBuddySlot = 0; //hard-coding this for now
|
||||||
//resp.BuddyInfo.iID = plrReq->iID;
|
//resp.BuddyInfo.iID = plrReq->iID;
|
||||||
resp.BuddyInfo.iPCUID = pkt->iBuddyPCUID;
|
resp.BuddyInfo.iPCUID = pkt->iBuddyPCUID;
|
||||||
resp.BuddyInfo.iNameCheckFlag = plr.plr->PCStyle.iNameCheck;
|
resp.BuddyInfo.iNameCheckFlag = plr.plr->PCStyle.iNameCheck;
|
||||||
resp.BuddyInfo.iPCState = plr.plr->iPCState;
|
resp.BuddyInfo.iPCState = plr.plr->iPCState;
|
||||||
resp.BuddyInfo.iGender = plr.plr->PCStyle.iGender;
|
resp.BuddyInfo.iGender = plr.plr->PCStyle.iGender;
|
||||||
resp.BuddyInfo.bBlocked = 0;
|
resp.BuddyInfo.bBlocked = 0;
|
||||||
resp.BuddyInfo.bFreeChat = 1;
|
resp.BuddyInfo.bFreeChat = 1;
|
||||||
|
|
||||||
memcpy(resp.BuddyInfo.szFirstName, plr.plr->PCStyle.szFirstName, sizeof(plr.plr->PCStyle.szFirstName));
|
memcpy(resp.BuddyInfo.szFirstName, plr.plr->PCStyle.szFirstName, sizeof(plr.plr->PCStyle.szFirstName));
|
||||||
memcpy(resp.BuddyInfo.szLastName, plr.plr->PCStyle.szLastName, sizeof(plr.plr->PCStyle.szLastName));
|
memcpy(resp.BuddyInfo.szLastName, plr.plr->PCStyle.szLastName, sizeof(plr.plr->PCStyle.szLastName));
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
|
||||||
buddyList(sock, resp.BuddyInfo);
|
buddyList(sock, resp.BuddyInfo);
|
||||||
|
|
||||||
if (plr.plr->PCStyle.iPC_UID == pkt->iBuddyPCUID) {
|
if (plr.plr->PCStyle.iPC_UID == pkt->iBuddyPCUID) {
|
||||||
resp.BuddyInfo.iID = plrReq->iID;
|
resp.BuddyInfo.iID = plrReq->iID;
|
||||||
resp.BuddyInfo.iPCUID = plrReq->PCStyle.iPC_UID;
|
resp.BuddyInfo.iPCUID = plrReq->PCStyle.iPC_UID;
|
||||||
resp.BuddyInfo.iNameCheckFlag = plrReq->PCStyle.iNameCheck;
|
resp.BuddyInfo.iNameCheckFlag = plrReq->PCStyle.iNameCheck;
|
||||||
resp.BuddyInfo.iPCState = plrReq->iPCState;
|
resp.BuddyInfo.iPCState = plrReq->iPCState;
|
||||||
resp.BuddyInfo.iGender = plrReq->PCStyle.iGender;
|
resp.BuddyInfo.iGender = plrReq->PCStyle.iGender;
|
||||||
resp.BuddyInfo.bBlocked = 0;
|
resp.BuddyInfo.bBlocked = 0;
|
||||||
resp.BuddyInfo.bFreeChat = 1;
|
resp.BuddyInfo.bFreeChat = 1;
|
||||||
|
|
||||||
memcpy(resp.BuddyInfo.szFirstName, plrReq->PCStyle.szFirstName, sizeof(plrReq->PCStyle.szFirstName));
|
memcpy(resp.BuddyInfo.szFirstName, plrReq->PCStyle.szFirstName, sizeof(plrReq->PCStyle.szFirstName));
|
||||||
memcpy(resp.BuddyInfo.szLastName, plrReq->PCStyle.szLastName, sizeof(plrReq->PCStyle.szLastName));
|
memcpy(resp.BuddyInfo.szLastName, plrReq->PCStyle.szLastName, sizeof(plrReq->PCStyle.szLastName));
|
||||||
|
|
||||||
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
|
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
|
||||||
buddyList(otherSock, resp.BuddyInfo);
|
buddyList(otherSock, resp.BuddyInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, declineResp);
|
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, declineResp);
|
||||||
|
|
||||||
declineResp.iErrorCode = 6; //Buddy declined notification
|
declineResp.iErrorCode = 6; //Buddy declined notification
|
||||||
declineResp.iBuddyID = plr.plr->iID;
|
declineResp.iBuddyID = plr.plr->iID;
|
||||||
declineResp.iBuddyPCUID = pkt->iBuddyPCUID;
|
declineResp.iBuddyPCUID = pkt->iBuddyPCUID;
|
||||||
|
|
||||||
otherSock->sendPacket((void*)&declineResp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL));
|
otherSock->sendPacket((void*)&declineResp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Buddy freechatting
|
//Buddy freechatting
|
||||||
void BuddyManager::reqBuddyFreechat(CNSocket* sock, CNPacketData* data) {
|
void BuddyManager::reqBuddyFreechat(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_SEND_BUDDY_FREECHAT_MESSAGE))
|
if (data->size != sizeof(sP_CL2FE_REQ_SEND_BUDDY_FREECHAT_MESSAGE))
|
||||||
return; // malformed packet
|
return; // malformed packet
|
||||||
|
|
||||||
sP_CL2FE_REQ_SEND_BUDDY_FREECHAT_MESSAGE* pkt = (sP_CL2FE_REQ_SEND_BUDDY_FREECHAT_MESSAGE*)data->buf;
|
sP_CL2FE_REQ_SEND_BUDDY_FREECHAT_MESSAGE* pkt = (sP_CL2FE_REQ_SEND_BUDDY_FREECHAT_MESSAGE*)data->buf;
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC, resp);
|
||||||
|
|
||||||
CNSocket* otherSock = sock;
|
CNSocket* otherSock = sock;
|
||||||
|
|
||||||
resp.iFromPCUID = plr->PCStyle.iPC_UID;
|
resp.iFromPCUID = plr->PCStyle.iPC_UID;
|
||||||
resp.iToPCUID = pkt->iBuddyPCUID;
|
resp.iToPCUID = pkt->iBuddyPCUID;
|
||||||
resp.iEmoteCode = pkt->iEmoteCode;
|
resp.iEmoteCode = pkt->iEmoteCode;
|
||||||
memcpy(resp.szFreeChat, pkt->szFreeChat, sizeof(pkt->szFreeChat));
|
memcpy(resp.szFreeChat, pkt->szFreeChat, sizeof(pkt->szFreeChat));
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC)); //shows the player that they sent the message to their buddy
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC)); //shows the player that they sent the message to their buddy
|
||||||
|
|
||||||
for (auto pair : PlayerManager::players) {
|
for (auto pair : PlayerManager::players) {
|
||||||
if (pair.second.plr->PCStyle.iPC_UID != plr->PCStyle.iPC_UID) {
|
if (pair.second.plr->PCStyle.iPC_UID != plr->PCStyle.iPC_UID) {
|
||||||
otherSock = pair.first;
|
otherSock = pair.first;
|
||||||
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC)); //sends the message to the buddy.
|
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_BUDDY_FREECHAT_MESSAGE_SUCC)); //sends the message to the buddy.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Buddy menuchat
|
//Buddy menuchat
|
||||||
void BuddyManager::reqBuddyMenuchat(CNSocket* sock, CNPacketData* data) {
|
void BuddyManager::reqBuddyMenuchat(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_SEND_BUDDY_MENUCHAT_MESSAGE))
|
if (data->size != sizeof(sP_CL2FE_REQ_SEND_BUDDY_MENUCHAT_MESSAGE))
|
||||||
return; // malformed packet
|
return; // malformed packet
|
||||||
|
|
||||||
sP_CL2FE_REQ_SEND_BUDDY_MENUCHAT_MESSAGE* pkt = (sP_CL2FE_REQ_SEND_BUDDY_MENUCHAT_MESSAGE*)data->buf;
|
sP_CL2FE_REQ_SEND_BUDDY_MENUCHAT_MESSAGE* pkt = (sP_CL2FE_REQ_SEND_BUDDY_MENUCHAT_MESSAGE*)data->buf;
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_SEND_BUDDY_MENUCHAT_MESSAGE_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_SEND_BUDDY_MENUCHAT_MESSAGE_SUCC, resp);
|
||||||
|
|
||||||
CNSocket* otherSock = sock;
|
CNSocket* otherSock = sock;
|
||||||
|
|
||||||
resp.iFromPCUID = plr->PCStyle.iPC_UID;
|
resp.iFromPCUID = plr->PCStyle.iPC_UID;
|
||||||
resp.iToPCUID = pkt->iBuddyPCUID;
|
resp.iToPCUID = pkt->iBuddyPCUID;
|
||||||
resp.iEmoteCode = pkt->iEmoteCode;
|
resp.iEmoteCode = pkt->iEmoteCode;
|
||||||
memcpy(resp.szFreeChat, pkt->szFreeChat, sizeof(pkt->szFreeChat));
|
memcpy(resp.szFreeChat, pkt->szFreeChat, sizeof(pkt->szFreeChat));
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_BUDDY_MENUCHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_BUDDY_MENUCHAT_MESSAGE_SUCC)); //shows the player that they sent the message to their buddy
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_BUDDY_MENUCHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_BUDDY_MENUCHAT_MESSAGE_SUCC)); //shows the player that they sent the message to their buddy
|
||||||
|
|
||||||
for (auto pair : PlayerManager::players) {
|
for (auto pair : PlayerManager::players) {
|
||||||
if (pair.second.plr->PCStyle.iPC_UID != plr->PCStyle.iPC_UID) {
|
if (pair.second.plr->PCStyle.iPC_UID != plr->PCStyle.iPC_UID) {
|
||||||
otherSock = pair.first;
|
otherSock = pair.first;
|
||||||
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_BUDDY_MENUCHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_BUDDY_MENUCHAT_MESSAGE_SUCC)); //sends the message to the buddy.
|
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_BUDDY_MENUCHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_BUDDY_MENUCHAT_MESSAGE_SUCC)); //sends the message to the buddy.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Getting buddy state
|
//Getting buddy state
|
||||||
void BuddyManager::reqPktGetBuddyState(CNSocket* sock, CNPacketData* data) {
|
void BuddyManager::reqPktGetBuddyState(CNSocket* sock, CNPacketData* data) {
|
||||||
INITSTRUCT(sP_FE2CL_REP_GET_BUDDY_STATE_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_GET_BUDDY_STATE_SUCC, resp);
|
||||||
INITSTRUCT(sBuddyBaseInfo, buddyInfo);
|
INITSTRUCT(sBuddyBaseInfo, buddyInfo);
|
||||||
|
|
||||||
for (int BuddySlot = 0; BuddySlot < 50; BuddySlot++) {
|
for (int BuddySlot = 0; BuddySlot < 50; BuddySlot++) {
|
||||||
resp.aBuddyState[BuddySlot] = 1; //this sets every buddy to online. Will get the pcstate right directly from the DB.
|
resp.aBuddyState[BuddySlot] = 1; //this sets every buddy to online. Will get the pcstate right directly from the DB.
|
||||||
resp.aBuddyID[BuddySlot] = buddyInfo.iID;
|
resp.aBuddyID[BuddySlot] = buddyInfo.iID;
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_GET_BUDDY_STATE_SUCC, sizeof(sP_FE2CL_REP_GET_BUDDY_STATE_SUCC));
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_GET_BUDDY_STATE_SUCC, sizeof(sP_FE2CL_REP_GET_BUDDY_STATE_SUCC));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Blocking the buddy
|
//Blocking the buddy
|
||||||
void BuddyManager::reqBuddyBlock(CNSocket* sock, CNPacketData* data) {
|
void BuddyManager::reqBuddyBlock(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_SET_BUDDY_BLOCK))
|
if (data->size != sizeof(sP_CL2FE_REQ_SET_BUDDY_BLOCK))
|
||||||
return; // malformed packet
|
return; // malformed packet
|
||||||
|
|
||||||
sP_CL2FE_REQ_SET_BUDDY_BLOCK* pkt = (sP_CL2FE_REQ_SET_BUDDY_BLOCK*)data->buf;
|
sP_CL2FE_REQ_SET_BUDDY_BLOCK* pkt = (sP_CL2FE_REQ_SET_BUDDY_BLOCK*)data->buf;
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_SET_BUDDY_BLOCK_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_SET_BUDDY_BLOCK_SUCC, resp);
|
||||||
|
|
||||||
resp.iBuddyPCUID = pkt->iBuddyPCUID;
|
resp.iBuddyPCUID = pkt->iBuddyPCUID;
|
||||||
resp.iBuddySlot = pkt->iBuddySlot;
|
resp.iBuddySlot = pkt->iBuddySlot;
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_SET_BUDDY_BLOCK_SUCC, sizeof(sP_FE2CL_REP_SET_BUDDY_BLOCK_SUCC));
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_SET_BUDDY_BLOCK_SUCC, sizeof(sP_FE2CL_REP_SET_BUDDY_BLOCK_SUCC));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Deleting the buddy
|
//Deleting the buddy
|
||||||
void BuddyManager::reqBuddyDelete(CNSocket* sock, CNPacketData* data) {
|
void BuddyManager::reqBuddyDelete(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_REMOVE_BUDDY))
|
if (data->size != sizeof(sP_CL2FE_REQ_REMOVE_BUDDY))
|
||||||
return; //malformed packet
|
return; //malformed packet
|
||||||
|
|
||||||
sP_CL2FE_REQ_REMOVE_BUDDY* pkt = (sP_CL2FE_REQ_REMOVE_BUDDY*)data->buf;
|
sP_CL2FE_REQ_REMOVE_BUDDY* pkt = (sP_CL2FE_REQ_REMOVE_BUDDY*)data->buf;
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_REMOVE_BUDDY_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_REMOVE_BUDDY_SUCC, resp);
|
||||||
|
|
||||||
resp.iBuddyPCUID = pkt->iBuddyPCUID;
|
resp.iBuddyPCUID = pkt->iBuddyPCUID;
|
||||||
resp.iBuddySlot = pkt->iBuddySlot;
|
resp.iBuddySlot = pkt->iBuddySlot;
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_REMOVE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_REMOVE_BUDDY_SUCC));
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_REMOVE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_REMOVE_BUDDY_SUCC));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Warping to buddy
|
//Warping to buddy
|
||||||
@ -340,104 +340,104 @@ void BuddyManager::reqBuddyWarp(CNSocket* sock, CNPacketData* data) {} //stub
|
|||||||
#pragma region Helper methods
|
#pragma region Helper methods
|
||||||
|
|
||||||
void BuddyManager::requestedBuddy(CNSocket* sock, Player* plrReq, PlayerView& plr) {
|
void BuddyManager::requestedBuddy(CNSocket* sock, Player* plrReq, PlayerView& plr) {
|
||||||
INITSTRUCT(sP_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC_TO_ACCEPTER, resp);
|
INITSTRUCT(sP_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC_TO_ACCEPTER, resp);
|
||||||
|
|
||||||
resp.iRequestID = plrReq->iID;
|
resp.iRequestID = plrReq->iID;
|
||||||
resp.iBuddyID = plr.plr->iID;
|
resp.iBuddyID = plr.plr->iID;
|
||||||
|
|
||||||
memcpy(resp.szFirstName, plrReq->PCStyle.szFirstName, sizeof(plrReq->PCStyle.szFirstName));
|
memcpy(resp.szFirstName, plrReq->PCStyle.szFirstName, sizeof(plrReq->PCStyle.szFirstName));
|
||||||
memcpy(resp.szLastName, plrReq->PCStyle.szLastName, sizeof(plrReq->PCStyle.szLastName));
|
memcpy(resp.szLastName, plrReq->PCStyle.szLastName, sizeof(plrReq->PCStyle.szLastName));
|
||||||
|
|
||||||
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC_TO_ACCEPTER, sizeof(sP_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC_TO_ACCEPTER)); //player get the buddy request.
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC_TO_ACCEPTER, sizeof(sP_FE2CL_REP_REQUEST_MAKE_BUDDY_SUCC_TO_ACCEPTER)); //player get the buddy request.
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Buddy list load
|
//Buddy list load
|
||||||
void BuddyManager::buddyList(CNSocket* sock, sBuddyBaseInfo BuddyInfo) {
|
void BuddyManager::buddyList(CNSocket* sock, sBuddyBaseInfo BuddyInfo) {
|
||||||
|
|
||||||
size_t resplen = sizeof(sP_FE2CL_REP_PC_BUDDYLIST_INFO_SUCC) + sizeof(sBuddyBaseInfo);
|
size_t resplen = sizeof(sP_FE2CL_REP_PC_BUDDYLIST_INFO_SUCC) + sizeof(sBuddyBaseInfo);
|
||||||
uint8_t respbuf[4096];
|
uint8_t respbuf[4096];
|
||||||
|
|
||||||
memset(respbuf, 0, resplen);
|
memset(respbuf, 0, resplen);
|
||||||
|
|
||||||
sP_FE2CL_REP_PC_BUDDYLIST_INFO_SUCC* resp = (sP_FE2CL_REP_PC_BUDDYLIST_INFO_SUCC*)respbuf;
|
sP_FE2CL_REP_PC_BUDDYLIST_INFO_SUCC* resp = (sP_FE2CL_REP_PC_BUDDYLIST_INFO_SUCC*)respbuf;
|
||||||
sBuddyBaseInfo* respdata = (sBuddyBaseInfo*)(respbuf + sizeof(sP_FE2CL_REP_PC_BUDDYLIST_INFO_SUCC));
|
sBuddyBaseInfo* respdata = (sBuddyBaseInfo*)(respbuf + sizeof(sP_FE2CL_REP_PC_BUDDYLIST_INFO_SUCC));
|
||||||
|
|
||||||
resp->iID = BuddyInfo.iID;
|
resp->iID = BuddyInfo.iID;
|
||||||
resp->iPCUID = BuddyInfo.iPCUID;
|
resp->iPCUID = BuddyInfo.iPCUID;
|
||||||
|
|
||||||
for (int i = 0; i < resp->iBuddyCnt && i < resp->iListNum; i++) {
|
for (int i = 0; i < resp->iBuddyCnt && i < resp->iListNum; i++) {
|
||||||
respdata->iID = BuddyInfo.iID;
|
respdata->iID = BuddyInfo.iID;
|
||||||
respdata->iPCUID = BuddyInfo.iPCUID;
|
respdata->iPCUID = BuddyInfo.iPCUID;
|
||||||
respdata->iGender = BuddyInfo.iGender;
|
respdata->iGender = BuddyInfo.iGender;
|
||||||
respdata->iPCState = BuddyInfo.iPCState;
|
respdata->iPCState = BuddyInfo.iPCState;
|
||||||
respdata->iNameCheckFlag = BuddyInfo.iNameCheckFlag;
|
respdata->iNameCheckFlag = BuddyInfo.iNameCheckFlag;
|
||||||
respdata->bBlocked = 0;
|
respdata->bBlocked = 0;
|
||||||
respdata->bFreeChat = 1;
|
respdata->bFreeChat = 1;
|
||||||
memcpy(respdata->szFirstName, BuddyInfo.szFirstName, sizeof(BuddyInfo.szFirstName));
|
memcpy(respdata->szFirstName, BuddyInfo.szFirstName, sizeof(BuddyInfo.szFirstName));
|
||||||
memcpy(respdata->szLastName, BuddyInfo.szLastName, sizeof(BuddyInfo.szLastName));
|
memcpy(respdata->szLastName, BuddyInfo.szLastName, sizeof(BuddyInfo.szLastName));
|
||||||
}
|
}
|
||||||
|
|
||||||
sock->sendPacket((void*)respbuf, P_FE2CL_REP_PC_BUDDYLIST_INFO_SUCC, resplen); //updates/loads player's buddy list
|
sock->sendPacket((void*)respbuf, P_FE2CL_REP_PC_BUDDYLIST_INFO_SUCC, resplen); //updates/loads player's buddy list
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//If the requested player accepts the buddy request, the requester's buddylist will get loaded up.
|
//If the requested player accepts the buddy request, the requester's buddylist will get loaded up.
|
||||||
void BuddyManager::otherAcceptBuddy(CNSocket* sock, int32_t BuddyID, int64_t BuddyPCUID, sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC resp, Player* plr) {
|
void BuddyManager::otherAcceptBuddy(CNSocket* sock, int32_t BuddyID, int64_t BuddyPCUID, sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC resp, Player* plr) {
|
||||||
|
|
||||||
//resp.iBuddySlot = 0; //hard-coding this for now
|
|
||||||
resp.BuddyInfo.iID = BuddyID;
|
|
||||||
resp.BuddyInfo.iPCUID = BuddyPCUID;
|
|
||||||
resp.BuddyInfo.iNameCheckFlag = plr->PCStyle.iNameCheck;
|
|
||||||
resp.BuddyInfo.iPCState = plr->iPCState;
|
|
||||||
resp.BuddyInfo.iGender = plr->PCStyle.iGender;
|
|
||||||
resp.BuddyInfo.bBlocked = 0;
|
|
||||||
resp.BuddyInfo.bFreeChat = 1;
|
|
||||||
|
|
||||||
memcpy(resp.BuddyInfo.szFirstName, plr->PCStyle.szFirstName, sizeof(plr->PCStyle.szFirstName));
|
//resp.iBuddySlot = 0; //hard-coding this for now
|
||||||
memcpy(resp.BuddyInfo.szLastName, plr->PCStyle.szLastName, sizeof(plr->PCStyle.szLastName));
|
resp.BuddyInfo.iID = BuddyID;
|
||||||
|
resp.BuddyInfo.iPCUID = BuddyPCUID;
|
||||||
|
resp.BuddyInfo.iNameCheckFlag = plr->PCStyle.iNameCheck;
|
||||||
|
resp.BuddyInfo.iPCState = plr->iPCState;
|
||||||
|
resp.BuddyInfo.iGender = plr->PCStyle.iGender;
|
||||||
|
resp.BuddyInfo.bBlocked = 0;
|
||||||
|
resp.BuddyInfo.bFreeChat = 1;
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
|
memcpy(resp.BuddyInfo.szFirstName, plr->PCStyle.szFirstName, sizeof(plr->PCStyle.szFirstName));
|
||||||
buddyList(sock, resp.BuddyInfo);
|
memcpy(resp.BuddyInfo.szLastName, plr->PCStyle.szLastName, sizeof(plr->PCStyle.szLastName));
|
||||||
|
|
||||||
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
|
||||||
|
buddyList(sock, resp.BuddyInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if the requested name matches the requested player's name
|
//Check if the requested name matches the requested player's name
|
||||||
bool BuddyManager::firstNameCheck(char16_t reqFirstName[], char16_t resFirstName[], int sizeOfReq, int sizeOfRes) {
|
bool BuddyManager::firstNameCheck(char16_t reqFirstName[], char16_t resFirstName[], int sizeOfReq, int sizeOfRes) {
|
||||||
// If lengths of array are not equal means
|
// If lengths of array are not equal means
|
||||||
// array are not equal
|
// array are not equal
|
||||||
if (sizeOfReq != sizeOfRes)
|
if (sizeOfReq != sizeOfRes)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Sort both arrays
|
// Sort both arrays
|
||||||
std::sort(reqFirstName, reqFirstName + sizeOfReq);
|
std::sort(reqFirstName, reqFirstName + sizeOfReq);
|
||||||
std::sort(resFirstName, resFirstName + sizeOfRes);
|
std::sort(resFirstName, resFirstName + sizeOfRes);
|
||||||
|
|
||||||
// Linearly compare elements
|
// Linearly compare elements
|
||||||
for (int i = 0; i < sizeOfReq; i++)
|
for (int i = 0; i < sizeOfReq; i++)
|
||||||
if (reqFirstName[i] != resFirstName[i])
|
if (reqFirstName[i] != resFirstName[i])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If all elements were same.
|
// If all elements were same.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BuddyManager::lastNameCheck(char16_t reqLastName[], char16_t resLastName[], int sizeOfLNReq, int sizeOfLNRes) {
|
bool BuddyManager::lastNameCheck(char16_t reqLastName[], char16_t resLastName[], int sizeOfLNReq, int sizeOfLNRes) {
|
||||||
// If lengths of array are not equal means
|
// If lengths of array are not equal means
|
||||||
// array are not equal
|
// array are not equal
|
||||||
if (sizeOfLNReq != sizeOfLNRes)
|
if (sizeOfLNReq != sizeOfLNRes)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Sort both arrays
|
// Sort both arrays
|
||||||
std::sort(reqLastName, reqLastName + sizeOfLNReq);
|
std::sort(reqLastName, reqLastName + sizeOfLNReq);
|
||||||
std::sort(resLastName, resLastName + sizeOfLNRes);
|
std::sort(resLastName, resLastName + sizeOfLNRes);
|
||||||
|
|
||||||
// Linearly compare elements
|
// Linearly compare elements
|
||||||
for (int i = 0; i < sizeOfLNReq; i++)
|
for (int i = 0; i < sizeOfLNReq; i++)
|
||||||
if (reqLastName[i] != resLastName[i])
|
if (reqLastName[i] != resLastName[i])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If all elements were same.
|
// If all elements were same.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
@ -10,22 +10,22 @@
|
|||||||
|
|
||||||
namespace BuddyManager {
|
namespace BuddyManager {
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
//Buddy requests
|
//Buddy requests
|
||||||
void requestBuddy(CNSocket* sock, CNPacketData* data);
|
void requestBuddy(CNSocket* sock, CNPacketData* data);
|
||||||
void reqBuddyByName(CNSocket* sock, CNPacketData* data);
|
void reqBuddyByName(CNSocket* sock, CNPacketData* data);
|
||||||
|
|
||||||
//Buddy accepting
|
//Buddy accepting
|
||||||
void reqAcceptBuddy(CNSocket* sock, CNPacketData* data);
|
void reqAcceptBuddy(CNSocket* sock, CNPacketData* data);
|
||||||
void reqFindNameBuddyAccept(CNSocket* sock, CNPacketData* data);
|
void reqFindNameBuddyAccept(CNSocket* sock, CNPacketData* data);
|
||||||
|
|
||||||
//Buddy Messaging
|
//Buddy Messaging
|
||||||
void reqBuddyFreechat(CNSocket* sock, CNPacketData* data);
|
void reqBuddyFreechat(CNSocket* sock, CNPacketData* data);
|
||||||
void reqBuddyMenuchat(CNSocket* sock, CNPacketData* data);
|
void reqBuddyMenuchat(CNSocket* sock, CNPacketData* data);
|
||||||
|
|
||||||
//Getting buddy state
|
//Getting buddy state
|
||||||
void reqPktGetBuddyState(CNSocket* sock, CNPacketData* data);
|
void reqPktGetBuddyState(CNSocket* sock, CNPacketData* data);
|
||||||
|
|
||||||
//Blocking/removing buddies
|
//Blocking/removing buddies
|
||||||
void reqBuddyBlock(CNSocket* sock, CNPacketData* data);
|
void reqBuddyBlock(CNSocket* sock, CNPacketData* data);
|
||||||
void reqBuddyDelete(CNSocket* sock, CNPacketData* data);
|
void reqBuddyDelete(CNSocket* sock, CNPacketData* data);
|
||||||
|
@ -59,7 +59,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
}
|
}
|
||||||
// if user exists, check if password is correct
|
// if user exists, check if password is correct
|
||||||
else if (CNLoginServer::isPasswordCorrect(findUser->Password, userPassword)) {
|
else if (CNLoginServer::isPasswordCorrect(findUser->Password, userPassword)) {
|
||||||
/*calling this here to timestamp login attempt,
|
/*calling this here to timestamp login attempt,
|
||||||
* in order to make duplicate exit sanity check work*/
|
* in order to make duplicate exit sanity check work*/
|
||||||
Database::updateSelected(findUser->AccountID, findUser->Selected);
|
Database::updateSelected(findUser->AccountID, findUser->Selected);
|
||||||
// check if account isn't currently in use
|
// check if account isn't currently in use
|
||||||
@ -94,7 +94,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp.iPaymentFlag = 1;
|
resp.iPaymentFlag = 1;
|
||||||
resp.iOpenBetaFlag = 0;
|
resp.iOpenBetaFlag = 0;
|
||||||
resp.uiSvrTime = getTime();
|
resp.uiSvrTime = getTime();
|
||||||
|
|
||||||
// send the resp in with original key
|
// send the resp in with original key
|
||||||
sock->sendPacket((void*)&resp, P_LS2CL_REP_LOGIN_SUCC, sizeof(sP_LS2CL_REP_LOGIN_SUCC));
|
sock->sendPacket((void*)&resp, P_LS2CL_REP_LOGIN_SUCC, sizeof(sP_LS2CL_REP_LOGIN_SUCC));
|
||||||
|
|
||||||
@ -340,7 +340,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
sP_CL2LS_REQ_PC_EXIT_DUPLICATE* exit = (sP_CL2LS_REQ_PC_EXIT_DUPLICATE*)data->buf;
|
sP_CL2LS_REQ_PC_EXIT_DUPLICATE* exit = (sP_CL2LS_REQ_PC_EXIT_DUPLICATE*)data->buf;
|
||||||
auto account = Database::findAccount(U16toU8(exit->szID));
|
auto account = Database::findAccount(U16toU8(exit->szID));
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
if (account == nullptr) {
|
if (account == nullptr) {
|
||||||
std::cout << "[WARN] P_CL2LS_REQ_PC_EXIT_DUPLICATE submitted unknown username: " << exit->szID << std::endl;
|
std::cout << "[WARN] P_CL2LS_REQ_PC_EXIT_DUPLICATE submitted unknown username: " << exit->szID << std::endl;
|
||||||
|
@ -77,9 +77,9 @@ void CNShardServer::_killConnection(CNSocket* cns) {
|
|||||||
// also, hopefully the player's progress was already saved since the last db save interval, but rip those 2 mins of progress lol
|
// also, hopefully the player's progress was already saved since the last db save interval, but rip those 2 mins of progress lol
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t key = plr->SerialKey;
|
int64_t key = plr->SerialKey;
|
||||||
|
|
||||||
// save player to DB
|
// save player to DB
|
||||||
Database::updatePlayer(PlayerManager::players[cns].plr);
|
Database::updatePlayer(PlayerManager::players[cns].plr);
|
||||||
PlayerManager::removePlayer(cns);
|
PlayerManager::removePlayer(cns);
|
||||||
|
@ -20,12 +20,12 @@ std::vector<std::string> parseArgs(std::string full) {
|
|||||||
bool runCmd(std::string full, CNSocket* sock) {
|
bool runCmd(std::string full, CNSocket* sock) {
|
||||||
std::vector<std::string> args = parseArgs(full);
|
std::vector<std::string> args = parseArgs(full);
|
||||||
std::string cmd = args[0].substr(1, args[0].size() - 1);
|
std::string cmd = args[0].substr(1, args[0].size() - 1);
|
||||||
|
|
||||||
// check if the command exists
|
// check if the command exists
|
||||||
if (ChatManager::commands.find(cmd) != ChatManager::commands.end()) {
|
if (ChatManager::commands.find(cmd) != ChatManager::commands.end()) {
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
ChatCommand command = ChatManager::commands[cmd];
|
ChatCommand command = ChatManager::commands[cmd];
|
||||||
|
|
||||||
// sanity check + does the player have the required account level to use the command?
|
// sanity check + does the player have the required account level to use the command?
|
||||||
if (plr != nullptr && plr->accountLevel <= command.requiredAccLevel) {
|
if (plr != nullptr && plr->accountLevel <= command.requiredAccLevel) {
|
||||||
command.handlr(full, args, sock);
|
command.handlr(full, args, sock);
|
||||||
@ -149,7 +149,7 @@ void mssCommand(std::string full, std::vector<std::string>& args, CNSocket* sock
|
|||||||
path.push(coords); // add keyframe to the queue
|
path.push(coords); // add keyframe to the queue
|
||||||
last = coords; // update start pos
|
last = coords; // update start pos
|
||||||
}
|
}
|
||||||
|
|
||||||
TransportManager::SkywayQueues[sock] = path;
|
TransportManager::SkywayQueues[sock] = path;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -184,7 +184,7 @@ void ChatManager::registerCommand(std::string cmd, int requiredLevel, CommandHan
|
|||||||
void ChatManager::chatHandler(CNSocket* sock, CNPacketData* data) {
|
void ChatManager::chatHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE))
|
if (data->size != sizeof(sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE))
|
||||||
return; // malformed packet
|
return; // malformed packet
|
||||||
|
|
||||||
sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE* chat = (sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE*)data->buf;
|
sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE* chat = (sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE*)data->buf;
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ void ChunkManager::addPlayer(int posX, int posY, int instanceID, CNSocket* sock)
|
|||||||
void ChunkManager::removePlayer(std::tuple<int, int, int> chunkPos, CNSocket* sock) {
|
void ChunkManager::removePlayer(std::tuple<int, int, int> chunkPos, CNSocket* sock) {
|
||||||
if (!checkChunk(chunkPos))
|
if (!checkChunk(chunkPos))
|
||||||
return; // do nothing if chunk doesn't even exist
|
return; // do nothing if chunk doesn't even exist
|
||||||
|
|
||||||
Chunk* chunk = chunks[chunkPos];
|
Chunk* chunk = chunks[chunkPos];
|
||||||
|
|
||||||
chunk->players.erase(sock); // gone
|
chunk->players.erase(sock); // gone
|
||||||
@ -78,7 +78,7 @@ std::vector<Chunk*> ChunkManager::grabChunks(std::tuple<int, int, int> chunk) {
|
|||||||
for (int i = -1; i < 2; i++) {
|
for (int i = -1; i < 2; i++) {
|
||||||
for (int z = -1; z < 2; z++) {
|
for (int z = -1; z < 2; z++) {
|
||||||
std::tuple<int, int, int> pos = std::make_tuple(x+i, y+z, inst);
|
std::tuple<int, int, int> pos = std::make_tuple(x+i, y+z, inst);
|
||||||
|
|
||||||
// if chunk exists, add it to the vector
|
// if chunk exists, add it to the vector
|
||||||
if (checkChunk(pos))
|
if (checkChunk(pos))
|
||||||
chnks.push_back(chunks[pos]);
|
chnks.push_back(chunks[pos]);
|
||||||
|
@ -189,7 +189,7 @@ int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
DbPlayer create = {};
|
DbPlayer create = {};
|
||||||
|
|
||||||
//set timestamp
|
//set timestamp
|
||||||
create.Created = getTimestamp();
|
create.Created = getTimestamp();
|
||||||
// save packet data
|
// save packet data
|
||||||
@ -466,7 +466,7 @@ Player Database::DbToPlayer(DbPlayer player) {
|
|||||||
Database::getInventory(&result);
|
Database::getInventory(&result);
|
||||||
Database::removeExpiredVehicles(&result);
|
Database::removeExpiredVehicles(&result);
|
||||||
Database::getNanos(&result);
|
Database::getNanos(&result);
|
||||||
Database::getQuests(&result);
|
Database::getQuests(&result);
|
||||||
|
|
||||||
// load completed quests
|
// load completed quests
|
||||||
memcpy(&result.aQuestFlag, player.QuestFlag.data(), std::min(sizeof(result.aQuestFlag), player.QuestFlag.size()));
|
memcpy(&result.aQuestFlag, player.QuestFlag.data(), std::min(sizeof(result.aQuestFlag), player.QuestFlag.size()));
|
||||||
|
@ -66,7 +66,7 @@ enum {
|
|||||||
EST__END = 37,
|
EST__END = 37,
|
||||||
EST_CORRUPTIONATTACKWIN = 38,
|
EST_CORRUPTIONATTACKWIN = 38,
|
||||||
EST_CORRUPTIONATTACKLOSE = 39,
|
EST_CORRUPTIONATTACKLOSE = 39,
|
||||||
|
|
||||||
ECSB_NONE = 0,
|
ECSB_NONE = 0,
|
||||||
ECSB_UP_MOVE_SPEED = 1,
|
ECSB_UP_MOVE_SPEED = 1,
|
||||||
ECSB_UP_SWIM_SPEED = 2,
|
ECSB_UP_SWIM_SPEED = 2,
|
||||||
@ -88,11 +88,11 @@ enum {
|
|||||||
ECSB_FREEDOM = 18,
|
ECSB_FREEDOM = 18,
|
||||||
ECSB_BOUNDINGBALL = 19,
|
ECSB_BOUNDINGBALL = 19,
|
||||||
ECSB_INVULNERABLE = 20,
|
ECSB_INVULNERABLE = 20,
|
||||||
ECSB_STIMPAKSLOT1 = 21,
|
ECSB_STIMPAKSLOT1 = 21,
|
||||||
ECSB_STIMPAKSLOT2 = 22,
|
ECSB_STIMPAKSLOT2 = 22,
|
||||||
ECSB_STIMPAKSLOT3 = 23,
|
ECSB_STIMPAKSLOT3 = 23,
|
||||||
ECSB_HEAL = 24,
|
ECSB_HEAL = 24,
|
||||||
ECSB_EXTRABANK = 25,
|
ECSB_EXTRABANK = 25,
|
||||||
ECSTB__END = 26,
|
ECSTB__END = 26,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,32 +21,32 @@ void GroupManager::init() {
|
|||||||
void GroupManager::requestGroup(CNSocket* sock, CNPacketData* data) {
|
void GroupManager::requestGroup(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_GROUP_INVITE))
|
if (data->size != sizeof(sP_CL2FE_REQ_PC_GROUP_INVITE))
|
||||||
return; // malformed packet
|
return; // malformed packet
|
||||||
|
|
||||||
sP_CL2FE_REQ_PC_GROUP_INVITE* recv = (sP_CL2FE_REQ_PC_GROUP_INVITE*)data->buf;
|
sP_CL2FE_REQ_PC_GROUP_INVITE* recv = (sP_CL2FE_REQ_PC_GROUP_INVITE*)data->buf;
|
||||||
|
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
Player* otherPlr = PlayerManager::getPlayerFromID(recv->iID_To);
|
Player* otherPlr = PlayerManager::getPlayerFromID(recv->iID_To);
|
||||||
|
|
||||||
if (plr == nullptr || otherPlr == nullptr)
|
if (plr == nullptr || otherPlr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
otherPlr = PlayerManager::getPlayerFromID(otherPlr->iIDGroup);
|
otherPlr = PlayerManager::getPlayerFromID(otherPlr->iIDGroup);
|
||||||
|
|
||||||
if (otherPlr == nullptr)
|
if (otherPlr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// fail if the group is full or the other player is already in a group
|
// 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->groupCnt > 1) {
|
||||||
INITSTRUCT(sP_FE2CL_PC_GROUP_INVITE_FAIL, resp);
|
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));
|
sock->sendPacket((void*)&resp, P_FE2CL_PC_GROUP_INVITE_FAIL, sizeof(sP_FE2CL_PC_GROUP_INVITE_FAIL));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CNSocket* otherSock = PlayerManager::getSockFromID(recv->iID_To);
|
CNSocket* otherSock = PlayerManager::getSockFromID(recv->iID_To);
|
||||||
|
|
||||||
if (otherSock == nullptr)
|
if (otherSock == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_PC_GROUP_INVITE, resp);
|
INITSTRUCT(sP_FE2CL_PC_GROUP_INVITE, resp);
|
||||||
|
|
||||||
resp.iHostID = plr->iIDGroup;
|
resp.iHostID = plr->iIDGroup;
|
||||||
@ -57,21 +57,21 @@ void GroupManager::requestGroup(CNSocket* sock, CNPacketData* data) {
|
|||||||
void GroupManager::refuseGroup(CNSocket* sock, CNPacketData* data) {
|
void GroupManager::refuseGroup(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_GROUP_INVITE_REFUSE))
|
if (data->size != sizeof(sP_CL2FE_REQ_PC_GROUP_INVITE_REFUSE))
|
||||||
return; // malformed packet
|
return; // malformed packet
|
||||||
|
|
||||||
sP_CL2FE_REQ_PC_GROUP_INVITE_REFUSE* recv = (sP_CL2FE_REQ_PC_GROUP_INVITE_REFUSE*)data->buf;
|
sP_CL2FE_REQ_PC_GROUP_INVITE_REFUSE* recv = (sP_CL2FE_REQ_PC_GROUP_INVITE_REFUSE*)data->buf;
|
||||||
|
|
||||||
CNSocket* otherSock = PlayerManager::getSockFromID(recv->iID_From);
|
CNSocket* otherSock = PlayerManager::getSockFromID(recv->iID_From);
|
||||||
|
|
||||||
if (otherSock == nullptr)
|
if (otherSock == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_PC_GROUP_INVITE_REFUSE, resp);
|
INITSTRUCT(sP_FE2CL_PC_GROUP_INVITE_REFUSE, resp);
|
||||||
|
|
||||||
resp.iID_To = plr->iID;
|
resp.iID_To = plr->iID;
|
||||||
|
|
||||||
otherSock->sendPacket((void*)&resp, P_FE2CL_PC_GROUP_INVITE_REFUSE, sizeof(sP_FE2CL_PC_GROUP_INVITE_REFUSE));
|
otherSock->sendPacket((void*)&resp, P_FE2CL_PC_GROUP_INVITE_REFUSE, sizeof(sP_FE2CL_PC_GROUP_INVITE_REFUSE));
|
||||||
@ -80,52 +80,52 @@ void GroupManager::refuseGroup(CNSocket* sock, CNPacketData* data) {
|
|||||||
void GroupManager::joinGroup(CNSocket* sock, CNPacketData* data) {
|
void GroupManager::joinGroup(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_GROUP_JOIN))
|
if (data->size != sizeof(sP_CL2FE_REQ_PC_GROUP_JOIN))
|
||||||
return; // malformed packet
|
return; // malformed packet
|
||||||
|
|
||||||
sP_CL2FE_REQ_PC_GROUP_JOIN* recv = (sP_CL2FE_REQ_PC_GROUP_JOIN*)data->buf;
|
sP_CL2FE_REQ_PC_GROUP_JOIN* recv = (sP_CL2FE_REQ_PC_GROUP_JOIN*)data->buf;
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
Player* otherPlr = PlayerManager::getPlayerFromID(recv->iID_From);
|
Player* otherPlr = PlayerManager::getPlayerFromID(recv->iID_From);
|
||||||
|
|
||||||
if (plr == nullptr || otherPlr == nullptr)
|
if (plr == nullptr || otherPlr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
otherPlr = PlayerManager::getPlayerFromID(otherPlr->iIDGroup);
|
otherPlr = PlayerManager::getPlayerFromID(otherPlr->iIDGroup);
|
||||||
|
|
||||||
if (otherPlr == nullptr)
|
if (otherPlr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// fail if the group is full the other player is already in a group
|
// fail if the group is full the other player is already in a group
|
||||||
if (plr->groupCnt > 1 || plr->iIDGroup != plr->iID || otherPlr->groupCnt >= 4) {
|
if (plr->groupCnt > 1 || plr->iIDGroup != plr->iID || otherPlr->groupCnt >= 4) {
|
||||||
INITSTRUCT(sP_FE2CL_PC_GROUP_INVITE_FAIL, resp);
|
INITSTRUCT(sP_FE2CL_PC_GROUP_INVITE_FAIL, resp);
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_PC_GROUP_JOIN_FAIL, sizeof(sP_FE2CL_PC_GROUP_JOIN_FAIL));
|
sock->sendPacket((void*)&resp, P_FE2CL_PC_GROUP_JOIN_FAIL, sizeof(sP_FE2CL_PC_GROUP_JOIN_FAIL));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validOutVarPacket(sizeof(sP_FE2CL_PC_GROUP_JOIN), otherPlr->groupCnt + 1, sizeof(sPCGroupMemberInfo))) {
|
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";
|
std::cout << "[WARN] bad sP_FE2CL_PC_GROUP_JOIN packet size\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
plr->iIDGroup = otherPlr->iID;
|
plr->iIDGroup = otherPlr->iID;
|
||||||
otherPlr->groupCnt += 1;
|
otherPlr->groupCnt += 1;
|
||||||
otherPlr->groupIDs[otherPlr->groupCnt-1] = plr->iID;
|
otherPlr->groupIDs[otherPlr->groupCnt-1] = plr->iID;
|
||||||
|
|
||||||
size_t resplen = sizeof(sP_FE2CL_PC_GROUP_JOIN) + otherPlr->groupCnt * sizeof(sPCGroupMemberInfo);
|
size_t resplen = sizeof(sP_FE2CL_PC_GROUP_JOIN) + otherPlr->groupCnt * sizeof(sPCGroupMemberInfo);
|
||||||
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
||||||
|
|
||||||
memset(respbuf, 0, resplen);
|
memset(respbuf, 0, resplen);
|
||||||
|
|
||||||
sP_FE2CL_PC_GROUP_JOIN *resp = (sP_FE2CL_PC_GROUP_JOIN*)respbuf;
|
sP_FE2CL_PC_GROUP_JOIN *resp = (sP_FE2CL_PC_GROUP_JOIN*)respbuf;
|
||||||
sPCGroupMemberInfo *respdata = (sPCGroupMemberInfo*)(respbuf+sizeof(sP_FE2CL_PC_GROUP_JOIN));
|
sPCGroupMemberInfo *respdata = (sPCGroupMemberInfo*)(respbuf+sizeof(sP_FE2CL_PC_GROUP_JOIN));
|
||||||
|
|
||||||
resp->iID_NewMember = plr->iID;
|
resp->iID_NewMember = plr->iID;
|
||||||
resp->iMemberPCCnt = otherPlr->groupCnt;
|
resp->iMemberPCCnt = otherPlr->groupCnt;
|
||||||
|
|
||||||
for (int i = 0; i < otherPlr->groupCnt; i++) {
|
for (int i = 0; i < otherPlr->groupCnt; i++) {
|
||||||
Player* varPlr = PlayerManager::getPlayerFromID(otherPlr->groupIDs[i]);
|
Player* varPlr = PlayerManager::getPlayerFromID(otherPlr->groupIDs[i]);
|
||||||
|
|
||||||
if (varPlr == nullptr)
|
if (varPlr == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
respdata[i].iPC_ID = varPlr->iID;
|
respdata[i].iPC_ID = varPlr->iID;
|
||||||
respdata[i].iPCUID = varPlr->PCStyle.iPC_UID;
|
respdata[i].iPCUID = varPlr->PCStyle.iPC_UID;
|
||||||
respdata[i].iNameCheck = varPlr->PCStyle.iNameCheck;
|
respdata[i].iNameCheck = varPlr->PCStyle.iNameCheck;
|
||||||
@ -142,33 +142,33 @@ void GroupManager::joinGroup(CNSocket* sock, CNPacketData* data) {
|
|||||||
respdata[i].iZ = varPlr->z;
|
respdata[i].iZ = varPlr->z;
|
||||||
// client doesnt read nano data here
|
// client doesnt read nano data here
|
||||||
}
|
}
|
||||||
|
|
||||||
sendToGroup(otherPlr, (void*)&respbuf, P_FE2CL_PC_GROUP_JOIN, resplen);
|
sendToGroup(otherPlr, (void*)&respbuf, P_FE2CL_PC_GROUP_JOIN, resplen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupManager::leaveGroup(CNSocket* sock, CNPacketData* data) {
|
void GroupManager::leaveGroup(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(P_CL2FE_REQ_PC_GROUP_LEAVE))
|
if (data->size != sizeof(P_CL2FE_REQ_PC_GROUP_LEAVE))
|
||||||
return; // malformed packet
|
return; // malformed packet
|
||||||
|
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
groupKickPlayer(plr);
|
groupKickPlayer(plr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupManager::chatGroup(CNSocket* sock, CNPacketData* data) {
|
void GroupManager::chatGroup(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_SEND_ALL_GROUP_FREECHAT_MESSAGE))
|
if (data->size != sizeof(sP_CL2FE_REQ_SEND_ALL_GROUP_FREECHAT_MESSAGE))
|
||||||
return; // malformed packet
|
return; // malformed packet
|
||||||
|
|
||||||
sP_CL2FE_REQ_SEND_ALL_GROUP_FREECHAT_MESSAGE* chat = (sP_CL2FE_REQ_SEND_ALL_GROUP_FREECHAT_MESSAGE*)data->buf;
|
sP_CL2FE_REQ_SEND_ALL_GROUP_FREECHAT_MESSAGE* chat = (sP_CL2FE_REQ_SEND_ALL_GROUP_FREECHAT_MESSAGE*)data->buf;
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||||
|
|
||||||
if (plr == nullptr || otherPlr == nullptr)
|
if (plr == nullptr || otherPlr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// send to client
|
// send to client
|
||||||
INITSTRUCT(sP_FE2CL_REP_SEND_ALL_GROUP_FREECHAT_MESSAGE_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_SEND_ALL_GROUP_FREECHAT_MESSAGE_SUCC, resp);
|
||||||
memcpy(resp.szFreeChat, chat->szFreeChat, sizeof(chat->szFreeChat));
|
memcpy(resp.szFreeChat, chat->szFreeChat, sizeof(chat->szFreeChat));
|
||||||
@ -176,18 +176,18 @@ void GroupManager::chatGroup(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp.iEmoteCode = chat->iEmoteCode;
|
resp.iEmoteCode = chat->iEmoteCode;
|
||||||
sendToGroup(otherPlr, (void*)&resp, P_FE2CL_REP_SEND_ALL_GROUP_FREECHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_ALL_GROUP_FREECHAT_MESSAGE_SUCC));
|
sendToGroup(otherPlr, (void*)&resp, P_FE2CL_REP_SEND_ALL_GROUP_FREECHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_ALL_GROUP_FREECHAT_MESSAGE_SUCC));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupManager::menuChatGroup(CNSocket* sock, CNPacketData* data) {
|
void GroupManager::menuChatGroup(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_SEND_ALL_GROUP_MENUCHAT_MESSAGE))
|
if (data->size != sizeof(sP_CL2FE_REQ_SEND_ALL_GROUP_MENUCHAT_MESSAGE))
|
||||||
return; // malformed packet
|
return; // malformed packet
|
||||||
|
|
||||||
sP_CL2FE_REQ_SEND_ALL_GROUP_MENUCHAT_MESSAGE* chat = (sP_CL2FE_REQ_SEND_ALL_GROUP_MENUCHAT_MESSAGE*)data->buf;
|
sP_CL2FE_REQ_SEND_ALL_GROUP_MENUCHAT_MESSAGE* chat = (sP_CL2FE_REQ_SEND_ALL_GROUP_MENUCHAT_MESSAGE*)data->buf;
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||||
|
|
||||||
if (plr == nullptr || otherPlr == nullptr)
|
if (plr == nullptr || otherPlr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// send to client
|
// send to client
|
||||||
INITSTRUCT(sP_FE2CL_REP_SEND_ALL_GROUP_MENUCHAT_MESSAGE_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_SEND_ALL_GROUP_MENUCHAT_MESSAGE_SUCC, resp);
|
||||||
memcpy(resp.szFreeChat, chat->szFreeChat, sizeof(chat->szFreeChat));
|
memcpy(resp.szFreeChat, chat->szFreeChat, sizeof(chat->szFreeChat));
|
||||||
@ -198,16 +198,16 @@ void GroupManager::menuChatGroup(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
void GroupManager::sendToGroup(Player* plr, void* buf, uint32_t type, size_t size) {
|
void GroupManager::sendToGroup(Player* plr, void* buf, uint32_t type, size_t size) {
|
||||||
for (int i = 0; i < plr->groupCnt; i++) {
|
for (int i = 0; i < plr->groupCnt; i++) {
|
||||||
CNSocket* sock = PlayerManager::getSockFromID(plr->groupIDs[i]);
|
CNSocket* sock = PlayerManager::getSockFromID(plr->groupIDs[i]);
|
||||||
|
|
||||||
if (sock == nullptr)
|
if (sock == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (type == P_FE2CL_PC_GROUP_LEAVE_SUCC) {
|
if (type == P_FE2CL_PC_GROUP_LEAVE_SUCC) {
|
||||||
Player* leavingPlr = PlayerManager::getPlayer(sock);
|
Player* leavingPlr = PlayerManager::getPlayer(sock);
|
||||||
leavingPlr->iIDGroup = leavingPlr->iID;
|
leavingPlr->iIDGroup = leavingPlr->iID;
|
||||||
}
|
}
|
||||||
|
|
||||||
sock->sendPacket(buf, type, size);
|
sock->sendPacket(buf, type, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -217,24 +217,24 @@ void GroupManager::groupTickInfo(Player* plr) {
|
|||||||
std::cout << "[WARN] bad sP_FE2CL_PC_GROUP_JOIN packet size\n";
|
std::cout << "[WARN] bad sP_FE2CL_PC_GROUP_JOIN packet size\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t resplen = sizeof(sP_FE2CL_PC_GROUP_MEMBER_INFO) + plr->groupCnt * sizeof(sPCGroupMemberInfo);
|
size_t resplen = sizeof(sP_FE2CL_PC_GROUP_MEMBER_INFO) + plr->groupCnt * sizeof(sPCGroupMemberInfo);
|
||||||
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
||||||
|
|
||||||
memset(respbuf, 0, resplen);
|
memset(respbuf, 0, resplen);
|
||||||
|
|
||||||
sP_FE2CL_PC_GROUP_MEMBER_INFO *resp = (sP_FE2CL_PC_GROUP_MEMBER_INFO*)respbuf;
|
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));
|
sPCGroupMemberInfo *respdata = (sPCGroupMemberInfo*)(respbuf+sizeof(sP_FE2CL_PC_GROUP_MEMBER_INFO));
|
||||||
|
|
||||||
resp->iID = plr->iID;
|
resp->iID = plr->iID;
|
||||||
resp->iMemberPCCnt = plr->groupCnt;
|
resp->iMemberPCCnt = plr->groupCnt;
|
||||||
|
|
||||||
for (int i = 0; i < plr->groupCnt; i++) {
|
for (int i = 0; i < plr->groupCnt; i++) {
|
||||||
Player* varPlr = PlayerManager::getPlayerFromID(plr->groupIDs[i]);
|
Player* varPlr = PlayerManager::getPlayerFromID(plr->groupIDs[i]);
|
||||||
|
|
||||||
if (varPlr == nullptr)
|
if (varPlr == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
respdata[i].iPC_ID = varPlr->iID;
|
respdata[i].iPC_ID = varPlr->iID;
|
||||||
respdata[i].iPCUID = varPlr->PCStyle.iPC_UID;
|
respdata[i].iPCUID = varPlr->PCStyle.iPC_UID;
|
||||||
respdata[i].iNameCheck = varPlr->PCStyle.iNameCheck;
|
respdata[i].iNameCheck = varPlr->PCStyle.iNameCheck;
|
||||||
@ -254,7 +254,7 @@ void GroupManager::groupTickInfo(Player* plr) {
|
|||||||
respdata[i].Nano = varPlr->Nanos[varPlr->activeNano];
|
respdata[i].Nano = varPlr->Nanos[varPlr->activeNano];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sendToGroup(plr, (void*)&respbuf, P_FE2CL_PC_GROUP_MEMBER_INFO, resplen);
|
sendToGroup(plr, (void*)&respbuf, P_FE2CL_PC_GROUP_MEMBER_INFO, resplen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,42 +263,42 @@ void GroupManager::groupKickPlayer(Player* plr) {
|
|||||||
if (plr->iID == plr->iIDGroup) {
|
if (plr->iID == plr->iIDGroup) {
|
||||||
INITSTRUCT(sP_FE2CL_PC_GROUP_LEAVE_SUCC, resp1);
|
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));
|
sendToGroup(plr, (void*)&resp1, P_FE2CL_PC_GROUP_LEAVE_SUCC, sizeof(sP_FE2CL_PC_GROUP_LEAVE_SUCC));
|
||||||
plr->groupCnt = 1;
|
plr->groupCnt = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||||
|
|
||||||
if (otherPlr == nullptr)
|
if (otherPlr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!validOutVarPacket(sizeof(sP_FE2CL_PC_GROUP_LEAVE), otherPlr->groupCnt - 1, sizeof(sPCGroupMemberInfo))) {
|
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";
|
std::cout << "[WARN] bad sP_FE2CL_PC_GROUP_LEAVE packet size\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t resplen = sizeof(sP_FE2CL_PC_GROUP_LEAVE) + (otherPlr->groupCnt - 1) * sizeof(sPCGroupMemberInfo);
|
size_t resplen = sizeof(sP_FE2CL_PC_GROUP_LEAVE) + (otherPlr->groupCnt - 1) * sizeof(sPCGroupMemberInfo);
|
||||||
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
||||||
|
|
||||||
memset(respbuf, 0, resplen);
|
memset(respbuf, 0, resplen);
|
||||||
|
|
||||||
sP_FE2CL_PC_GROUP_LEAVE *resp = (sP_FE2CL_PC_GROUP_LEAVE*)respbuf;
|
sP_FE2CL_PC_GROUP_LEAVE *resp = (sP_FE2CL_PC_GROUP_LEAVE*)respbuf;
|
||||||
sPCGroupMemberInfo *respdata = (sPCGroupMemberInfo*)(respbuf+sizeof(sP_FE2CL_PC_GROUP_LEAVE));
|
sPCGroupMemberInfo *respdata = (sPCGroupMemberInfo*)(respbuf+sizeof(sP_FE2CL_PC_GROUP_LEAVE));
|
||||||
|
|
||||||
resp->iID_LeaveMember = plr->iID;
|
resp->iID_LeaveMember = plr->iID;
|
||||||
resp->iMemberPCCnt = otherPlr->groupCnt - 1;
|
resp->iMemberPCCnt = otherPlr->groupCnt - 1;
|
||||||
|
|
||||||
int moveDown = 0;
|
int moveDown = 0;
|
||||||
|
|
||||||
for (int i = 0; i < otherPlr->groupCnt; i++) {
|
for (int i = 0; i < otherPlr->groupCnt; i++) {
|
||||||
Player* varPlr = PlayerManager::getPlayerFromID(otherPlr->groupIDs[i]);
|
Player* varPlr = PlayerManager::getPlayerFromID(otherPlr->groupIDs[i]);
|
||||||
|
|
||||||
if (varPlr == nullptr)
|
if (varPlr == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (moveDown == 1)
|
if (moveDown == 1)
|
||||||
otherPlr->groupIDs[i-1] = otherPlr->groupIDs[i];
|
otherPlr->groupIDs[i-1] = otherPlr->groupIDs[i];
|
||||||
|
|
||||||
respdata[i-moveDown].iPC_ID = varPlr->iID;
|
respdata[i-moveDown].iPC_ID = varPlr->iID;
|
||||||
respdata[i-moveDown].iPCUID = varPlr->PCStyle.iPC_UID;
|
respdata[i-moveDown].iPCUID = varPlr->PCStyle.iPC_UID;
|
||||||
respdata[i-moveDown].iNameCheck = varPlr->PCStyle.iNameCheck;
|
respdata[i-moveDown].iNameCheck = varPlr->PCStyle.iNameCheck;
|
||||||
@ -314,23 +314,23 @@ void GroupManager::groupKickPlayer(Player* plr) {
|
|||||||
respdata[i-moveDown].iY = varPlr->y;
|
respdata[i-moveDown].iY = varPlr->y;
|
||||||
respdata[i-moveDown].iZ = varPlr->z;
|
respdata[i-moveDown].iZ = varPlr->z;
|
||||||
// client doesnt read nano data here
|
// client doesnt read nano data here
|
||||||
|
|
||||||
if (varPlr == plr) {
|
if (varPlr == plr) {
|
||||||
moveDown = 1;
|
moveDown = 1;
|
||||||
otherPlr->groupIDs[i] = 0;
|
otherPlr->groupIDs[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plr->iIDGroup = plr->iID;
|
plr->iIDGroup = plr->iID;
|
||||||
otherPlr->groupCnt -= 1;
|
otherPlr->groupCnt -= 1;
|
||||||
|
|
||||||
sendToGroup(otherPlr, (void*)&respbuf, P_FE2CL_PC_GROUP_LEAVE, resplen);
|
sendToGroup(otherPlr, (void*)&respbuf, P_FE2CL_PC_GROUP_LEAVE, resplen);
|
||||||
|
|
||||||
CNSocket* sock = PlayerManager::getSockFromID(plr->iID);
|
CNSocket* sock = PlayerManager::getSockFromID(plr->iID);
|
||||||
|
|
||||||
if (sock == nullptr)
|
if (sock == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_PC_GROUP_LEAVE_SUCC, resp1);
|
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));
|
sock->sendPacket((void*)&resp1, P_FE2CL_PC_GROUP_LEAVE_SUCC, sizeof(sP_FE2CL_PC_GROUP_LEAVE_SUCC));
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
namespace GroupManager {
|
namespace GroupManager {
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
void requestGroup(CNSocket* sock, CNPacketData* data);
|
void requestGroup(CNSocket* sock, CNPacketData* data);
|
||||||
void refuseGroup(CNSocket* sock, CNPacketData* data);
|
void refuseGroup(CNSocket* sock, CNPacketData* data);
|
||||||
void joinGroup(CNSocket* sock, CNPacketData* data);
|
void joinGroup(CNSocket* sock, CNPacketData* data);
|
||||||
|
@ -151,7 +151,7 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
// send equip event to other players
|
// send equip event to other players
|
||||||
PlayerManager::sendToViewable(sock, (void*)&equipChange, P_FE2CL_PC_EQUIP_CHANGE, sizeof(sP_FE2CL_PC_EQUIP_CHANGE));
|
PlayerManager::sendToViewable(sock, (void*)&equipChange, P_FE2CL_PC_EQUIP_CHANGE, sizeof(sP_FE2CL_PC_EQUIP_CHANGE));
|
||||||
|
|
||||||
// set equipment stats serverside
|
// set equipment stats serverside
|
||||||
setItemStats(plr.plr);
|
setItemStats(plr.plr);
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
// send response
|
// send response
|
||||||
resp.eTo = itemmove->eFrom;
|
resp.eTo = itemmove->eFrom;
|
||||||
resp.eFrom = itemmove->eTo;
|
resp.eFrom = itemmove->eTo;
|
||||||
|
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_PC_ITEM_MOVE_SUCC, sizeof(sP_FE2CL_PC_ITEM_MOVE_SUCC));
|
sock->sendPacket((void*)&resp, P_FE2CL_PC_ITEM_MOVE_SUCC, sizeof(sP_FE2CL_PC_ITEM_MOVE_SUCC));
|
||||||
}
|
}
|
||||||
@ -876,7 +876,7 @@ void ItemManager::checkItemExpire(CNSocket* sock, Player* player) {
|
|||||||
const size_t resplen = sizeof(sP_FE2CL_PC_DELETE_TIME_LIMIT_ITEM) + sizeof(sTimeLimitItemDeleteInfo2CL);
|
const size_t resplen = sizeof(sP_FE2CL_PC_DELETE_TIME_LIMIT_ITEM) + sizeof(sTimeLimitItemDeleteInfo2CL);
|
||||||
assert(resplen < CN_PACKET_BUFFER_SIZE - 8);
|
assert(resplen < CN_PACKET_BUFFER_SIZE - 8);
|
||||||
// we know it's only one trailing struct, so we can skip full validation
|
// we know it's only one trailing struct, so we can skip full validation
|
||||||
uint8_t respbuf[resplen]; // not a variable length array, don't worry
|
uint8_t respbuf[resplen]; // not a variable length array, don't worry
|
||||||
sP_FE2CL_PC_DELETE_TIME_LIMIT_ITEM* packet = (sP_FE2CL_PC_DELETE_TIME_LIMIT_ITEM*)respbuf;
|
sP_FE2CL_PC_DELETE_TIME_LIMIT_ITEM* packet = (sP_FE2CL_PC_DELETE_TIME_LIMIT_ITEM*)respbuf;
|
||||||
sTimeLimitItemDeleteInfo2CL* itemData = (sTimeLimitItemDeleteInfo2CL*)(respbuf + sizeof(sP_FE2CL_PC_DELETE_TIME_LIMIT_ITEM));
|
sTimeLimitItemDeleteInfo2CL* itemData = (sTimeLimitItemDeleteInfo2CL*)(respbuf + sizeof(sP_FE2CL_PC_DELETE_TIME_LIMIT_ITEM));
|
||||||
memset(respbuf, 0, resplen);
|
memset(respbuf, 0, resplen);
|
||||||
@ -885,7 +885,7 @@ void ItemManager::checkItemExpire(CNSocket* sock, Player* player) {
|
|||||||
itemData->eIL = player->toRemoveVehicle.eIL;
|
itemData->eIL = player->toRemoveVehicle.eIL;
|
||||||
itemData->iSlotNum = player->toRemoveVehicle.iSlotNum;
|
itemData->iSlotNum = player->toRemoveVehicle.iSlotNum;
|
||||||
sock->sendPacket((void*)&respbuf, P_FE2CL_PC_DELETE_TIME_LIMIT_ITEM, resplen);
|
sock->sendPacket((void*)&respbuf, P_FE2CL_PC_DELETE_TIME_LIMIT_ITEM, resplen);
|
||||||
|
|
||||||
// delete serverside
|
// delete serverside
|
||||||
if (player->toRemoveVehicle.eIL == 0)
|
if (player->toRemoveVehicle.eIL == 0)
|
||||||
memset(&player->Equip[8], 0, sizeof(sItemBase));
|
memset(&player->Equip[8], 0, sizeof(sItemBase));
|
||||||
@ -910,7 +910,7 @@ void ItemManager::setItemStats(Player* plr) {
|
|||||||
plr->groupDamage += itemStatsDat->groupDamage;
|
plr->groupDamage += itemStatsDat->groupDamage;
|
||||||
plr->defense += itemStatsDat->defense;
|
plr->defense += itemStatsDat->defense;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK: work around the invisible weapon bug
|
// HACK: work around the invisible weapon bug
|
||||||
void ItemManager::updateEquips(CNSocket* sock, Player* plr) {
|
void ItemManager::updateEquips(CNSocket* sock, Player* plr) {
|
||||||
@ -920,7 +920,7 @@ void ItemManager::updateEquips(CNSocket* sock, Player* plr) {
|
|||||||
resp.iPC_ID = plr->iID;
|
resp.iPC_ID = plr->iID;
|
||||||
resp.iEquipSlotNum = i;
|
resp.iEquipSlotNum = i;
|
||||||
resp.EquipSlotItem = plr->Equip[i];
|
resp.EquipSlotItem = plr->Equip[i];
|
||||||
|
|
||||||
PlayerManager::sendToViewable(sock, (void*)&resp, P_FE2CL_PC_EQUIP_CHANGE, sizeof(sP_FE2CL_PC_EQUIP_CHANGE));
|
PlayerManager::sendToViewable(sock, (void*)&resp, P_FE2CL_PC_EQUIP_CHANGE, sizeof(sP_FE2CL_PC_EQUIP_CHANGE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ namespace ItemManager {
|
|||||||
extern std::map<int32_t, std::vector<VendorListing>> VendorTables;
|
extern std::map<int32_t, std::vector<VendorListing>> VendorTables;
|
||||||
extern std::map<int32_t, CrocPotEntry> CrocPotTable; // level gap -> entry
|
extern std::map<int32_t, CrocPotEntry> CrocPotTable; // level gap -> entry
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
void itemMoveHandler(CNSocket* sock, CNPacketData* data);
|
void itemMoveHandler(CNSocket* sock, CNPacketData* data);
|
||||||
void itemDeleteHandler(CNSocket* sock, CNPacketData* data);
|
void itemDeleteHandler(CNSocket* sock, CNPacketData* data);
|
||||||
|
@ -23,7 +23,7 @@ bool startTask(Player* plr, int TaskID, bool NanoMission) {
|
|||||||
std::cout << "[WARN] Player submitted unknown task!?" << std::endl;
|
std::cout << "[WARN] Player submitted unknown task!?" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// client freaks out if nano mission isn't sent first after reloging, so it's easiest to set it here
|
// client freaks out if nano mission isn't sent first after reloging, so it's easiest to set it here
|
||||||
if (NanoMission && plr->tasks[0] != 0) {
|
if (NanoMission && plr->tasks[0] != 0) {
|
||||||
// lets move task0 to different spot
|
// lets move task0 to different spot
|
||||||
@ -76,7 +76,7 @@ void MissionManager::taskStart(CNSocket* sock, CNPacketData* data) {
|
|||||||
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_TASK_START_SUCC, sizeof(sP_FE2CL_REP_PC_TASK_START_SUCC));
|
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_TASK_START_SUCC, sizeof(sP_FE2CL_REP_PC_TASK_START_SUCC));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
response.iTaskNum = missionData->iTaskNum;
|
response.iTaskNum = missionData->iTaskNum;
|
||||||
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_TASK_START_SUCC, sizeof(sP_FE2CL_REP_PC_TASK_START_SUCC));
|
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_TASK_START_SUCC, sizeof(sP_FE2CL_REP_PC_TASK_START_SUCC));
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ void MissionManager::setMission(CNSocket* sock, CNPacketData* data) {
|
|||||||
return; // malformed packet
|
return; // malformed packet
|
||||||
|
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ void MissionManager::dropQuestItem(CNSocket *sock, int task, int count, int id,
|
|||||||
const size_t resplen = sizeof(sP_FE2CL_REP_REWARD_ITEM) + sizeof(sItemReward);
|
const size_t resplen = sizeof(sP_FE2CL_REP_REWARD_ITEM) + sizeof(sItemReward);
|
||||||
assert(resplen < CN_PACKET_BUFFER_SIZE);
|
assert(resplen < CN_PACKET_BUFFER_SIZE);
|
||||||
// we know it's only one trailing struct, so we can skip full validation
|
// we know it's only one trailing struct, so we can skip full validation
|
||||||
|
|
||||||
Player *plr = PlayerManager::getPlayer(sock);
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
@ -423,7 +423,7 @@ void MissionManager::mobKilled(CNSocket *sock, int mobid) {
|
|||||||
|
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool missionmob = false;
|
bool missionmob = false;
|
||||||
|
|
||||||
for (int i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
for (int i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
||||||
|
@ -272,7 +272,7 @@ void MobManager::combatStep(Mob *mob, time_t currTime) {
|
|||||||
aggroCheck(mob, currTime);
|
aggroCheck(mob, currTime);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player *plr = PlayerManager::getPlayer(mob->target);
|
Player *plr = PlayerManager::getPlayer(mob->target);
|
||||||
|
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
@ -396,7 +396,7 @@ void MobManager::retreatStep(Mob *mob, time_t currTime) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
mob->nextMovement = currTime + 500;
|
mob->nextMovement = currTime + 500;
|
||||||
|
|
||||||
int distance = hypot(mob->appearanceData.iX - mob->spawnX, mob->appearanceData.iY - mob->spawnY);
|
int distance = hypot(mob->appearanceData.iX - mob->spawnX, mob->appearanceData.iY - mob->spawnY);
|
||||||
|
|
||||||
if (distance > mob->data["m_iIdleRange"]) {
|
if (distance > mob->data["m_iIdleRange"]) {
|
||||||
@ -421,7 +421,7 @@ void MobManager::retreatStep(Mob *mob, time_t currTime) {
|
|||||||
mob->killedTime = 0;
|
mob->killedTime = 0;
|
||||||
mob->nextAttack = 0;
|
mob->nextAttack = 0;
|
||||||
mob->appearanceData.iConditionBitFlag = 0;
|
mob->appearanceData.iConditionBitFlag = 0;
|
||||||
|
|
||||||
resendMobHP(mob);
|
resendMobHP(mob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -478,18 +478,18 @@ std::pair<int,int> MobManager::lerp(int x1, int y1, int x2, int y2, int speed) {
|
|||||||
std::pair<int,int> ret = {x1, y1};
|
std::pair<int,int> ret = {x1, y1};
|
||||||
|
|
||||||
speed /= 2;
|
speed /= 2;
|
||||||
|
|
||||||
if (speed == 0)
|
if (speed == 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
int distance = hypot(x1 - x2, y1 - y2);
|
int distance = hypot(x1 - x2, y1 - y2);
|
||||||
|
|
||||||
if (distance > speed) {
|
if (distance > speed) {
|
||||||
|
|
||||||
int lerps = distance / speed;
|
int lerps = distance / speed;
|
||||||
|
|
||||||
// interpolate only the first point
|
// interpolate only the first point
|
||||||
float frac = 1.0f / lerps;
|
float frac = 1.0f / lerps;
|
||||||
|
|
||||||
ret.first = (x1 + (x2 - x1) * frac);
|
ret.first = (x1 + (x2 - x1) * frac);
|
||||||
ret.second = (y1 + (y2 - y1) * frac);
|
ret.second = (y1 + (y2 - y1) * frac);
|
||||||
@ -510,14 +510,14 @@ void MobManager::combatBegin(CNSocket *sock, CNPacketData *data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plr->inCombat = true;
|
plr->inCombat = true;
|
||||||
|
|
||||||
// HACK: make sure the player has the right weapon out for combat
|
// HACK: make sure the player has the right weapon out for combat
|
||||||
INITSTRUCT(sP_FE2CL_PC_EQUIP_CHANGE, resp);
|
INITSTRUCT(sP_FE2CL_PC_EQUIP_CHANGE, resp);
|
||||||
|
|
||||||
resp.iPC_ID = plr->iID;
|
resp.iPC_ID = plr->iID;
|
||||||
resp.iEquipSlotNum = 0;
|
resp.iEquipSlotNum = 0;
|
||||||
resp.EquipSlotItem = plr->Equip[0];
|
resp.EquipSlotItem = plr->Equip[0];
|
||||||
|
|
||||||
PlayerManager::sendToViewable(sock, (void*)&resp, P_FE2CL_PC_EQUIP_CHANGE, sizeof(sP_FE2CL_PC_EQUIP_CHANGE));
|
PlayerManager::sendToViewable(sock, (void*)&resp, P_FE2CL_PC_EQUIP_CHANGE, sizeof(sP_FE2CL_PC_EQUIP_CHANGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,7 +539,7 @@ void MobManager::dotDamageOnOff(CNSocket *sock, CNPacketData *data) {
|
|||||||
|
|
||||||
if ((plr->iConditionBitFlag & CSB_BIT_INFECTION) != (bool)pkt->iFlag)
|
if ((plr->iConditionBitFlag & CSB_BIT_INFECTION) != (bool)pkt->iFlag)
|
||||||
plr->iConditionBitFlag ^= CSB_BIT_INFECTION;
|
plr->iConditionBitFlag ^= CSB_BIT_INFECTION;
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, pkt1);
|
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, pkt1);
|
||||||
|
|
||||||
pkt1.eCSTB = ECSB_INFECTION; //eCharStatusTimeBuffID
|
pkt1.eCSTB = ECSB_INFECTION; //eCharStatusTimeBuffID
|
||||||
@ -555,7 +555,7 @@ void MobManager::dealGooDamage(CNSocket *sock, int amount) {
|
|||||||
assert(resplen < CN_PACKET_BUFFER_SIZE - 8);
|
assert(resplen < CN_PACKET_BUFFER_SIZE - 8);
|
||||||
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
||||||
Player *plr = PlayerManager::getPlayer(sock);
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -606,7 +606,7 @@ void MobManager::playerTick(CNServer *serv, time_t currTime) {
|
|||||||
CNSocket *sock = pair.first;
|
CNSocket *sock = pair.first;
|
||||||
Player *plr = pair.second.plr;
|
Player *plr = pair.second.plr;
|
||||||
bool transmit = false;
|
bool transmit = false;
|
||||||
|
|
||||||
// group ticks
|
// group ticks
|
||||||
if (plr->groupCnt > 1)
|
if (plr->groupCnt > 1)
|
||||||
GroupManager::groupTickInfo(plr);
|
GroupManager::groupTickInfo(plr);
|
||||||
@ -614,7 +614,7 @@ void MobManager::playerTick(CNServer *serv, time_t currTime) {
|
|||||||
// do not tick dead players
|
// do not tick dead players
|
||||||
if (plr->HP <= 0)
|
if (plr->HP <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// fm patch/lake damage
|
// fm patch/lake damage
|
||||||
if (plr->iConditionBitFlag & CSB_BIT_INFECTION)
|
if (plr->iConditionBitFlag & CSB_BIT_INFECTION)
|
||||||
dealGooDamage(sock, PC_MAXHEALTH(plr->level) * 3 / 20);
|
dealGooDamage(sock, PC_MAXHEALTH(plr->level) * 3 / 20);
|
||||||
@ -630,9 +630,9 @@ void MobManager::playerTick(CNServer *serv, time_t currTime) {
|
|||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if (plr->activeNano != 0 && plr->equippedNanos[i] == plr->activeNano) { // spend stamina
|
if (plr->activeNano != 0 && plr->equippedNanos[i] == plr->activeNano) { // spend stamina
|
||||||
plr->Nanos[plr->activeNano].iStamina -= 1;
|
plr->Nanos[plr->activeNano].iStamina -= 1;
|
||||||
|
|
||||||
if (plr->passiveNanoOut)
|
if (plr->passiveNanoOut)
|
||||||
plr->Nanos[plr->activeNano].iStamina -= 1;
|
plr->Nanos[plr->activeNano].iStamina -= 1;
|
||||||
|
|
||||||
if (plr->Nanos[plr->activeNano].iStamina <= 0) {
|
if (plr->Nanos[plr->activeNano].iStamina <= 0) {
|
||||||
plr->Nanos[plr->activeNano].iStamina = 0;
|
plr->Nanos[plr->activeNano].iStamina = 0;
|
||||||
@ -733,9 +733,9 @@ void MobManager::pcAttackChars(CNSocket *sock, CNPacketData *data) {
|
|||||||
std::cout << "[WARN] pcAttackChars: player ID not found" << std::endl;
|
std::cout << "[WARN] pcAttackChars: player ID not found" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<int,int> damage;
|
std::pair<int,int> damage;
|
||||||
|
|
||||||
if (pkt->iTargetCnt > 1)
|
if (pkt->iTargetCnt > 1)
|
||||||
damage = getDamage(plr->groupDamage, target->defense, true, 1);
|
damage = getDamage(plr->groupDamage, target->defense, true, 1);
|
||||||
else
|
else
|
||||||
@ -817,22 +817,22 @@ bool MobManager::aggroCheck(Mob *mob, time_t currTime) {
|
|||||||
for (Chunk *chunk : mob->currentChunks) {
|
for (Chunk *chunk : mob->currentChunks) {
|
||||||
for (CNSocket *s : chunk->players) {
|
for (CNSocket *s : chunk->players) {
|
||||||
Player *plr = s->plr;
|
Player *plr = s->plr;
|
||||||
|
|
||||||
if (plr->HP <= 0)
|
if (plr->HP <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int mobRange = mob->data["m_iSightRange"];
|
int mobRange = mob->data["m_iSightRange"];
|
||||||
|
|
||||||
if (plr->iConditionBitFlag & CSB_BIT_UP_STEALTH)
|
if (plr->iConditionBitFlag & CSB_BIT_UP_STEALTH)
|
||||||
mobRange /= 3;
|
mobRange /= 3;
|
||||||
|
|
||||||
if (plr->iSpecialState & CN_SPECIAL_STATE_FLAG__INVISIBLE)
|
if (plr->iSpecialState & CN_SPECIAL_STATE_FLAG__INVISIBLE)
|
||||||
mobRange = -1;
|
mobRange = -1;
|
||||||
|
|
||||||
// height is relevant for aggro distance because of platforming
|
// height is relevant for aggro distance because of platforming
|
||||||
int xyDistance = hypot(mob->appearanceData.iX - plr->x, mob->appearanceData.iY - plr->y);
|
int xyDistance = hypot(mob->appearanceData.iX - plr->x, mob->appearanceData.iY - plr->y);
|
||||||
int distance = hypot(xyDistance, mob->appearanceData.iZ - plr->z);
|
int distance = hypot(xyDistance, mob->appearanceData.iZ - plr->z);
|
||||||
|
|
||||||
if (distance > mobRange)
|
if (distance > mobRange)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -119,14 +119,14 @@ void NPCManager::destroyNPC(int32_t id) {
|
|||||||
// remove NPC from the chunk
|
// remove NPC from the chunk
|
||||||
Chunk* chunk = ChunkManager::chunks[entity->chunkPos];
|
Chunk* chunk = ChunkManager::chunks[entity->chunkPos];
|
||||||
chunk->NPCs.erase(id);
|
chunk->NPCs.erase(id);
|
||||||
|
|
||||||
// remove from viewable chunks
|
// remove from viewable chunks
|
||||||
removeNPC(entity->currentChunks, id);
|
removeNPC(entity->currentChunks, id);
|
||||||
|
|
||||||
// remove from mob manager
|
// remove from mob manager
|
||||||
if (MobManager::Mobs.find(id) != MobManager::Mobs.end())
|
if (MobManager::Mobs.find(id) != MobManager::Mobs.end())
|
||||||
MobManager::Mobs.erase(id);
|
MobManager::Mobs.erase(id);
|
||||||
|
|
||||||
// finally, remove it from the map and free it
|
// finally, remove it from the map and free it
|
||||||
NPCs.erase(id);
|
NPCs.erase(id);
|
||||||
delete entity;
|
delete entity;
|
||||||
@ -257,7 +257,7 @@ void NPCManager::npcVendorSell(CNSocket* sock, CNPacketData* data) {
|
|||||||
memcpy(&original, item, sizeof(sItemBase));
|
memcpy(&original, item, sizeof(sItemBase));
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_SUCC, resp);
|
||||||
|
|
||||||
int sellValue = itemData->sellPrice * req->iItemCnt;
|
int sellValue = itemData->sellPrice * req->iItemCnt;
|
||||||
|
|
||||||
// increment taros
|
// increment taros
|
||||||
@ -338,7 +338,7 @@ void NPCManager::npcVendorTable(CNSocket* sock, CNPacketData* data) {
|
|||||||
return; // malformed packet
|
return; // malformed packet
|
||||||
|
|
||||||
sP_CL2FE_REQ_PC_VENDOR_TABLE_UPDATE* req = (sP_CL2FE_REQ_PC_VENDOR_TABLE_UPDATE*)data->buf;
|
sP_CL2FE_REQ_PC_VENDOR_TABLE_UPDATE* req = (sP_CL2FE_REQ_PC_VENDOR_TABLE_UPDATE*)data->buf;
|
||||||
|
|
||||||
if (req->iVendorID != req->iNPC_ID || ItemManager::VendorTables.find(req->iNPC_ID) == ItemManager::VendorTables.end())
|
if (req->iVendorID != req->iNPC_ID || ItemManager::VendorTables.find(req->iNPC_ID) == ItemManager::VendorTables.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -423,7 +423,7 @@ void NPCManager::npcCombineItems(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (req->iCostumeItemSlot < 0 || req->iCostumeItemSlot >= AINVEN_COUNT || req->iStatItemSlot < 0 || req->iStatItemSlot >= AINVEN_COUNT) { // sanity check 1
|
if (req->iCostumeItemSlot < 0 || req->iCostumeItemSlot >= AINVEN_COUNT || req->iStatItemSlot < 0 || req->iStatItemSlot >= AINVEN_COUNT) { // sanity check 1
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_ITEM_COMBINATION_FAIL, failResp);
|
INITSTRUCT(sP_FE2CL_REP_PC_ITEM_COMBINATION_FAIL, failResp);
|
||||||
failResp.iCostumeItemSlot = req->iCostumeItemSlot;
|
failResp.iCostumeItemSlot = req->iCostumeItemSlot;
|
||||||
@ -502,7 +502,7 @@ void NPCManager::npcCombineItems(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp.iNewItemSlot = req->iCostumeItemSlot;
|
resp.iNewItemSlot = req->iCostumeItemSlot;
|
||||||
resp.iStatItemSlot = req->iStatItemSlot;
|
resp.iStatItemSlot = req->iStatItemSlot;
|
||||||
resp.sNewItem = *itemLooks;
|
resp.sNewItem = *itemLooks;
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_ITEM_COMBINATION_SUCC, sizeof(sP_FE2CL_REP_PC_ITEM_COMBINATION_SUCC));
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_ITEM_COMBINATION_SUCC, sizeof(sP_FE2CL_REP_PC_ITEM_COMBINATION_SUCC));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -516,7 +516,7 @@ void NPCManager::npcUnsummonHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
if (plr == nullptr || plr->accountLevel > 30)
|
if (plr == nullptr || plr->accountLevel > 30)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sP_CL2FE_REQ_NPC_UNSUMMON* req = (sP_CL2FE_REQ_NPC_UNSUMMON*)data->buf;
|
sP_CL2FE_REQ_NPC_UNSUMMON* req = (sP_CL2FE_REQ_NPC_UNSUMMON*)data->buf;
|
||||||
NPCManager::destroyNPC(req->iNPC_ID);
|
NPCManager::destroyNPC(req->iNPC_ID);
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ void NanoManager::nanoSkillUseHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
int16_t nanoId = plr->activeNano;
|
int16_t nanoId = plr->activeNano;
|
||||||
int16_t skillId = plr->Nanos[nanoId].iSkillID;
|
int16_t skillId = plr->Nanos[nanoId].iSkillID;
|
||||||
|
|
||||||
DEBUGLOG(
|
DEBUGLOG(
|
||||||
std::cout << U16toU8(plr->PCStyle.szFirstName) << U16toU8(plr->PCStyle.szLastName) << " requested to summon nano skill " << std::endl;
|
std::cout << U16toU8(plr->PCStyle.szFirstName) << U16toU8(plr->PCStyle.szLastName) << " requested to summon nano skill " << std::endl;
|
||||||
)
|
)
|
||||||
@ -160,22 +160,22 @@ void NanoManager::nanoSkillUseHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
for (auto& pwr : ActivePowers)
|
for (auto& pwr : ActivePowers)
|
||||||
if (pwr.powers.count(skillId)) // std::set's contains method is C++20 only...
|
if (pwr.powers.count(skillId)) // std::set's contains method is C++20 only...
|
||||||
pwr.handle(sock, data, nanoId, skillId);
|
pwr.handle(sock, data, nanoId, skillId);
|
||||||
|
|
||||||
// Group Revive is handled separately (XXX: move into table?)
|
// Group Revive is handled separately (XXX: move into table?)
|
||||||
if (GroupRevivePowers.find(skillId) == GroupRevivePowers.end())
|
if (GroupRevivePowers.find(skillId) == GroupRevivePowers.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player *leader = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
Player *leader = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||||
|
|
||||||
if (leader == nullptr)
|
if (leader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < leader->groupCnt; i++) {
|
for (int i = 0; i < leader->groupCnt; i++) {
|
||||||
Player* varPlr = PlayerManager::getPlayerFromID(leader->groupIDs[i]);
|
Player* varPlr = PlayerManager::getPlayerFromID(leader->groupIDs[i]);
|
||||||
|
|
||||||
if (varPlr == nullptr)
|
if (varPlr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (varPlr->HP <= 0)
|
if (varPlr->HP <= 0)
|
||||||
revivePlayer(varPlr);
|
revivePlayer(varPlr);
|
||||||
}
|
}
|
||||||
@ -200,7 +200,7 @@ void NanoManager::nanoSkillSetGMHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
void NanoManager::nanoRecallHandler(CNSocket* sock, CNPacketData* data) {
|
void NanoManager::nanoRecallHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_WARP_USE_RECALL))
|
if (data->size != sizeof(sP_CL2FE_REQ_WARP_USE_RECALL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_WARP_USE_RECALL_FAIL, resp);
|
INITSTRUCT(sP_FE2CL_REP_WARP_USE_RECALL_FAIL, resp);
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_WARP_USE_RECALL_FAIL, sizeof(sP_FE2CL_REP_WARP_USE_RECALL_FAIL));
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_WARP_USE_RECALL_FAIL, sizeof(sP_FE2CL_REP_WARP_USE_RECALL_FAIL));
|
||||||
@ -210,9 +210,9 @@ void NanoManager::nanoRecallHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
void NanoManager::nanoPotionHandler(CNSocket* sock, CNPacketData* data) {
|
void NanoManager::nanoPotionHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_CHARGE_NANO_STAMINA))
|
if (data->size != sizeof(sP_CL2FE_REQ_CHARGE_NANO_STAMINA))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player* player = PlayerManager::getPlayer(sock);
|
Player* player = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
// sanity checks
|
// sanity checks
|
||||||
if (player == nullptr || player->activeNano == -1 || player->batteryN == 0)
|
if (player == nullptr || player->activeNano == -1 || player->batteryN == 0)
|
||||||
return;
|
return;
|
||||||
@ -255,7 +255,7 @@ void NanoManager::addNano(CNSocket* sock, int16_t nanoId, int16_t slot, bool spe
|
|||||||
* Doing it the other way always leaves the FM at 0. Jade totally called it.
|
* Doing it the other way always leaves the FM at 0. Jade totally called it.
|
||||||
*/
|
*/
|
||||||
plr->level = level;
|
plr->level = level;
|
||||||
|
|
||||||
if (spendfm)
|
if (spendfm)
|
||||||
MissionManager::updateFusionMatter(sock, -(int)MissionManager::AvatarGrowth[plr->level-1]["m_iReqBlob_NanoCreate"]);
|
MissionManager::updateFusionMatter(sock, -(int)MissionManager::AvatarGrowth[plr->level-1]["m_iReqBlob_NanoCreate"]);
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ void NanoManager::addNano(CNSocket* sock, int16_t nanoId, int16_t slot, bool spe
|
|||||||
|
|
||||||
if (plr->activeNano > 0 && plr->activeNano == nanoId)
|
if (plr->activeNano > 0 && plr->activeNano == nanoId)
|
||||||
summonNano(sock, -1); // just unsummon the nano to prevent infinite buffs
|
summonNano(sock, -1); // just unsummon the nano to prevent infinite buffs
|
||||||
|
|
||||||
// Update player
|
// Update player
|
||||||
plr->Nanos[nanoId] = resp.Nano;
|
plr->Nanos[nanoId] = resp.Nano;
|
||||||
|
|
||||||
@ -303,22 +303,22 @@ void NanoManager::summonNano(CNSocket *sock, int slot) {
|
|||||||
|
|
||||||
if (nanoId > 36 || nanoId < -1)
|
if (nanoId > 36 || nanoId < -1)
|
||||||
return; // sanity check
|
return; // sanity check
|
||||||
|
|
||||||
int16_t skillId = 0;
|
int16_t skillId = 0;
|
||||||
|
|
||||||
if (plr->activeNano > 0)
|
if (plr->activeNano > 0)
|
||||||
for (auto& pwr : PassivePowers)
|
for (auto& pwr : PassivePowers)
|
||||||
if (pwr.powers.count(plr->Nanos[plr->activeNano].iSkillID)) { // std::set's contains method is C++20 only...
|
if (pwr.powers.count(plr->Nanos[plr->activeNano].iSkillID)) { // std::set's contains method is C++20 only...
|
||||||
nanoUnbuff(sock, pwr.iCBFlag, pwr.eCharStatusTimeBuffID, pwr.iValue, pwr.groupPower);
|
nanoUnbuff(sock, pwr.iCBFlag, pwr.eCharStatusTimeBuffID, pwr.iValue, pwr.groupPower);
|
||||||
plr->passiveNanoOut = false;
|
plr->passiveNanoOut = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sNano nano = plr->Nanos[nanoId];
|
sNano nano = plr->Nanos[nanoId];
|
||||||
skillId = nano.iSkillID;
|
skillId = nano.iSkillID;
|
||||||
|
|
||||||
if (slot > -1) {
|
if (slot > -1) {
|
||||||
plr->activeNano = nanoId;
|
plr->activeNano = nanoId;
|
||||||
|
|
||||||
for (auto& pwr : PassivePowers)
|
for (auto& pwr : PassivePowers)
|
||||||
if (pwr.powers.count(skillId)) { // std::set's contains method is C++20 only...
|
if (pwr.powers.count(skillId)) { // std::set's contains method is C++20 only...
|
||||||
resp.eCSTB___Add = 1;
|
resp.eCSTB___Add = 1;
|
||||||
@ -327,14 +327,14 @@ void NanoManager::summonNano(CNSocket *sock, int slot) {
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
plr->activeNano = 0;
|
plr->activeNano = 0;
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_NANO_ACTIVE_SUCC, sizeof(sP_FE2CL_REP_NANO_ACTIVE_SUCC));
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_NANO_ACTIVE_SUCC, sizeof(sP_FE2CL_REP_NANO_ACTIVE_SUCC));
|
||||||
|
|
||||||
// Send to other players
|
// Send to other players
|
||||||
INITSTRUCT(sP_FE2CL_NANO_ACTIVE, pkt1);
|
INITSTRUCT(sP_FE2CL_NANO_ACTIVE, pkt1);
|
||||||
|
|
||||||
pkt1.iPC_ID = plr->iID;
|
pkt1.iPC_ID = plr->iID;
|
||||||
|
|
||||||
if (nanoId == -1)
|
if (nanoId == -1)
|
||||||
memset(&pkt1.Nano, 0, sizeof(pkt1.Nano));
|
memset(&pkt1.Nano, 0, sizeof(pkt1.Nano));
|
||||||
else
|
else
|
||||||
@ -354,10 +354,10 @@ void NanoManager::setNanoSkill(CNSocket* sock, int16_t nanoId, int16_t skillId)
|
|||||||
|
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (plr->activeNano > 0 && plr->activeNano == nanoId)
|
if (plr->activeNano > 0 && plr->activeNano == nanoId)
|
||||||
summonNano(sock, -1); // just unsummon the nano to prevent infinite buffs
|
summonNano(sock, -1); // just unsummon the nano to prevent infinite buffs
|
||||||
|
|
||||||
sNano nano = plr->Nanos[nanoId];
|
sNano nano = plr->Nanos[nanoId];
|
||||||
|
|
||||||
nano.iSkillID = skillId;
|
nano.iSkillID = skillId;
|
||||||
@ -385,7 +385,7 @@ void NanoManager::resetNanoSkill(CNSocket* sock, int16_t nanoId) {
|
|||||||
|
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sNano nano = plr->Nanos[nanoId];
|
sNano nano = plr->Nanos[nanoId];
|
||||||
|
|
||||||
// 0 is reset
|
// 0 is reset
|
||||||
@ -405,9 +405,9 @@ bool doDebuff(CNSocket *sock, int32_t *pktdata, sSkillResult_Damage_N_Debuff *re
|
|||||||
}
|
}
|
||||||
|
|
||||||
Mob* mob = MobManager::Mobs[pktdata[i]];
|
Mob* mob = MobManager::Mobs[pktdata[i]];
|
||||||
|
|
||||||
int damage = MobManager::hitMob(sock, mob, amount);
|
int damage = MobManager::hitMob(sock, mob, amount);
|
||||||
|
|
||||||
respdata[i].eCT = 4;
|
respdata[i].eCT = 4;
|
||||||
respdata[i].iDamage = damage;
|
respdata[i].iDamage = damage;
|
||||||
respdata[i].iID = mob->appearanceData.iNPC_ID;
|
respdata[i].iID = mob->appearanceData.iNPC_ID;
|
||||||
@ -427,7 +427,7 @@ bool doBuff(CNSocket *sock, int32_t *pktdata, sSkillResult_Buff *respdata, int i
|
|||||||
}
|
}
|
||||||
|
|
||||||
Mob* mob = MobManager::Mobs[pktdata[i]];
|
Mob* mob = MobManager::Mobs[pktdata[i]];
|
||||||
|
|
||||||
respdata[i].eCT = 4;
|
respdata[i].eCT = 4;
|
||||||
respdata[i].iID = mob->appearanceData.iNPC_ID;
|
respdata[i].iID = mob->appearanceData.iNPC_ID;
|
||||||
respdata[i].iConditionBitFlag = mob->appearanceData.iConditionBitFlag |= iCBFlag;
|
respdata[i].iConditionBitFlag = mob->appearanceData.iConditionBitFlag |= iCBFlag;
|
||||||
@ -450,11 +450,11 @@ bool doHeal(CNSocket *sock, int32_t *pktdata, sSkillResult_Heal_HP *respdata, in
|
|||||||
// player not found
|
// player not found
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int healedAmount = PC_MAXHEALTH(plr->level) * amount / 100;
|
int healedAmount = PC_MAXHEALTH(plr->level) * amount / 100;
|
||||||
|
|
||||||
plr->HP += healedAmount;
|
plr->HP += healedAmount;
|
||||||
|
|
||||||
if (plr->HP > PC_MAXHEALTH(plr->level))
|
if (plr->HP > PC_MAXHEALTH(plr->level))
|
||||||
plr->HP = PC_MAXHEALTH(plr->level);
|
plr->HP = PC_MAXHEALTH(plr->level);
|
||||||
|
|
||||||
@ -462,7 +462,7 @@ bool doHeal(CNSocket *sock, int32_t *pktdata, sSkillResult_Heal_HP *respdata, in
|
|||||||
respdata[i].iID = plr->iID;
|
respdata[i].iID = plr->iID;
|
||||||
respdata[i].iHP = plr->HP;
|
respdata[i].iHP = plr->HP;
|
||||||
respdata[i].iHealHP = healedAmount;
|
respdata[i].iHealHP = healedAmount;
|
||||||
|
|
||||||
std::cout << (int)plr->iID << " was healed" << std::endl;
|
std::cout << (int)plr->iID << " was healed" << std::endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -481,17 +481,17 @@ bool doGroupHeal(CNSocket *sock, int32_t *pktdata, sSkillResult_Heal_HP *respdat
|
|||||||
// player not found
|
// player not found
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Player *leader = PlayerManager::getPlayer(sock);
|
Player *leader = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
// player not found
|
// player not found
|
||||||
if (leader == nullptr)
|
if (leader == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int healedAmount = PC_MAXHEALTH(plr->level) * amount / 100;
|
int healedAmount = PC_MAXHEALTH(plr->level) * amount / 100;
|
||||||
|
|
||||||
leader->HP += healedAmount;
|
leader->HP += healedAmount;
|
||||||
|
|
||||||
if (leader->HP > PC_MAXHEALTH(leader->level))
|
if (leader->HP > PC_MAXHEALTH(leader->level))
|
||||||
leader->HP = PC_MAXHEALTH(leader->level);
|
leader->HP = PC_MAXHEALTH(leader->level);
|
||||||
|
|
||||||
@ -499,7 +499,7 @@ bool doGroupHeal(CNSocket *sock, int32_t *pktdata, sSkillResult_Heal_HP *respdat
|
|||||||
respdata[i].iID = plr->iID;
|
respdata[i].iID = plr->iID;
|
||||||
respdata[i].iHP = plr->HP;
|
respdata[i].iHP = plr->HP;
|
||||||
respdata[i].iHealHP = healedAmount;
|
respdata[i].iHealHP = healedAmount;
|
||||||
|
|
||||||
std::cout << (int)plr->iID << " was healed" << std::endl;
|
std::cout << (int)plr->iID << " was healed" << std::endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -512,12 +512,12 @@ bool doDamage(CNSocket *sock, int32_t *pktdata, sSkillResult_Damage *respdata, i
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Mob* mob = MobManager::Mobs[pktdata[i]];
|
Mob* mob = MobManager::Mobs[pktdata[i]];
|
||||||
|
|
||||||
Player *plr = PlayerManager::getPlayer(sock);
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int damage = MobManager::hitMob(sock, mob, PC_MAXHEALTH(plr->level) * amount / 100);
|
int damage = MobManager::hitMob(sock, mob, PC_MAXHEALTH(plr->level) * amount / 100);
|
||||||
|
|
||||||
respdata[i].eCT = 4;
|
respdata[i].eCT = 4;
|
||||||
@ -552,9 +552,9 @@ bool doLeech(CNSocket *sock, int32_t *pktdata, sSkillResult_Heal_HP *healdata, i
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
int healedAmount = PC_MAXHEALTH(plr->level) * amount / 100;
|
int healedAmount = PC_MAXHEALTH(plr->level) * amount / 100;
|
||||||
|
|
||||||
plr->HP += healedAmount;
|
plr->HP += healedAmount;
|
||||||
|
|
||||||
if (plr->HP > PC_MAXHEALTH(plr->level))
|
if (plr->HP > PC_MAXHEALTH(plr->level))
|
||||||
plr->HP = PC_MAXHEALTH(plr->level);
|
plr->HP = PC_MAXHEALTH(plr->level);
|
||||||
|
|
||||||
@ -569,9 +569,9 @@ bool doLeech(CNSocket *sock, int32_t *pktdata, sSkillResult_Heal_HP *healdata, i
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Mob* mob = MobManager::Mobs[pktdata[i]];
|
Mob* mob = MobManager::Mobs[pktdata[i]];
|
||||||
|
|
||||||
int damage = MobManager::hitMob(sock, mob, PC_MAXHEALTH(plr->level) * amount / 100);
|
int damage = MobManager::hitMob(sock, mob, PC_MAXHEALTH(plr->level) * amount / 100);
|
||||||
|
|
||||||
damagedata->eCT = 4;
|
damagedata->eCT = 4;
|
||||||
damagedata->iDamage = damage;
|
damagedata->iDamage = damage;
|
||||||
damagedata->iID = mob->appearanceData.iNPC_ID;
|
damagedata->iID = mob->appearanceData.iNPC_ID;
|
||||||
@ -607,7 +607,7 @@ void activePower(CNSocket *sock, CNPacketData *data,
|
|||||||
int32_t *pktdata = (int32_t*)((uint8_t*)data->buf + sizeof(sP_CL2FE_REQ_NANO_SKILL_USE));
|
int32_t *pktdata = (int32_t*)((uint8_t*)data->buf + sizeof(sP_CL2FE_REQ_NANO_SKILL_USE));
|
||||||
|
|
||||||
size_t resplen;
|
size_t resplen;
|
||||||
|
|
||||||
Player *plr = PlayerManager::getPlayer(sock);
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
Player *otherPlr = plr;
|
Player *otherPlr = plr;
|
||||||
|
|
||||||
@ -619,15 +619,15 @@ void activePower(CNSocket *sock, CNPacketData *data,
|
|||||||
resplen = sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC) + sizeof(sSkillResult_Heal_HP) + sizeof(sSkillResult_Damage);
|
resplen = sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC) + sizeof(sSkillResult_Heal_HP) + sizeof(sSkillResult_Damage);
|
||||||
else if constexpr (specialCase == GHEAL) {
|
else if constexpr (specialCase == GHEAL) {
|
||||||
otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||||
|
|
||||||
if (otherPlr == nullptr)
|
if (otherPlr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pkt->iTargetCnt = otherPlr->groupCnt;
|
pkt->iTargetCnt = otherPlr->groupCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
resplen = sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC) + pkt->iTargetCnt * sizeof(sPAYLOAD);
|
resplen = sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC) + pkt->iTargetCnt * sizeof(sPAYLOAD);
|
||||||
|
|
||||||
// validate response packet
|
// validate response packet
|
||||||
if (!validOutVarPacket(sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC), pkt->iTargetCnt, sizeof(sPAYLOAD))) {
|
if (!validOutVarPacket(sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC), pkt->iTargetCnt, sizeof(sPAYLOAD))) {
|
||||||
std::cout << "[WARN] bad sP_FE2CL_NANO_SKILL_USE packet size" << std::endl;
|
std::cout << "[WARN] bad sP_FE2CL_NANO_SKILL_USE packet size" << std::endl;
|
||||||
@ -644,7 +644,7 @@ void activePower(CNSocket *sock, CNPacketData *data,
|
|||||||
plr->Nanos[plr->activeNano].iStamina -= 40;
|
plr->Nanos[plr->activeNano].iStamina -= 40;
|
||||||
if (plr->Nanos[plr->activeNano].iStamina < 0)
|
if (plr->Nanos[plr->activeNano].iStamina < 0)
|
||||||
plr->Nanos[plr->activeNano].iStamina = 0;
|
plr->Nanos[plr->activeNano].iStamina = 0;
|
||||||
|
|
||||||
resp->iPC_ID = plr->iID;
|
resp->iPC_ID = plr->iID;
|
||||||
resp->iSkillID = skillId;
|
resp->iSkillID = skillId;
|
||||||
resp->iNanoID = nanoId;
|
resp->iNanoID = nanoId;
|
||||||
@ -653,7 +653,7 @@ void activePower(CNSocket *sock, CNPacketData *data,
|
|||||||
resp->iTargetCnt = pkt->iTargetCnt;
|
resp->iTargetCnt = pkt->iTargetCnt;
|
||||||
|
|
||||||
CNSocket *workSock = sock;
|
CNSocket *workSock = sock;
|
||||||
|
|
||||||
for (int i = 0; i < pkt->iTargetCnt; i++) {
|
for (int i = 0; i < pkt->iTargetCnt; i++) {
|
||||||
if constexpr (specialCase == GHEAL)
|
if constexpr (specialCase == GHEAL)
|
||||||
workSock = PlayerManager::getSockFromID(otherPlr->groupIDs[i]);
|
workSock = PlayerManager::getSockFromID(otherPlr->groupIDs[i]);
|
||||||
@ -689,44 +689,44 @@ void NanoManager::nanoBuff(CNSocket* sock, int16_t nanoId, int skillId, int16_t
|
|||||||
|
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (plr->iID == plr->iIDGroup)
|
if (plr->iID == plr->iIDGroup)
|
||||||
leader = plr;
|
leader = plr;
|
||||||
else
|
else
|
||||||
leader = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
leader = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||||
|
|
||||||
if (leader == nullptr)
|
if (leader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int pktCnt = 1;
|
int pktCnt = 1;
|
||||||
|
|
||||||
if (groupPower)
|
if (groupPower)
|
||||||
pktCnt = leader->groupCnt;
|
pktCnt = leader->groupCnt;
|
||||||
|
|
||||||
if (!validOutVarPacket(sizeof(sP_FE2CL_NANO_SKILL_USE), pktCnt, sizeof(sSkillResult_Buff))) {
|
if (!validOutVarPacket(sizeof(sP_FE2CL_NANO_SKILL_USE), pktCnt, sizeof(sSkillResult_Buff))) {
|
||||||
std::cout << "[WARN] bad sP_FE2CL_NANO_SKILL_USE packet size\n";
|
std::cout << "[WARN] bad sP_FE2CL_NANO_SKILL_USE packet size\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t resplen = sizeof(sP_FE2CL_NANO_SKILL_USE) + pktCnt * sizeof(sSkillResult_Buff);
|
size_t resplen = sizeof(sP_FE2CL_NANO_SKILL_USE) + pktCnt * sizeof(sSkillResult_Buff);
|
||||||
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
||||||
|
|
||||||
memset(respbuf, 0, resplen);
|
memset(respbuf, 0, resplen);
|
||||||
|
|
||||||
sP_FE2CL_NANO_SKILL_USE *resp = (sP_FE2CL_NANO_SKILL_USE*)respbuf;
|
sP_FE2CL_NANO_SKILL_USE *resp = (sP_FE2CL_NANO_SKILL_USE*)respbuf;
|
||||||
sSkillResult_Buff *respdata = (sSkillResult_Buff*)(respbuf+sizeof(sP_FE2CL_NANO_SKILL_USE));
|
sSkillResult_Buff *respdata = (sSkillResult_Buff*)(respbuf+sizeof(sP_FE2CL_NANO_SKILL_USE));
|
||||||
|
|
||||||
resp->iPC_ID = plr->iID;
|
resp->iPC_ID = plr->iID;
|
||||||
resp->iSkillID = skillId;
|
resp->iSkillID = skillId;
|
||||||
resp->iNanoID = nanoId;
|
resp->iNanoID = nanoId;
|
||||||
resp->iNanoStamina = plr->Nanos[plr->activeNano].iStamina;
|
resp->iNanoStamina = plr->Nanos[plr->activeNano].iStamina;
|
||||||
resp->eST = eSkillType;
|
resp->eST = eSkillType;
|
||||||
resp->iTargetCnt = pktCnt;
|
resp->iTargetCnt = pktCnt;
|
||||||
|
|
||||||
for (int i = 0; i < pktCnt; i++) {
|
for (int i = 0; i < pktCnt; i++) {
|
||||||
Player* varPlr;
|
Player* varPlr;
|
||||||
CNSocket* sockTo;
|
CNSocket* sockTo;
|
||||||
|
|
||||||
if (plr->iID == leader->groupIDs[i]) {
|
if (plr->iID == leader->groupIDs[i]) {
|
||||||
varPlr = plr;
|
varPlr = plr;
|
||||||
sockTo = sock;
|
sockTo = sock;
|
||||||
@ -734,27 +734,27 @@ void NanoManager::nanoBuff(CNSocket* sock, int16_t nanoId, int skillId, int16_t
|
|||||||
varPlr = PlayerManager::getPlayerFromID(leader->groupIDs[i]);
|
varPlr = PlayerManager::getPlayerFromID(leader->groupIDs[i]);
|
||||||
sockTo = PlayerManager::getSockFromID(leader->groupIDs[i]);
|
sockTo = PlayerManager::getSockFromID(leader->groupIDs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (varPlr == nullptr || sockTo == nullptr)
|
if (varPlr == nullptr || sockTo == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(varPlr->iConditionBitFlag & iCBFlag))
|
if (!(varPlr->iConditionBitFlag & iCBFlag))
|
||||||
varPlr->iConditionBitFlag ^= iCBFlag;
|
varPlr->iConditionBitFlag ^= iCBFlag;
|
||||||
|
|
||||||
respdata[i].eCT = 1;
|
respdata[i].eCT = 1;
|
||||||
respdata[i].iID = varPlr->iID;
|
respdata[i].iID = varPlr->iID;
|
||||||
respdata[i].iConditionBitFlag = iCBFlag;
|
respdata[i].iConditionBitFlag = iCBFlag;
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, pkt1);
|
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, pkt1);
|
||||||
|
|
||||||
pkt1.eCSTB = eCharStatusTimeBuffID; //eCharStatusTimeBuffID
|
pkt1.eCSTB = eCharStatusTimeBuffID; //eCharStatusTimeBuffID
|
||||||
pkt1.eTBU = 1; //eTimeBuffUpdate
|
pkt1.eTBU = 1; //eTimeBuffUpdate
|
||||||
pkt1.eTBT = 1; //eTimeBuffType 1 means nano
|
pkt1.eTBT = 1; //eTimeBuffType 1 means nano
|
||||||
pkt1.iConditionBitFlag = varPlr->iConditionBitFlag;
|
pkt1.iConditionBitFlag = varPlr->iConditionBitFlag;
|
||||||
|
|
||||||
if (iValue > 0)
|
if (iValue > 0)
|
||||||
pkt1.TimeBuff.iValue = iValue;
|
pkt1.TimeBuff.iValue = iValue;
|
||||||
|
|
||||||
sockTo->sendPacket((void*)&pkt1, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE));
|
sockTo->sendPacket((void*)&pkt1, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -764,30 +764,30 @@ void NanoManager::nanoBuff(CNSocket* sock, int16_t nanoId, int skillId, int16_t
|
|||||||
|
|
||||||
void NanoManager::nanoUnbuff(CNSocket* sock, int32_t iCBFlag, int16_t eCharStatusTimeBuffID, int16_t iValue, bool groupPower) {
|
void NanoManager::nanoUnbuff(CNSocket* sock, int32_t iCBFlag, int16_t eCharStatusTimeBuffID, int16_t iValue, bool groupPower) {
|
||||||
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, resp1);
|
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, resp1);
|
||||||
|
|
||||||
Player *plr = PlayerManager::getPlayer(sock);
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
Player *leader;
|
Player *leader;
|
||||||
|
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (plr->iID == plr->iIDGroup)
|
if (plr->iID == plr->iIDGroup)
|
||||||
leader = plr;
|
leader = plr;
|
||||||
else
|
else
|
||||||
leader = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
leader = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||||
|
|
||||||
if (leader == nullptr)
|
if (leader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int pktCnt = 1;
|
int pktCnt = 1;
|
||||||
|
|
||||||
if (groupPower)
|
if (groupPower)
|
||||||
pktCnt = leader->groupCnt;
|
pktCnt = leader->groupCnt;
|
||||||
|
|
||||||
for (int i = 0; i < pktCnt; i++) {
|
for (int i = 0; i < pktCnt; i++) {
|
||||||
Player* varPlr;
|
Player* varPlr;
|
||||||
CNSocket* sockTo;
|
CNSocket* sockTo;
|
||||||
|
|
||||||
if (plr->iID == leader->groupIDs[i]) {
|
if (plr->iID == leader->groupIDs[i]) {
|
||||||
varPlr = plr;
|
varPlr = plr;
|
||||||
sockTo = sock;
|
sockTo = sock;
|
||||||
@ -795,18 +795,18 @@ void NanoManager::nanoUnbuff(CNSocket* sock, int32_t iCBFlag, int16_t eCharStatu
|
|||||||
varPlr = PlayerManager::getPlayerFromID(leader->groupIDs[i]);
|
varPlr = PlayerManager::getPlayerFromID(leader->groupIDs[i]);
|
||||||
sockTo = PlayerManager::getSockFromID(leader->groupIDs[i]);
|
sockTo = PlayerManager::getSockFromID(leader->groupIDs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (varPlr->iConditionBitFlag & iCBFlag)
|
if (varPlr->iConditionBitFlag & iCBFlag)
|
||||||
varPlr->iConditionBitFlag ^= iCBFlag;
|
varPlr->iConditionBitFlag ^= iCBFlag;
|
||||||
|
|
||||||
resp1.eCSTB = eCharStatusTimeBuffID; //eCharStatusTimeBuffID
|
resp1.eCSTB = eCharStatusTimeBuffID; //eCharStatusTimeBuffID
|
||||||
resp1.eTBU = 2; //eTimeBuffUpdate
|
resp1.eTBU = 2; //eTimeBuffUpdate
|
||||||
resp1.eTBT = 1; //eTimeBuffType 1 means nano
|
resp1.eTBT = 1; //eTimeBuffType 1 means nano
|
||||||
resp1.iConditionBitFlag = varPlr->iConditionBitFlag;
|
resp1.iConditionBitFlag = varPlr->iConditionBitFlag;
|
||||||
|
|
||||||
if (iValue > 0)
|
if (iValue > 0)
|
||||||
resp1.TimeBuff.iValue = iValue;
|
resp1.TimeBuff.iValue = iValue;
|
||||||
|
|
||||||
sockTo->sendPacket((void*)&resp1, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE));
|
sockTo->sendPacket((void*)&resp1, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -847,7 +847,7 @@ void NanoManager::revivePlayer(Player* plr) {
|
|||||||
INITSTRUCT(sP_FE2CL_PC_REGEN, resp2);
|
INITSTRUCT(sP_FE2CL_PC_REGEN, resp2);
|
||||||
|
|
||||||
plr->HP = PC_MAXHEALTH(plr->level);
|
plr->HP = PC_MAXHEALTH(plr->level);
|
||||||
|
|
||||||
// Nanos
|
// Nanos
|
||||||
int activeSlot = -1;
|
int activeSlot = -1;
|
||||||
for (int n = 0; n < 3; n++) {
|
for (int n = 0; n < 3; n++) {
|
||||||
|
@ -31,7 +31,7 @@ struct PassivePower {
|
|||||||
int16_t eCharStatusTimeBuffID;
|
int16_t eCharStatusTimeBuffID;
|
||||||
int16_t iValue;
|
int16_t iValue;
|
||||||
bool groupPower;
|
bool groupPower;
|
||||||
|
|
||||||
PassivePower(std::set<int> p, int16_t t, int32_t f, int16_t b, int16_t a, bool g) : powers(p), eSkillType(t), iCBFlag(f), eCharStatusTimeBuffID(b), iValue(a), groupPower(g) {}
|
PassivePower(std::set<int> p, int16_t t, int32_t f, int16_t b, int16_t a, bool g) : powers(p), eSkillType(t), iCBFlag(f), eCharStatusTimeBuffID(b), iValue(a), groupPower(g) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -60,10 +60,10 @@ namespace NanoManager {
|
|||||||
void summonNano(CNSocket* sock, int slot);
|
void summonNano(CNSocket* sock, int slot);
|
||||||
void setNanoSkill(CNSocket* sock, int16_t nanoId, int16_t skillId);
|
void setNanoSkill(CNSocket* sock, int16_t nanoId, int16_t skillId);
|
||||||
void resetNanoSkill(CNSocket* sock, int16_t nanoId);
|
void resetNanoSkill(CNSocket* sock, int16_t nanoId);
|
||||||
|
|
||||||
void nanoBuff(CNSocket* sock, int16_t nanoId, int skillId, int16_t eSkillType, int32_t iCBFlag, int16_t eCharStatusTimeBuffID, int16_t iValue = 0, bool groupPower = false);
|
void nanoBuff(CNSocket* sock, int16_t nanoId, int skillId, int16_t eSkillType, int32_t iCBFlag, int16_t eCharStatusTimeBuffID, int16_t iValue = 0, bool groupPower = false);
|
||||||
void nanoUnbuff(CNSocket* sock, int32_t iCBFlag, int16_t eCharStatusTimeBuffID, int16_t iValue = 0, bool groupPower = false);
|
void nanoUnbuff(CNSocket* sock, int32_t iCBFlag, int16_t eCharStatusTimeBuffID, int16_t iValue = 0, bool groupPower = false);
|
||||||
|
|
||||||
int nanoStyle(int nanoId);
|
int nanoStyle(int nanoId);
|
||||||
void revivePlayer(Player* plr);
|
void revivePlayer(Player* plr);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ struct Player {
|
|||||||
|
|
||||||
bool inCombat;
|
bool inCombat;
|
||||||
bool passiveNanoOut;
|
bool passiveNanoOut;
|
||||||
|
|
||||||
int pointDamage;
|
int pointDamage;
|
||||||
int groupDamage;
|
int groupDamage;
|
||||||
int defense;
|
int defense;
|
||||||
@ -60,7 +60,7 @@ struct Player {
|
|||||||
int32_t CurrentMissionID;
|
int32_t CurrentMissionID;
|
||||||
|
|
||||||
sTimeLimitItemDeleteInfo2CL toRemoveVehicle;
|
sTimeLimitItemDeleteInfo2CL toRemoveVehicle;
|
||||||
|
|
||||||
int32_t iIDGroup;
|
int32_t iIDGroup;
|
||||||
int groupCnt;
|
int groupCnt;
|
||||||
int32_t groupIDs[4];
|
int32_t groupIDs[4];
|
||||||
|
@ -41,7 +41,7 @@ void PlayerManager::init() {
|
|||||||
REGISTER_SHARD_PACKET(P_CL2FE_GM_REQ_PC_SPECIAL_STATE_SWITCH, PlayerManager::setGMSpecialSwitchPlayer);
|
REGISTER_SHARD_PACKET(P_CL2FE_GM_REQ_PC_SPECIAL_STATE_SWITCH, PlayerManager::setGMSpecialSwitchPlayer);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_VEHICLE_ON, PlayerManager::enterPlayerVehicle);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_VEHICLE_ON, PlayerManager::enterPlayerVehicle);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_VEHICLE_OFF, PlayerManager::exitPlayerVehicle);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_VEHICLE_OFF, PlayerManager::exitPlayerVehicle);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_CHANGE_MENTOR, PlayerManager::changePlayerGuide);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_CHANGE_MENTOR, PlayerManager::changePlayerGuide);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerManager::addPlayer(CNSocket* key, Player plr) {
|
void PlayerManager::addPlayer(CNSocket* key, Player plr) {
|
||||||
@ -63,7 +63,7 @@ void PlayerManager::addPlayer(CNSocket* key, Player plr) {
|
|||||||
|
|
||||||
void PlayerManager::removePlayer(CNSocket* key) {
|
void PlayerManager::removePlayer(CNSocket* key) {
|
||||||
PlayerView& view = players[key];
|
PlayerView& view = players[key];
|
||||||
|
|
||||||
GroupManager::groupKickPlayer(view.plr);
|
GroupManager::groupKickPlayer(view.plr);
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_PC_EXIT, exitPacket);
|
INITSTRUCT(sP_FE2CL_PC_EXIT, exitPacket);
|
||||||
@ -222,7 +222,7 @@ void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z, int I) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z) {
|
void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z) {
|
||||||
|
|
||||||
PlayerManager::updatePlayerPosition(sock, X, Y, Z);
|
PlayerManager::updatePlayerPosition(sock, X, Y, Z);
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_GOTO_SUCC, pkt);
|
INITSTRUCT(sP_FE2CL_REP_PC_GOTO_SUCC, pkt);
|
||||||
pkt.iX = X;
|
pkt.iX = X;
|
||||||
@ -246,7 +246,7 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
// TODO: check if serialkey exists, if it doesn't send sP_FE2CL_REP_PC_ENTER_FAIL
|
// TODO: check if serialkey exists, if it doesn't send sP_FE2CL_REP_PC_ENTER_FAIL
|
||||||
Player plr = CNSharedData::getPlayer(enter->iEnterSerialKey);
|
Player plr = CNSharedData::getPlayer(enter->iEnterSerialKey);
|
||||||
|
|
||||||
plr.groupCnt = 1;
|
plr.groupCnt = 1;
|
||||||
plr.iIDGroup = plr.groupIDs[0] = plr.iID;
|
plr.iIDGroup = plr.groupIDs[0] = plr.iID;
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
response.PCLoadData2CL.iActiveNanoSlotNum = -1;
|
response.PCLoadData2CL.iActiveNanoSlotNum = -1;
|
||||||
response.PCLoadData2CL.iFatigue = 50;
|
response.PCLoadData2CL.iFatigue = 50;
|
||||||
response.PCLoadData2CL.PCStyle = plr.PCStyle;
|
response.PCLoadData2CL.PCStyle = plr.PCStyle;
|
||||||
|
|
||||||
//client doesnt read this, it gets it from charinfo
|
//client doesnt read this, it gets it from charinfo
|
||||||
//response.PCLoadData2CL.PCStyle2 = plr.PCStyle2;
|
//response.PCLoadData2CL.PCStyle2 = plr.PCStyle2;
|
||||||
// inventory
|
// inventory
|
||||||
@ -318,7 +318,7 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
/*
|
/*
|
||||||
* client doesn't care about NeededItem ID and Count,
|
* client doesn't care about NeededItem ID and Count,
|
||||||
* it gets Count from Quest Inventory
|
* it gets Count from Quest Inventory
|
||||||
*
|
*
|
||||||
* KillNPCCount sets RemainEnemyNum in the client
|
* KillNPCCount sets RemainEnemyNum in the client
|
||||||
* Yes, this is extraordinary stupid.
|
* Yes, this is extraordinary stupid.
|
||||||
*/
|
*/
|
||||||
@ -351,7 +351,7 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
addPlayer(sock, plr);
|
addPlayer(sock, plr);
|
||||||
//check if there is an expiring vehicle
|
//check if there is an expiring vehicle
|
||||||
ItemManager::checkItemExpire(sock, getPlayer(sock));
|
ItemManager::checkItemExpire(sock, getPlayer(sock));
|
||||||
|
|
||||||
//set player equip stats
|
//set player equip stats
|
||||||
ItemManager::setItemStats(getPlayer(sock));
|
ItemManager::setItemStats(getPlayer(sock));
|
||||||
}
|
}
|
||||||
@ -361,7 +361,7 @@ void PlayerManager::sendToViewable(CNSocket* sock, void* buf, uint32_t type, siz
|
|||||||
for (CNSocket* otherSock : chunk->players) {
|
for (CNSocket* otherSock : chunk->players) {
|
||||||
if (otherSock == sock)
|
if (otherSock == sock)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
otherSock->sendPacket(buf, type, size);
|
otherSock->sendPacket(buf, type, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -394,7 +394,7 @@ void PlayerManager::movePlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
sP_CL2FE_REQ_PC_MOVE* moveData = (sP_CL2FE_REQ_PC_MOVE*)data->buf;
|
sP_CL2FE_REQ_PC_MOVE* moveData = (sP_CL2FE_REQ_PC_MOVE*)data->buf;
|
||||||
updatePlayerPosition(sock, moveData->iX, moveData->iY, moveData->iZ, moveData->iAngle);
|
updatePlayerPosition(sock, moveData->iX, moveData->iY, moveData->iZ, moveData->iAngle);
|
||||||
|
|
||||||
players[sock].plr->angle = moveData->iAngle;
|
players[sock].plr->angle = moveData->iAngle;
|
||||||
uint64_t tm = getTime();
|
uint64_t tm = getTime();
|
||||||
|
|
||||||
@ -746,9 +746,9 @@ void PlayerManager::revivePlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
sP_CL2FE_REQ_PC_REGEN* reviveData = (sP_CL2FE_REQ_PC_REGEN*)data->buf;
|
sP_CL2FE_REQ_PC_REGEN* reviveData = (sP_CL2FE_REQ_PC_REGEN*)data->buf;
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_REGEN_SUCC, response);
|
INITSTRUCT(sP_FE2CL_REP_PC_REGEN_SUCC, response);
|
||||||
INITSTRUCT(sP_FE2CL_PC_REGEN, resp2);
|
INITSTRUCT(sP_FE2CL_PC_REGEN, resp2);
|
||||||
|
|
||||||
int activeSlot = -1;
|
int activeSlot = -1;
|
||||||
|
|
||||||
if (reviveData->iRegenType == 3 && plr->iConditionBitFlag & CSB_BIT_PHOENIX) {
|
if (reviveData->iRegenType == 3 && plr->iConditionBitFlag & CSB_BIT_PHOENIX) {
|
||||||
// nano revive
|
// nano revive
|
||||||
plr->Nanos[plr->activeNano].iStamina = 0;
|
plr->Nanos[plr->activeNano].iStamina = 0;
|
||||||
@ -761,7 +761,7 @@ void PlayerManager::revivePlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
if (reviveData->iRegenType != 5)
|
if (reviveData->iRegenType != 5)
|
||||||
plr->HP = PC_MAXHEALTH(plr->level);
|
plr->HP = PC_MAXHEALTH(plr->level);
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
int nanoID = plr->equippedNanos[i];
|
int nanoID = plr->equippedNanos[i];
|
||||||
|
|
||||||
@ -874,7 +874,7 @@ void PlayerManager::changePlayerGuide(CNSocket *sock, CNPacketData *data) {
|
|||||||
resp.iMentor = pkt->iMentor;
|
resp.iMentor = pkt->iMentor;
|
||||||
resp.iMentorCnt = 1;
|
resp.iMentorCnt = 1;
|
||||||
resp.iFusionMatter = plr->fusionmatter; // no cost
|
resp.iFusionMatter = plr->fusionmatter; // no cost
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_CHANGE_MENTOR_SUCC, sizeof(sP_FE2CL_REP_PC_CHANGE_MENTOR_SUCC));
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_CHANGE_MENTOR_SUCC, sizeof(sP_FE2CL_REP_PC_CHANGE_MENTOR_SUCC));
|
||||||
// if it's changed from computress
|
// if it's changed from computress
|
||||||
if (plr->mentor == 5) {
|
if (plr->mentor == 5) {
|
||||||
@ -897,7 +897,7 @@ void PlayerManager::changePlayerGuide(CNSocket *sock, CNPacketData *data) {
|
|||||||
Player *PlayerManager::getPlayer(CNSocket* key) {
|
Player *PlayerManager::getPlayer(CNSocket* key) {
|
||||||
if (players.find(key) != players.end())
|
if (players.find(key) != players.end())
|
||||||
return players[key].plr;
|
return players[key].plr;
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ void TableData::init() {
|
|||||||
std::cout << "[INFO] Loaded " << ItemManager::ItemData.size() << " items" << std::endl;
|
std::cout << "[INFO] Loaded " << ItemManager::ItemData.size() << " items" << std::endl;
|
||||||
|
|
||||||
// load player limits from m_pAvatarTable.m_pAvatarGrowData
|
// load player limits from m_pAvatarTable.m_pAvatarGrowData
|
||||||
|
|
||||||
nlohmann::json growth = xdtData["m_pAvatarTable"]["m_pAvatarGrowData"];
|
nlohmann::json growth = xdtData["m_pAvatarTable"]["m_pAvatarGrowData"];
|
||||||
|
|
||||||
for (int i = 0; i < 37; i++) {
|
for (int i = 0; i < 37; i++) {
|
||||||
|
@ -194,15 +194,15 @@ void TransportManager::tickTransportationSystem(CNServer* serv, time_t currTime)
|
|||||||
* If the player has disconnected or finished the route, clean up and remove them from the queue.
|
* If the player has disconnected or finished the route, clean up and remove them from the queue.
|
||||||
*/
|
*/
|
||||||
void TransportManager::stepSkywaySystem() {
|
void TransportManager::stepSkywaySystem() {
|
||||||
|
|
||||||
// using an unordered map so we can remove finished players in one iteration
|
// using an unordered map so we can remove finished players in one iteration
|
||||||
std::unordered_map<CNSocket*, std::queue<WarpLocation>>::iterator it = SkywayQueues.begin();
|
std::unordered_map<CNSocket*, std::queue<WarpLocation>>::iterator it = SkywayQueues.begin();
|
||||||
while (it != SkywayQueues.end()) {
|
while (it != SkywayQueues.end()) {
|
||||||
|
|
||||||
std::queue<WarpLocation>* queue = &it->second;
|
std::queue<WarpLocation>* queue = &it->second;
|
||||||
|
|
||||||
Player* plr = PlayerManager::getPlayer(it->first);
|
Player* plr = PlayerManager::getPlayer(it->first);
|
||||||
|
|
||||||
if (plr == nullptr) {
|
if (plr == nullptr) {
|
||||||
// pluck out dead socket + update iterator
|
// pluck out dead socket + update iterator
|
||||||
it = SkywayQueues.erase(it);
|
it = SkywayQueues.erase(it);
|
||||||
|
Loading…
Reference in New Issue
Block a user