summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhilipp Sehmisch <mana@crushnet.org>2010-03-24 21:37:59 +0100
committerPhilipp Sehmisch <mana@crushnet.org>2010-04-11 18:27:21 +0200
commit4d1cfb2379f6222b3cdceba90480121d39536081 (patch)
treeab4c73c7d6ef18aaeeba2b094ded04782df85620 /src
parent88f8e20871fadc58bc69c5b1fca4b7c4d850fdb2 (diff)
downloadmanaserv-4d1cfb2379f6222b3cdceba90480121d39536081.tar.gz
manaserv-4d1cfb2379f6222b3cdceba90480121d39536081.tar.xz
manaserv-4d1cfb2379f6222b3cdceba90480121d39536081.zip
Implemented handler for on_chr_death and put the loading of the global script into a method of class LuaScript
Reviewed-by: Jared Adams <Jaxad0127@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/game-server/main-game.cpp23
-rw-r--r--src/scripting/luascript.cpp11
-rw-r--r--src/scripting/luascript.hpp5
-rw-r--r--src/scripting/script.hpp5
4 files changed, 29 insertions, 15 deletions
diff --git a/src/game-server/main-game.cpp b/src/game-server/main-game.cpp
index 3ad265f..36da4c3 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 cb6ba3a..b48ec51 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 25fc997..315c759 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 2c8481d..96df085 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: