From 85dcdd4cc5c6b6b76bc2a42ef31e9c76d29f8072 Mon Sep 17 00:00:00 2001 From: Gent S Date: Fri, 4 Dec 2020 07:04:59 -0500 Subject: [PATCH] Added /hide command to exclude players from monitor output --- src/ChatManager.cpp | 24 ++++++++++++++++++++++++ src/Monitor.cpp | 3 +++ src/Player.hpp | 1 + 3 files changed, 28 insertions(+) diff --git a/src/ChatManager.cpp b/src/ChatManager.cpp index 18e95e9..548de0f 100644 --- a/src/ChatManager.cpp +++ b/src/ChatManager.cpp @@ -745,6 +745,28 @@ void lairUnlockCommand(std::string full, std::vector& args, CNSocke sock->sendPacket((void*)&missionResp, P_FE2CL_REP_PC_SET_CURRENT_MISSION_ID, sizeof(sP_FE2CL_REP_PC_SET_CURRENT_MISSION_ID)); } +void hideCommand(std::string full, std::vector& args, CNSocket* sock) { + Player* plr = PlayerManager::getPlayer(sock); + if (plr->hidden) { + ChatManager::sendServerMessage(sock, "[HIDE] You're already hidden from the map."); + return; + } + + plr->hidden = true; + ChatManager::sendServerMessage(sock, "[HIDE] Successfully hidden from the map."); +} + +void unhideCommand(std::string full, std::vector& args, CNSocket* sock) { + Player* plr = PlayerManager::getPlayer(sock); + if (!plr->hidden) { + ChatManager::sendServerMessage(sock, "[HIDE] You're already visible from the map."); + return; + } + + plr->hidden = false; + ChatManager::sendServerMessage(sock, "[HIDE] Successfully un-hidden from the map."); +} + void ChatManager::init() { REGISTER_SHARD_PACKET(P_CL2FE_REQ_SEND_FREECHAT_MESSAGE, chatHandler); REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT, emoteHandler); @@ -774,6 +796,8 @@ void ChatManager::init() { registerCommand("summonGroupW", 30, summonGroupCommand, "permanently summon group NPCs"); registerCommand("whois", 50, whoisCommand, "describe nearest NPC"); registerCommand("lair", 50, lairUnlockCommand, "get the required mission for the nearest fusion lair"); + registerCommand("hide", 100, hideCommand, "hide yourself from the global player map"); + registerCommand("unhide", 100, unhideCommand, "un-hide yourself from the global player map"); } void ChatManager::registerCommand(std::string cmd, int requiredLevel, CommandHandler handlr, std::string help) { diff --git a/src/Monitor.cpp b/src/Monitor.cpp index b333801..ffea41e 100644 --- a/src/Monitor.cpp +++ b/src/Monitor.cpp @@ -77,6 +77,9 @@ void Monitor::tick(CNServer *serv, time_t delta) { continue; for (auto& pair : PlayerManager::players) { + if (pair.second->hidden) + continue; + int n = std::snprintf(buff, sizeof(buff), "player %d %d %s\n", pair.second->x, pair.second->y, PlayerManager::getPlayerName(pair.second, false).c_str()); diff --git a/src/Player.hpp b/src/Player.hpp index 91bd3bc..3ec533e 100644 --- a/src/Player.hpp +++ b/src/Player.hpp @@ -74,6 +74,7 @@ struct Player { int32_t iGroupConditionBitFlag; bool notify; + bool hidden; bool buddiesSynced; int64_t buddyIDs[50];