diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-27 16:05:57 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-27 16:05:57 +0000 |
commit | ae167e5ff4d05823542466301298579a117a96ea (patch) | |
tree | d995d912efae67b82c02bf5a18f910ecdeccd7b5 | |
parent | 2922e40cae58bbddf629733a9a7865f2a00ed9e1 (diff) | |
download | manaserv-ae167e5ff4d05823542466301298579a117a96ea.tar.gz manaserv-ae167e5ff4d05823542466301298579a117a96ea.tar.bz2 manaserv-ae167e5ff4d05823542466301298579a117a96ea.tar.xz manaserv-ae167e5ff4d05823542466301298579a117a96ea.zip |
Implemented "money" remote command.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/game-server/command.cpp | 30 |
2 files changed, 33 insertions, 2 deletions
@@ -8,8 +8,9 @@ src/serialize/characterdata.hpp, src/account-server/characterdata.hpp: Added serialization of account level. * src/game-server/gamehandler.cpp, src/game-server/command.cpp, - src/Makefile.am: Added support for user commands. Implemented "warp" - and "item". + src/Makefile.am: Added support for remote commands. + * src/game-server/command.cpp: Implemented "warp", "item", and "money" + 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 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), }; /** |