From 81d09649718d5bd30cbb1b7e2ac2266e3e865d4f Mon Sep 17 00:00:00 2001 From: dongresource Date: Mon, 28 Dec 2020 16:13:38 +0100 Subject: [PATCH] Disallow warping to players using the MSS --- src/BuddyManager.cpp | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/BuddyManager.cpp b/src/BuddyManager.cpp index 01e1438..9c2d929 100644 --- a/src/BuddyManager.cpp +++ b/src/BuddyManager.cpp @@ -505,6 +505,7 @@ void BuddyManager::reqBuddyDelete(CNSocket* sock, CNPacketData* data) { void BuddyManager::reqBuddyWarp(CNSocket* sock, CNPacketData* data) { if (data->size != sizeof(sP_CL2FE_REQ_PC_BUDDY_WARP)) return; // malformed packet + Player *plr = PlayerManager::getPlayer(sock); sP_CL2FE_REQ_PC_BUDDY_WARP* pkt = (sP_CL2FE_REQ_PC_BUDDY_WARP*)data->buf; @@ -515,27 +516,27 @@ void BuddyManager::reqBuddyWarp(CNSocket* sock, CNPacketData* data) { if (otherPlr == nullptr) return; // buddy offline - if (otherPlr->instanceID != INSTANCE_OVERWORLD) { - // player is instanced; no warp allowed - 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; - } + // if the player is instanced; no warp allowed + if (otherPlr->instanceID != INSTANCE_OVERWORLD) + goto fail; - 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; - } + // check if the players are at the same point in time (or in the training area or not) + if (otherPlr->PCStyle2.iPayzoneFlag != plr->PCStyle2.iPayzoneFlag) + goto fail; + + // do not warp to players on monkeys + if (otherPlr->onMonkey) + goto fail; // otherPlr->instanceID should always be INSTANCE_OVERWORLD at this point PlayerManager::sendPlayerTo(sock, otherPlr->x, otherPlr->y, otherPlr->z, otherPlr->instanceID); + return; + +fail: + 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)); } void BuddyManager::emailUpdateCheck(CNSocket* sock, CNPacketData* data) {