mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-04 22:40:05 +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>
|
||||
|
||||
void BuddyManager::init() {
|
||||
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_ACCEPT_MAKE_BUDDY, reqAcceptBuddy);
|
||||
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_MENUCHAT_MESSAGE, reqBuddyMenuchat);
|
||||
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_REMOVE_BUDDY, reqBuddyDelete);
|
||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_BUDDY_WARP, reqBuddyWarp);
|
||||
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_ACCEPT_MAKE_BUDDY, reqAcceptBuddy);
|
||||
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_MENUCHAT_MESSAGE, reqBuddyMenuchat);
|
||||
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_REMOVE_BUDDY, reqBuddyDelete);
|
||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_BUDDY_WARP, reqBuddyWarp);
|
||||
}
|
||||
|
||||
//Buddy request
|
||||
void BuddyManager::requestBuddy(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_REQUEST_MAKE_BUDDY))
|
||||
return; // malformed packet
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_REQUEST_MAKE_BUDDY))
|
||||
return; // malformed packet
|
||||
|
||||
Player* plrReq = PlayerManager::getPlayer(sock);
|
||||
Player* plrReq = PlayerManager::getPlayer(sock);
|
||||
|
||||
if (plrReq == nullptr)
|
||||
return;
|
||||
if (plrReq == nullptr)
|
||||
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) {
|
||||
if (pair.second.plr->PCStyle.iPC_UID == pkt->iBuddyPCUID) {
|
||||
otherSock = pair.first;
|
||||
for (auto pair : PlayerManager::players) {
|
||||
if (pair.second.plr->PCStyle.iPC_UID == pkt->iBuddyPCUID) {
|
||||
otherSock = pair.first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlayerView& plr = PlayerManager::players[otherSock];
|
||||
PlayerView& plr = PlayerManager::players[otherSock];
|
||||
|
||||
resp.iRequestID = plr.plr->iID;
|
||||
resp.iBuddyID = plr.plr->iID;
|
||||
resp.iBuddyPCUID = plr.plr->PCStyle.iPC_UID;
|
||||
resp.iRequestID = plr.plr->iID;
|
||||
resp.iBuddyID = plr.plr->iID;
|
||||
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
|
||||
requestedBuddy(otherSock, plrReq, plr); //The other player will see the request
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
//Sending buddy request by player name
|
||||
void BuddyManager::reqBuddyByName(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY)) {
|
||||
return; // malformed packet
|
||||
}
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY)) {
|
||||
return; // malformed packet
|
||||
}
|
||||
|
||||
sP_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY* pkt = (sP_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY*)data->buf;
|
||||
Player* plrReq = PlayerManager::getPlayer(sock);
|
||||
sP_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY* pkt = (sP_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY*)data->buf;
|
||||
Player* plrReq = PlayerManager::getPlayer(sock);
|
||||
|
||||
if (plrReq == nullptr)
|
||||
return;
|
||||
if (plrReq == nullptr)
|
||||
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 sizeOfLNRes = sizeof(pkt->szLastName) / 17; //Maximum size of a player's last 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
|
||||
|
||||
for (auto pair : PlayerManager::players) {
|
||||
int sizeOfReq = sizeof(pair.second.plr->PCStyle.szFirstName) / 9;
|
||||
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:
|
||||
otherSock = pair.first;
|
||||
for (auto pair : PlayerManager::players) {
|
||||
int sizeOfReq = sizeof(pair.second.plr->PCStyle.szFirstName) / 9;
|
||||
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:
|
||||
otherSock = pair.first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resp.iPCUID = plrReq->PCStyle.iPC_UID;
|
||||
resp.iNameCheckFlag = plrReq->PCStyle.iNameCheck;
|
||||
resp.iPCUID = plrReq->PCStyle.iPC_UID;
|
||||
resp.iNameCheckFlag = plrReq->PCStyle.iNameCheck;
|
||||
|
||||
memcpy(resp.szFirstName, plrReq->PCStyle.szFirstName, sizeof(plrReq->PCStyle.szFirstName));
|
||||
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));
|
||||
memcpy(resp.szFirstName, plrReq->PCStyle.szFirstName, sizeof(plrReq->PCStyle.szFirstName));
|
||||
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));
|
||||
|
||||
}
|
||||
|
||||
//Accepting buddy request
|
||||
void BuddyManager::reqAcceptBuddy(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_ACCEPT_MAKE_BUDDY))
|
||||
return; // malformed packet
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_ACCEPT_MAKE_BUDDY))
|
||||
return; // malformed packet
|
||||
|
||||
sP_CL2FE_REQ_ACCEPT_MAKE_BUDDY* pkt = (sP_CL2FE_REQ_ACCEPT_MAKE_BUDDY*)data->buf;
|
||||
Player* plrReq = PlayerManager::getPlayer(sock);
|
||||
sP_CL2FE_REQ_ACCEPT_MAKE_BUDDY* pkt = (sP_CL2FE_REQ_ACCEPT_MAKE_BUDDY*)data->buf;
|
||||
Player* plrReq = PlayerManager::getPlayer(sock);
|
||||
|
||||
if (plrReq == nullptr)
|
||||
return;
|
||||
if (plrReq == nullptr)
|
||||
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) {
|
||||
if (pair.second.plr->PCStyle.iPC_UID == pkt->iBuddyPCUID) {
|
||||
otherSock = pair.first;
|
||||
for (auto pair : PlayerManager::players) {
|
||||
if (pair.second.plr->PCStyle.iPC_UID == pkt->iBuddyPCUID) {
|
||||
otherSock = pair.first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlayerView& plr = PlayerManager::players[otherSock];
|
||||
PlayerView& plr = PlayerManager::players[otherSock];
|
||||
|
||||
if (pkt->iAcceptFlag == 1) {
|
||||
//resp.iBuddySlot = 0; //hard-coding this for now
|
||||
resp.BuddyInfo.iID = pkt->iBuddyID;
|
||||
resp.BuddyInfo.iPCUID = pkt->iBuddyPCUID;
|
||||
resp.BuddyInfo.iNameCheckFlag = plr.plr->PCStyle.iNameCheck;
|
||||
resp.BuddyInfo.iPCState = plr.plr->iPCState;
|
||||
resp.BuddyInfo.iGender = plr.plr->PCStyle.iGender;
|
||||
resp.BuddyInfo.bBlocked = 0;
|
||||
resp.BuddyInfo.bFreeChat = 1;
|
||||
if (pkt->iAcceptFlag == 1) {
|
||||
//resp.iBuddySlot = 0; //hard-coding this for now
|
||||
resp.BuddyInfo.iID = pkt->iBuddyID;
|
||||
resp.BuddyInfo.iPCUID = pkt->iBuddyPCUID;
|
||||
resp.BuddyInfo.iNameCheckFlag = plr.plr->PCStyle.iNameCheck;
|
||||
resp.BuddyInfo.iPCState = plr.plr->iPCState;
|
||||
resp.BuddyInfo.iGender = plr.plr->PCStyle.iGender;
|
||||
resp.BuddyInfo.bBlocked = 0;
|
||||
resp.BuddyInfo.bFreeChat = 1;
|
||||
|
||||
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.szFirstName, plr.plr->PCStyle.szFirstName, sizeof(plr.plr->PCStyle.szFirstName));
|
||||
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));
|
||||
buddyList(sock, resp.BuddyInfo); //saves buddy data to player's buddylist
|
||||
if (plr.plr->PCStyle.iPC_UID == pkt->iBuddyPCUID) {
|
||||
resp.BuddyInfo.iID = plrReq->iID;
|
||||
resp.BuddyInfo.iPCUID = plrReq->PCStyle.iPC_UID;
|
||||
resp.BuddyInfo.iNameCheckFlag = plrReq->PCStyle.iNameCheck;
|
||||
resp.BuddyInfo.iPCState = plrReq->iPCState;
|
||||
resp.BuddyInfo.iGender = plrReq->PCStyle.iGender;
|
||||
resp.BuddyInfo.bBlocked = 0;
|
||||
resp.BuddyInfo.bFreeChat = 1;
|
||||
memcpy(resp.BuddyInfo.szFirstName, plrReq->PCStyle.szFirstName, sizeof(plrReq->PCStyle.szFirstName));
|
||||
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));
|
||||
buddyList(otherSock, resp.BuddyInfo); //saves requester's data to this player's buddylist
|
||||
}
|
||||
}
|
||||
else {
|
||||
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, declineResp);
|
||||
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
|
||||
if (plr.plr->PCStyle.iPC_UID == pkt->iBuddyPCUID) {
|
||||
resp.BuddyInfo.iID = plrReq->iID;
|
||||
resp.BuddyInfo.iPCUID = plrReq->PCStyle.iPC_UID;
|
||||
resp.BuddyInfo.iNameCheckFlag = plrReq->PCStyle.iNameCheck;
|
||||
resp.BuddyInfo.iPCState = plrReq->iPCState;
|
||||
resp.BuddyInfo.iGender = plrReq->PCStyle.iGender;
|
||||
resp.BuddyInfo.bBlocked = 0;
|
||||
resp.BuddyInfo.bFreeChat = 1;
|
||||
memcpy(resp.BuddyInfo.szFirstName, plrReq->PCStyle.szFirstName, sizeof(plrReq->PCStyle.szFirstName));
|
||||
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));
|
||||
buddyList(otherSock, resp.BuddyInfo); //saves requester's data to this player's buddylist
|
||||
}
|
||||
}
|
||||
else {
|
||||
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, declineResp);
|
||||
|
||||
declineResp.iErrorCode = 6; //Buddy declined notification
|
||||
declineResp.iBuddyID = pkt->iBuddyID;
|
||||
declineResp.iBuddyPCUID = pkt->iBuddyPCUID;
|
||||
declineResp.iErrorCode = 6; //Buddy declined notification
|
||||
declineResp.iBuddyID = pkt->iBuddyID;
|
||||
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
|
||||
void BuddyManager::reqFindNameBuddyAccept(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_FIND_NAME_ACCEPT_BUDDY)) {
|
||||
return; // malformed packet
|
||||
}
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_FIND_NAME_ACCEPT_BUDDY)) {
|
||||
return; // malformed packet
|
||||
}
|
||||
|
||||
sP_CL2FE_REQ_PC_FIND_NAME_ACCEPT_BUDDY* pkt = (sP_CL2FE_REQ_PC_FIND_NAME_ACCEPT_BUDDY*)data->buf;
|
||||
Player* plrReq = PlayerManager::getPlayer(sock);
|
||||
sP_CL2FE_REQ_PC_FIND_NAME_ACCEPT_BUDDY* pkt = (sP_CL2FE_REQ_PC_FIND_NAME_ACCEPT_BUDDY*)data->buf;
|
||||
Player* plrReq = PlayerManager::getPlayer(sock);
|
||||
|
||||
if (plrReq == nullptr)
|
||||
return;
|
||||
if (plrReq == nullptr)
|
||||
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 sizeOfLNRes = sizeof(pkt->szLastName) / 17;
|
||||
int sizeOfRes = sizeof(pkt->szFirstName) / 9;
|
||||
int sizeOfLNRes = sizeof(pkt->szLastName) / 17;
|
||||
|
||||
for (auto pair : PlayerManager::players) {
|
||||
int sizeOfReq = sizeof(pair.second.plr->PCStyle.szFirstName) / 9;
|
||||
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) {
|
||||
otherSock = pair.first;
|
||||
for (auto pair : PlayerManager::players) {
|
||||
int sizeOfReq = sizeof(pair.second.plr->PCStyle.szFirstName) / 9;
|
||||
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) {
|
||||
otherSock = pair.first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlayerView& plr = PlayerManager::players[otherSock];
|
||||
PlayerView& plr = PlayerManager::players[otherSock];
|
||||
|
||||
if (pkt->iAcceptFlag == 1) {
|
||||
//resp.iBuddySlot = 0; //hard-coding this for now
|
||||
//resp.BuddyInfo.iID = plrReq->iID;
|
||||
resp.BuddyInfo.iPCUID = pkt->iBuddyPCUID;
|
||||
resp.BuddyInfo.iNameCheckFlag = plr.plr->PCStyle.iNameCheck;
|
||||
resp.BuddyInfo.iPCState = plr.plr->iPCState;
|
||||
resp.BuddyInfo.iGender = plr.plr->PCStyle.iGender;
|
||||
resp.BuddyInfo.bBlocked = 0;
|
||||
resp.BuddyInfo.bFreeChat = 1;
|
||||
if (pkt->iAcceptFlag == 1) {
|
||||
//resp.iBuddySlot = 0; //hard-coding this for now
|
||||
//resp.BuddyInfo.iID = plrReq->iID;
|
||||
resp.BuddyInfo.iPCUID = pkt->iBuddyPCUID;
|
||||
resp.BuddyInfo.iNameCheckFlag = plr.plr->PCStyle.iNameCheck;
|
||||
resp.BuddyInfo.iPCState = plr.plr->iPCState;
|
||||
resp.BuddyInfo.iGender = plr.plr->PCStyle.iGender;
|
||||
resp.BuddyInfo.bBlocked = 0;
|
||||
resp.BuddyInfo.bFreeChat = 1;
|
||||
|
||||
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.szFirstName, plr.plr->PCStyle.szFirstName, sizeof(plr.plr->PCStyle.szFirstName));
|
||||
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));
|
||||
buddyList(sock, resp.BuddyInfo);
|
||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
|
||||
buddyList(sock, resp.BuddyInfo);
|
||||
|
||||
if (plr.plr->PCStyle.iPC_UID == pkt->iBuddyPCUID) {
|
||||
resp.BuddyInfo.iID = plrReq->iID;
|
||||
resp.BuddyInfo.iPCUID = plrReq->PCStyle.iPC_UID;
|
||||
resp.BuddyInfo.iNameCheckFlag = plrReq->PCStyle.iNameCheck;
|
||||
resp.BuddyInfo.iPCState = plrReq->iPCState;
|
||||
resp.BuddyInfo.iGender = plrReq->PCStyle.iGender;
|
||||
resp.BuddyInfo.bBlocked = 0;
|
||||
resp.BuddyInfo.bFreeChat = 1;
|
||||
if (plr.plr->PCStyle.iPC_UID == pkt->iBuddyPCUID) {
|
||||
resp.BuddyInfo.iID = plrReq->iID;
|
||||
resp.BuddyInfo.iPCUID = plrReq->PCStyle.iPC_UID;
|
||||
resp.BuddyInfo.iNameCheckFlag = plrReq->PCStyle.iNameCheck;
|
||||
resp.BuddyInfo.iPCState = plrReq->iPCState;
|
||||
resp.BuddyInfo.iGender = plrReq->PCStyle.iGender;
|
||||
resp.BuddyInfo.bBlocked = 0;
|
||||
resp.BuddyInfo.bFreeChat = 1;
|
||||
|
||||
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.szFirstName, plrReq->PCStyle.szFirstName, sizeof(plrReq->PCStyle.szFirstName));
|
||||
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));
|
||||
buddyList(otherSock, resp.BuddyInfo);
|
||||
}
|
||||
}
|
||||
else {
|
||||
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, declineResp);
|
||||
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
|
||||
buddyList(otherSock, resp.BuddyInfo);
|
||||
}
|
||||
}
|
||||
else {
|
||||
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, declineResp);
|
||||
|
||||
declineResp.iErrorCode = 6; //Buddy declined notification
|
||||
declineResp.iBuddyID = plr.plr->iID;
|
||||
declineResp.iBuddyPCUID = pkt->iBuddyPCUID;
|
||||
declineResp.iErrorCode = 6; //Buddy declined notification
|
||||
declineResp.iBuddyID = plr.plr->iID;
|
||||
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
|
||||
void BuddyManager::reqBuddyFreechat(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_SEND_BUDDY_FREECHAT_MESSAGE))
|
||||
return; // malformed packet
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_SEND_BUDDY_FREECHAT_MESSAGE))
|
||||
return; // malformed packet
|
||||
|
||||
sP_CL2FE_REQ_SEND_BUDDY_FREECHAT_MESSAGE* pkt = (sP_CL2FE_REQ_SEND_BUDDY_FREECHAT_MESSAGE*)data->buf;
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
sP_CL2FE_REQ_SEND_BUDDY_FREECHAT_MESSAGE* pkt = (sP_CL2FE_REQ_SEND_BUDDY_FREECHAT_MESSAGE*)data->buf;
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
if (plr == nullptr)
|
||||
return;
|
||||
if (plr == nullptr)
|
||||
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.iToPCUID = pkt->iBuddyPCUID;
|
||||
resp.iEmoteCode = pkt->iEmoteCode;
|
||||
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
|
||||
resp.iFromPCUID = plr->PCStyle.iPC_UID;
|
||||
resp.iToPCUID = pkt->iBuddyPCUID;
|
||||
resp.iEmoteCode = pkt->iEmoteCode;
|
||||
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
|
||||
|
||||
for (auto pair : PlayerManager::players) {
|
||||
if (pair.second.plr->PCStyle.iPC_UID != plr->PCStyle.iPC_UID) {
|
||||
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.
|
||||
}
|
||||
}
|
||||
for (auto pair : PlayerManager::players) {
|
||||
if (pair.second.plr->PCStyle.iPC_UID != plr->PCStyle.iPC_UID) {
|
||||
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.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Buddy menuchat
|
||||
void BuddyManager::reqBuddyMenuchat(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_SEND_BUDDY_MENUCHAT_MESSAGE))
|
||||
return; // malformed packet
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_SEND_BUDDY_MENUCHAT_MESSAGE))
|
||||
return; // malformed packet
|
||||
|
||||
sP_CL2FE_REQ_SEND_BUDDY_MENUCHAT_MESSAGE* pkt = (sP_CL2FE_REQ_SEND_BUDDY_MENUCHAT_MESSAGE*)data->buf;
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
sP_CL2FE_REQ_SEND_BUDDY_MENUCHAT_MESSAGE* pkt = (sP_CL2FE_REQ_SEND_BUDDY_MENUCHAT_MESSAGE*)data->buf;
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
if (plr == nullptr)
|
||||
return;
|
||||
if (plr == nullptr)
|
||||
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.iToPCUID = pkt->iBuddyPCUID;
|
||||
resp.iEmoteCode = pkt->iEmoteCode;
|
||||
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
|
||||
resp.iFromPCUID = plr->PCStyle.iPC_UID;
|
||||
resp.iToPCUID = pkt->iBuddyPCUID;
|
||||
resp.iEmoteCode = pkt->iEmoteCode;
|
||||
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
|
||||
|
||||
for (auto pair : PlayerManager::players) {
|
||||
if (pair.second.plr->PCStyle.iPC_UID != plr->PCStyle.iPC_UID) {
|
||||
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.
|
||||
}
|
||||
}
|
||||
for (auto pair : PlayerManager::players) {
|
||||
if (pair.second.plr->PCStyle.iPC_UID != plr->PCStyle.iPC_UID) {
|
||||
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.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Getting buddy state
|
||||
void BuddyManager::reqPktGetBuddyState(CNSocket* sock, CNPacketData* data) {
|
||||
INITSTRUCT(sP_FE2CL_REP_GET_BUDDY_STATE_SUCC, resp);
|
||||
INITSTRUCT(sBuddyBaseInfo, buddyInfo);
|
||||
INITSTRUCT(sP_FE2CL_REP_GET_BUDDY_STATE_SUCC, resp);
|
||||
INITSTRUCT(sBuddyBaseInfo, buddyInfo);
|
||||
|
||||
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.aBuddyID[BuddySlot] = buddyInfo.iID;
|
||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_GET_BUDDY_STATE_SUCC, sizeof(sP_FE2CL_REP_GET_BUDDY_STATE_SUCC));
|
||||
}
|
||||
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.aBuddyID[BuddySlot] = buddyInfo.iID;
|
||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_GET_BUDDY_STATE_SUCC, sizeof(sP_FE2CL_REP_GET_BUDDY_STATE_SUCC));
|
||||
}
|
||||
}
|
||||
|
||||
//Blocking the buddy
|
||||
void BuddyManager::reqBuddyBlock(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_SET_BUDDY_BLOCK))
|
||||
return; // malformed packet
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_SET_BUDDY_BLOCK))
|
||||
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.iBuddySlot = pkt->iBuddySlot;
|
||||
resp.iBuddyPCUID = pkt->iBuddyPCUID;
|
||||
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
|
||||
void BuddyManager::reqBuddyDelete(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_REMOVE_BUDDY))
|
||||
return; //malformed packet
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_REMOVE_BUDDY))
|
||||
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.iBuddySlot = pkt->iBuddySlot;
|
||||
resp.iBuddyPCUID = pkt->iBuddyPCUID;
|
||||
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
|
||||
@ -340,104 +340,104 @@ void BuddyManager::reqBuddyWarp(CNSocket* sock, CNPacketData* data) {} //stub
|
||||
#pragma region Helper methods
|
||||
|
||||
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.iBuddyID = plr.plr->iID;
|
||||
resp.iRequestID = plrReq->iID;
|
||||
resp.iBuddyID = plr.plr->iID;
|
||||
|
||||
memcpy(resp.szFirstName, plrReq->PCStyle.szFirstName, sizeof(plrReq->PCStyle.szFirstName));
|
||||
memcpy(resp.szLastName, plrReq->PCStyle.szLastName, sizeof(plrReq->PCStyle.szLastName));
|
||||
memcpy(resp.szFirstName, plrReq->PCStyle.szFirstName, sizeof(plrReq->PCStyle.szFirstName));
|
||||
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
|
||||
void BuddyManager::buddyList(CNSocket* sock, sBuddyBaseInfo BuddyInfo) {
|
||||
|
||||
size_t resplen = sizeof(sP_FE2CL_REP_PC_BUDDYLIST_INFO_SUCC) + sizeof(sBuddyBaseInfo);
|
||||
uint8_t respbuf[4096];
|
||||
size_t resplen = sizeof(sP_FE2CL_REP_PC_BUDDYLIST_INFO_SUCC) + sizeof(sBuddyBaseInfo);
|
||||
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;
|
||||
sBuddyBaseInfo* respdata = (sBuddyBaseInfo*)(respbuf + sizeof(sP_FE2CL_REP_PC_BUDDYLIST_INFO_SUCC));
|
||||
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));
|
||||
|
||||
resp->iID = BuddyInfo.iID;
|
||||
resp->iPCUID = BuddyInfo.iPCUID;
|
||||
resp->iID = BuddyInfo.iID;
|
||||
resp->iPCUID = BuddyInfo.iPCUID;
|
||||
|
||||
for (int i = 0; i < resp->iBuddyCnt && i < resp->iListNum; i++) {
|
||||
respdata->iID = BuddyInfo.iID;
|
||||
respdata->iPCUID = BuddyInfo.iPCUID;
|
||||
respdata->iGender = BuddyInfo.iGender;
|
||||
respdata->iPCState = BuddyInfo.iPCState;
|
||||
respdata->iNameCheckFlag = BuddyInfo.iNameCheckFlag;
|
||||
respdata->bBlocked = 0;
|
||||
respdata->bFreeChat = 1;
|
||||
memcpy(respdata->szFirstName, BuddyInfo.szFirstName, sizeof(BuddyInfo.szFirstName));
|
||||
memcpy(respdata->szLastName, BuddyInfo.szLastName, sizeof(BuddyInfo.szLastName));
|
||||
}
|
||||
for (int i = 0; i < resp->iBuddyCnt && i < resp->iListNum; i++) {
|
||||
respdata->iID = BuddyInfo.iID;
|
||||
respdata->iPCUID = BuddyInfo.iPCUID;
|
||||
respdata->iGender = BuddyInfo.iGender;
|
||||
respdata->iPCState = BuddyInfo.iPCState;
|
||||
respdata->iNameCheckFlag = BuddyInfo.iNameCheckFlag;
|
||||
respdata->bBlocked = 0;
|
||||
respdata->bFreeChat = 1;
|
||||
memcpy(respdata->szFirstName, BuddyInfo.szFirstName, sizeof(BuddyInfo.szFirstName));
|
||||
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.
|
||||
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));
|
||||
memcpy(resp.BuddyInfo.szLastName, plr->PCStyle.szLastName, sizeof(plr->PCStyle.szLastName));
|
||||
//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;
|
||||
|
||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
|
||||
buddyList(sock, resp.BuddyInfo);
|
||||
memcpy(resp.BuddyInfo.szFirstName, plr->PCStyle.szFirstName, sizeof(plr->PCStyle.szFirstName));
|
||||
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
|
||||
bool BuddyManager::firstNameCheck(char16_t reqFirstName[], char16_t resFirstName[], int sizeOfReq, int sizeOfRes) {
|
||||
// If lengths of array are not equal means
|
||||
// array are not equal
|
||||
if (sizeOfReq != sizeOfRes)
|
||||
return false;
|
||||
// If lengths of array are not equal means
|
||||
// array are not equal
|
||||
if (sizeOfReq != sizeOfRes)
|
||||
return false;
|
||||
|
||||
// Sort both arrays
|
||||
std::sort(reqFirstName, reqFirstName + sizeOfReq);
|
||||
std::sort(resFirstName, resFirstName + sizeOfRes);
|
||||
// Sort both arrays
|
||||
std::sort(reqFirstName, reqFirstName + sizeOfReq);
|
||||
std::sort(resFirstName, resFirstName + sizeOfRes);
|
||||
|
||||
// Linearly compare elements
|
||||
for (int i = 0; i < sizeOfReq; i++)
|
||||
if (reqFirstName[i] != resFirstName[i])
|
||||
return false;
|
||||
// Linearly compare elements
|
||||
for (int i = 0; i < sizeOfReq; i++)
|
||||
if (reqFirstName[i] != resFirstName[i])
|
||||
return false;
|
||||
|
||||
// If all elements were same.
|
||||
return true;
|
||||
// If all elements were same.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BuddyManager::lastNameCheck(char16_t reqLastName[], char16_t resLastName[], int sizeOfLNReq, int sizeOfLNRes) {
|
||||
// If lengths of array are not equal means
|
||||
// array are not equal
|
||||
if (sizeOfLNReq != sizeOfLNRes)
|
||||
return false;
|
||||
// If lengths of array are not equal means
|
||||
// array are not equal
|
||||
if (sizeOfLNReq != sizeOfLNRes)
|
||||
return false;
|
||||
|
||||
// Sort both arrays
|
||||
std::sort(reqLastName, reqLastName + sizeOfLNReq);
|
||||
std::sort(resLastName, resLastName + sizeOfLNRes);
|
||||
// Sort both arrays
|
||||
std::sort(reqLastName, reqLastName + sizeOfLNReq);
|
||||
std::sort(resLastName, resLastName + sizeOfLNRes);
|
||||
|
||||
// Linearly compare elements
|
||||
for (int i = 0; i < sizeOfLNReq; i++)
|
||||
if (reqLastName[i] != resLastName[i])
|
||||
return false;
|
||||
// Linearly compare elements
|
||||
for (int i = 0; i < sizeOfLNReq; i++)
|
||||
if (reqLastName[i] != resLastName[i])
|
||||
return false;
|
||||
|
||||
// If all elements were same.
|
||||
return true;
|
||||
// If all elements were same.
|
||||
return true;
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
@ -10,22 +10,22 @@
|
||||
|
||||
namespace BuddyManager {
|
||||
void init();
|
||||
|
||||
|
||||
//Buddy requests
|
||||
void requestBuddy(CNSocket* sock, CNPacketData* data);
|
||||
void reqBuddyByName(CNSocket* sock, CNPacketData* data);
|
||||
|
||||
|
||||
//Buddy accepting
|
||||
void reqAcceptBuddy(CNSocket* sock, CNPacketData* data);
|
||||
void reqFindNameBuddyAccept(CNSocket* sock, CNPacketData* data);
|
||||
|
||||
|
||||
//Buddy Messaging
|
||||
void reqBuddyFreechat(CNSocket* sock, CNPacketData* data);
|
||||
void reqBuddyMenuchat(CNSocket* sock, CNPacketData* data);
|
||||
|
||||
|
||||
//Getting buddy state
|
||||
void reqPktGetBuddyState(CNSocket* sock, CNPacketData* data);
|
||||
|
||||
|
||||
//Blocking/removing buddies
|
||||
void reqBuddyBlock(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
|
||||
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*/
|
||||
Database::updateSelected(findUser->AccountID, findUser->Selected);
|
||||
// check if account isn't currently in use
|
||||
@ -94,7 +94,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
||||
resp.iPaymentFlag = 1;
|
||||
resp.iOpenBetaFlag = 0;
|
||||
resp.uiSvrTime = getTime();
|
||||
|
||||
|
||||
// send the resp in with original key
|
||||
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;
|
||||
auto account = Database::findAccount(U16toU8(exit->szID));
|
||||
|
||||
|
||||
// sanity check
|
||||
if (account == nullptr) {
|
||||
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
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int64_t key = plr->SerialKey;
|
||||
|
||||
|
||||
// save player to DB
|
||||
Database::updatePlayer(PlayerManager::players[cns].plr);
|
||||
PlayerManager::removePlayer(cns);
|
||||
|
@ -20,12 +20,12 @@ std::vector<std::string> parseArgs(std::string full) {
|
||||
bool runCmd(std::string full, CNSocket* sock) {
|
||||
std::vector<std::string> args = parseArgs(full);
|
||||
std::string cmd = args[0].substr(1, args[0].size() - 1);
|
||||
|
||||
|
||||
// check if the command exists
|
||||
if (ChatManager::commands.find(cmd) != ChatManager::commands.end()) {
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
ChatCommand command = ChatManager::commands[cmd];
|
||||
|
||||
|
||||
// sanity check + does the player have the required account level to use the command?
|
||||
if (plr != nullptr && plr->accountLevel <= command.requiredAccLevel) {
|
||||
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
|
||||
last = coords; // update start pos
|
||||
}
|
||||
|
||||
|
||||
TransportManager::SkywayQueues[sock] = path;
|
||||
return;
|
||||
}
|
||||
@ -184,7 +184,7 @@ void ChatManager::registerCommand(std::string cmd, int requiredLevel, CommandHan
|
||||
void ChatManager::chatHandler(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE))
|
||||
return; // malformed packet
|
||||
|
||||
|
||||
sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE* chat = (sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE*)data->buf;
|
||||
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) {
|
||||
if (!checkChunk(chunkPos))
|
||||
return; // do nothing if chunk doesn't even exist
|
||||
|
||||
|
||||
Chunk* chunk = chunks[chunkPos];
|
||||
|
||||
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 z = -1; z < 2; z++) {
|
||||
std::tuple<int, int, int> pos = std::make_tuple(x+i, y+z, inst);
|
||||
|
||||
|
||||
// if chunk exists, add it to the vector
|
||||
if (checkChunk(pos))
|
||||
chnks.push_back(chunks[pos]);
|
||||
|
@ -189,7 +189,7 @@ int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID)
|
||||
return -1;
|
||||
|
||||
DbPlayer create = {};
|
||||
|
||||
|
||||
//set timestamp
|
||||
create.Created = getTimestamp();
|
||||
// save packet data
|
||||
@ -466,7 +466,7 @@ Player Database::DbToPlayer(DbPlayer player) {
|
||||
Database::getInventory(&result);
|
||||
Database::removeExpiredVehicles(&result);
|
||||
Database::getNanos(&result);
|
||||
Database::getQuests(&result);
|
||||
Database::getQuests(&result);
|
||||
|
||||
// load completed quests
|
||||
memcpy(&result.aQuestFlag, player.QuestFlag.data(), std::min(sizeof(result.aQuestFlag), player.QuestFlag.size()));
|
||||
|
@ -66,7 +66,7 @@ enum {
|
||||
EST__END = 37,
|
||||
EST_CORRUPTIONATTACKWIN = 38,
|
||||
EST_CORRUPTIONATTACKLOSE = 39,
|
||||
|
||||
|
||||
ECSB_NONE = 0,
|
||||
ECSB_UP_MOVE_SPEED = 1,
|
||||
ECSB_UP_SWIM_SPEED = 2,
|
||||
@ -88,11 +88,11 @@ enum {
|
||||
ECSB_FREEDOM = 18,
|
||||
ECSB_BOUNDINGBALL = 19,
|
||||
ECSB_INVULNERABLE = 20,
|
||||
ECSB_STIMPAKSLOT1 = 21,
|
||||
ECSB_STIMPAKSLOT2 = 22,
|
||||
ECSB_STIMPAKSLOT3 = 23,
|
||||
ECSB_HEAL = 24,
|
||||
ECSB_EXTRABANK = 25,
|
||||
ECSB_STIMPAKSLOT1 = 21,
|
||||
ECSB_STIMPAKSLOT2 = 22,
|
||||
ECSB_STIMPAKSLOT3 = 23,
|
||||
ECSB_HEAL = 24,
|
||||
ECSB_EXTRABANK = 25,
|
||||
ECSTB__END = 26,
|
||||
};
|
||||
|
||||
|
@ -21,32 +21,32 @@ void GroupManager::init() {
|
||||
void GroupManager::requestGroup(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_GROUP_INVITE))
|
||||
return; // malformed packet
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
if (plr == nullptr || otherPlr == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
otherPlr = PlayerManager::getPlayerFromID(otherPlr->iIDGroup);
|
||||
|
||||
|
||||
if (otherPlr == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
// fail if the group is full or the other player is already in a group
|
||||
if (plr->groupCnt >= 4 || otherPlr->groupCnt > 1) {
|
||||
INITSTRUCT(sP_FE2CL_PC_GROUP_INVITE_FAIL, resp);
|
||||
sock->sendPacket((void*)&resp, P_FE2CL_PC_GROUP_INVITE_FAIL, sizeof(sP_FE2CL_PC_GROUP_INVITE_FAIL));
|
||||
return;
|
||||
}
|
||||
|
||||
CNSocket* otherSock = PlayerManager::getSockFromID(recv->iID_To);
|
||||
|
||||
|
||||
CNSocket* otherSock = PlayerManager::getSockFromID(recv->iID_To);
|
||||
|
||||
if (otherSock == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
INITSTRUCT(sP_FE2CL_PC_GROUP_INVITE, resp);
|
||||
|
||||
resp.iHostID = plr->iIDGroup;
|
||||
@ -57,21 +57,21 @@ void GroupManager::requestGroup(CNSocket* sock, CNPacketData* data) {
|
||||
void GroupManager::refuseGroup(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_GROUP_INVITE_REFUSE))
|
||||
return; // malformed packet
|
||||
|
||||
|
||||
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)
|
||||
return;
|
||||
|
||||
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
|
||||
if (plr == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
INITSTRUCT(sP_FE2CL_PC_GROUP_INVITE_REFUSE, resp);
|
||||
|
||||
|
||||
resp.iID_To = plr->iID;
|
||||
|
||||
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) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_GROUP_JOIN))
|
||||
return; // malformed packet
|
||||
|
||||
|
||||
sP_CL2FE_REQ_PC_GROUP_JOIN* recv = (sP_CL2FE_REQ_PC_GROUP_JOIN*)data->buf;
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
Player* otherPlr = PlayerManager::getPlayerFromID(recv->iID_From);
|
||||
|
||||
|
||||
if (plr == nullptr || otherPlr == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
otherPlr = PlayerManager::getPlayerFromID(otherPlr->iIDGroup);
|
||||
|
||||
|
||||
if (otherPlr == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
// 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) {
|
||||
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));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!validOutVarPacket(sizeof(sP_FE2CL_PC_GROUP_JOIN), otherPlr->groupCnt + 1, sizeof(sPCGroupMemberInfo))) {
|
||||
std::cout << "[WARN] bad sP_FE2CL_PC_GROUP_JOIN packet size\n";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
plr->iIDGroup = otherPlr->iID;
|
||||
otherPlr->groupCnt += 1;
|
||||
otherPlr->groupIDs[otherPlr->groupCnt-1] = plr->iID;
|
||||
|
||||
|
||||
size_t resplen = sizeof(sP_FE2CL_PC_GROUP_JOIN) + otherPlr->groupCnt * sizeof(sPCGroupMemberInfo);
|
||||
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
||||
|
||||
|
||||
memset(respbuf, 0, resplen);
|
||||
|
||||
|
||||
sP_FE2CL_PC_GROUP_JOIN *resp = (sP_FE2CL_PC_GROUP_JOIN*)respbuf;
|
||||
sPCGroupMemberInfo *respdata = (sPCGroupMemberInfo*)(respbuf+sizeof(sP_FE2CL_PC_GROUP_JOIN));
|
||||
|
||||
|
||||
resp->iID_NewMember = plr->iID;
|
||||
resp->iMemberPCCnt = otherPlr->groupCnt;
|
||||
|
||||
|
||||
for (int i = 0; i < otherPlr->groupCnt; i++) {
|
||||
Player* varPlr = PlayerManager::getPlayerFromID(otherPlr->groupIDs[i]);
|
||||
|
||||
|
||||
if (varPlr == nullptr)
|
||||
continue;
|
||||
|
||||
|
||||
respdata[i].iPC_ID = varPlr->iID;
|
||||
respdata[i].iPCUID = varPlr->PCStyle.iPC_UID;
|
||||
respdata[i].iNameCheck = varPlr->PCStyle.iNameCheck;
|
||||
@ -142,33 +142,33 @@ void GroupManager::joinGroup(CNSocket* sock, CNPacketData* data) {
|
||||
respdata[i].iZ = varPlr->z;
|
||||
// client doesnt read nano data here
|
||||
}
|
||||
|
||||
|
||||
sendToGroup(otherPlr, (void*)&respbuf, P_FE2CL_PC_GROUP_JOIN, resplen);
|
||||
}
|
||||
|
||||
void GroupManager::leaveGroup(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(P_CL2FE_REQ_PC_GROUP_LEAVE))
|
||||
return; // malformed packet
|
||||
|
||||
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
|
||||
if (plr == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
groupKickPlayer(plr);
|
||||
}
|
||||
|
||||
void GroupManager::chatGroup(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_SEND_ALL_GROUP_FREECHAT_MESSAGE))
|
||||
return; // malformed packet
|
||||
|
||||
|
||||
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* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||
|
||||
|
||||
if (plr == nullptr || otherPlr == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
// send to client
|
||||
INITSTRUCT(sP_FE2CL_REP_SEND_ALL_GROUP_FREECHAT_MESSAGE_SUCC, resp);
|
||||
memcpy(resp.szFreeChat, chat->szFreeChat, sizeof(chat->szFreeChat));
|
||||
@ -176,18 +176,18 @@ void GroupManager::chatGroup(CNSocket* sock, CNPacketData* data) {
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
void GroupManager::menuChatGroup(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_SEND_ALL_GROUP_MENUCHAT_MESSAGE))
|
||||
return; // malformed packet
|
||||
|
||||
|
||||
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* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||
|
||||
|
||||
if (plr == nullptr || otherPlr == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
// send to client
|
||||
INITSTRUCT(sP_FE2CL_REP_SEND_ALL_GROUP_MENUCHAT_MESSAGE_SUCC, resp);
|
||||
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) {
|
||||
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)
|
||||
continue;
|
||||
|
||||
|
||||
if (type == P_FE2CL_PC_GROUP_LEAVE_SUCC) {
|
||||
Player* leavingPlr = PlayerManager::getPlayer(sock);
|
||||
Player* leavingPlr = PlayerManager::getPlayer(sock);
|
||||
leavingPlr->iIDGroup = leavingPlr->iID;
|
||||
}
|
||||
|
||||
|
||||
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";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
size_t resplen = sizeof(sP_FE2CL_PC_GROUP_MEMBER_INFO) + plr->groupCnt * sizeof(sPCGroupMemberInfo);
|
||||
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
||||
|
||||
|
||||
memset(respbuf, 0, resplen);
|
||||
|
||||
|
||||
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));
|
||||
|
||||
|
||||
resp->iID = plr->iID;
|
||||
resp->iMemberPCCnt = plr->groupCnt;
|
||||
|
||||
|
||||
for (int i = 0; i < plr->groupCnt; i++) {
|
||||
Player* varPlr = PlayerManager::getPlayerFromID(plr->groupIDs[i]);
|
||||
|
||||
|
||||
if (varPlr == nullptr)
|
||||
continue;
|
||||
|
||||
|
||||
respdata[i].iPC_ID = varPlr->iID;
|
||||
respdata[i].iPCUID = varPlr->PCStyle.iPC_UID;
|
||||
respdata[i].iNameCheck = varPlr->PCStyle.iNameCheck;
|
||||
@ -254,7 +254,7 @@ void GroupManager::groupTickInfo(Player* plr) {
|
||||
respdata[i].Nano = varPlr->Nanos[varPlr->activeNano];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
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));
|
||||
plr->groupCnt = 1;
|
||||
plr->groupCnt = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||
|
||||
|
||||
if (otherPlr == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
if (!validOutVarPacket(sizeof(sP_FE2CL_PC_GROUP_LEAVE), otherPlr->groupCnt - 1, sizeof(sPCGroupMemberInfo))) {
|
||||
std::cout << "[WARN] bad sP_FE2CL_PC_GROUP_LEAVE packet size\n";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
size_t resplen = sizeof(sP_FE2CL_PC_GROUP_LEAVE) + (otherPlr->groupCnt - 1) * sizeof(sPCGroupMemberInfo);
|
||||
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
||||
|
||||
|
||||
memset(respbuf, 0, resplen);
|
||||
|
||||
|
||||
sP_FE2CL_PC_GROUP_LEAVE *resp = (sP_FE2CL_PC_GROUP_LEAVE*)respbuf;
|
||||
sPCGroupMemberInfo *respdata = (sPCGroupMemberInfo*)(respbuf+sizeof(sP_FE2CL_PC_GROUP_LEAVE));
|
||||
|
||||
|
||||
resp->iID_LeaveMember = plr->iID;
|
||||
resp->iMemberPCCnt = otherPlr->groupCnt - 1;
|
||||
|
||||
|
||||
int moveDown = 0;
|
||||
|
||||
|
||||
for (int i = 0; i < otherPlr->groupCnt; i++) {
|
||||
Player* varPlr = PlayerManager::getPlayerFromID(otherPlr->groupIDs[i]);
|
||||
|
||||
|
||||
if (varPlr == nullptr)
|
||||
continue;
|
||||
|
||||
|
||||
if (moveDown == 1)
|
||||
otherPlr->groupIDs[i-1] = otherPlr->groupIDs[i];
|
||||
|
||||
|
||||
respdata[i-moveDown].iPC_ID = varPlr->iID;
|
||||
respdata[i-moveDown].iPCUID = varPlr->PCStyle.iPC_UID;
|
||||
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].iZ = varPlr->z;
|
||||
// client doesnt read nano data here
|
||||
|
||||
|
||||
if (varPlr == plr) {
|
||||
moveDown = 1;
|
||||
otherPlr->groupIDs[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
plr->iIDGroup = plr->iID;
|
||||
otherPlr->groupCnt -= 1;
|
||||
|
||||
|
||||
sendToGroup(otherPlr, (void*)&respbuf, P_FE2CL_PC_GROUP_LEAVE, resplen);
|
||||
|
||||
|
||||
CNSocket* sock = PlayerManager::getSockFromID(plr->iID);
|
||||
|
||||
|
||||
if (sock == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
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));
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
namespace GroupManager {
|
||||
void init();
|
||||
|
||||
|
||||
void requestGroup(CNSocket* sock, CNPacketData* data);
|
||||
void refuseGroup(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
|
||||
PlayerManager::sendToViewable(sock, (void*)&equipChange, P_FE2CL_PC_EQUIP_CHANGE, sizeof(sP_FE2CL_PC_EQUIP_CHANGE));
|
||||
|
||||
|
||||
// set equipment stats serverside
|
||||
setItemStats(plr.plr);
|
||||
}
|
||||
@ -159,7 +159,7 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
||||
// send response
|
||||
resp.eTo = itemmove->eFrom;
|
||||
resp.eFrom = itemmove->eTo;
|
||||
|
||||
|
||||
|
||||
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);
|
||||
assert(resplen < CN_PACKET_BUFFER_SIZE - 8);
|
||||
// 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;
|
||||
sTimeLimitItemDeleteInfo2CL* itemData = (sTimeLimitItemDeleteInfo2CL*)(respbuf + sizeof(sP_FE2CL_PC_DELETE_TIME_LIMIT_ITEM));
|
||||
memset(respbuf, 0, resplen);
|
||||
@ -885,7 +885,7 @@ void ItemManager::checkItemExpire(CNSocket* sock, Player* player) {
|
||||
itemData->eIL = player->toRemoveVehicle.eIL;
|
||||
itemData->iSlotNum = player->toRemoveVehicle.iSlotNum;
|
||||
sock->sendPacket((void*)&respbuf, P_FE2CL_PC_DELETE_TIME_LIMIT_ITEM, resplen);
|
||||
|
||||
|
||||
// delete serverside
|
||||
if (player->toRemoveVehicle.eIL == 0)
|
||||
memset(&player->Equip[8], 0, sizeof(sItemBase));
|
||||
@ -910,7 +910,7 @@ void ItemManager::setItemStats(Player* plr) {
|
||||
plr->groupDamage += itemStatsDat->groupDamage;
|
||||
plr->defense += itemStatsDat->defense;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// HACK: work around the invisible weapon bug
|
||||
void ItemManager::updateEquips(CNSocket* sock, Player* plr) {
|
||||
@ -920,7 +920,7 @@ void ItemManager::updateEquips(CNSocket* sock, Player* plr) {
|
||||
resp.iPC_ID = plr->iID;
|
||||
resp.iEquipSlotNum = i;
|
||||
resp.EquipSlotItem = plr->Equip[i];
|
||||
|
||||
|
||||
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, CrocPotEntry> CrocPotTable; // level gap -> entry
|
||||
|
||||
void init();
|
||||
void init();
|
||||
|
||||
void itemMoveHandler(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;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// 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) {
|
||||
// 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));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
response.iTaskNum = missionData->iTaskNum;
|
||||
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
|
||||
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
|
||||
if (plr == nullptr)
|
||||
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);
|
||||
assert(resplen < CN_PACKET_BUFFER_SIZE);
|
||||
// we know it's only one trailing struct, so we can skip full validation
|
||||
|
||||
|
||||
Player *plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
if (plr == nullptr)
|
||||
@ -423,7 +423,7 @@ void MissionManager::mobKilled(CNSocket *sock, int mobid) {
|
||||
|
||||
if (plr == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
bool missionmob = false;
|
||||
|
||||
for (int i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
||||
|
@ -272,7 +272,7 @@ void MobManager::combatStep(Mob *mob, time_t currTime) {
|
||||
aggroCheck(mob, currTime);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Player *plr = PlayerManager::getPlayer(mob->target);
|
||||
|
||||
if (plr == nullptr)
|
||||
@ -396,7 +396,7 @@ void MobManager::retreatStep(Mob *mob, time_t currTime) {
|
||||
return;
|
||||
|
||||
mob->nextMovement = currTime + 500;
|
||||
|
||||
|
||||
int distance = hypot(mob->appearanceData.iX - mob->spawnX, mob->appearanceData.iY - mob->spawnY);
|
||||
|
||||
if (distance > mob->data["m_iIdleRange"]) {
|
||||
@ -421,7 +421,7 @@ void MobManager::retreatStep(Mob *mob, time_t currTime) {
|
||||
mob->killedTime = 0;
|
||||
mob->nextAttack = 0;
|
||||
mob->appearanceData.iConditionBitFlag = 0;
|
||||
|
||||
|
||||
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};
|
||||
|
||||
speed /= 2;
|
||||
|
||||
|
||||
if (speed == 0)
|
||||
return ret;
|
||||
|
||||
|
||||
int distance = hypot(x1 - x2, y1 - y2);
|
||||
|
||||
if (distance > speed) {
|
||||
|
||||
|
||||
int lerps = distance / speed;
|
||||
|
||||
// interpolate only the first point
|
||||
float frac = 1.0f / lerps;
|
||||
float frac = 1.0f / lerps;
|
||||
|
||||
ret.first = (x1 + (x2 - x1) * frac);
|
||||
ret.second = (y1 + (y2 - y1) * frac);
|
||||
@ -510,14 +510,14 @@ void MobManager::combatBegin(CNSocket *sock, CNPacketData *data) {
|
||||
}
|
||||
|
||||
plr->inCombat = true;
|
||||
|
||||
|
||||
// HACK: make sure the player has the right weapon out for combat
|
||||
INITSTRUCT(sP_FE2CL_PC_EQUIP_CHANGE, resp);
|
||||
|
||||
resp.iPC_ID = plr->iID;
|
||||
resp.iEquipSlotNum = 0;
|
||||
resp.EquipSlotItem = plr->Equip[0];
|
||||
|
||||
|
||||
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)
|
||||
plr->iConditionBitFlag ^= CSB_BIT_INFECTION;
|
||||
|
||||
|
||||
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, pkt1);
|
||||
|
||||
pkt1.eCSTB = ECSB_INFECTION; //eCharStatusTimeBuffID
|
||||
@ -555,7 +555,7 @@ void MobManager::dealGooDamage(CNSocket *sock, int amount) {
|
||||
assert(resplen < CN_PACKET_BUFFER_SIZE - 8);
|
||||
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
||||
Player *plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
|
||||
if (plr == nullptr)
|
||||
return;
|
||||
|
||||
@ -606,7 +606,7 @@ void MobManager::playerTick(CNServer *serv, time_t currTime) {
|
||||
CNSocket *sock = pair.first;
|
||||
Player *plr = pair.second.plr;
|
||||
bool transmit = false;
|
||||
|
||||
|
||||
// group ticks
|
||||
if (plr->groupCnt > 1)
|
||||
GroupManager::groupTickInfo(plr);
|
||||
@ -614,7 +614,7 @@ void MobManager::playerTick(CNServer *serv, time_t currTime) {
|
||||
// do not tick dead players
|
||||
if (plr->HP <= 0)
|
||||
continue;
|
||||
|
||||
|
||||
// fm patch/lake damage
|
||||
if (plr->iConditionBitFlag & CSB_BIT_INFECTION)
|
||||
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++) {
|
||||
if (plr->activeNano != 0 && plr->equippedNanos[i] == plr->activeNano) { // spend stamina
|
||||
plr->Nanos[plr->activeNano].iStamina -= 1;
|
||||
|
||||
|
||||
if (plr->passiveNanoOut)
|
||||
plr->Nanos[plr->activeNano].iStamina -= 1;
|
||||
plr->Nanos[plr->activeNano].iStamina -= 1;
|
||||
|
||||
if (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;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
std::pair<int,int> damage;
|
||||
|
||||
|
||||
if (pkt->iTargetCnt > 1)
|
||||
damage = getDamage(plr->groupDamage, target->defense, true, 1);
|
||||
else
|
||||
@ -817,22 +817,22 @@ bool MobManager::aggroCheck(Mob *mob, time_t currTime) {
|
||||
for (Chunk *chunk : mob->currentChunks) {
|
||||
for (CNSocket *s : chunk->players) {
|
||||
Player *plr = s->plr;
|
||||
|
||||
|
||||
if (plr->HP <= 0)
|
||||
continue;
|
||||
|
||||
int mobRange = mob->data["m_iSightRange"];
|
||||
|
||||
|
||||
if (plr->iConditionBitFlag & CSB_BIT_UP_STEALTH)
|
||||
mobRange /= 3;
|
||||
|
||||
|
||||
if (plr->iSpecialState & CN_SPECIAL_STATE_FLAG__INVISIBLE)
|
||||
mobRange = -1;
|
||||
|
||||
|
||||
// height is relevant for aggro distance because of platforming
|
||||
int xyDistance = hypot(mob->appearanceData.iX - plr->x, mob->appearanceData.iY - plr->y);
|
||||
int distance = hypot(xyDistance, mob->appearanceData.iZ - plr->z);
|
||||
|
||||
|
||||
if (distance > mobRange)
|
||||
continue;
|
||||
|
||||
|
@ -119,14 +119,14 @@ void NPCManager::destroyNPC(int32_t id) {
|
||||
// remove NPC from the chunk
|
||||
Chunk* chunk = ChunkManager::chunks[entity->chunkPos];
|
||||
chunk->NPCs.erase(id);
|
||||
|
||||
|
||||
// remove from viewable chunks
|
||||
removeNPC(entity->currentChunks, id);
|
||||
|
||||
// remove from mob manager
|
||||
if (MobManager::Mobs.find(id) != MobManager::Mobs.end())
|
||||
MobManager::Mobs.erase(id);
|
||||
|
||||
|
||||
// finally, remove it from the map and free it
|
||||
NPCs.erase(id);
|
||||
delete entity;
|
||||
@ -257,7 +257,7 @@ void NPCManager::npcVendorSell(CNSocket* sock, CNPacketData* data) {
|
||||
memcpy(&original, item, sizeof(sItemBase));
|
||||
|
||||
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_SUCC, resp);
|
||||
|
||||
|
||||
int sellValue = itemData->sellPrice * req->iItemCnt;
|
||||
|
||||
// increment taros
|
||||
@ -338,7 +338,7 @@ void NPCManager::npcVendorTable(CNSocket* sock, CNPacketData* data) {
|
||||
return; // malformed packet
|
||||
|
||||
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())
|
||||
return;
|
||||
|
||||
@ -423,7 +423,7 @@ void NPCManager::npcCombineItems(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
if (plr == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
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);
|
||||
failResp.iCostumeItemSlot = req->iCostumeItemSlot;
|
||||
@ -502,7 +502,7 @@ void NPCManager::npcCombineItems(CNSocket* sock, CNPacketData* data) {
|
||||
resp.iNewItemSlot = req->iCostumeItemSlot;
|
||||
resp.iStatItemSlot = req->iStatItemSlot;
|
||||
resp.sNewItem = *itemLooks;
|
||||
|
||||
|
||||
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)
|
||||
return;
|
||||
|
||||
|
||||
sP_CL2FE_REQ_NPC_UNSUMMON* req = (sP_CL2FE_REQ_NPC_UNSUMMON*)data->buf;
|
||||
NPCManager::destroyNPC(req->iNPC_ID);
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ void NanoManager::nanoSkillUseHandler(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
int16_t nanoId = plr->activeNano;
|
||||
int16_t skillId = plr->Nanos[nanoId].iSkillID;
|
||||
|
||||
|
||||
DEBUGLOG(
|
||||
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)
|
||||
if (pwr.powers.count(skillId)) // std::set's contains method is C++20 only...
|
||||
pwr.handle(sock, data, nanoId, skillId);
|
||||
|
||||
|
||||
// Group Revive is handled separately (XXX: move into table?)
|
||||
if (GroupRevivePowers.find(skillId) == GroupRevivePowers.end())
|
||||
return;
|
||||
|
||||
Player *leader = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||
|
||||
|
||||
if (leader == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
for (int i = 0; i < leader->groupCnt; i++) {
|
||||
Player* varPlr = PlayerManager::getPlayerFromID(leader->groupIDs[i]);
|
||||
|
||||
|
||||
if (varPlr == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
if (varPlr->HP <= 0)
|
||||
revivePlayer(varPlr);
|
||||
}
|
||||
@ -200,7 +200,7 @@ void NanoManager::nanoSkillSetGMHandler(CNSocket* sock, CNPacketData* data) {
|
||||
void NanoManager::nanoRecallHandler(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_WARP_USE_RECALL))
|
||||
return;
|
||||
|
||||
|
||||
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));
|
||||
@ -210,9 +210,9 @@ void NanoManager::nanoRecallHandler(CNSocket* sock, CNPacketData* data) {
|
||||
void NanoManager::nanoPotionHandler(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_CHARGE_NANO_STAMINA))
|
||||
return;
|
||||
|
||||
|
||||
Player* player = PlayerManager::getPlayer(sock);
|
||||
|
||||
|
||||
// sanity checks
|
||||
if (player == nullptr || player->activeNano == -1 || player->batteryN == 0)
|
||||
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.
|
||||
*/
|
||||
plr->level = level;
|
||||
|
||||
|
||||
if (spendfm)
|
||||
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)
|
||||
summonNano(sock, -1); // just unsummon the nano to prevent infinite buffs
|
||||
|
||||
|
||||
// Update player
|
||||
plr->Nanos[nanoId] = resp.Nano;
|
||||
|
||||
@ -303,22 +303,22 @@ void NanoManager::summonNano(CNSocket *sock, int slot) {
|
||||
|
||||
if (nanoId > 36 || nanoId < -1)
|
||||
return; // sanity check
|
||||
|
||||
|
||||
int16_t skillId = 0;
|
||||
|
||||
|
||||
if (plr->activeNano > 0)
|
||||
for (auto& pwr : PassivePowers)
|
||||
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);
|
||||
plr->passiveNanoOut = false;
|
||||
}
|
||||
|
||||
|
||||
sNano nano = plr->Nanos[nanoId];
|
||||
skillId = nano.iSkillID;
|
||||
|
||||
|
||||
if (slot > -1) {
|
||||
plr->activeNano = nanoId;
|
||||
|
||||
|
||||
for (auto& pwr : PassivePowers)
|
||||
if (pwr.powers.count(skillId)) { // std::set's contains method is C++20 only...
|
||||
resp.eCSTB___Add = 1;
|
||||
@ -327,14 +327,14 @@ void NanoManager::summonNano(CNSocket *sock, int slot) {
|
||||
}
|
||||
} else
|
||||
plr->activeNano = 0;
|
||||
|
||||
|
||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_NANO_ACTIVE_SUCC, sizeof(sP_FE2CL_REP_NANO_ACTIVE_SUCC));
|
||||
|
||||
|
||||
// Send to other players
|
||||
INITSTRUCT(sP_FE2CL_NANO_ACTIVE, pkt1);
|
||||
|
||||
pkt1.iPC_ID = plr->iID;
|
||||
|
||||
|
||||
if (nanoId == -1)
|
||||
memset(&pkt1.Nano, 0, sizeof(pkt1.Nano));
|
||||
else
|
||||
@ -354,10 +354,10 @@ void NanoManager::setNanoSkill(CNSocket* sock, int16_t nanoId, int16_t skillId)
|
||||
|
||||
if (plr == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
if (plr->activeNano > 0 && plr->activeNano == nanoId)
|
||||
summonNano(sock, -1); // just unsummon the nano to prevent infinite buffs
|
||||
|
||||
|
||||
sNano nano = plr->Nanos[nanoId];
|
||||
|
||||
nano.iSkillID = skillId;
|
||||
@ -385,7 +385,7 @@ void NanoManager::resetNanoSkill(CNSocket* sock, int16_t nanoId) {
|
||||
|
||||
if (plr == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
sNano nano = plr->Nanos[nanoId];
|
||||
|
||||
// 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]];
|
||||
|
||||
|
||||
int damage = MobManager::hitMob(sock, mob, amount);
|
||||
|
||||
|
||||
respdata[i].eCT = 4;
|
||||
respdata[i].iDamage = damage;
|
||||
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]];
|
||||
|
||||
|
||||
respdata[i].eCT = 4;
|
||||
respdata[i].iID = mob->appearanceData.iNPC_ID;
|
||||
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
|
||||
if (plr == nullptr)
|
||||
return false;
|
||||
|
||||
|
||||
int healedAmount = PC_MAXHEALTH(plr->level) * amount / 100;
|
||||
|
||||
|
||||
plr->HP += healedAmount;
|
||||
|
||||
|
||||
if (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].iHP = plr->HP;
|
||||
respdata[i].iHealHP = healedAmount;
|
||||
|
||||
|
||||
std::cout << (int)plr->iID << " was healed" << std::endl;
|
||||
|
||||
return true;
|
||||
@ -481,17 +481,17 @@ bool doGroupHeal(CNSocket *sock, int32_t *pktdata, sSkillResult_Heal_HP *respdat
|
||||
// player not found
|
||||
if (plr == nullptr)
|
||||
return false;
|
||||
|
||||
|
||||
Player *leader = PlayerManager::getPlayer(sock);
|
||||
|
||||
// player not found
|
||||
if (leader == nullptr)
|
||||
return false;
|
||||
|
||||
|
||||
int healedAmount = PC_MAXHEALTH(plr->level) * amount / 100;
|
||||
|
||||
|
||||
leader->HP += healedAmount;
|
||||
|
||||
|
||||
if (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].iHP = plr->HP;
|
||||
respdata[i].iHealHP = healedAmount;
|
||||
|
||||
|
||||
std::cout << (int)plr->iID << " was healed" << std::endl;
|
||||
|
||||
return true;
|
||||
@ -512,12 +512,12 @@ bool doDamage(CNSocket *sock, int32_t *pktdata, sSkillResult_Damage *respdata, i
|
||||
return false;
|
||||
}
|
||||
Mob* mob = MobManager::Mobs[pktdata[i]];
|
||||
|
||||
|
||||
Player *plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
if (plr == nullptr)
|
||||
return false;
|
||||
|
||||
|
||||
int damage = MobManager::hitMob(sock, mob, PC_MAXHEALTH(plr->level) * amount / 100);
|
||||
|
||||
respdata[i].eCT = 4;
|
||||
@ -552,9 +552,9 @@ bool doLeech(CNSocket *sock, int32_t *pktdata, sSkillResult_Heal_HP *healdata, i
|
||||
return false;
|
||||
|
||||
int healedAmount = PC_MAXHEALTH(plr->level) * amount / 100;
|
||||
|
||||
|
||||
plr->HP += healedAmount;
|
||||
|
||||
|
||||
if (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;
|
||||
}
|
||||
Mob* mob = MobManager::Mobs[pktdata[i]];
|
||||
|
||||
|
||||
int damage = MobManager::hitMob(sock, mob, PC_MAXHEALTH(plr->level) * amount / 100);
|
||||
|
||||
|
||||
damagedata->eCT = 4;
|
||||
damagedata->iDamage = damage;
|
||||
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));
|
||||
|
||||
size_t resplen;
|
||||
|
||||
|
||||
Player *plr = PlayerManager::getPlayer(sock);
|
||||
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);
|
||||
else if constexpr (specialCase == GHEAL) {
|
||||
otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||
|
||||
|
||||
if (otherPlr == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
pkt->iTargetCnt = otherPlr->groupCnt;
|
||||
}
|
||||
|
||||
resplen = sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC) + pkt->iTargetCnt * sizeof(sPAYLOAD);
|
||||
|
||||
|
||||
// validate response packet
|
||||
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;
|
||||
@ -644,7 +644,7 @@ void activePower(CNSocket *sock, CNPacketData *data,
|
||||
plr->Nanos[plr->activeNano].iStamina -= 40;
|
||||
if (plr->Nanos[plr->activeNano].iStamina < 0)
|
||||
plr->Nanos[plr->activeNano].iStamina = 0;
|
||||
|
||||
|
||||
resp->iPC_ID = plr->iID;
|
||||
resp->iSkillID = skillId;
|
||||
resp->iNanoID = nanoId;
|
||||
@ -653,7 +653,7 @@ void activePower(CNSocket *sock, CNPacketData *data,
|
||||
resp->iTargetCnt = pkt->iTargetCnt;
|
||||
|
||||
CNSocket *workSock = sock;
|
||||
|
||||
|
||||
for (int i = 0; i < pkt->iTargetCnt; i++) {
|
||||
if constexpr (specialCase == GHEAL)
|
||||
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)
|
||||
return;
|
||||
|
||||
|
||||
if (plr->iID == plr->iIDGroup)
|
||||
leader = plr;
|
||||
else
|
||||
leader = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||
|
||||
|
||||
if (leader == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
int pktCnt = 1;
|
||||
|
||||
|
||||
if (groupPower)
|
||||
pktCnt = leader->groupCnt;
|
||||
pktCnt = leader->groupCnt;
|
||||
|
||||
if (!validOutVarPacket(sizeof(sP_FE2CL_NANO_SKILL_USE), pktCnt, sizeof(sSkillResult_Buff))) {
|
||||
std::cout << "[WARN] bad sP_FE2CL_NANO_SKILL_USE packet size\n";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
size_t resplen = sizeof(sP_FE2CL_NANO_SKILL_USE) + pktCnt * sizeof(sSkillResult_Buff);
|
||||
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
||||
|
||||
|
||||
memset(respbuf, 0, resplen);
|
||||
|
||||
|
||||
sP_FE2CL_NANO_SKILL_USE *resp = (sP_FE2CL_NANO_SKILL_USE*)respbuf;
|
||||
sSkillResult_Buff *respdata = (sSkillResult_Buff*)(respbuf+sizeof(sP_FE2CL_NANO_SKILL_USE));
|
||||
|
||||
|
||||
resp->iPC_ID = plr->iID;
|
||||
resp->iSkillID = skillId;
|
||||
resp->iNanoID = nanoId;
|
||||
resp->iNanoStamina = plr->Nanos[plr->activeNano].iStamina;
|
||||
resp->eST = eSkillType;
|
||||
resp->iTargetCnt = pktCnt;
|
||||
|
||||
|
||||
for (int i = 0; i < pktCnt; i++) {
|
||||
Player* varPlr;
|
||||
CNSocket* sockTo;
|
||||
|
||||
|
||||
if (plr->iID == leader->groupIDs[i]) {
|
||||
varPlr = plr;
|
||||
sockTo = sock;
|
||||
@ -734,27 +734,27 @@ void NanoManager::nanoBuff(CNSocket* sock, int16_t nanoId, int skillId, int16_t
|
||||
varPlr = PlayerManager::getPlayerFromID(leader->groupIDs[i]);
|
||||
sockTo = PlayerManager::getSockFromID(leader->groupIDs[i]);
|
||||
}
|
||||
|
||||
|
||||
if (varPlr == nullptr || sockTo == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
if (!(varPlr->iConditionBitFlag & iCBFlag))
|
||||
varPlr->iConditionBitFlag ^= iCBFlag;
|
||||
|
||||
|
||||
respdata[i].eCT = 1;
|
||||
respdata[i].iID = varPlr->iID;
|
||||
respdata[i].iConditionBitFlag = iCBFlag;
|
||||
|
||||
|
||||
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, pkt1);
|
||||
|
||||
|
||||
pkt1.eCSTB = eCharStatusTimeBuffID; //eCharStatusTimeBuffID
|
||||
pkt1.eTBU = 1; //eTimeBuffUpdate
|
||||
pkt1.eTBT = 1; //eTimeBuffType 1 means nano
|
||||
pkt1.iConditionBitFlag = varPlr->iConditionBitFlag;
|
||||
|
||||
|
||||
if (iValue > 0)
|
||||
pkt1.TimeBuff.iValue = iValue;
|
||||
|
||||
|
||||
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) {
|
||||
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, resp1);
|
||||
|
||||
|
||||
Player *plr = PlayerManager::getPlayer(sock);
|
||||
Player *leader;
|
||||
|
||||
if (plr == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
if (plr->iID == plr->iIDGroup)
|
||||
leader = plr;
|
||||
else
|
||||
leader = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||
|
||||
|
||||
if (leader == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
int pktCnt = 1;
|
||||
|
||||
|
||||
if (groupPower)
|
||||
pktCnt = leader->groupCnt;
|
||||
|
||||
pktCnt = leader->groupCnt;
|
||||
|
||||
for (int i = 0; i < pktCnt; i++) {
|
||||
Player* varPlr;
|
||||
CNSocket* sockTo;
|
||||
|
||||
|
||||
if (plr->iID == leader->groupIDs[i]) {
|
||||
varPlr = plr;
|
||||
sockTo = sock;
|
||||
@ -795,18 +795,18 @@ void NanoManager::nanoUnbuff(CNSocket* sock, int32_t iCBFlag, int16_t eCharStatu
|
||||
varPlr = PlayerManager::getPlayerFromID(leader->groupIDs[i]);
|
||||
sockTo = PlayerManager::getSockFromID(leader->groupIDs[i]);
|
||||
}
|
||||
|
||||
|
||||
if (varPlr->iConditionBitFlag & iCBFlag)
|
||||
varPlr->iConditionBitFlag ^= iCBFlag;
|
||||
|
||||
|
||||
resp1.eCSTB = eCharStatusTimeBuffID; //eCharStatusTimeBuffID
|
||||
resp1.eTBU = 2; //eTimeBuffUpdate
|
||||
resp1.eTBT = 1; //eTimeBuffType 1 means nano
|
||||
resp1.iConditionBitFlag = varPlr->iConditionBitFlag;
|
||||
|
||||
|
||||
if (iValue > 0)
|
||||
resp1.TimeBuff.iValue = iValue;
|
||||
|
||||
|
||||
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);
|
||||
|
||||
plr->HP = PC_MAXHEALTH(plr->level);
|
||||
|
||||
|
||||
// Nanos
|
||||
int activeSlot = -1;
|
||||
for (int n = 0; n < 3; n++) {
|
||||
|
@ -31,7 +31,7 @@ struct PassivePower {
|
||||
int16_t eCharStatusTimeBuffID;
|
||||
int16_t iValue;
|
||||
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) {}
|
||||
};
|
||||
|
||||
@ -60,10 +60,10 @@ namespace NanoManager {
|
||||
void summonNano(CNSocket* sock, int slot);
|
||||
void setNanoSkill(CNSocket* sock, int16_t nanoId, int16_t skillId);
|
||||
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 nanoUnbuff(CNSocket* sock, int32_t iCBFlag, int16_t eCharStatusTimeBuffID, int16_t iValue = 0, bool groupPower = false);
|
||||
|
||||
|
||||
int nanoStyle(int nanoId);
|
||||
void revivePlayer(Player* plr);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ struct Player {
|
||||
|
||||
bool inCombat;
|
||||
bool passiveNanoOut;
|
||||
|
||||
|
||||
int pointDamage;
|
||||
int groupDamage;
|
||||
int defense;
|
||||
@ -60,7 +60,7 @@ struct Player {
|
||||
int32_t CurrentMissionID;
|
||||
|
||||
sTimeLimitItemDeleteInfo2CL toRemoveVehicle;
|
||||
|
||||
|
||||
int32_t iIDGroup;
|
||||
int groupCnt;
|
||||
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_REQ_PC_VEHICLE_ON, PlayerManager::enterPlayerVehicle);
|
||||
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) {
|
||||
@ -63,7 +63,7 @@ void PlayerManager::addPlayer(CNSocket* key, Player plr) {
|
||||
|
||||
void PlayerManager::removePlayer(CNSocket* key) {
|
||||
PlayerView& view = players[key];
|
||||
|
||||
|
||||
GroupManager::groupKickPlayer(view.plr);
|
||||
|
||||
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) {
|
||||
|
||||
|
||||
PlayerManager::updatePlayerPosition(sock, X, Y, Z);
|
||||
INITSTRUCT(sP_FE2CL_REP_PC_GOTO_SUCC, pkt);
|
||||
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
|
||||
Player plr = CNSharedData::getPlayer(enter->iEnterSerialKey);
|
||||
|
||||
|
||||
plr.groupCnt = 1;
|
||||
plr.iIDGroup = plr.groupIDs[0] = plr.iID;
|
||||
|
||||
@ -288,7 +288,7 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
response.PCLoadData2CL.iActiveNanoSlotNum = -1;
|
||||
response.PCLoadData2CL.iFatigue = 50;
|
||||
response.PCLoadData2CL.PCStyle = plr.PCStyle;
|
||||
|
||||
|
||||
//client doesnt read this, it gets it from charinfo
|
||||
//response.PCLoadData2CL.PCStyle2 = plr.PCStyle2;
|
||||
// inventory
|
||||
@ -318,7 +318,7 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
/*
|
||||
* client doesn't care about NeededItem ID and Count,
|
||||
* it gets Count from Quest Inventory
|
||||
*
|
||||
*
|
||||
* KillNPCCount sets RemainEnemyNum in the client
|
||||
* Yes, this is extraordinary stupid.
|
||||
*/
|
||||
@ -351,7 +351,7 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
addPlayer(sock, plr);
|
||||
//check if there is an expiring vehicle
|
||||
ItemManager::checkItemExpire(sock, getPlayer(sock));
|
||||
|
||||
|
||||
//set player equip stats
|
||||
ItemManager::setItemStats(getPlayer(sock));
|
||||
}
|
||||
@ -361,7 +361,7 @@ void PlayerManager::sendToViewable(CNSocket* sock, void* buf, uint32_t type, siz
|
||||
for (CNSocket* otherSock : chunk->players) {
|
||||
if (otherSock == sock)
|
||||
continue;
|
||||
|
||||
|
||||
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;
|
||||
updatePlayerPosition(sock, moveData->iX, moveData->iY, moveData->iZ, moveData->iAngle);
|
||||
|
||||
|
||||
players[sock].plr->angle = moveData->iAngle;
|
||||
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;
|
||||
INITSTRUCT(sP_FE2CL_REP_PC_REGEN_SUCC, response);
|
||||
INITSTRUCT(sP_FE2CL_PC_REGEN, resp2);
|
||||
|
||||
|
||||
int activeSlot = -1;
|
||||
|
||||
|
||||
if (reviveData->iRegenType == 3 && plr->iConditionBitFlag & CSB_BIT_PHOENIX) {
|
||||
// nano revive
|
||||
plr->Nanos[plr->activeNano].iStamina = 0;
|
||||
@ -761,7 +761,7 @@ void PlayerManager::revivePlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
if (reviveData->iRegenType != 5)
|
||||
plr->HP = PC_MAXHEALTH(plr->level);
|
||||
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
int nanoID = plr->equippedNanos[i];
|
||||
|
||||
@ -874,7 +874,7 @@ void PlayerManager::changePlayerGuide(CNSocket *sock, CNPacketData *data) {
|
||||
resp.iMentor = pkt->iMentor;
|
||||
resp.iMentorCnt = 1;
|
||||
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));
|
||||
// if it's changed from computress
|
||||
if (plr->mentor == 5) {
|
||||
@ -897,7 +897,7 @@ void PlayerManager::changePlayerGuide(CNSocket *sock, CNPacketData *data) {
|
||||
Player *PlayerManager::getPlayer(CNSocket* key) {
|
||||
if (players.find(key) != players.end())
|
||||
return players[key].plr;
|
||||
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ void TableData::init() {
|
||||
std::cout << "[INFO] Loaded " << ItemManager::ItemData.size() << " items" << std::endl;
|
||||
|
||||
// load player limits from m_pAvatarTable.m_pAvatarGrowData
|
||||
|
||||
|
||||
nlohmann::json growth = xdtData["m_pAvatarTable"]["m_pAvatarGrowData"];
|
||||
|
||||
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.
|
||||
*/
|
||||
void TransportManager::stepSkywaySystem() {
|
||||
|
||||
|
||||
// using an unordered map so we can remove finished players in one iteration
|
||||
std::unordered_map<CNSocket*, std::queue<WarpLocation>>::iterator it = SkywayQueues.begin();
|
||||
while (it != SkywayQueues.end()) {
|
||||
|
||||
std::queue<WarpLocation>* queue = &it->second;
|
||||
|
||||
|
||||
Player* plr = PlayerManager::getPlayer(it->first);
|
||||
|
||||
|
||||
if (plr == nullptr) {
|
||||
// pluck out dead socket + update iterator
|
||||
it = SkywayQueues.erase(it);
|
||||
|
Loading…
Reference in New Issue
Block a user