diff options
Diffstat (limited to 'src/game-server/quest.h')
-rw-r--r-- | src/game-server/quest.h | 55 |
1 files changed, 48 insertions, 7 deletions
diff --git a/src/game-server/quest.h b/src/game-server/quest.h index 0125e84b..05caa6ab 100644 --- a/src/game-server/quest.h +++ b/src/game-server/quest.h @@ -23,16 +23,58 @@ #include <string> +#include "scripting/scriptmanager.h" + class Character; class Script; -struct QuestCallback + +class QuestCallback { - void (*handler)(Character *, - const std::string &value, - Script *script); + public: + virtual ~QuestCallback() + { } + + virtual void triggerCallback(Character *ch, + const std::string &value) const = 0; +}; + +class QuestThreadCallback : public QuestCallback +{ + public: + QuestThreadCallback(void (*handler)(Character *, + const std::string &value, + Script *mScript), + Script *script) : + mHandler(handler), + mScript(script) + { } + + virtual void triggerCallback(Character *ch, + const std::string &value) const + { mHandler(ch, value, mScript); } + + private: + void (*mHandler)(Character *, + const std::string &value, + Script *mScript); + + Script *mScript; +}; + +class QuestRefCallback : public QuestCallback +{ + public: + QuestRefCallback(Script *script, const std::string &questName) : + mQuestName(questName) + { script->assignCallback(mRef); } + + virtual void triggerCallback(Character *ch, + const std::string &value) const; - Script *script; + private: + Script::Ref mRef; + std::string mQuestName; }; /** @@ -51,8 +93,7 @@ void setQuestVar(Character *, const std::string &name, * Starts the recovery of a variable and returns immediatly. The callback will * be called once the value has been recovered. */ -void recoverQuestVar(Character *, const std::string &name, - const QuestCallback &); +void recoverQuestVar(Character *, const std::string &name, QuestCallback *); /** * Called by the handler of the account server when a value is received. |