mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
Cleanup for 1.2.
Cleaned up whitespace, comments, brace style, etc. Updated tdata reference.
This commit is contained in:
parent
d713fafb1c
commit
10534886b8
@ -22,7 +22,7 @@ void BuddyManager::init() {
|
|||||||
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
|
||||||
@ -51,12 +51,12 @@ void BuddyManager::requestBuddy(CNSocket* sock, CNPacketData* data) {
|
|||||||
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
|
||||||
@ -72,13 +72,13 @@ void BuddyManager::reqBuddyByName(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ void BuddyManager::reqBuddyByName(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//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
|
||||||
@ -118,7 +118,7 @@ void BuddyManager::reqAcceptBuddy(CNSocket* sock, CNPacketData* data) {
|
|||||||
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;
|
||||||
@ -131,7 +131,7 @@ void BuddyManager::reqAcceptBuddy(CNSocket* sock, CNPacketData* data) {
|
|||||||
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;
|
||||||
@ -143,21 +143,20 @@ void BuddyManager::reqAcceptBuddy(CNSocket* sock, CNPacketData* data) {
|
|||||||
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
|
||||||
@ -188,7 +187,7 @@ void BuddyManager::reqFindNameBuddyAccept(CNSocket* sock, CNPacketData* data) {
|
|||||||
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;
|
||||||
@ -218,11 +217,10 @@ void BuddyManager::reqFindNameBuddyAccept(CNSocket* sock, CNPacketData* data) {
|
|||||||
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;
|
||||||
|
|
||||||
@ -231,7 +229,7 @@ void BuddyManager::reqFindNameBuddyAccept(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//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
|
||||||
@ -250,19 +248,19 @@ void BuddyManager::reqBuddyFreechat(CNSocket* sock, CNPacketData* data) {
|
|||||||
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
|
||||||
@ -281,29 +279,29 @@ void BuddyManager::reqBuddyMenuchat(CNSocket* sock, CNPacketData* data) {
|
|||||||
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
|
||||||
@ -319,10 +317,10 @@ void BuddyManager::reqBuddyBlock(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//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;
|
||||||
|
|
||||||
@ -334,8 +332,8 @@ void BuddyManager::reqBuddyDelete(CNSocket* sock, CNPacketData* data) {
|
|||||||
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
|
||||||
void BuddyManager::reqBuddyWarp(CNSocket* sock, CNPacketData* data) {} //stub
|
void BuddyManager::reqBuddyWarp(CNSocket* sock, CNPacketData* data) {} // stub
|
||||||
|
|
||||||
#pragma region Helper methods
|
#pragma region Helper methods
|
||||||
|
|
||||||
@ -348,11 +346,11 @@ void BuddyManager::requestedBuddy(CNSocket* sock, Player* plrReq, PlayerView& pl
|
|||||||
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);
|
||||||
@ -378,14 +376,14 @@ void BuddyManager::buddyList(CNSocket* sock, sBuddyBaseInfo BuddyInfo) {
|
|||||||
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.iBuddySlot = 0; //hard-coding this for now
|
||||||
resp.BuddyInfo.iID = BuddyID;
|
resp.BuddyInfo.iID = BuddyID;
|
||||||
resp.BuddyInfo.iPCUID = BuddyPCUID;
|
resp.BuddyInfo.iPCUID = BuddyPCUID;
|
||||||
resp.BuddyInfo.iNameCheckFlag = plr->PCStyle.iNameCheck;
|
resp.BuddyInfo.iNameCheckFlag = plr->PCStyle.iNameCheck;
|
||||||
@ -401,7 +399,7 @@ void BuddyManager::otherAcceptBuddy(CNSocket* sock, int32_t BuddyID, int64_t Bud
|
|||||||
buddyList(sock, resp.BuddyInfo);
|
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
|
||||||
|
@ -1,44 +1,44 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Player.hpp"
|
|
||||||
#include "CNProtocol.hpp"
|
|
||||||
#include "CNStructs.hpp"
|
|
||||||
#include "CNShardServer.hpp"
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
namespace BuddyManager {
|
|
||||||
void init();
|
|
||||||
|
|
||||||
//Buddy requests
|
#include "Player.hpp"
|
||||||
void requestBuddy(CNSocket* sock, CNPacketData* data);
|
#include "CNProtocol.hpp"
|
||||||
|
#include "CNStructs.hpp"
|
||||||
|
#include "CNShardServer.hpp"
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
namespace BuddyManager {
|
||||||
|
void init();
|
||||||
|
|
||||||
|
// Buddy requests
|
||||||
|
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);
|
||||||
|
|
||||||
//Buddy warping
|
// Buddy warping
|
||||||
void reqBuddyWarp(CNSocket* sock, CNPacketData* data);
|
void reqBuddyWarp(CNSocket* sock, CNPacketData* data);
|
||||||
|
|
||||||
//helper methods
|
|
||||||
void requestedBuddy(CNSocket* sock, Player* plrReq, PlayerView& plr);
|
|
||||||
void buddyList(CNSocket* sock, sBuddyBaseInfo BuddyInfo); //updates the buddylist
|
|
||||||
void otherAcceptBuddy(CNSocket* sock, int32_t BuddyID, int64_t BuddyPCUID, sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC resp, Player* plr); //tells the other player that they are now buddies with the requester.
|
|
||||||
|
|
||||||
//Name checks
|
// helper methods
|
||||||
bool firstNameCheck(char16_t reqFirstName[], char16_t resFirstName[], int sizeOfReq, int sizeOfRes); //checks if the request and requested player's first names match
|
void requestedBuddy(CNSocket* sock, Player* plrReq, PlayerView& plr);
|
||||||
bool lastNameCheck(char16_t reqLastName[], char16_t resLastName[], int sizeOfLNReq, int sizeOfLNRes); //checks if the request and requested player's last names match
|
void buddyList(CNSocket* sock, sBuddyBaseInfo BuddyInfo); // updates the buddylist
|
||||||
|
void otherAcceptBuddy(CNSocket* sock, int32_t BuddyID, int64_t BuddyPCUID, sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC resp, Player* plr); // tells the other player that they are now buddies with the requester.
|
||||||
|
|
||||||
|
// Name checks
|
||||||
|
bool firstNameCheck(char16_t reqFirstName[], char16_t resFirstName[], int sizeOfReq, int sizeOfRes); // checks if the request and requested player's first names match
|
||||||
|
bool lastNameCheck(char16_t reqLastName[], char16_t resLastName[], int sizeOfLNReq, int sizeOfLNRes); // checks if the request and requested player's last names match
|
||||||
}
|
}
|
||||||
|
@ -57,27 +57,23 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
loginSessions[sock].slot = 1;
|
loginSessions[sock].slot = 1;
|
||||||
loginSessions[sock].lastHeartbeat = getTime();
|
loginSessions[sock].lastHeartbeat = getTime();
|
||||||
success = true;
|
success = true;
|
||||||
}
|
|
||||||
// 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
|
||||||
if (CNLoginServer::isAccountInUse(findUser->AccountID)) {
|
if (CNLoginServer::isAccountInUse(findUser->AccountID)) {
|
||||||
errorCode = (int)LoginError::ID_ALREADY_IN_USE;
|
errorCode = (int)LoginError::ID_ALREADY_IN_USE;
|
||||||
}
|
} else { // if not, login success
|
||||||
// if not, login success
|
|
||||||
else
|
|
||||||
{
|
|
||||||
loginSessions[sock] = CNLoginData();
|
loginSessions[sock] = CNLoginData();
|
||||||
loginSessions[sock].userID = findUser->AccountID;
|
loginSessions[sock].userID = findUser->AccountID;
|
||||||
loginSessions[sock].slot = findUser->Selected;
|
loginSessions[sock].slot = findUser->Selected;
|
||||||
loginSessions[sock].lastHeartbeat = getTime();
|
loginSessions[sock].lastHeartbeat = getTime();
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
errorCode = (int)LoginError::ID_AND_PASSWORD_DO_NOT_MATCH;
|
errorCode = (int)LoginError::ID_AND_PASSWORD_DO_NOT_MATCH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -369,11 +365,12 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
if (settings::VERBOSITY)
|
if (settings::VERBOSITY)
|
||||||
std::cerr << "OpenFusion: LOGIN UNIMPLM ERR. PacketType: " << Defines::p2str(CL2LS, data->type) << " (" << data->type << ")" << std::endl;
|
std::cerr << "OpenFusion: LOGIN UNIMPLM ERR. PacketType: " << Defines::p2str(CL2LS, data->type) << " (" << data->type << ")" << std::endl;
|
||||||
break;
|
break;
|
||||||
/* Unimplemented CL2LS packets:
|
/*
|
||||||
P_CL2LS_CHECK_NAME_LIST - unused by the client
|
* Unimplemented CL2LS packets:
|
||||||
P_CL2LS_REQ_SERVER_SELECT
|
* P_CL2LS_CHECK_NAME_LIST - unused by the client
|
||||||
P_CL2LS_REQ_SHARD_LIST_INFO - dev commands, useless as we only run 1 server
|
* P_CL2LS_REQ_SERVER_SELECT
|
||||||
*/
|
* P_CL2LS_REQ_SHARD_LIST_INFO - dev commands, useless as we only run 1 server
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,8 +9,7 @@ int CNSocketEncryption::Encrypt_byte_change_A(int ERSize, uint8_t* data, int siz
|
|||||||
int num2 = 0;
|
int num2 = 0;
|
||||||
int num3 = 0;
|
int num3 = 0;
|
||||||
|
|
||||||
while (num + ERSize <= size)
|
while (num + ERSize <= size) {
|
||||||
{
|
|
||||||
int num4 = num + num3;
|
int num4 = num + num3;
|
||||||
int num5 = num + (ERSize - 1 - num3);
|
int num5 = num + (ERSize - 1 - num3);
|
||||||
|
|
||||||
@ -19,8 +18,7 @@ int CNSocketEncryption::Encrypt_byte_change_A(int ERSize, uint8_t* data, int siz
|
|||||||
data[num5] = b;
|
data[num5] = b;
|
||||||
num += ERSize;
|
num += ERSize;
|
||||||
num3++;
|
num3++;
|
||||||
if (num3 > ERSize / 2)
|
if (num3 > ERSize / 2) {
|
||||||
{
|
|
||||||
num3 = 0;
|
num3 = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,13 +54,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Packets format (sent from the client):
|
* Packets format (sent from the client):
|
||||||
[4 bytes] - size of packet including the 4 byte packet type
|
* [4 bytes] - size of packet including the 4 byte packet type
|
||||||
[size bytes] - Encrypted packet (byte swapped && xor'd with 8 byte key; see CNSocketEncryption)
|
* [size bytes] - Encrypted packet (byte swapped && xor'd with 8 byte key; see CNSocketEncryption)
|
||||||
[4 bytes] - packet type (which is a combination of the first 4 bytes of the packet and a checksum in some versions)
|
* [4 bytes] - packet type (which is a combination of the first 4 bytes of the packet and a checksum in some versions)
|
||||||
[structure] - one member contains length of trailing data (expressed in packet-dependant structures)
|
* [structure] - one member contains length of trailing data (expressed in packet-dependant structures)
|
||||||
[trailing data] - optional variable-length data that only some packets make use of
|
* [trailing data] - optional variable-length data that only some packets make use of
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// error checking calloc wrapper
|
// error checking calloc wrapper
|
||||||
inline void* xmalloc(size_t sz) {
|
inline void* xmalloc(size_t sz) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
CNShared.hpp
|
* CNShared.hpp
|
||||||
There's some data shared between the Login Server and the Shard Server. Of course all of this needs to be thread-safe. No mucking about on this one!
|
* There's some data shared between the Login Server and the Shard Server. Of course all of this needs to be thread-safe. No mucking about on this one!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
CNStructs.hpp - defines some basic structs & useful methods for packets used by FusionFall based on the version defined
|
* CNStructs.hpp - defines some basic structs & useful methods for packets used by FusionFall based on the version defined
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ void toggleAiCommand(std::string full, std::vector<std::string>& args, CNSocket*
|
|||||||
void npcRotateCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
void npcRotateCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
PlayerView& plrv = PlayerManager::players[sock];
|
PlayerView& plrv = PlayerManager::players[sock];
|
||||||
Player* plr = plrv.plr;
|
Player* plr = plrv.plr;
|
||||||
|
|
||||||
BaseNPC* npc = NPCManager::getNearestNPC(plrv.currentChunks, plr->x, plr->y, plr->z);
|
BaseNPC* npc = NPCManager::getNearestNPC(plrv.currentChunks, plr->x, plr->y, plr->z);
|
||||||
|
|
||||||
if (npc == nullptr) {
|
if (npc == nullptr) {
|
||||||
|
@ -94,7 +94,7 @@ void ChunkManager::destroyChunk(std::tuple<int, int, uint64_t> chunkPos) {
|
|||||||
for (Chunk* otherChunk : grabChunks(chunkPos)) {
|
for (Chunk* otherChunk : grabChunks(chunkPos)) {
|
||||||
if (otherChunk == chunk)
|
if (otherChunk == chunk)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// remove from NPCs
|
// remove from NPCs
|
||||||
for (uint32_t id : otherChunk->NPCs) {
|
for (uint32_t id : otherChunk->NPCs) {
|
||||||
if (std::find(NPCManager::NPCs[id]->currentChunks.begin(), NPCManager::NPCs[id]->currentChunks.end(), chunk) != NPCManager::NPCs[id]->currentChunks.end()) {
|
if (std::find(NPCManager::NPCs[id]->currentChunks.begin(), NPCManager::NPCs[id]->currentChunks.end(), chunk) != NPCManager::NPCs[id]->currentChunks.end()) {
|
||||||
@ -223,8 +223,7 @@ void ChunkManager::createInstance(uint64_t instanceID) {
|
|||||||
NPCManager::updateNPCInstance(newID, instanceID); // make sure the npc state gets updated
|
NPCManager::updateNPCInstance(newID, instanceID); // make sure the npc state gets updated
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
std::cout << "Instance " << instanceID << " already exists" << std::endl;
|
std::cout << "Instance " << instanceID << " already exists" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
INSTANCE_OVERWORLD // default instance every player starts in
|
INSTANCE_OVERWORLD, // default instance every player starts in
|
||||||
//INSTANCE_IZ, // these aren't actually used
|
INSTANCE_IZ, // these aren't actually used
|
||||||
//INSTANCE_UNIQUE
|
INSTANCE_UNIQUE // these aren't actually used
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace ChunkManager {
|
namespace ChunkManager {
|
||||||
|
@ -100,8 +100,7 @@ auto db = make_storage("database.db",
|
|||||||
|
|
||||||
#pragma region LoginServer
|
#pragma region LoginServer
|
||||||
|
|
||||||
void Database::open()
|
void Database::open() {
|
||||||
{
|
|
||||||
// this parameter means it will try to preserve data during migration
|
// this parameter means it will try to preserve data during migration
|
||||||
bool preserve = true;
|
bool preserve = true;
|
||||||
db.sync_schema(preserve);
|
db.sync_schema(preserve);
|
||||||
@ -130,8 +129,7 @@ int Database::getPlayersCount() {
|
|||||||
return db.count<DbPlayer>();
|
return db.count<DbPlayer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Database::addAccount(std::string login, std::string password)
|
int Database::addAccount(std::string login, std::string password) {
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
password = BCrypt::generateHash(password);
|
password = BCrypt::generateHash(password);
|
||||||
@ -143,19 +141,17 @@ int Database::addAccount(std::string login, std::string password)
|
|||||||
return db.insert(account);
|
return db.insert(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::updateSelected(int accountId, int slot)
|
void Database::updateSelected(int accountId, int slot) {
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
Account acc = db.get<Account>(accountId);
|
Account acc = db.get<Account>(accountId);
|
||||||
acc.Selected = slot;
|
acc.Selected = slot;
|
||||||
//timestamp
|
// timestamp
|
||||||
acc.LastLogin = getTimestamp();
|
acc.LastLogin = getTimestamp();
|
||||||
db.update(acc);
|
db.update(acc);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Database::Account> Database::findAccount(std::string login)
|
std::unique_ptr<Database::Account> Database::findAccount(std::string login) {
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
// this is awful, I've tried everything to improve it
|
// this is awful, I've tried everything to improve it
|
||||||
@ -167,8 +163,7 @@ std::unique_ptr<Database::Account> Database::findAccount(std::string login)
|
|||||||
std::unique_ptr<Account>(new Account(find.front()));
|
std::unique_ptr<Account>(new Account(find.front()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::isNameFree(sP_CL2LS_REQ_CHECK_CHAR_NAME* nameCheck)
|
bool Database::isNameFree(sP_CL2LS_REQ_CHECK_CHAR_NAME* nameCheck) {
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
std::string First = U16toU8(nameCheck->szFirstName);
|
std::string First = U16toU8(nameCheck->szFirstName);
|
||||||
@ -180,8 +175,7 @@ bool Database::isNameFree(sP_CL2LS_REQ_CHECK_CHAR_NAME* nameCheck)
|
|||||||
.empty());
|
.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID)
|
int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID) {
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
// fail if the player already has 4 or more characters
|
// fail if the player already has 4 or more characters
|
||||||
@ -190,7 +184,7 @@ int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID)
|
|||||||
|
|
||||||
DbPlayer create = {};
|
DbPlayer create = {};
|
||||||
|
|
||||||
//set timestamp
|
// set timestamp
|
||||||
create.Created = getTimestamp();
|
create.Created = getTimestamp();
|
||||||
// save packet data
|
// save packet data
|
||||||
create.FirstName = U16toU8(save->szFirstName);
|
create.FirstName = U16toU8(save->szFirstName);
|
||||||
@ -226,7 +220,7 @@ int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID)
|
|||||||
create.y_coordinates = settings::SPAWN_Y;
|
create.y_coordinates = settings::SPAWN_Y;
|
||||||
create.z_coordinates = settings::SPAWN_Z;
|
create.z_coordinates = settings::SPAWN_Z;
|
||||||
create.angle = settings::SPAWN_ANGLE;
|
create.angle = settings::SPAWN_ANGLE;
|
||||||
//set mentor to computress
|
// set mentor to computress
|
||||||
create.Mentor = 5;
|
create.Mentor = 5;
|
||||||
|
|
||||||
// initialize the quest blob to 128 0-bytes
|
// initialize the quest blob to 128 0-bytes
|
||||||
@ -235,8 +229,7 @@ int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID)
|
|||||||
return db.insert(create);
|
return db.insert(create);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character)
|
void Database::finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character) {
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
DbPlayer finish = getDbPlayerById(character->PCStyle.iPC_UID);
|
DbPlayer finish = getDbPlayerById(character->PCStyle.iPC_UID);
|
||||||
@ -277,8 +270,7 @@ void Database::finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character)
|
|||||||
db.insert(UB);
|
db.insert(UB);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::finishTutorial(int PlayerID)
|
void Database::finishTutorial(int PlayerID) {
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
Player finish = getPlayer(PlayerID);
|
Player finish = getPlayer(PlayerID);
|
||||||
@ -307,8 +299,7 @@ void Database::finishTutorial(int PlayerID)
|
|||||||
db.update(playerToDb(&finish));
|
db.update(playerToDb(&finish));
|
||||||
}
|
}
|
||||||
|
|
||||||
int Database::deleteCharacter(int characterID, int userID)
|
int Database::deleteCharacter(int characterID, int userID) {
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
auto find =
|
auto find =
|
||||||
@ -321,8 +312,7 @@ int Database::deleteCharacter(int characterID, int userID)
|
|||||||
return slot;
|
return slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector <Player> Database::getCharacters(int UserID)
|
std::vector <Player> Database::getCharacters(int UserID) {
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
std::vector<DbPlayer>characters =
|
std::vector<DbPlayer>characters =
|
||||||
@ -361,9 +351,8 @@ void Database::changeName(sP_CL2LS_REQ_CHANGE_CHAR_NAME* save) {
|
|||||||
db.update(Player);
|
db.update(Player);
|
||||||
}
|
}
|
||||||
|
|
||||||
Database::DbPlayer Database::playerToDb(Player *player)
|
Database::DbPlayer Database::playerToDb(Player *player) {
|
||||||
{
|
// TODO: move stuff that is never updated to separate table so it doesn't try to update it every time
|
||||||
//TODO: move stuff that is never updated to separate table so it doesn't try to update it every time
|
|
||||||
DbPlayer result = {};
|
DbPlayer result = {};
|
||||||
|
|
||||||
result.PlayerID = player->iID;
|
result.PlayerID = player->iID;
|
||||||
@ -395,8 +384,7 @@ Database::DbPlayer Database::playerToDb(Player *player)
|
|||||||
result.y_coordinates = player->y;
|
result.y_coordinates = player->y;
|
||||||
result.z_coordinates = player->z;
|
result.z_coordinates = player->z;
|
||||||
result.angle = player->angle;
|
result.angle = player->angle;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
result.x_coordinates = player->lastX;
|
result.x_coordinates = player->lastX;
|
||||||
result.y_coordinates = player->lastY;
|
result.y_coordinates = player->lastY;
|
||||||
result.z_coordinates = player->lastZ;
|
result.z_coordinates = player->lastZ;
|
||||||
@ -580,8 +568,7 @@ void Database::updateNanos(Player *player) {
|
|||||||
where(c(&Nano::playerId) == player->iID)
|
where(c(&Nano::playerId) == player->iID)
|
||||||
);
|
);
|
||||||
// insert
|
// insert
|
||||||
for (int i=1; i < SIZEOF_NANO_BANK_SLOT; i++)
|
for (int i=1; i < SIZEOF_NANO_BANK_SLOT; i++) {
|
||||||
{
|
|
||||||
if ((player->Nanos[i]).iID == 0)
|
if ((player->Nanos[i]).iID == 0)
|
||||||
continue;
|
continue;
|
||||||
Nano toAdd = {};
|
Nano toAdd = {};
|
||||||
@ -603,8 +590,7 @@ void Database::updateQuests(Player* player) {
|
|||||||
where(c(&DbQuest::PlayerId) == player->iID)
|
where(c(&DbQuest::PlayerId) == player->iID)
|
||||||
);
|
);
|
||||||
// insert
|
// insert
|
||||||
for (int i = 0; i < ACTIVE_MISSION_COUNT; i++)
|
for (int i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
||||||
{
|
|
||||||
if (player->tasks[i] == 0)
|
if (player->tasks[i] == 0)
|
||||||
continue;
|
continue;
|
||||||
DbQuest toAdd = {};
|
DbQuest toAdd = {};
|
||||||
@ -655,8 +641,7 @@ void Database::removeExpiredVehicles(Player* player) {
|
|||||||
std::vector<sItemBase*> toRemove;
|
std::vector<sItemBase*> toRemove;
|
||||||
|
|
||||||
// equiped vehicle
|
// equiped vehicle
|
||||||
if (player->Equip[8].iOpt > 0 && player->Equip[8].iTimeLimit < currentTime)
|
if (player->Equip[8].iOpt > 0 && player->Equip[8].iTimeLimit < currentTime) {
|
||||||
{
|
|
||||||
toRemove.push_back(&player->Equip[8]);
|
toRemove.push_back(&player->Equip[8]);
|
||||||
player->toRemoveVehicle.eIL = 0;
|
player->toRemoveVehicle.eIL = 0;
|
||||||
player->toRemoveVehicle.iSlotNum = 8;
|
player->toRemoveVehicle.iSlotNum = 8;
|
||||||
|
@ -7,8 +7,7 @@
|
|||||||
namespace Database {
|
namespace Database {
|
||||||
#pragma region DatabaseStructs
|
#pragma region DatabaseStructs
|
||||||
|
|
||||||
struct Account
|
struct Account {
|
||||||
{
|
|
||||||
int AccountID;
|
int AccountID;
|
||||||
std::string Login;
|
std::string Login;
|
||||||
std::string Password;
|
std::string Password;
|
||||||
@ -16,8 +15,7 @@ namespace Database {
|
|||||||
uint64_t Created;
|
uint64_t Created;
|
||||||
uint64_t LastLogin;
|
uint64_t LastLogin;
|
||||||
};
|
};
|
||||||
struct Inventory
|
struct Inventory {
|
||||||
{
|
|
||||||
int playerId;
|
int playerId;
|
||||||
int slot;
|
int slot;
|
||||||
int16_t Type;
|
int16_t Type;
|
||||||
@ -31,8 +29,7 @@ namespace Database {
|
|||||||
int16_t iSkillID;
|
int16_t iSkillID;
|
||||||
int16_t iStamina;
|
int16_t iStamina;
|
||||||
};
|
};
|
||||||
struct DbPlayer
|
struct DbPlayer {
|
||||||
{
|
|
||||||
int PlayerID;
|
int PlayerID;
|
||||||
int AccountID;
|
int AccountID;
|
||||||
short int slot;
|
short int slot;
|
||||||
@ -130,7 +127,7 @@ namespace Database {
|
|||||||
void getNanos(Player* player);
|
void getNanos(Player* player);
|
||||||
void getQuests(Player* player);
|
void getQuests(Player* player);
|
||||||
|
|
||||||
//parsing blobs
|
// parsing blobs
|
||||||
void appendBlob(std::vector<char>*blob, int64_t input);
|
void appendBlob(std::vector<char>*blob, int64_t input);
|
||||||
int64_t blobToInt64(std::vector<char>::iterator it);
|
int64_t blobToInt64(std::vector<char>::iterator it);
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ void GroupManager::joinGroup(CNSocket* sock, CNPacketData* data) {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bitFlagBefore = getGroupFlags(otherPlr);
|
int bitFlagBefore = getGroupFlags(otherPlr);
|
||||||
|
|
||||||
plr->iIDGroup = otherPlr->iID;
|
plr->iIDGroup = otherPlr->iID;
|
||||||
@ -122,7 +122,7 @@ void GroupManager::joinGroup(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
resp->iID_NewMember = plr->iID;
|
resp->iID_NewMember = plr->iID;
|
||||||
resp->iMemberPCCnt = otherPlr->groupCnt;
|
resp->iMemberPCCnt = otherPlr->groupCnt;
|
||||||
|
|
||||||
int bitFlag = getGroupFlags(otherPlr);
|
int bitFlag = getGroupFlags(otherPlr);
|
||||||
|
|
||||||
for (int i = 0; i < otherPlr->groupCnt; i++) {
|
for (int i = 0; i < otherPlr->groupCnt; i++) {
|
||||||
@ -147,10 +147,10 @@ void GroupManager::joinGroup(CNSocket* sock, CNPacketData* data) {
|
|||||||
respdata[i].iY = varPlr->y;
|
respdata[i].iY = varPlr->y;
|
||||||
respdata[i].iZ = varPlr->z;
|
respdata[i].iZ = varPlr->z;
|
||||||
// client doesnt read nano data here
|
// client doesnt read nano data here
|
||||||
|
|
||||||
NanoManager::nanoChangeBuff(sockTo, varPlr, bitFlagBefore | varPlr->iConditionBitFlag, bitFlag | varPlr->iConditionBitFlag);
|
NanoManager::nanoChangeBuff(sockTo, varPlr, bitFlagBefore | varPlr->iConditionBitFlag, bitFlag | varPlr->iConditionBitFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendToGroup(otherPlr, (void*)&respbuf, P_FE2CL_PC_GROUP_JOIN, resplen);
|
sendToGroup(otherPlr, (void*)&respbuf, P_FE2CL_PC_GROUP_JOIN, resplen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,10 +236,10 @@ void GroupManager::groupTickInfo(Player* plr) {
|
|||||||
|
|
||||||
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;
|
||||||
@ -263,7 +263,7 @@ void GroupManager::groupTickInfo(Player* plr) {
|
|||||||
sendToGroup(plr, (void*)&respbuf, P_FE2CL_PC_GROUP_MEMBER_INFO, resplen);
|
sendToGroup(plr, (void*)&respbuf, P_FE2CL_PC_GROUP_MEMBER_INFO, resplen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupManager::groupKickPlayer(Player* plr) {
|
void GroupManager::groupKickPlayer(Player* plr) {
|
||||||
// if you are the group leader, destroy your own group and kick everybody
|
// if you are the group leader, destroy your own group and kick everybody
|
||||||
if (plr->iID == plr->iIDGroup) {
|
if (plr->iID == plr->iIDGroup) {
|
||||||
groupUnbuff(plr);
|
groupUnbuff(plr);
|
||||||
@ -282,7 +282,7 @@ void GroupManager::groupKickPlayer(Player* plr) {
|
|||||||
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];
|
||||||
|
|
||||||
@ -317,8 +317,8 @@ void GroupManager::groupKickPlayer(Player* plr) {
|
|||||||
respdata[i-moveDown].iLv = varPlr->level;
|
respdata[i-moveDown].iLv = varPlr->level;
|
||||||
respdata[i-moveDown].iHP = varPlr->HP;
|
respdata[i-moveDown].iHP = varPlr->HP;
|
||||||
respdata[i-moveDown].iMaxHP = PC_MAXHEALTH(varPlr->level);
|
respdata[i-moveDown].iMaxHP = PC_MAXHEALTH(varPlr->level);
|
||||||
//respdata[i-moveDown]].iMapType = 0;
|
// respdata[i-moveDown]].iMapType = 0;
|
||||||
//respdata[i-moveDown]].iMapNum = 0;
|
// respdata[i-moveDown]].iMapNum = 0;
|
||||||
respdata[i-moveDown].iX = varPlr->x;
|
respdata[i-moveDown].iX = varPlr->x;
|
||||||
respdata[i-moveDown].iY = varPlr->y;
|
respdata[i-moveDown].iY = varPlr->y;
|
||||||
respdata[i-moveDown].iZ = varPlr->z;
|
respdata[i-moveDown].iZ = varPlr->z;
|
||||||
@ -334,9 +334,9 @@ void GroupManager::groupKickPlayer(Player* plr) {
|
|||||||
|
|
||||||
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)
|
||||||
@ -348,13 +348,13 @@ void GroupManager::groupKickPlayer(Player* plr) {
|
|||||||
|
|
||||||
void GroupManager::groupUnbuff(Player* plr) {
|
void GroupManager::groupUnbuff(Player* plr) {
|
||||||
int bitFlag = getGroupFlags(plr);
|
int bitFlag = getGroupFlags(plr);
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
Player* otherPlr = PlayerManager::getPlayer(sock);
|
Player* otherPlr = PlayerManager::getPlayer(sock);
|
||||||
NanoManager::nanoChangeBuff(sock, otherPlr, bitFlag | otherPlr->iConditionBitFlag, otherPlr->iConditionBitFlag);
|
NanoManager::nanoChangeBuff(sock, otherPlr, bitFlag | otherPlr->iConditionBitFlag, otherPlr->iConditionBitFlag);
|
||||||
}
|
}
|
||||||
@ -362,15 +362,15 @@ void GroupManager::groupUnbuff(Player* plr) {
|
|||||||
|
|
||||||
int GroupManager::getGroupFlags(Player* plr) {
|
int GroupManager::getGroupFlags(Player* plr) {
|
||||||
int bitFlag = 0;
|
int bitFlag = 0;
|
||||||
|
|
||||||
for (int i = 0; i < plr->groupCnt; i++) {
|
for (int i = 0; i < plr->groupCnt; i++) {
|
||||||
Player* otherPlr = PlayerManager::getPlayerFromID(plr->groupIDs[i]);
|
Player* otherPlr = PlayerManager::getPlayerFromID(plr->groupIDs[i]);
|
||||||
|
|
||||||
if (otherPlr == nullptr)
|
if (otherPlr == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bitFlag |= otherPlr->iGroupConditionBitFlag;
|
bitFlag |= otherPlr->iGroupConditionBitFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bitFlag;
|
return bitFlag;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ std::map<int32_t, std::vector<VendorListing>> ItemManager::VendorTables;
|
|||||||
std::map<int32_t, CrocPotEntry> ItemManager::CrocPotTable;
|
std::map<int32_t, CrocPotEntry> ItemManager::CrocPotTable;
|
||||||
std::map<int32_t, std::vector<int>> ItemManager::RarityRatios;
|
std::map<int32_t, std::vector<int>> ItemManager::RarityRatios;
|
||||||
std::map<int32_t, Crate> ItemManager::Crates;
|
std::map<int32_t, Crate> ItemManager::Crates;
|
||||||
/// pair Itemset, Rarity -> vector of pointers (map iterators) to records in ItemData
|
// pair Itemset, Rarity -> vector of pointers (map iterators) to records in ItemData
|
||||||
std::map<std::pair<int32_t, int32_t>, std::vector<std::map<std::pair<int32_t, int32_t>, Item>::iterator>> ItemManager::CrateItems;
|
std::map<std::pair<int32_t, int32_t>, std::vector<std::map<std::pair<int32_t, int32_t>, Item>::iterator>> ItemManager::CrateItems;
|
||||||
|
|
||||||
void ItemManager::init() {
|
void ItemManager::init() {
|
||||||
@ -143,8 +143,7 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
if (itemmove->eFrom == (int)SlotType::EQUIP) {
|
if (itemmove->eFrom == (int)SlotType::EQUIP) {
|
||||||
equipChange.iEquipSlotNum = itemmove->iFromSlotNum;
|
equipChange.iEquipSlotNum = itemmove->iFromSlotNum;
|
||||||
equipChange.EquipSlotItem = resp.ToSlotItem;
|
equipChange.EquipSlotItem = resp.ToSlotItem;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
equipChange.iEquipSlotNum = itemmove->iToSlotNum;
|
equipChange.iEquipSlotNum = itemmove->iToSlotNum;
|
||||||
equipChange.EquipSlotItem = resp.FromSlotItem;
|
equipChange.EquipSlotItem = resp.FromSlotItem;
|
||||||
}
|
}
|
||||||
@ -237,11 +236,11 @@ void ItemManager::itemUseHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
if (player == nullptr)
|
if (player == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//gumball can only be used from inventory, so we ignore eIL
|
// gumball can only be used from inventory, so we ignore eIL
|
||||||
sItemBase gumball = player->Inven[request->iSlotNum];
|
sItemBase gumball = player->Inven[request->iSlotNum];
|
||||||
sNano nano = player->Nanos[player->equippedNanos[request->iNanoSlot]];
|
sNano nano = player->Nanos[player->equippedNanos[request->iNanoSlot]];
|
||||||
|
|
||||||
//sanity check, check if gumball exists
|
// sanity check, check if gumball exists
|
||||||
if (!(gumball.iOpt > 0 && gumball.iType == 7 && gumball.iID>=119 && gumball.iID<=121)) {
|
if (!(gumball.iOpt > 0 && gumball.iType == 7 && gumball.iID>=119 && gumball.iID<=121)) {
|
||||||
std::cout << "[WARN] Gumball not found" << std::endl;
|
std::cout << "[WARN] Gumball not found" << std::endl;
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_ITEM_USE_FAIL, response);
|
INITSTRUCT(sP_FE2CL_REP_PC_ITEM_USE_FAIL, response);
|
||||||
@ -249,7 +248,7 @@ void ItemManager::itemUseHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//sanity check, check if gumball type matches nano style
|
// sanity check, check if gumball type matches nano style
|
||||||
int nanoStyle = NanoManager::nanoStyle(nano.iID);
|
int nanoStyle = NanoManager::nanoStyle(nano.iID);
|
||||||
if (!((gumball.iID == 119 && nanoStyle == 0) ||
|
if (!((gumball.iID == 119 && nanoStyle == 0) ||
|
||||||
( gumball.iID == 120 && nanoStyle == 1) ||
|
( gumball.iID == 120 && nanoStyle == 1) ||
|
||||||
@ -274,11 +273,11 @@ void ItemManager::itemUseHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
// response.iSkillID = ?
|
// response.iSkillID = ?
|
||||||
|
|
||||||
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_ITEM_USE_SUCC, sizeof(sP_FE2CL_REP_PC_ITEM_USE_SUCC));
|
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_ITEM_USE_SUCC, sizeof(sP_FE2CL_REP_PC_ITEM_USE_SUCC));
|
||||||
//update inventory serverside
|
// update inventory serverside
|
||||||
player->Inven[response.iSlotNum] = response.RemainItem;
|
player->Inven[response.iSlotNum] = response.RemainItem;
|
||||||
|
|
||||||
//this is a temporary way of calling buff efect
|
// this is a temporary way of calling buff efect
|
||||||
//TODO: send buff data via response packet
|
// TODO: send buff data via response packet
|
||||||
int value1 = CSB_BIT_STIMPAKSLOT1 << request->iNanoSlot;
|
int value1 = CSB_BIT_STIMPAKSLOT1 << request->iNanoSlot;
|
||||||
int value2 = ECSB_STIMPAKSLOT1 + request->iNanoSlot;
|
int value2 = ECSB_STIMPAKSLOT1 + request->iNanoSlot;
|
||||||
|
|
||||||
@ -950,8 +949,7 @@ int ItemManager::getCrateItem(sItemBase& result, int itemSetId, int rarity, int
|
|||||||
|
|
||||||
// only take into account items that have correct gender
|
// only take into account items that have correct gender
|
||||||
std::vector<std::map<std::pair<int32_t, int32_t>, Item>::iterator> items;
|
std::vector<std::map<std::pair<int32_t, int32_t>, Item>::iterator> items;
|
||||||
for (auto crateitem : CrateItems[key])
|
for (auto crateitem : CrateItems[key]) {
|
||||||
{
|
|
||||||
int gender = crateitem->second.gender;
|
int gender = crateitem->second.gender;
|
||||||
// if gender is incorrect, exclude item
|
// if gender is incorrect, exclude item
|
||||||
if (gender != 0 && gender != playerGender)
|
if (gender != 0 && gender != playerGender)
|
||||||
|
@ -44,7 +44,6 @@ namespace ItemManager {
|
|||||||
// Bank
|
// Bank
|
||||||
void itemBankOpenHandler(CNSocket* sock, CNPacketData* data);
|
void itemBankOpenHandler(CNSocket* sock, CNPacketData* data);
|
||||||
void itemTradeOfferHandler(CNSocket* sock, CNPacketData* data);
|
void itemTradeOfferHandler(CNSocket* sock, CNPacketData* data);
|
||||||
//void itemTradeOfferCancel(CNSocket* sock, CNPacketData* data);
|
|
||||||
void itemTradeOfferAcceptHandler(CNSocket* sock, CNPacketData* data);
|
void itemTradeOfferAcceptHandler(CNSocket* sock, CNPacketData* data);
|
||||||
void itemTradeOfferRefusalHandler(CNSocket* sock, CNPacketData* data);
|
void itemTradeOfferRefusalHandler(CNSocket* sock, CNPacketData* data);
|
||||||
void itemTradeConfirmHandler(CNSocket* sock, CNPacketData* data);
|
void itemTradeConfirmHandler(CNSocket* sock, CNPacketData* data);
|
||||||
|
@ -148,8 +148,7 @@ bool MissionManager::endTask(CNSocket *sock, int32_t taskNum) {
|
|||||||
// update player
|
// update player
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
for (i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
||||||
if (plr->tasks[i] == taskNum)
|
if (plr->tasks[i] == taskNum) {
|
||||||
{
|
|
||||||
plr->tasks[i] = 0;
|
plr->tasks[i] = 0;
|
||||||
for (int j = 0; j < 3; j++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
plr->RemainingNPCCount[i][j] = 0;
|
plr->RemainingNPCCount[i][j] = 0;
|
||||||
@ -161,8 +160,7 @@ bool MissionManager::endTask(CNSocket *sock, int32_t taskNum) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if it's the last task
|
// if it's the last task
|
||||||
if (task["m_iSUOutgoingTask"] == 0)
|
if (task["m_iSUOutgoingTask"] == 0) {
|
||||||
{
|
|
||||||
// save completed mission on player
|
// save completed mission on player
|
||||||
saveMission(plr, (int)(task["m_iHMissionID"])-1);
|
saveMission(plr, (int)(task["m_iHMissionID"])-1);
|
||||||
|
|
||||||
@ -211,8 +209,7 @@ void MissionManager::quitTask(CNSocket* sock, int32_t taskNum, bool manual) {
|
|||||||
// update player
|
// update player
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
for (i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
||||||
if (plr->tasks[i] == taskNum)
|
if (plr->tasks[i] == taskNum) {
|
||||||
{
|
|
||||||
plr->tasks[i] = 0;
|
plr->tasks[i] = 0;
|
||||||
for (int j = 0; j < 3; j++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
plr->RemainingNPCCount[i][j] = 0;
|
plr->RemainingNPCCount[i][j] = 0;
|
||||||
@ -247,7 +244,7 @@ void MissionManager::quitTask(CNSocket* sock, int32_t taskNum, bool manual) {
|
|||||||
failResp.iTaskNum = taskNum;
|
failResp.iTaskNum = taskNum;
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_TASK_END_FAIL, sizeof(sP_FE2CL_REP_PC_TASK_END_FAIL));
|
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_TASK_END_FAIL, sizeof(sP_FE2CL_REP_PC_TASK_END_FAIL));
|
||||||
}
|
}
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_TASK_STOP_SUCC, response);
|
INITSTRUCT(sP_FE2CL_REP_PC_TASK_STOP_SUCC, response);
|
||||||
response.iTaskNum = taskNum;
|
response.iTaskNum = taskNum;
|
||||||
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_TASK_STOP_SUCC, sizeof(sP_FE2CL_REP_PC_TASK_STOP_SUCC));
|
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_TASK_STOP_SUCC, sizeof(sP_FE2CL_REP_PC_TASK_STOP_SUCC));
|
||||||
@ -449,14 +446,12 @@ void MissionManager::mobKilled(CNSocket *sock, int mobid) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// acknowledge killing of mission mob...
|
// acknowledge killing of mission mob...
|
||||||
if (task["m_iCSUNumToKill"][j] != 0)
|
if (task["m_iCSUNumToKill"][j] != 0) {
|
||||||
{
|
|
||||||
missionmob = true;
|
missionmob = true;
|
||||||
// sanity check
|
// sanity check
|
||||||
if (plr->RemainingNPCCount[i][j] == 0) {
|
if (plr->RemainingNPCCount[i][j] == 0) {
|
||||||
std::cout << "[WARN] RemainingNPCCount tries to go below 0?!" << std::endl;
|
std::cout << "[WARN] RemainingNPCCount tries to go below 0?!" << std::endl;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
plr->RemainingNPCCount[i][j]--;
|
plr->RemainingNPCCount[i][j]--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -486,7 +481,7 @@ void MissionManager::mobKilled(CNSocket *sock, int mobid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MissionManager::saveMission(Player* player, int missionId) {
|
void MissionManager::saveMission(Player* player, int missionId) {
|
||||||
//sanity check missionID so we don't get exceptions
|
// sanity check missionID so we don't get exceptions
|
||||||
if (missionId < 0 || missionId>1023) {
|
if (missionId < 0 || missionId>1023) {
|
||||||
std::cout << "[WARN] Client submitted invalid missionId: " <<missionId<< std::endl;
|
std::cout << "[WARN] Client submitted invalid missionId: " <<missionId<< std::endl;
|
||||||
return;
|
return;
|
||||||
|
@ -48,7 +48,7 @@ namespace MissionManager {
|
|||||||
|
|
||||||
int findQSlot(Player *plr, int id);
|
int findQSlot(Player *plr, int id);
|
||||||
void dropQuestItem(CNSocket *sock, int task, int count, int id, int mobid);
|
void dropQuestItem(CNSocket *sock, int task, int count, int id, int mobid);
|
||||||
//checks if player doesn't have n/n quest items
|
// checks if player doesn't have n/n quest items
|
||||||
bool isQuestItemFull(CNSocket* sock, int itemId, int itemCount);
|
bool isQuestItemFull(CNSocket* sock, int itemId, int itemCount);
|
||||||
int giveMissionReward(CNSocket *sock, int task);
|
int giveMissionReward(CNSocket *sock, int task);
|
||||||
void updateFusionMatter(CNSocket* sock, int fusion);
|
void updateFusionMatter(CNSocket* sock, int fusion);
|
||||||
|
@ -83,11 +83,11 @@ void MobManager::pcAttackNpcs(CNSocket *sock, CNPacketData *data) {
|
|||||||
damage.first = plr->groupDamage;
|
damage.first = plr->groupDamage;
|
||||||
else
|
else
|
||||||
damage.first = plr->pointDamage;
|
damage.first = plr->pointDamage;
|
||||||
|
|
||||||
int difficulty = (int)mob->data["m_iNpcLevel"];
|
int difficulty = (int)mob->data["m_iNpcLevel"];
|
||||||
|
|
||||||
damage = getDamage(damage.first, (int)mob->data["m_iProtection"], true, (plr->batteryW >= 11 + difficulty), NanoManager::nanoStyle(plr->activeNano), (int)mob->data["m_iNpcStyle"], difficulty);
|
damage = getDamage(damage.first, (int)mob->data["m_iProtection"], true, (plr->batteryW >= 11 + difficulty), NanoManager::nanoStyle(plr->activeNano), (int)mob->data["m_iNpcStyle"], difficulty);
|
||||||
|
|
||||||
if (plr->batteryW >= 11 + difficulty)
|
if (plr->batteryW >= 11 + difficulty)
|
||||||
plr->batteryW -= 11 + difficulty;
|
plr->batteryW -= 11 + difficulty;
|
||||||
|
|
||||||
@ -258,6 +258,7 @@ void MobManager::giveEventReward(CNSocket* sock, Player* player) {
|
|||||||
// random drop chance
|
// random drop chance
|
||||||
if (rand() % 100 > settings::EVENTCRATECHANCE)
|
if (rand() % 100 > settings::EVENTCRATECHANCE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// no slot = no reward
|
// no slot = no reward
|
||||||
int slot = ItemManager::findFreeSlot(player);
|
int slot = ItemManager::findFreeSlot(player);
|
||||||
if (slot == -1)
|
if (slot == -1)
|
||||||
@ -284,18 +285,17 @@ void MobManager::giveEventReward(CNSocket* sock, Player* player) {
|
|||||||
|
|
||||||
// which crate to drop
|
// which crate to drop
|
||||||
int crateId;
|
int crateId;
|
||||||
switch (settings::EVENTMODE)
|
switch (settings::EVENTMODE) {
|
||||||
{
|
// knishmas
|
||||||
// knishmas
|
case 1: crateId = 1187; break;
|
||||||
case 1: crateId = 1187; break;
|
// halloween
|
||||||
// halloween
|
case 2: crateId = 1181; break;
|
||||||
case 2: crateId = 1181; break;
|
// spring
|
||||||
// spring
|
case 3: crateId = 1126; break;
|
||||||
case 3: crateId = 1126; break;
|
// what
|
||||||
// what
|
default:
|
||||||
default:
|
std::cout << "[WARN] Unknown event Id " << settings::EVENTMODE << std::endl;
|
||||||
std::cout << "[WARN] Unknown event Id " << settings::EVENTMODE << std::endl;
|
return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
item->sItem.iType = 9;
|
item->sItem.iType = 9;
|
||||||
@ -352,7 +352,7 @@ void MobManager::killMob(CNSocket *sock, Mob *mob) {
|
|||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (plr->groupCnt == 1 && plr->iIDGroup == plr->iID) {
|
if (plr->groupCnt == 1 && plr->iIDGroup == plr->iID) {
|
||||||
giveReward(sock, mob);
|
giveReward(sock, mob);
|
||||||
MissionManager::mobKilled(sock, mob->appearanceData.iNPCType);
|
MissionManager::mobKilled(sock, mob->appearanceData.iNPCType);
|
||||||
} else {
|
} else {
|
||||||
@ -360,7 +360,7 @@ void MobManager::killMob(CNSocket *sock, Mob *mob) {
|
|||||||
|
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < plr->groupCnt; i++) {
|
for (int i = 0; i < plr->groupCnt; i++) {
|
||||||
CNSocket* sockTo = PlayerManager::getSockFromID(plr->groupIDs[i]);
|
CNSocket* sockTo = PlayerManager::getSockFromID(plr->groupIDs[i]);
|
||||||
giveReward(sockTo, mob);
|
giveReward(sockTo, mob);
|
||||||
@ -732,9 +732,9 @@ void MobManager::dotDamageOnOff(CNSocket *sock, CNPacketData *data) {
|
|||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, pkt1);
|
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, pkt1);
|
||||||
|
|
||||||
pkt1.eCSTB = ECSB_INFECTION; //eCharStatusTimeBuffID
|
pkt1.eCSTB = ECSB_INFECTION; // eCharStatusTimeBuffID
|
||||||
pkt1.eTBU = 1; //eTimeBuffUpdate
|
pkt1.eTBU = 1; // eTimeBuffUpdate
|
||||||
pkt1.eTBT = 0; //eTimeBuffType 1 means nano
|
pkt1.eTBT = 0; // eTimeBuffType 1 means nano
|
||||||
pkt1.iConditionBitFlag = plr->iConditionBitFlag;
|
pkt1.iConditionBitFlag = plr->iConditionBitFlag;
|
||||||
|
|
||||||
sock->sendPacket((void*)&pkt1, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE));
|
sock->sendPacket((void*)&pkt1, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE));
|
||||||
@ -871,19 +871,19 @@ std::pair<int,int> MobManager::getDamage(int attackPower, int defensePower, bool
|
|||||||
int damage = attackPower * attackPower / (attackPower + defensePower);
|
int damage = attackPower * attackPower / (attackPower + defensePower);
|
||||||
damage = std::max(std::max(29, attackPower / 7), damage - defensePower * (12 + difficulty) / 65);
|
damage = std::max(std::max(29, attackPower / 7), damage - defensePower * (12 + difficulty) / 65);
|
||||||
damage = damage * (rand() % 40 + 80) / 100;
|
damage = damage * (rand() % 40 + 80) / 100;
|
||||||
|
|
||||||
// Adaptium/Blastons/Cosmix
|
// Adaptium/Blastons/Cosmix
|
||||||
if (attackerStyle != -1 && defenderStyle != -1 && attackerStyle != defenderStyle) {
|
if (attackerStyle != -1 && defenderStyle != -1 && attackerStyle != defenderStyle) {
|
||||||
if (attackerStyle < defenderStyle || attackerStyle - defenderStyle == 2)
|
if (attackerStyle < defenderStyle || attackerStyle - defenderStyle == 2)
|
||||||
damage = damage * 5 / 4;
|
damage = damage * 5 / 4;
|
||||||
else
|
else
|
||||||
damage = damage * 4 / 5;
|
damage = damage * 4 / 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// weapon boosts
|
// weapon boosts
|
||||||
if (batteryBoost)
|
if (batteryBoost)
|
||||||
damage = damage * 5 / 4;
|
damage = damage * 5 / 4;
|
||||||
|
|
||||||
ret.first = damage;
|
ret.first = damage;
|
||||||
ret.second = 1;
|
ret.second = 1;
|
||||||
|
|
||||||
@ -949,9 +949,9 @@ void MobManager::pcAttackChars(CNSocket *sock, CNPacketData *data) {
|
|||||||
damage.first = plr->groupDamage;
|
damage.first = plr->groupDamage;
|
||||||
else
|
else
|
||||||
damage.first = plr->pointDamage;
|
damage.first = plr->pointDamage;
|
||||||
|
|
||||||
damage = getDamage(damage.first, target->defense, true, (plr->batteryW >= 12), -1, -1, 1);
|
damage = getDamage(damage.first, target->defense, true, (plr->batteryW >= 12), -1, -1, 1);
|
||||||
|
|
||||||
if (plr->batteryW >= 12)
|
if (plr->batteryW >= 12)
|
||||||
plr->batteryW -= 12;
|
plr->batteryW -= 12;
|
||||||
|
|
||||||
@ -976,12 +976,12 @@ void MobManager::pcAttackChars(CNSocket *sock, CNPacketData *data) {
|
|||||||
damage.first = plr->groupDamage;
|
damage.first = plr->groupDamage;
|
||||||
else
|
else
|
||||||
damage.first = plr->pointDamage;
|
damage.first = plr->pointDamage;
|
||||||
|
|
||||||
int difficulty = (int)mob->data["m_iNpcLevel"];
|
int difficulty = (int)mob->data["m_iNpcLevel"];
|
||||||
|
|
||||||
damage = getDamage(damage.first, (int)mob->data["m_iProtection"], true, (plr->batteryW >= 11 + difficulty),
|
damage = getDamage(damage.first, (int)mob->data["m_iProtection"], true, (plr->batteryW >= 11 + difficulty),
|
||||||
NanoManager::nanoStyle(plr->activeNano), (int)mob->data["m_iNpcStyle"], difficulty);
|
NanoManager::nanoStyle(plr->activeNano), (int)mob->data["m_iNpcStyle"], difficulty);
|
||||||
|
|
||||||
if (plr->batteryW >= 11 + difficulty)
|
if (plr->batteryW >= 11 + difficulty)
|
||||||
plr->batteryW -= 11 + difficulty;
|
plr->batteryW -= 11 + difficulty;
|
||||||
|
|
||||||
|
@ -60,10 +60,6 @@ struct Mob : public BaseNPC {
|
|||||||
dropType = data["m_iDropType"];
|
dropType = data["m_iDropType"];
|
||||||
level = data["m_iNpcLevel"];
|
level = data["m_iNpcLevel"];
|
||||||
|
|
||||||
// XXX: temporarily force respawns for Fusions until we implement instancing
|
|
||||||
//if (regenTime >= 300000000)
|
|
||||||
// regenTime = 1500;
|
|
||||||
|
|
||||||
roamX = spawnX = appearanceData.iX;
|
roamX = spawnX = appearanceData.iX;
|
||||||
roamY = spawnY = appearanceData.iY;
|
roamY = spawnY = appearanceData.iY;
|
||||||
roamZ = spawnZ = appearanceData.iZ;
|
roamZ = spawnZ = appearanceData.iZ;
|
||||||
|
@ -288,8 +288,7 @@ void NPCManager::npcVendorSell(CNSocket* sock, CNPacketData* data) {
|
|||||||
if (plr->Inven[req->iInvenSlotNum].iOpt - req->iItemCnt > 0) { // selling part of a stack
|
if (plr->Inven[req->iInvenSlotNum].iOpt - req->iItemCnt > 0) { // selling part of a stack
|
||||||
item->iOpt -= req->iItemCnt;
|
item->iOpt -= req->iItemCnt;
|
||||||
original.iOpt = req->iItemCnt;
|
original.iOpt = req->iItemCnt;
|
||||||
}
|
} else { // selling entire slot
|
||||||
else { // selling entire slot
|
|
||||||
item->iID = 0;
|
item->iID = 0;
|
||||||
item->iOpt = 0;
|
item->iOpt = 0;
|
||||||
item->iType = 0;
|
item->iType = 0;
|
||||||
@ -378,7 +377,7 @@ void NPCManager::npcVendorTable(CNSocket* sock, CNPacketData* data) {
|
|||||||
vItem.item = base;
|
vItem.item = base;
|
||||||
vItem.iSortNum = listings[i].sort;
|
vItem.iSortNum = listings[i].sort;
|
||||||
vItem.iVendorID = req->iVendorID;
|
vItem.iVendorID = req->iVendorID;
|
||||||
//vItem.fBuyCost = listings[i].price; this value is not actually the one that is used
|
//vItem.fBuyCost = listings[i].price; // this value is not actually the one that is used
|
||||||
|
|
||||||
resp.item[i] = vItem;
|
resp.item[i] = vItem;
|
||||||
}
|
}
|
||||||
@ -461,8 +460,7 @@ void NPCManager::npcCombineItems(CNSocket* sock, CNPacketData* data) {
|
|||||||
Item* itemLooksDat = ItemManager::getItemData(itemLooks->iID, itemLooks->iType);
|
Item* itemLooksDat = ItemManager::getItemData(itemLooks->iID, itemLooks->iType);
|
||||||
|
|
||||||
if (itemStatsDat == nullptr || itemLooksDat == nullptr
|
if (itemStatsDat == nullptr || itemLooksDat == nullptr
|
||||||
|| ItemManager::CrocPotTable.find(abs(itemStatsDat->level - itemLooksDat->level)) == ItemManager::CrocPotTable.end()) // sanity check 2
|
|| ItemManager::CrocPotTable.find(abs(itemStatsDat->level - itemLooksDat->level)) == ItemManager::CrocPotTable.end()) { // sanity check 2
|
||||||
{
|
|
||||||
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;
|
||||||
failResp.iStatItemSlot = req->iStatItemSlot;
|
failResp.iStatItemSlot = req->iStatItemSlot;
|
||||||
@ -477,8 +475,7 @@ void NPCManager::npcCombineItems(CNSocket* sock, CNPacketData* data) {
|
|||||||
float successChance = recipe->base / 100.0f; // base success chance
|
float successChance = recipe->base / 100.0f; // base success chance
|
||||||
|
|
||||||
// rarity gap multiplier
|
// rarity gap multiplier
|
||||||
switch(abs(itemStatsDat->rarity - itemLooksDat->rarity))
|
switch(abs(itemStatsDat->rarity - itemLooksDat->rarity)) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
successChance *= recipe->rd0;
|
successChance *= recipe->rd0;
|
||||||
break;
|
break;
|
||||||
@ -514,8 +511,7 @@ void NPCManager::npcCombineItems(CNSocket* sock, CNPacketData* data) {
|
|||||||
itemStats->iOpt = 0;
|
itemStats->iOpt = 0;
|
||||||
itemStats->iTimeLimit = 0;
|
itemStats->iTimeLimit = 0;
|
||||||
itemStats->iType = 0;
|
itemStats->iType = 0;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// failure; don't do anything?
|
// failure; don't do anything?
|
||||||
resp.iSuccessFlag = 0;
|
resp.iSuccessFlag = 0;
|
||||||
}
|
}
|
||||||
@ -591,7 +587,7 @@ void NPCManager::handleWarp(CNSocket* sock, int32_t warpId) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
MissionManager::failInstancedMissions(sock); // fail any missions that require the player's current instance
|
MissionManager::failInstancedMissions(sock); // fail any missions that require the player's current instance
|
||||||
|
|
||||||
uint64_t fromInstance = plrv.plr->instanceID; // saved for post-warp
|
uint64_t fromInstance = plrv.plr->instanceID; // saved for post-warp
|
||||||
|
|
||||||
if (plrv.plr->instanceID == 0) {
|
if (plrv.plr->instanceID == 0) {
|
||||||
@ -603,19 +599,16 @@ void NPCManager::handleWarp(CNSocket* sock, int32_t warpId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// std::cerr << "Warped to Map Num:" << Warps[warpId].instanceID << " NPC ID " << Warps[warpId].npcID << std::endl;
|
// std::cerr << "Warped to Map Num:" << Warps[warpId].instanceID << " NPC ID " << Warps[warpId].npcID << std::endl;
|
||||||
if (Warps[warpId].isInstance)
|
if (Warps[warpId].isInstance) {
|
||||||
{
|
|
||||||
uint64_t instanceID = Warps[warpId].instanceID;
|
uint64_t instanceID = Warps[warpId].instanceID;
|
||||||
if (Warps[warpId].limitTaskID != 0) { // if warp requires you to be on a mission, it's gotta be a unique instance
|
if (Warps[warpId].limitTaskID != 0) { // if warp requires you to be on a mission, it's gotta be a unique instance
|
||||||
instanceID += ((uint64_t)plrv.plr->iIDGroup << 32); // upper 32 bits are leader ID
|
instanceID += ((uint64_t)plrv.plr->iIDGroup << 32); // upper 32 bits are leader ID
|
||||||
ChunkManager::createInstance(instanceID);
|
ChunkManager::createInstance(instanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerManager::sendPlayerTo(sock, Warps[warpId].x, Warps[warpId].y, Warps[warpId].z, instanceID);
|
PlayerManager::sendPlayerTo(sock, Warps[warpId].x, Warps[warpId].y, Warps[warpId].z, instanceID);
|
||||||
}
|
} else {
|
||||||
else
|
INITSTRUCT(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC, resp); // Can only be used for exiting instances because it sets the instance flag to false
|
||||||
{
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC, resp); //Can only be used for exiting instances because it sets the instance flag to false
|
|
||||||
resp.iX = Warps[warpId].x;
|
resp.iX = Warps[warpId].x;
|
||||||
resp.iY = Warps[warpId].y;
|
resp.iY = Warps[warpId].y;
|
||||||
resp.iZ = Warps[warpId].z;
|
resp.iZ = Warps[warpId].z;
|
||||||
|
@ -232,7 +232,7 @@ void NanoManager::nanoPotionHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
response.iBatteryN = player->batteryN - difference;
|
response.iBatteryN = player->batteryN - difference;
|
||||||
|
|
||||||
sock->sendPacket((void*)&response, P_FE2CL_REP_CHARGE_NANO_STAMINA, sizeof(sP_FE2CL_REP_CHARGE_NANO_STAMINA));
|
sock->sendPacket((void*)&response, P_FE2CL_REP_CHARGE_NANO_STAMINA, sizeof(sP_FE2CL_REP_CHARGE_NANO_STAMINA));
|
||||||
//now update serverside
|
// now update serverside
|
||||||
player->batteryN -= difference;
|
player->batteryN -= difference;
|
||||||
player->Nanos[nano.iID].iStamina += difference;
|
player->Nanos[nano.iID].iStamina += difference;
|
||||||
|
|
||||||
@ -689,26 +689,26 @@ void NanoManager::nanoBuff(CNSocket* sock, int16_t nanoId, int skillId, int16_t
|
|||||||
|
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int pktCnt = 1;
|
int pktCnt = 1;
|
||||||
Player *leader = plr;
|
Player *leader = plr;
|
||||||
plr->iConditionBitFlag |= iCBFlag;
|
plr->iConditionBitFlag |= iCBFlag;
|
||||||
|
|
||||||
if (groupPower) {
|
if (groupPower) {
|
||||||
plr->iGroupConditionBitFlag |= iCBFlag;
|
plr->iGroupConditionBitFlag |= iCBFlag;
|
||||||
|
|
||||||
if (plr->iID != plr->iIDGroup)
|
if (plr->iID != plr->iIDGroup)
|
||||||
leader = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
leader = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||||
|
|
||||||
if (leader == nullptr)
|
if (leader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pktCnt = leader->groupCnt;
|
pktCnt = leader->groupCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leader == nullptr)
|
if (leader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
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;
|
||||||
@ -728,7 +728,7 @@ void NanoManager::nanoBuff(CNSocket* sock, int16_t nanoId, int skillId, int16_t
|
|||||||
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;
|
||||||
|
|
||||||
int bitFlag = GroupManager::getGroupFlags(leader);
|
int bitFlag = GroupManager::getGroupFlags(leader);
|
||||||
|
|
||||||
for (int i = 0; i < pktCnt; i++) {
|
for (int i = 0; i < pktCnt; i++) {
|
||||||
@ -745,15 +745,15 @@ void NanoManager::nanoBuff(CNSocket* sock, int16_t nanoId, int skillId, int16_t
|
|||||||
|
|
||||||
if (varPlr == nullptr || sockTo == nullptr)
|
if (varPlr == nullptr || sockTo == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
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 = bitFlag | varPlr->iConditionBitFlag;
|
pkt1.iConditionBitFlag = bitFlag | varPlr->iConditionBitFlag;
|
||||||
|
|
||||||
if (iValue > 0)
|
if (iValue > 0)
|
||||||
@ -771,23 +771,23 @@ void NanoManager::nanoUnbuff(CNSocket* sock, int32_t iCBFlag, int16_t eCharStatu
|
|||||||
|
|
||||||
if (plr == nullptr)
|
if (plr == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int pktCnt = 1;
|
int pktCnt = 1;
|
||||||
Player *leader = plr;
|
Player *leader = plr;
|
||||||
plr->iConditionBitFlag &= ~iCBFlag;
|
plr->iConditionBitFlag &= ~iCBFlag;
|
||||||
|
|
||||||
if (groupPower) {
|
if (groupPower) {
|
||||||
plr->iGroupConditionBitFlag &= ~iCBFlag;
|
plr->iGroupConditionBitFlag &= ~iCBFlag;
|
||||||
|
|
||||||
if (plr->iID != plr->iIDGroup)
|
if (plr->iID != plr->iIDGroup)
|
||||||
leader = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
leader = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||||
|
|
||||||
if (leader == nullptr)
|
if (leader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pktCnt = leader->groupCnt;
|
pktCnt = leader->groupCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bitFlag = GroupManager::getGroupFlags(leader);
|
int bitFlag = GroupManager::getGroupFlags(leader);
|
||||||
|
|
||||||
for (int i = 0; i < pktCnt; i++) {
|
for (int i = 0; i < pktCnt; i++) {
|
||||||
@ -801,11 +801,11 @@ 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]);
|
||||||
}
|
}
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, resp1);
|
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, resp1);
|
||||||
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 = bitFlag | varPlr->iConditionBitFlag;
|
resp1.iConditionBitFlag = bitFlag | varPlr->iConditionBitFlag;
|
||||||
|
|
||||||
if (iValue > 0)
|
if (iValue > 0)
|
||||||
@ -892,8 +892,8 @@ void NanoManager::nanoChangeBuff(CNSocket* sock, Player* plr, int32_t cbFrom, in
|
|||||||
resp.eTBU = 3;
|
resp.eTBU = 3;
|
||||||
resp.eTBT = 1;
|
resp.eTBT = 1;
|
||||||
resp.iConditionBitFlag = cbTo;
|
resp.iConditionBitFlag = cbTo;
|
||||||
|
|
||||||
if (!(cbFrom & CSB_BIT_UP_MOVE_SPEED) && (cbTo & CSB_BIT_UP_MOVE_SPEED)) {
|
if (!(cbFrom & CSB_BIT_UP_MOVE_SPEED) && (cbTo & CSB_BIT_UP_MOVE_SPEED)) {
|
||||||
resp.eCSTB = ECSB_UP_MOVE_SPEED;
|
resp.eCSTB = ECSB_UP_MOVE_SPEED;
|
||||||
resp.eTBU = 1;
|
resp.eTBU = 1;
|
||||||
resp.TimeBuff.iValue = 200;
|
resp.TimeBuff.iValue = 200;
|
||||||
@ -906,7 +906,7 @@ void NanoManager::nanoChangeBuff(CNSocket* sock, Player* plr, int32_t cbFrom, in
|
|||||||
sock->sendPacket((void*)&resp, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE));
|
sock->sendPacket((void*)&resp, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE));
|
||||||
sentPacket = true;
|
sentPacket = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cbFrom & CSB_BIT_UP_JUMP_HEIGHT) && (cbTo & CSB_BIT_UP_JUMP_HEIGHT)) {
|
if (!(cbFrom & CSB_BIT_UP_JUMP_HEIGHT) && (cbTo & CSB_BIT_UP_JUMP_HEIGHT)) {
|
||||||
resp.eCSTB = ECSB_UP_JUMP_HEIGHT;
|
resp.eCSTB = ECSB_UP_JUMP_HEIGHT;
|
||||||
resp.eTBU = 1;
|
resp.eTBU = 1;
|
||||||
@ -920,7 +920,7 @@ void NanoManager::nanoChangeBuff(CNSocket* sock, Player* plr, int32_t cbFrom, in
|
|||||||
sock->sendPacket((void*)&resp, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE));
|
sock->sendPacket((void*)&resp, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE));
|
||||||
sentPacket = true;
|
sentPacket = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sentPacket)
|
if (!sentPacket)
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE));
|
sock->sendPacket((void*)&resp, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE));
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,6 @@ void PlayerManager::removePlayer(CNSocket* key) {
|
|||||||
PlayerView& view = players[key];
|
PlayerView& view = players[key];
|
||||||
uint64_t fromInstance = view.plr->instanceID;
|
uint64_t fromInstance = view.plr->instanceID;
|
||||||
|
|
||||||
//MissionManager::failInstancedMissions(key); moved to enter
|
|
||||||
GroupManager::groupKickPlayer(view.plr);
|
GroupManager::groupKickPlayer(view.plr);
|
||||||
|
|
||||||
// save player to DB
|
// save player to DB
|
||||||
@ -315,7 +314,7 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
response.PCLoadData2CL.iAngle = plr.angle;
|
response.PCLoadData2CL.iAngle = plr.angle;
|
||||||
response.PCLoadData2CL.iBatteryN = plr.batteryN;
|
response.PCLoadData2CL.iBatteryN = plr.batteryN;
|
||||||
response.PCLoadData2CL.iBatteryW = plr.batteryW;
|
response.PCLoadData2CL.iBatteryW = plr.batteryW;
|
||||||
response.PCLoadData2CL.iBuddyWarpTime = 60; //sets 60s warp cooldown on login
|
response.PCLoadData2CL.iBuddyWarpTime = 60; // sets 60s warp cooldown on login
|
||||||
|
|
||||||
response.PCLoadData2CL.iWarpLocationFlag = plr.iWarpLocationFlag;
|
response.PCLoadData2CL.iWarpLocationFlag = plr.iWarpLocationFlag;
|
||||||
response.PCLoadData2CL.aWyvernLocationFlag[0] = plr.aSkywayLocationFlag[0];
|
response.PCLoadData2CL.aWyvernLocationFlag[0] = plr.aSkywayLocationFlag[0];
|
||||||
@ -325,8 +324,8 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
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
|
||||||
for (int i = 0; i < AEQUIP_COUNT; i++)
|
for (int i = 0; i < AEQUIP_COUNT; i++)
|
||||||
response.PCLoadData2CL.aEquip[i] = plr.Equip[i];
|
response.PCLoadData2CL.aEquip[i] = plr.Equip[i];
|
||||||
@ -342,7 +341,7 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
response.PCLoadData2CL.aNanoSlots[i] = plr.equippedNanos[i];
|
response.PCLoadData2CL.aNanoSlots[i] = plr.equippedNanos[i];
|
||||||
}
|
}
|
||||||
//missions in progress
|
// missions in progress
|
||||||
for (int i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
for (int i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
||||||
if (plr.tasks[i] == 0)
|
if (plr.tasks[i] == 0)
|
||||||
break;
|
break;
|
||||||
@ -385,10 +384,10 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
ChatManager::sendServerMessage(sock, settings::MOTDSTRING);
|
ChatManager::sendServerMessage(sock, settings::MOTDSTRING);
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
MissionManager::failInstancedMissions(sock);
|
MissionManager::failInstancedMissions(sock);
|
||||||
@ -863,8 +862,7 @@ void PlayerManager::enterPlayerVehicle(CNSocket* sock, CNPacketData* data) {
|
|||||||
sock->sendPacket((void*)&response, P_FE2CL_PC_VEHICLE_ON_FAIL, sizeof(sP_FE2CL_PC_VEHICLE_ON_FAIL));
|
sock->sendPacket((void*)&response, P_FE2CL_PC_VEHICLE_ON_FAIL, sizeof(sP_FE2CL_PC_VEHICLE_ON_FAIL));
|
||||||
|
|
||||||
// check if vehicle didn't expire
|
// check if vehicle didn't expire
|
||||||
if (plr.plr->Equip[8].iTimeLimit < getTimestamp())
|
if (plr.plr->Equip[8].iTimeLimit < getTimestamp()) {
|
||||||
{
|
|
||||||
plr.plr->toRemoveVehicle.eIL = 0;
|
plr.plr->toRemoveVehicle.eIL = 0;
|
||||||
plr.plr->toRemoveVehicle.iSlotNum = 8;
|
plr.plr->toRemoveVehicle.iSlotNum = 8;
|
||||||
ItemManager::checkItemExpire(sock, plr.plr);
|
ItemManager::checkItemExpire(sock, plr.plr);
|
||||||
@ -955,8 +953,7 @@ WarpLocation PlayerManager::getRespawnPoint(Player *plr) {
|
|||||||
|
|
||||||
bool PlayerManager::isAccountInUse(int accountId) {
|
bool PlayerManager::isAccountInUse(int accountId) {
|
||||||
std::map<CNSocket*, PlayerView>::iterator it;
|
std::map<CNSocket*, PlayerView>::iterator it;
|
||||||
for (it = PlayerManager::players.begin(); it != PlayerManager::players.end(); it++)
|
for (it = PlayerManager::players.begin(); it != PlayerManager::players.end(); it++) {
|
||||||
{
|
|
||||||
if (it->second.plr->accountId == accountId)
|
if (it->second.plr->accountId == accountId)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ void TableData::init() {
|
|||||||
|
|
||||||
std::cout << "[INFO] Loaded " << ItemManager::CrocPotTable.size() << " croc pot value sets" << std::endl;
|
std::cout << "[INFO] Loaded " << ItemManager::CrocPotTable.size() << " croc pot value sets" << std::endl;
|
||||||
|
|
||||||
//load nano info
|
// load nano info
|
||||||
nlohmann::json nanoInfo = xdtData["m_pNanoTable"]["m_pNanoData"];
|
nlohmann::json nanoInfo = xdtData["m_pNanoTable"]["m_pNanoData"];
|
||||||
for (nlohmann::json::iterator _nano = nanoInfo.begin(); _nano != nanoInfo.end(); _nano++) {
|
for (nlohmann::json::iterator _nano = nanoInfo.begin(); _nano != nanoInfo.end(); _nano++) {
|
||||||
auto nano = _nano.value();
|
auto nano = _nano.value();
|
||||||
@ -223,8 +223,7 @@ void TableData::init() {
|
|||||||
*/
|
*/
|
||||||
int TableData::getItemType(int itemSet) {
|
int TableData::getItemType(int itemSet) {
|
||||||
int overriden;
|
int overriden;
|
||||||
switch (itemSet)
|
switch (itemSet) {
|
||||||
{
|
|
||||||
case 11: // Chest items don't have iEquipLoc and are type 9.
|
case 11: // Chest items don't have iEquipLoc and are type 9.
|
||||||
overriden = 9;
|
overriden = 9;
|
||||||
break;
|
break;
|
||||||
@ -343,13 +342,11 @@ void TableData::loadDrops() {
|
|||||||
|
|
||||||
toAdd.dropChanceType = (int)drop["DropChance"];
|
toAdd.dropChanceType = (int)drop["DropChance"];
|
||||||
// Check if DropChance exists
|
// Check if DropChance exists
|
||||||
if (MobManager::MobDropChances.find(toAdd.dropChanceType) == MobManager::MobDropChances.end())
|
if (MobManager::MobDropChances.find(toAdd.dropChanceType) == MobManager::MobDropChances.end()) {
|
||||||
{
|
|
||||||
throw TableException(" MobDropChance not found: " + std::to_string((toAdd.dropChanceType)));
|
throw TableException(" MobDropChance not found: " + std::to_string((toAdd.dropChanceType)));
|
||||||
}
|
}
|
||||||
// Check if number of crates is correct
|
// Check if number of crates is correct
|
||||||
if (!(MobManager::MobDropChances[(int)drop["DropChance"]].cratesRatio.size() == toAdd.crateIDs.size()))
|
if (!(MobManager::MobDropChances[(int)drop["DropChance"]].cratesRatio.size() == toAdd.crateIDs.size())) {
|
||||||
{
|
|
||||||
throw TableException(" DropType " + std::to_string((int)drop["DropType"]) + " contains invalid number of crates");
|
throw TableException(" DropType " + std::to_string((int)drop["DropType"]) + " contains invalid number of crates");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,8 +389,7 @@ void TableData::loadDrops() {
|
|||||||
std::pair<int32_t, int32_t> itemSetkey = std::make_pair((int)item["ItemSet"], (int)item["Rarity"]);
|
std::pair<int32_t, int32_t> itemSetkey = std::make_pair((int)item["ItemSet"], (int)item["Rarity"]);
|
||||||
std::pair<int32_t, int32_t> itemDataKey = std::make_pair((int)item["Id"], (int)item["Type"]);
|
std::pair<int32_t, int32_t> itemDataKey = std::make_pair((int)item["Id"], (int)item["Type"]);
|
||||||
|
|
||||||
if (ItemManager::ItemData.find(itemDataKey) == ItemManager::ItemData.end())
|
if (ItemManager::ItemData.find(itemDataKey) == ItemManager::ItemData.end()) {
|
||||||
{
|
|
||||||
char buff[255];
|
char buff[255];
|
||||||
sprintf(buff, "Unknown item with Id %d and Type %d", (int)item["Id"], (int)item["Type"]);
|
sprintf(buff, "Unknown item with Id %d and Type %d", (int)item["Id"], (int)item["Type"]);
|
||||||
throw TableException(std::string(buff));
|
throw TableException(std::string(buff));
|
||||||
|
2
tdata
2
tdata
@ -1 +1 @@
|
|||||||
Subproject commit ffbb1afb36381e99e2ec7de3006bcbe09b3d4e18
|
Subproject commit aa4338202eb02d913bdfd8cf6d008795ded0f026
|
Loading…
Reference in New Issue
Block a user