From d9dc86b8dce433947c81ba87ad0bad83d4bc96f6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 24 Aug 2014 22:06:47 +0300 Subject: Move chat command /erase into actions. --- src/actions/commands.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ src/actions/commands.h | 1 + 2 files changed, 48 insertions(+) (limited to 'src/actions') diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index 5c16d17cc..2b4c40b0e 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -184,6 +184,53 @@ impHandler(chatUnignore) return true; } +impHandler(chatErase) +{ + std::string args = event.args; + if (args.empty()) + { + WhisperTab *const whisper = dynamic_cast(event.tab); + if (!whisper || whisper->getNick().empty()) + { + // TRANSLATORS: change relation + event.tab->chatLog(_("Please specify a name."), ChatMsgType::BY_SERVER); + return false; + } + args = whisper->getNick(); + } + + if (player_relations.getRelation(args) == PlayerRelation::ERASED) + { + if (event.tab) + { + // TRANSLATORS: erase command + event.tab->chatLog(_("Player already erased!"), ChatMsgType::BY_SERVER); + } + return true; + } + else + { + player_relations.setRelation(args, PlayerRelation::ERASED); + } + + if (event.tab) + { + if (player_relations.getRelation(args) == PlayerRelation::ERASED) + { + // TRANSLATORS: erase command + event.tab->chatLog(_("Player successfully erased!"), + ChatMsgType::BY_SERVER); + } + else + { + // TRANSLATORS: erase command + event.tab->chatLog(_("Player could not be erased!"), + ChatMsgType::BY_SERVER); + } + } + return true; +} + impHandler(chatFriend) { // TRANSLATORS: adding friend command diff --git a/src/actions/commands.h b/src/actions/commands.h index 306c46cb9..c978cb57b 100644 --- a/src/actions/commands.h +++ b/src/actions/commands.h @@ -35,6 +35,7 @@ namespace Actions decHandler(chatNeutral); decHandler(chatBlackList); decHandler(chatEnemy); + decHandler(chatErase); } // namespace Actions #undef decHandler -- cgit v1.2.3-70-g09d2