summaryrefslogtreecommitdiff
path: root/src/actions
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-05-11 02:37:15 +0300
committerAndrei Karas <akaras@inbox.ru>2017-05-11 02:37:15 +0300
commit3f93a5c9fbe8f4d42d5cb25364b3bf16b59963ab (patch)
treece02f79d991f526ca8f78d58564cdcaa5db53d67 /src/actions
parent9ac735047746b9455a896b6fe82da36ea4b13ceb (diff)
downloadmv-3f93a5c9fbe8f4d42d5cb25364b3bf16b59963ab.tar.gz
mv-3f93a5c9fbe8f4d42d5cb25364b3bf16b59963ab.tar.bz2
mv-3f93a5c9fbe8f4d42d5cb25364b3bf16b59963ab.tar.xz
mv-3f93a5c9fbe8f4d42d5cb25364b3bf16b59963ab.zip
Extend undress chat command for undress item by id.
Diffstat (limited to 'src/actions')
-rw-r--r--src/actions/actions.cpp37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index eaf0da026..78ebe6406 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -104,8 +104,9 @@
#include "utils/chatutils.h"
#include "utils/delete2.h"
#include "utils/gettext.h"
-#include "utils/timer.h"
#include "utils/mathutils.h"
+#include "utils/parameters.h"
+#include "utils/timer.h"
#ifdef ANDROID
#ifndef USE_SDL2
@@ -1166,27 +1167,43 @@ impHandler(undress)
return false;
const std::string args = event.args;
-
+ StringVect pars;
+ if (!splitParameters(pars, args, " ,", '\"'))
+ return false;
Being *target = nullptr;
- if (!args.empty())
+ const size_t sz = pars.size();
+ if (sz == 0)
{
- if (args[0] == ':')
+ if (!target)
+ target = localPlayer->getTarget();
+ }
+ else
+ {
+ if (pars[0][0] == ':')
{
target = actorManager->findBeing(fromInt(atoi(
- args.substr(1).c_str()), BeingId));
+ pars[0].substr(1).c_str()), BeingId));
if (target && target->getType() == ActorType::Monster)
target = nullptr;
}
else
{
- target = actorManager->findNearestByName(event.args);
+ target = actorManager->findNearestByName(args);
}
}
- if (!target)
- target = localPlayer->getTarget();
- if (target && beingHandler)
- beingHandler->undress(target);
+ if (sz == 2)
+ {
+ const int itemId = atoi(pars[1].c_str());
+ if (target)
+ target->undressItemById(itemId);
+ }
+ else
+ {
+ if (target && beingHandler)
+ beingHandler->undress(target);
+ }
+
return true;
}