diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game-server/character.cpp | 6 | ||||
-rw-r--r-- | src/game-server/main-game.cpp | 7 | ||||
-rw-r--r-- | src/scripting/luascript.cpp | 16 | ||||
-rw-r--r-- | src/scripting/luascript.hpp | 9 | ||||
-rw-r--r-- | src/scripting/script.cpp | 14 | ||||
-rw-r--r-- | src/scripting/script.hpp | 12 |
6 files changed, 31 insertions, 33 deletions
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp index 9230458e..1c96818f 100644 --- a/src/game-server/character.cpp +++ b/src/game-server/character.cpp @@ -180,7 +180,7 @@ void Character::perform() void Character::died() { Being::died(); - Script::execute_global_event_function("on_chr_death", this); + Script::executeGlobalEventFunction("on_chr_death", this); } void Character::respawn() @@ -197,7 +197,7 @@ void Character::respawn() mTarget = NULL; // execute respawn script - if (!Script::execute_global_event_function("on_chr_death_accept", this)) + if (!Script::executeGlobalEventFunction("on_chr_death_accept", this)) { // script-controlled respawning didn't work - fall back to // hardcoded logic @@ -232,7 +232,7 @@ void Character::useSpecial(int id) //tell script engine to cast the spell special->currentMana = 0; - Script::perform_special_action(id, this); + Script::performSpecialAction(id, this); mSpecialUpdateNeeded = true; return; } diff --git a/src/game-server/main-game.cpp b/src/game-server/main-game.cpp index 2ae84a06..d7ddefa2 100644 --- a/src/game-server/main-game.cpp +++ b/src/game-server/main-game.cpp @@ -157,10 +157,9 @@ static void initializeServer() MonsterManager::initialize(DEFAULT_MONSTERSDB_FILE); StatusManager::initialize(DEFAULT_STATUSDB_FILE); PermissionManager::initialize(DEFAULT_PERMISSION_FILE); - // Initialize global event script - LuaScript::load_global_event_script(DEFAULT_GLOBAL_EVENT_SCRIPT_FILE); - // Initialize special action script - LuaScript::load_special_actions_script(DEFAULT_SPECIAL_ACTIONS_SCRIPT_FILE); + + LuaScript::loadGlobalEventScript(DEFAULT_GLOBAL_EVENT_SCRIPT_FILE); + LuaScript::loadSpecialActionsScript(DEFAULT_SPECIAL_ACTIONS_SCRIPT_FILE); // --- Initialize the global handlers // FIXME: Make the global handlers global vars or part of a bigger diff --git a/src/scripting/luascript.cpp b/src/scripting/luascript.cpp index 922c15d0..ee727060 100644 --- a/src/scripting/luascript.cpp +++ b/src/scripting/luascript.cpp @@ -161,23 +161,23 @@ void LuaScript::getPostCallback(Character *q, const std::string &sender, s->execute(); } -bool LuaScript::load_global_event_script(const std::string &file) +bool LuaScript::loadGlobalEventScript(const std::string &file) { - Script::global_event_script = new LuaScript(); - if (!Script::global_event_script->loadFile(file)) + Script::globalEventScript = new LuaScript(); + if (!Script::globalEventScript->loadFile(file)) { - Script::global_event_script = NULL; + Script::globalEventScript = NULL; return false; } return true; } -bool LuaScript::load_special_actions_script(const std::string &file) +bool LuaScript::loadSpecialActionsScript(const std::string &file) { - Script::special_actions_script = new LuaScript(); - if (!Script::special_actions_script->loadFile(file)) + Script::specialActionsScript = new LuaScript(); + if (!Script::specialActionsScript->loadFile(file)) { - Script::special_actions_script = NULL; + Script::specialActionsScript = NULL; return false; } return true; diff --git a/src/scripting/luascript.hpp b/src/scripting/luascript.hpp index 94851ac7..5e4deea1 100644 --- a/src/scripting/luascript.hpp +++ b/src/scripting/luascript.hpp @@ -63,18 +63,17 @@ class LuaScript: public Script static void getPostCallback(Character *, const std::string &, const std::string &, void *); - void processDeathEvent(Being* thing); + void processDeathEvent(Being *thing); - void processRemoveEvent(Thing* thing); + void processRemoveEvent(Thing *thing); /** * Loads the global event script file */ - static bool load_global_event_script(const std::string &file); - static bool load_special_actions_script(const std::string &file); + static bool loadGlobalEventScript(const std::string &file); + static bool loadSpecialActionsScript(const std::string &file); private: - lua_State *mState; int nbArgs; std::string mCurFunction; diff --git a/src/scripting/script.cpp b/src/scripting/script.cpp index 8aa450b8..3d16a7d1 100644 --- a/src/scripting/script.cpp +++ b/src/scripting/script.cpp @@ -32,8 +32,8 @@ typedef std::map< std::string, Script::Factory > Engines; static Engines *engines = NULL; -Script *Script::global_event_script = NULL; -Script *Script::special_actions_script = NULL; +Script *Script::globalEventScript = NULL; +Script *Script::specialActionsScript = NULL; Script::Script(): mMap(NULL), @@ -108,10 +108,10 @@ void Script::loadNPC(const std::string &name, int id, int x, int y, execute(); } -bool Script::execute_global_event_function(const std::string &function, Being* obj) +bool Script::executeGlobalEventFunction(const std::string &function, Being* obj) { bool isScriptHandled = false; - Script *script = Script::global_event_script; + Script *script = Script::globalEventScript; if (script) { script->setMap(obj->getMap()); @@ -134,7 +134,7 @@ void Script::addDataToSpecial(int id, Special* special) */ if (special) { - Script *script = Script::special_actions_script; + Script *script = Script::specialActionsScript; if (script) { script->prepare("get_special_recharge_cost"); @@ -146,9 +146,9 @@ void Script::addDataToSpecial(int id, Special* special) } -bool Script::perform_special_action(int specialId, Being* caster) +bool Script::performSpecialAction(int specialId, Being* caster) { - Script *script = Script::special_actions_script; + Script *script = Script::specialActionsScript; if (script) { script->prepare("use_special"); diff --git a/src/scripting/script.hpp b/src/scripting/script.hpp index 0e874151..dfba06f0 100644 --- a/src/scripting/script.hpp +++ b/src/scripting/script.hpp @@ -128,21 +128,21 @@ class Script EventListener *getScriptListener() { return &mEventListener; } - virtual void processDeathEvent(Being* thing) = 0; + virtual void processDeathEvent(Being *thing) = 0; - virtual void processRemoveEvent(Thing* thing) = 0; + virtual void processRemoveEvent(Thing *thing) = 0; /** * Runs a function from the global event script file */ - static bool execute_global_event_function(const std::string &function, Being *obj); + static bool executeGlobalEventFunction(const std::string &function, Being *obj); static void addDataToSpecial(int specialId, Special *special); - static bool perform_special_action(int specialId, Being *caster); + static bool performSpecialAction(int specialId, Being *caster); protected: - static Script* global_event_script; // the global event script - static Script* special_actions_script; // the special actions script + static Script *globalEventScript; + static Script *specialActionsScript; std::string mScriptFile; private: |