From 4516227a7b31283017c0bf7a94ccc718c80caa38 Mon Sep 17 00:00:00 2001 From: dongresource Date: Fri, 1 Jan 2021 21:38:03 +0100 Subject: [PATCH] Fix a few GM issues * Invert access check when kicking players * Add validation to ensure only GMs can PVP * Account for instance in /teleport2me --- src/MobManager.cpp | 4 ++++ src/PlayerManager.cpp | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/MobManager.cpp b/src/MobManager.cpp index c1c21aa..ec267ae 100644 --- a/src/MobManager.cpp +++ b/src/MobManager.cpp @@ -1048,6 +1048,10 @@ void MobManager::pcAttackChars(CNSocket *sock, CNPacketData *data) { sP_CL2FE_REQ_PC_ATTACK_CHARs* pkt = (sP_CL2FE_REQ_PC_ATTACK_CHARs*)data->buf; Player *plr = PlayerManager::getPlayer(sock); + // only GMs can use this this variant + if (plr->accountLevel > 30) + return; + // Unlike the attack mob packet, attacking players packet has an 8-byte trail (Instead of 4 bytes). if (!validInVarPacket(sizeof(sP_CL2FE_REQ_PC_ATTACK_CHARs), pkt->iTargetCnt, sizeof(int32_t) * 2, data->size)) { std::cout << "[WARN] bad sP_CL2FE_REQ_PC_ATTACK_CHARs packet size\n"; diff --git a/src/PlayerManager.cpp b/src/PlayerManager.cpp index 84191b8..203b171 100644 --- a/src/PlayerManager.cpp +++ b/src/PlayerManager.cpp @@ -1067,7 +1067,7 @@ void PlayerManager::kickPlayer(CNSocket *sock, CNPacketData *data) { Player *otherPlr = getPlayer(otherSock); - if (otherPlr->accountLevel > plr->accountLevel) { + if (plr->accountLevel > otherPlr->accountLevel) { ChatManager::sendServerMessage(sock, "player has higher access level"); return; } @@ -1131,7 +1131,7 @@ void PlayerManager::teleportPlayer(CNSocket *sock, CNPacketData *data) { switch (req->eTeleportType) { case eCN_GM_TeleportMapType__MyLocation: - sendPlayerTo(targetSock, plr->x, plr->y, plr->z); + sendPlayerTo(targetSock, plr->x, plr->y, plr->z, instance); break; case eCN_GM_TeleportMapType__MapXYZ: instance = req->iToMap;