summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-04-08 23:58:35 +0300
committerAndrei Karas <akaras@inbox.ru>2016-04-08 23:58:35 +0300
commited5561b7965118fc11ae278e968c3de08eae98a7 (patch)
treef1e8b8e518dcc249dc09b70553034d074b4fa4cb
parentc8007693768d599726119b89cff5ab6aa1cf000d (diff)
downloadmv-ed5561b7965118fc11ae278e968c3de08eae98a7.tar.gz
mv-ed5561b7965118fc11ae278e968c3de08eae98a7.tar.bz2
mv-ed5561b7965118fc11ae278e968c3de08eae98a7.tar.xz
mv-ed5561b7965118fc11ae278e968c3de08eae98a7.zip
In debugspawn check clones positions and not spawn them outside of map.
-rw-r--r--src/actions/commands.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp
index 529025481..5fe0f1b08 100644
--- a/src/actions/commands.cpp
+++ b/src/actions/commands.cpp
@@ -75,6 +75,8 @@
#include "resources/db/itemdb.h"
+#include "resources/map/map.h"
+
#include "utils/chatutils.h"
#include "utils/gettext.h"
#include "utils/gmfunctions.h"
@@ -842,13 +844,25 @@ impHandler(hack)
impHandler(debugSpawn)
{
+ if (!localPlayer)
+ return false;
int cnt = atoi(event.args.c_str());
if (cnt < 1)
cnt = 1;
const int half = cnt / 2;
- for (int x = -half; x < cnt - half; x ++)
- {
- for (int y = -half; y < cnt - half; y ++)
+ const Map *const map = localPlayer->getMap();
+ int x1 = -half;
+ if (x1 < 0)
+ x1 = 0;
+ int y1 = x1;
+ int x2 = cnt - half;
+ if (x2 > map->getWidth())
+ x2 = map->getWidth();
+ int y2 = x2;
+
+ for (int x = x1; x < x2; x ++)
+ {
+ for (int y = y1; y < y2; y ++)
ActorManager::cloneBeing(localPlayer, x, y, cnt);
}
return true;