Added checks to prevent buddy warping and item sending across time (#183)

This commit is contained in:
actuallyamoose 2020-12-13 19:05:11 -05:00 committed by GitHub
parent b947ff65cf
commit 143bb00ac0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -456,6 +456,16 @@ void BuddyManager::reqBuddyWarp(CNSocket* sock, CNPacketData* data) {
return;
}
Player *plr = PlayerManager::getPlayer(sock);
if (otherPlr->PCStyle2.iPayzoneFlag != plr->PCStyle2.iPayzoneFlag) {
// players are not at the same point in time
INITSTRUCT(sP_FE2CL_REP_PC_BUDDY_WARP_FAIL, resp);
resp.iBuddyPCUID = pkt->iBuddyPCUID;
resp.iErrorCode = 0;
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_BUDDY_WARP_FAIL, sizeof(sP_FE2CL_REP_PC_BUDDY_WARP_FAIL));
return;
}
PlayerManager::sendPlayerTo(sock, otherPlr->x, otherPlr->y, otherPlr->z);
}
@ -649,8 +659,22 @@ void BuddyManager::emailSend(CNSocket* sock, CNPacketData* data) {
INITSTRUCT(sP_FE2CL_REP_PC_SEND_EMAIL_SUCC, resp);
if (pkt->iCash || pkt->aItem[0].ItemInven.iID) {
// if there are item or taro attachments
Database::DbPlayer otherPlayerData = Database::getDbPlayerById(pkt->iTo_PCUID);
if (otherPlayerData.PlayerID != -1 && plr->PCStyle2.iPayzoneFlag != otherPlayerData.PayZoneFlag) {
// if the players are not in the same time period
INITSTRUCT(sP_FE2CL_REP_PC_SEND_EMAIL_FAIL, resp);
resp.iErrorCode = 9; //error code 9 tells the player they can't send attachments across time
resp.iTo_PCUID = pkt->iTo_PCUID;
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_SEND_EMAIL_FAIL, sizeof(sP_FE2CL_REP_PC_SEND_EMAIL_FAIL));
return;
}
}
// handle items
std::vector<sItemBase> attachments;
for (int i = 0; i < 4; i++) {
sEmailItemInfoFromCL attachment = pkt->aItem[i];
resp.aItem[i] = attachment;