From 143bb00ac0a3d9606ac231cd8a3bd74c915ad216 Mon Sep 17 00:00:00 2001 From: actuallyamoose <35468230+actuallyamoose@users.noreply.github.com> Date: Sun, 13 Dec 2020 19:05:11 -0500 Subject: [PATCH] Added checks to prevent buddy warping and item sending across time (#183) --- src/BuddyManager.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/BuddyManager.cpp b/src/BuddyManager.cpp index e72a2aa..dc6d9c4 100644 --- a/src/BuddyManager.cpp +++ b/src/BuddyManager.cpp @@ -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 attachments; + for (int i = 0; i < 4; i++) { sEmailItemInfoFromCL attachment = pkt->aItem[i]; resp.aItem[i] = attachment;