From c69866123ba83f9dd4619c81eca312dda0559393 Mon Sep 17 00:00:00 2001 From: Stefan Dombrowski Date: Mon, 11 Oct 2010 22:05:02 +0200 Subject: Implementing show IP for game masters As an upcoming feature the TMW-Athena server sends IP addresses or IP hashes to game masters. The current client freezes if it receives such a packet, therefor the game masters need to use a new client before the server can use it. Normal players are not affected, because they do not get this packet. Showing the IP is optional and can be enable with the chat command "/showip 1". The IP is then shown behind the players name. Reviewed-by: Bertram --- src/commandhandler.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/commandhandler.cpp') diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index dab51c8f..1c375ad9 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -21,6 +21,7 @@ #include "commandhandler.h" +#include "beingmanager.h" #include "channelmanager.h" #include "channel.h" #include "game.h" @@ -126,6 +127,10 @@ void CommandHandler::handleCommand(const std::string &command, ChatTab *tab) { handleAway(args, tab); } + else if (type == "showip" && Net::getNetworkType() == ServerInfo::TMWATHENA) + { + handleShowIp(args, tab); + } else { tab->chatLog(_("Unknown command.")); @@ -479,6 +484,35 @@ void CommandHandler::handleToggle(const std::string &args, ChatTab *tab) } } +void CommandHandler::handleShowIp(const std::string &args, ChatTab *tab) +{ + if (args.empty()) + { + tab->chatLog(player_node->getShowIp() ? + _("Show IP: On") : _("Show IP: Off")); + return; + } + + char opt = parseBoolean(args); + + switch (opt) + { + case 0: + tab->chatLog(_("Show IP: Off")); + player_node->setShowIp(false); + break; + case 1: + tab->chatLog(_("Show IP: On")); + player_node->setShowIp(true); + break; + case -1: + tab->chatLog(strprintf(BOOLEAN_OPTIONS, "showip")); + return; + } + + beingManager->updatePlayerNames(); +} + void CommandHandler::handlePresent(const std::string &args, ChatTab *tab) { chatWindow->doPresent(); -- cgit v1.2.3-70-g09d2