diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-08-25 22:29:29 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-08-25 22:29:29 +0300 |
commit | 3a091245572872f5cda79eab92eb392f92c02b39 (patch) | |
tree | 512e1b815194d865f67714542ab076411e084f32 /src | |
parent | 10029599ee4cb4c26531303ab0e07cedc856f1ad (diff) | |
download | manaverse-3a091245572872f5cda79eab92eb392f92c02b39.tar.gz manaverse-3a091245572872f5cda79eab92eb392f92c02b39.tar.bz2 manaverse-3a091245572872f5cda79eab92eb392f92c02b39.tar.xz manaverse-3a091245572872f5cda79eab92eb392f92c02b39.zip |
Move chat command /move into actions.
Diffstat (limited to 'src')
-rw-r--r-- | src/actions/commands.cpp | 14 | ||||
-rw-r--r-- | src/actions/commands.h | 1 | ||||
-rw-r--r-- | src/commands.cpp | 29 | ||||
-rw-r--r-- | src/commands.h | 5 | ||||
-rw-r--r-- | src/input/inputaction.h | 1 | ||||
-rw-r--r-- | src/input/inputactionmap.h | 11 | ||||
-rw-r--r-- | src/utils/stringutils.cpp | 16 | ||||
-rw-r--r-- | src/utils/stringutils.h | 2 |
8 files changed, 45 insertions, 34 deletions
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index 797c75edb..712850a9f 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -72,6 +72,7 @@ #include "net/net.h" #include "utils/gettext.h" +#include "utils/stringutils.h" #include "debug.h" @@ -272,4 +273,17 @@ impHandler0(printAll) return false; } +impHandler(move) +{ + int x = 0; + int y = 0; + + if (localPlayer && parse2Int(event.args, x, y)) + { + localPlayer->setDestination(x, y); + return true; + } + return false; +} + } // namespace Actions diff --git a/src/actions/commands.h b/src/actions/commands.h index 02810286c..35bd27538 100644 --- a/src/actions/commands.h +++ b/src/actions/commands.h @@ -38,6 +38,7 @@ namespace Actions decHandler(chatErase); decHandler(present); decHandler(printAll); + decHandler(move); } // namespace Actions #undef decHandler diff --git a/src/commands.cpp b/src/commands.cpp index bc3fc37c7..80fac44fe 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -99,22 +99,6 @@ extern char **environ; namespace Commands { -static bool parse2Int(const std::string &args, int &x, int &y) -{ - bool isValid = false; - const size_t pos = args.find(" "); - if (pos != std::string::npos) - { - if (pos + 1 < args.length()) - { - x = atoi(args.substr(0, pos).c_str()); - y = atoi(args.substr(pos + 1, args.length()).c_str()); - isValid = true; - } - } - return isValid; -} - static void outStringNormal(ChatTab *const tab, const std::string &str, const std::string &def) @@ -167,19 +151,6 @@ static void outStringNormal(ChatTab *const tab, } } -impHandler(move) -{ - int x = 0; - int y = 0; - - if (localPlayer && parse2Int(event.args, x, y)) - { - localPlayer->setDestination(x, y); - return true; - } - return false; -} - impHandler(navigate) { if (!localPlayer) diff --git a/src/commands.h b/src/commands.h index 41b2231c8..71c11113f 100644 --- a/src/commands.h +++ b/src/commands.h @@ -51,7 +51,6 @@ struct CommandInfo final namespace Commands { - decHandler(move); decHandler(target); decHandler(attackHuman); decHandler(outfit); @@ -116,8 +115,7 @@ namespace Commands enum { - COMMAND_MOVE = 0, - COMMAND_TARGET, + COMMAND_TARGET = 0, COMMAND_ATKHUMAN, COMMAND_OUTFIT, COMMAND_EMOTE, @@ -181,7 +179,6 @@ enum static const CommandInfo commands[] = { - {"move", &Commands::move, -1, true}, {"target", &Commands::target, -1, true}, {"atkhuman", &Commands::attackHuman, -1, true}, {"outfit", &Commands::outfit, -1, true}, diff --git a/src/input/inputaction.h b/src/input/inputaction.h index 9385ae765..aeb2164e6 100644 --- a/src/input/inputaction.h +++ b/src/input/inputaction.h @@ -367,6 +367,7 @@ namespace InputAction TOGGLE, PRESENT, PRINT_ALL, + MOVE, TOTAL }; } // namespace InputAction diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index b55887c65..05bb49616 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -3072,7 +3072,16 @@ static const InputActionData inputActionData[InputAction::TOTAL] = { InputAction::NO_VALUE, 50, InputCondition::INGAME, "all", - false} + false}, + {"keyMove", + InputType::UNKNOWN, InputAction::NO_VALUE, + InputType::UNKNOWN, InputAction::NO_VALUE, + Input::GRP_DEFAULT, + &Actions::move, + InputAction::NO_VALUE, 50, + InputCondition::INGAME, + "move", + true}, }; #endif // INPUT_INPUTACTIONMAP_H diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 31d68a418..11143206e 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -730,3 +730,19 @@ void secureChatCommand(std::string &str) if (str[0] == '/' || str[0] == '@' || str[0] == '#') str = "_" + str; } + +bool parse2Int(const std::string &args, int &x, int &y) +{ + bool isValid = false; + const size_t pos = args.find(" "); + if (pos != std::string::npos) + { + if (pos + 1 < args.length()) + { + x = atoi(args.substr(0, pos).c_str()); + y = atoi(args.substr(pos + 1, args.length()).c_str()); + isValid = true; + } + } + return isValid; +} diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h index 4f84dab76..5cf685a89 100644 --- a/src/utils/stringutils.h +++ b/src/utils/stringutils.h @@ -238,4 +238,6 @@ bool isDigit(const std::string &str); void secureChatCommand(std::string &str); +bool parse2Int(const std::string &args, int &x, int &y); + #endif // UTILS_STRINGUTILS_H |