summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-08-26 19:38:55 +0300
committerAndrei Karas <akaras@inbox.ru>2014-08-26 20:40:39 +0300
commita4077c474c370275442982965bb174b2e1e59422 (patch)
tree86607326f06bb241cb0245d294b3220eacaba5cc
parent647c1a8b8b02b737b11b1e08af86ecc84f649a81 (diff)
downloadplus-a4077c474c370275442982965bb174b2e1e59422.tar.gz
plus-a4077c474c370275442982965bb174b2e1e59422.tar.bz2
plus-a4077c474c370275442982965bb174b2e1e59422.tar.xz
plus-a4077c474c370275442982965bb174b2e1e59422.zip
Move chat command /attack into actions.
-rw-r--r--src/actions/actions.cpp27
-rw-r--r--src/commands.cpp12
-rw-r--r--src/commands.h5
-rw-r--r--src/input/inputactionmap.h2
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,