diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game-server/main-game.cpp | 23 | ||||
-rw-r--r-- | src/scripting/luascript.cpp | 11 | ||||
-rw-r--r-- | src/scripting/luascript.hpp | 5 | ||||
-rw-r--r-- | src/scripting/script.hpp | 5 |
4 files changed, 29 insertions, 15 deletions
diff --git a/src/game-server/main-game.cpp b/src/game-server/main-game.cpp index 3ad265fe..36da4c3d 100644 --- a/src/game-server/main-game.cpp +++ b/src/game-server/main-game.cpp @@ -60,14 +60,15 @@ using utils::Logger; // Default options that automake should be able to override. -#define DEFAULT_LOG_FILE "manaserv-game.log" -#define DEFAULT_CONFIG_FILE "manaserv.xml" -#define DEFAULT_ITEMSDB_FILE "items.xml" -#define DEFAULT_SKILLSDB_FILE "mana-skills.xml" -#define DEFAULT_MAPSDB_FILE "maps.xml" -#define DEFAULT_MONSTERSDB_FILE "monsters.xml" -#define DEFAULT_STATUSDB_FILE "mana-status-effect.xml" -#define DEFAULT_PERMISSION_FILE "permissions.xml" +#define DEFAULT_LOG_FILE "manaserv-game.log" +#define DEFAULT_CONFIG_FILE "manaserv.xml" +#define DEFAULT_ITEMSDB_FILE "items.xml" +#define DEFAULT_SKILLSDB_FILE "mana-skills.xml" +#define DEFAULT_MAPSDB_FILE "maps.xml" +#define DEFAULT_MONSTERSDB_FILE "monsters.xml" +#define DEFAULT_STATUSDB_FILE "mana-status-effect.xml" +#define DEFAULT_PERMISSION_FILE "permissions.xml" +#define DEFAULT_GLOBAL_EVENT_SCRIPT_FILE "scripts/global_events.lua" static int const WORLD_TICK_SKIP = 2; /** tolerance for lagging behind in world calculation) **/ @@ -174,11 +175,7 @@ void initialize() StatusManager::initialize(DEFAULT_STATUSDB_FILE); PermissionManager::initialize(DEFAULT_PERMISSION_FILE); // Initialize global event script - Script::global_event_script = new LuaScript(); - if (!Script::global_event_script->loadFile("scripts/global_events.lua")) - { - Script::global_event_script = NULL; - } + LuaScript::load_global_event_script(DEFAULT_GLOBAL_EVENT_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 cb6ba3a6..b48ec511 100644 --- a/src/scripting/luascript.cpp +++ b/src/scripting/luascript.cpp @@ -156,3 +156,14 @@ void LuaScript::getPostCallback(Character *q, const std::string &sender, s->nbArgs = 3; s->execute(); } + +bool LuaScript::load_global_event_script(const std::string &file) +{ + Script::global_event_script = new LuaScript(); + if (!Script::global_event_script->loadFile(file)) + { + Script::global_event_script = NULL; + return false; + } + return true; +} diff --git a/src/scripting/luascript.hpp b/src/scripting/luascript.hpp index 25fc997a..315c759f 100644 --- a/src/scripting/luascript.hpp +++ b/src/scripting/luascript.hpp @@ -67,6 +67,11 @@ class LuaScript: public Script void processRemoveEvent(Thing* thing); + /** + * Loads the global event script file + */ + static bool load_global_event_script(const std::string &file); + private: lua_State *mState; diff --git a/src/scripting/script.hpp b/src/scripting/script.hpp index 2c8481dd..96df0859 100644 --- a/src/scripting/script.hpp +++ b/src/scripting/script.hpp @@ -132,13 +132,14 @@ class Script virtual void processRemoveEvent(Thing* thing) = 0; /** - * Runs a function in the global event script file + * Runs a function from the global event script file */ static bool execute_global_event_function(const std::string &function, Being *obj); - static Script* global_event_script; // the global event script + protected: + static Script* global_event_script; // the global event script std::string mScriptFile; private: |