summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-08-24 22:06:47 +0300
committerAndrei Karas <akaras@inbox.ru>2014-08-24 22:06:47 +0300
commitd9dc86b8dce433947c81ba87ad0bad83d4bc96f6 (patch)
tree02afde544303ab88ab5a1f726d7c3a6f5794e341
parent4805bee18392b56f39be68b0d6a0384cbda0f846 (diff)
downloadmanaverse-d9dc86b8dce433947c81ba87ad0bad83d4bc96f6.tar.gz
manaverse-d9dc86b8dce433947c81ba87ad0bad83d4bc96f6.tar.bz2
manaverse-d9dc86b8dce433947c81ba87ad0bad83d4bc96f6.tar.xz
manaverse-d9dc86b8dce433947c81ba87ad0bad83d4bc96f6.zip
Move chat command /erase into actions.
-rw-r--r--src/actions/commands.cpp47
-rw-r--r--src/actions/commands.h1
-rw-r--r--src/commands.cpp44
-rw-r--r--src/commands.h5
-rw-r--r--src/input/inputaction.h1
-rw-r--r--src/input/inputactionmap.h9
6 files changed, 59 insertions, 48 deletions
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<WhisperTab* const>(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
diff --git a/src/commands.cpp b/src/commands.cpp
index 031bcd0a9..953f2679d 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -384,50 +384,6 @@ impHandler0(present)
return false;
}
-impHandler(erase)
-{
- if (event.args.empty())
- {
- if (event.tab)
- {
- // TRANSLATORS: erase command
- event.tab->chatLog(_("Please specify a name."), ChatMsgType::BY_SERVER);
- }
- return true;
- }
-
- if (player_relations.getRelation(event.args) == PlayerRelation::ERASED)
- {
- if (event.tab)
- {
- // TRANSLATORS: erase command
- event.tab->chatLog(_("Player already erased!"), ChatMsgType::BY_SERVER);
- }
- return true;
- }
- else
- {
- player_relations.setRelation(event.args, PlayerRelation::ERASED);
- }
-
- if (event.tab)
- {
- if (player_relations.getRelation(event.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;
-}
-
impHandler0(quit)
{
// quit();
diff --git a/src/commands.h b/src/commands.h
index a017eb2ac..9fb8013d2 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -59,7 +59,6 @@ namespace Commands
decHandler(me);
decHandler(toggle);
decHandler(present);
- decHandler(erase);
decHandler(quit);
decHandler(showAll);
decHandler(move);
@@ -127,8 +126,7 @@ namespace Commands
enum
{
- COMMAND_ERASE = 0,
- COMMAND_CLEANGRAPHICS,
+ COMMAND_CLEANGRAPHICS = 0,
COMMAND_CLEANFONTS,
COMMAND_CREATEPARTY,
COMMAND_CREATEGUILD,
@@ -203,7 +201,6 @@ enum
static const CommandInfo commands[] =
{
- {"erase", &Commands::erase, -1, true},
{"cleangraphics", &Commands::cleanGraphics, -1, false},
{"cleanfonts", &Commands::cleanFonts, -1, false},
{"createparty", &Commands::createParty, -1, true},
diff --git a/src/input/inputaction.h b/src/input/inputaction.h
index 258c3c3e7..3fc39aaf3 100644
--- a/src/input/inputaction.h
+++ b/src/input/inputaction.h
@@ -357,6 +357,7 @@ namespace InputAction
NEUTRAL,
BLACKLIST,
ENEMY,
+ ERASE,
TOTAL
};
} // namespace InputAction
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index e3d17710c..ebadff15d 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -2982,6 +2982,15 @@ static const InputActionData inputActionData[InputAction::TOTAL] = {
InputAction::NO_VALUE, 50,
InputCondition::INGAME,
"enemy",
+ true},
+ {"keyErase",
+ InputType::UNKNOWN, InputAction::NO_VALUE,
+ InputType::UNKNOWN, InputAction::NO_VALUE,
+ Input::GRP_DEFAULT,
+ &Actions::chatErase,
+ InputAction::NO_VALUE, 50,
+ InputCondition::INGAME,
+ "erase",
true}
};