From 83d6c17799c4d448a67ab5cdad02954282fa5c94 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 1 Nov 2008 13:33:18 +0000 Subject: server-side model loading, initial @dock function --- src/core/func.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/core/func.h') diff --git a/src/core/func.h b/src/core/func.h index 7c5635f..eacd47e 100644 --- a/src/core/func.h +++ b/src/core/func.h @@ -8,6 +8,7 @@ #define __INCLUDED_CORE_FUNC_H__ #include "core/player.h" +#include "core/entity.h" #include #include @@ -22,12 +23,15 @@ typedef void(* FuncPtr)(std::string const &args); /// fuction pointer for game functions typedef void(* GameFuncPtr)(Player *player, std::string const &args); +/// fuction pointer for target functions +typedef void(* TargetFuncPtr)(Player *player, Entity *entity); + /// a function pointer encapsulation class class Func { public: /// function flags - enum Flags {Game=1, Shared=2}; + enum Flags {Game=1, Shared=2, Target=4}; /// create a new function Func(char const * name, void *ptr, unsigned int flags = 0); @@ -56,16 +60,22 @@ public: /// execute the function if the Game flag is set void exec(Player *player, std::string const &args); + /// execute the function if the Target flag is set + void exec(Player *player, Entity *entity); + /* ---- Static functions for the Func registry -------------------- */ /// type definition typedef std::map Registry; /// add a function to the registry - static Func *add(const char *name, FuncPtr functionptr, unsigned int flags=0); + static Func *add(const char *name, FuncPtr functionptr, bool shared=false); /// add a game function to the registry and set the Game flag - static Func *add(const char *name, GameFuncPtr functionptr, unsigned int flags=0); + static Func *add(const char *name, GameFuncPtr functionptr); + + /// add a target function to the registry and set Game and Target flag + static Func *add(const char *name, TargetFuncPtr targetfunctionptr); /// remove a function from the registry static void remove(const char *name); -- cgit v1.2.3