diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-08-26 19:38:55 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-08-26 20:40:39 +0300 |
commit | a4077c474c370275442982965bb174b2e1e59422 (patch) | |
tree | 86607326f06bb241cb0245d294b3220eacaba5cc /src | |
parent | 647c1a8b8b02b737b11b1e08af86ecc84f649a81 (diff) | |
download | plus-a4077c474c370275442982965bb174b2e1e59422.tar.gz plus-a4077c474c370275442982965bb174b2e1e59422.tar.bz2 plus-a4077c474c370275442982965bb174b2e1e59422.tar.xz plus-a4077c474c370275442982965bb174b2e1e59422.zip |
Move chat command /attack into actions.
Diffstat (limited to 'src')
-rw-r--r-- | src/actions/actions.cpp | 27 | ||||
-rw-r--r-- | src/commands.cpp | 12 | ||||
-rw-r--r-- | src/commands.h | 5 | ||||
-rw-r--r-- | src/input/inputactionmap.h | 2 |
4 files changed, 19 insertions, 27 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index 6c5f365af..a46e37347 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -407,14 +407,19 @@ impHandler0(untarget) impHandler0(attack) { - if (localPlayer) - { - Being *const target = localPlayer->getTarget(); - if (target) - localPlayer->attack(target, true); - return true; - } - return false; + if (!localPlayer || !actorManager) + return false; + + Being *target = nullptr; + if (!event.args.empty()) + target = actorManager->findNearestByName(event.args); + if (!target) + target = localPlayer->getTarget(); + else + localPlayer->setTarget(target); + if (target) + localPlayer->attack(target, true); + return true; } impHandler0(targetAttack) @@ -687,9 +692,11 @@ impHandler(undress) if (!actorManager || !localPlayer) return false; - Being *target = localPlayer->getTarget(); - if (!target) + Being *target = nullptr; + if (!event.args.empty()) target = actorManager->findNearestByName(event.args); + if (!target) + target = localPlayer->getTarget(); if (target) Net::getBeingHandler()->undress(target); return true; diff --git a/src/commands.cpp b/src/commands.cpp index 78ea09576..3c3b1dbe4 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -157,18 +157,6 @@ impHandler(hack) return true; } -impHandler(attack) -{ - if (!localPlayer || !actorManager) - return false; - - Being *const target = actorManager->findNearestByName(event.args); - if (target) - localPlayer->setTarget(target); - localPlayer->attack2(localPlayer->getTarget(), true); - return true; -} - impHandler0(dirs) { if (!localPlayer || !debugChatTab) diff --git a/src/commands.h b/src/commands.h index 2089cb760..5dde98d8f 100644 --- a/src/commands.h +++ b/src/commands.h @@ -52,7 +52,6 @@ struct CommandInfo final namespace Commands { decHandler(hack); - decHandler(attack); decHandler(dirs); decHandler(info); decHandler(wait); @@ -97,8 +96,7 @@ namespace Commands enum { - COMMAND_ATTACK = 0, - COMMAND_DIRS, + COMMAND_DIRS = 0, COMMAND_INFO, COMMAND_WAIT, COMMAND_UPTIME, @@ -143,7 +141,6 @@ enum static const CommandInfo commands[] = { - {"attack", &Commands::attack, -1, true}, {"dirs", &Commands::dirs, -1, false}, {"info", &Commands::info, -1, false}, {"wait", &Commands::wait, -1, true}, diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index 952926510..7fdda0480 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -92,7 +92,7 @@ static const InputActionData inputActionData[InputAction::TOTAL] = { InputAction::NO_VALUE, 50, InputCondition::GAME | InputCondition::NOFOLLOW | InputCondition::VALIDSPEED, - "", + "attack", false}, {"keyTargetAttack", InputType::KEYBOARD, SDLK_LCTRL, |