diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-03-01 21:54:04 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-03-02 22:57:47 +0100 |
commit | c0c208d4c29ff49f940e8a6c54adb26cc4e5eba3 (patch) | |
tree | 8de105c5e154912acf354bbe1bbf8509ac44e25a /src/game-server | |
parent | ba5b55f3eba0aa3898c5fe42de9838b22473c24a (diff) | |
download | manaserv-c0c208d4c29ff49f940e8a6c54adb26cc4e5eba3.tar.gz manaserv-c0c208d4c29ff49f940e8a6c54adb26cc4e5eba3.tar.bz2 manaserv-c0c208d4c29ff49f940e8a6c54adb26cc4e5eba3.tar.xz manaserv-c0c208d4c29ff49f940e8a6c54adb26cc4e5eba3.zip |
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
Diffstat (limited to 'src/game-server')
-rw-r--r-- | src/game-server/character.cpp | 6 | ||||
-rw-r--r-- | src/game-server/postman.h | 7 | ||||
-rw-r--r-- | src/game-server/quest.cpp | 2 | ||||
-rw-r--r-- | src/game-server/quest.h | 5 |
4 files changed, 11 insertions, 9 deletions
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp index b5051764..950c6496 100644 --- a/src/game-server/character.cpp +++ b/src/game-server/character.cpp @@ -52,12 +52,12 @@ const float Character::EXPCURVE_FACTOR = 10.0f; const float Character::LEVEL_SKILL_PRECEDENCE_FACTOR = 0.75f; const float Character::EXP_LEVEL_FLEXIBILITY = 1.0f; -Script::Ref Character::mDeathCallback = Script::NoRef; -Script::Ref Character::mDeathAcceptedCallback = Script::NoRef; +Script::Ref Character::mDeathCallback; +Script::Ref Character::mDeathAcceptedCallback; static bool executeCallback(Script::Ref function, Character *character) { - if (function == Script::NoRef) + if (!function.isValid()) return false; Script *script = ScriptManager::currentState(); diff --git a/src/game-server/postman.h b/src/game-server/postman.h index 82b7a5a7..5669ebef 100644 --- a/src/game-server/postman.h +++ b/src/game-server/postman.h @@ -25,12 +25,13 @@ #include <string> class Character; +class Script; struct PostCallback { void (*handler)(Character *, const std::string &sender, - const std::string &letter, void *data); - void *data; + const std::string &letter, Script *script); + Script *script; }; class PostMan @@ -64,7 +65,7 @@ public: std::map<Character*, PostCallback>::iterator itr = mCallbacks.find(player); if (itr != mCallbacks.end()) { - itr->second.handler(player, sender, letter, itr->second.data); + itr->second.handler(player, sender, letter, itr->second.script); } } diff --git a/src/game-server/quest.cpp b/src/game-server/quest.cpp index e4607c6a..974fc4ce 100644 --- a/src/game-server/quest.cpp +++ b/src/game-server/quest.cpp @@ -152,7 +152,7 @@ void recoveredQuestVar(int id, const std::string &name, for (QuestCallbacks::const_iterator k = j->second.begin(), k_end = j->second.end(); k != k_end; ++k) { - k->handler(ch, name, value, k->data); + k->handler(ch, name, value, k->script); } variables.erase(j); diff --git a/src/game-server/quest.h b/src/game-server/quest.h index 56fa5c2a..86d2be46 100644 --- a/src/game-server/quest.h +++ b/src/game-server/quest.h @@ -24,12 +24,13 @@ #include <string> class Character; +class Script; struct QuestCallback { void (*handler)(Character *, const std::string &name, - const std::string &value, void *data); - void *data; + const std::string &value, Script *script); + Script *script; }; /** |