From c0c208d4c29ff49f940e8a6c54adb26cc4e5eba3 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Thu, 1 Mar 2012 21:54:04 +0100 Subject: Converted functions called by LuaScript to callbacks This includes the quest reply, post reply, death notification and remove notification. Also, Script::Ref was changed from a typedef to a small class, automating initialization and making the check for validness clearer. Reviewed-by: Erik Schilling --- src/scripting/luascript.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/scripting/luascript.h') diff --git a/src/scripting/luascript.h b/src/scripting/luascript.h index 6f2bceee..ecd249ae 100644 --- a/src/scripting/luascript.h +++ b/src/scripting/luascript.h @@ -61,19 +61,37 @@ class LuaScript : public Script void assignCallback(Ref &function); static void getQuestCallback(Character *, const std::string &, - const std::string &, void *); + const std::string &, Script *); static void getPostCallback(Character *, const std::string &, - const std::string &, void *); + const std::string &, Script *); void processDeathEvent(Being *thing); void processRemoveEvent(Thing *thing); + + static void setQuestReplyCallback(Script *script) + { script->assignCallback(mQuestReplyCallback); } + + static void setPostReplyCallback(Script *script) + { script->assignCallback(mPostReplyCallback); } + + static void setDeathNotificationCallback(Script *script) + { script->assignCallback(mDeathNotificationCallback); } + + static void setRemoveNotificationCallback(Script *script) + { script->assignCallback(mRemoveNotificationCallback); } + private: lua_State *mState; int nbArgs; std::string mCurFunction; + + static Ref mQuestReplyCallback; + static Ref mPostReplyCallback; + static Ref mDeathNotificationCallback; + static Ref mRemoveNotificationCallback; }; static char const registryKey = 0; -- cgit v1.2.3-70-g09d2