summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-27 16:39:12 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-27 16:39:12 +0000
commitfb3df5df8f20cbc2e5958c64a2c70cdb98925666 (patch)
treed371b06fd7ad54a91acd8bb0525cc49fbc31df22
parent9adc1a5cf223f78aa885a59374716bf6f1181c3d (diff)
downloadmanaserv-fb3df5df8f20cbc2e5958c64a2c70cdb98925666.tar.gz
manaserv-fb3df5df8f20cbc2e5958c64a2c70cdb98925666.tar.xz
manaserv-fb3df5df8f20cbc2e5958c64a2c70cdb98925666.zip
Implemented "spawn" remote command.
-rw-r--r--ChangeLog2
-rw-r--r--src/game-server/command.cpp33
2 files changed, 34 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 1b12c47..d5db867 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,7 +10,7 @@
* src/game-server/gamehandler.cpp, src/game-server/command.cpp,
src/Makefile.am: Added support for remote commands.
* src/game-server/command.cpp: Implemented "warp", "item", "money",
- and "drop" remote commands.
+ "drop", and "spawn" remote commands.
2007-08-20 Bjørn Lindeijer <bjorn@lindeijer.nl>
diff --git a/src/game-server/command.cpp b/src/game-server/command.cpp
index 8b6fa04..d4327c3 100644
--- a/src/game-server/command.cpp
+++ b/src/game-server/command.cpp
@@ -29,6 +29,8 @@
#include "game-server/item.hpp"
#include "game-server/itemmanager.hpp"
#include "game-server/mapmanager.hpp"
+#include "game-server/monster.hpp"
+#include "game-server/monstermanager.hpp"
#include "game-server/state.hpp"
template< typename T1 >
@@ -73,6 +75,8 @@ template<> struct Argument< MapComposite * >
{ static char const type = 'm'; };
template<> struct Argument< ItemClass * >
{ static char const type = 'i'; };
+template<> struct Argument< MonsterClass * >
+{ static char const type = 'o'; };
/**
* A command that a user can run remotely with sufficient rights.
@@ -184,6 +188,22 @@ static void drop(Character *from, ItemClass *it, int nb)
GameState::enqueueEvent(item, e);
}
+static void spawn(Character *from, MonsterClass *specy, int nb)
+{
+ MapComposite *map = from->getMap();
+ Point const &pos = from->getPosition();
+
+ for (int i = 0; i < nb; ++i)
+ {
+ Being *monster = new Monster(specy);
+ monster->setMap(map);
+ monster->setPosition(pos);
+ monster->clearDestination();
+ DelayedEvent e = { EVENT_INSERT };
+ GameState::enqueueEvent(monster, e);
+ }
+}
+
/**
* List of remote commands.
*/
@@ -193,6 +213,7 @@ static Command const commands[] =
handle("item", AL_GM, item),
handle("drop", AL_GM, drop),
handle("money", AL_GM, money),
+ handle("spawn", AL_GM, spawn),
};
/**
@@ -285,6 +306,18 @@ void runCommand(Character *ch, std::string const &text)
case 'n':
args[i] = atoi(arg.c_str());
break;
+
+ case 'o':
+ if (MonsterClass *mc = MonsterManager::getMonster(atoi(arg.c_str())))
+ {
+ args[i] = (intptr_t)mc;
+ }
+ else
+ {
+ // No such item.
+ return;
+ }
+ break;
}
pos = pos2;
}