summaryrefslogtreecommitdiff
path: root/src/game-server/command.cpp
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-27 16:05:57 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-27 16:05:57 +0000
commitae167e5ff4d05823542466301298579a117a96ea (patch)
treed995d912efae67b82c02bf5a18f910ecdeccd7b5 /src/game-server/command.cpp
parent2922e40cae58bbddf629733a9a7865f2a00ed9e1 (diff)
downloadmanaserv-ae167e5ff4d05823542466301298579a117a96ea.tar.gz
manaserv-ae167e5ff4d05823542466301298579a117a96ea.tar.bz2
manaserv-ae167e5ff4d05823542466301298579a117a96ea.tar.xz
manaserv-ae167e5ff4d05823542466301298579a117a96ea.zip
Implemented "money" remote command.
Diffstat (limited to 'src/game-server/command.cpp')
-rw-r--r--src/game-server/command.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/game-server/command.cpp b/src/game-server/command.cpp
index 2920c30a..19326f08 100644
--- a/src/game-server/command.cpp
+++ b/src/game-server/command.cpp
@@ -31,6 +31,12 @@
#include "game-server/mapmanager.hpp"
#include "game-server/state.hpp"
+template< typename T1, typename T2 >
+static void proxy(void (*f)(), intptr_t args[4])
+{
+ ((void (*)(T1, T2))f)((T1)args[0], (T2)args[1]);
+}
+
template< typename T1, typename T2, typename T3 >
static void proxy(void (*f)(), intptr_t args[4])
{
@@ -71,6 +77,24 @@ struct Command
};
/**
+ * Creates a command with a 2-parameter handler.
+ */
+template< typename T1, typename T2 >
+static Command handle(char const *name, int level, void (*f)(T1, T2))
+{
+ Command c;
+ c.name = name;
+ c.level = level;
+ c.handler = &proxy< T1, T2 >;
+ c.target = (void (*)())f;
+ c.type[0] = Argument<T1>::type;
+ c.type[1] = Argument<T2>::type;
+ c.type[2] = 0;
+ c.type[3] = 0;
+ return c;
+}
+
+/**
* Creates a command with a 3-parameter handler.
*/
template< typename T1, typename T2, typename T3 >
@@ -117,6 +141,11 @@ static void item(Character *q, ItemClass *it, int nb)
Inventory(q).insert(it->getDatabaseID(), nb);
}
+static void money(Character *q, int nb)
+{
+ Inventory(q).changeMoney(nb);
+}
+
/**
* List of remote commands.
*/
@@ -124,6 +153,7 @@ static Command const commands[] =
{
handle("warp", AL_GM, warp),
handle("item", AL_GM, item),
+ handle("money", AL_GM, money),
};
/**