summaryrefslogtreecommitdiff
path: root/src/game-server/main-game.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-02-26 22:06:10 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-03-02 18:12:07 +0100
commit34ac0d64e23f2b2d3981dbb0ea72157f334805dd (patch)
tree114b1f7a65956c097f7a59078292c9fa29c6451f /src/game-server/main-game.cpp
parente896d0b0125b48e12d43d99ace4498e56d968d50 (diff)
downloadmanaserv-34ac0d64e23f2b2d3981dbb0ea72157f334805dd.tar.gz
manaserv-34ac0d64e23f2b2d3981dbb0ea72157f334805dd.tar.bz2
manaserv-34ac0d64e23f2b2d3981dbb0ea72157f334805dd.tar.xz
manaserv-34ac0d64e23f2b2d3981dbb0ea72157f334805dd.zip
Merged all the different Lua states into one
No more Lua state for each status effect, monster, item effect or map. All scripts are loaded into the same state. This should be more efficient overall and make it easier to implement dynamic reloading of the scripts in the future. Now, this introduces the problem of name collisions between different Lua scripts. For now this is solved by using more specific function names, like 'tick_plague' and 'tick_jump' rather than just 'tick'. The plan is however to get rid of these globals, and register these callbacks from the script, so that they can be local functions without the danger of colliding with other scripts. Reviewed-by: Erik Schilling Reviewed-by: Yohann Ferreira
Diffstat (limited to 'src/game-server/main-game.cpp')
-rw-r--r--src/game-server/main-game.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/game-server/main-game.cpp b/src/game-server/main-game.cpp
index daf15611..c3b3c36a 100644
--- a/src/game-server/main-game.cpp
+++ b/src/game-server/main-game.cpp
@@ -52,7 +52,7 @@
#include "net/bandwidth.h"
#include "net/connectionhandler.h"
#include "net/messageout.h"
-#include "scripting/luascript.h"
+#include "scripting/scriptmanager.h"
#include "utils/logger.h"
#include "utils/processorutils.h"
#include "utils/stringfilter.h"
@@ -71,7 +71,7 @@ using utils::Logger;
#define DEFAULT_MONSTERSDB_FILE "monsters.xml"
#define DEFAULT_STATUSDB_FILE "status-effects.xml"
#define DEFAULT_PERMISSION_FILE "permissions.xml"
-#define DEFAULT_GLOBAL_EVENT_SCRIPT_FILE "scripts/main.lua"
+#define DEFAULT_MAIN_SCRIPT_FILE "scripts/main.lua"
static int const WORLD_TICK_SKIP = 2; /** tolerance for lagging behind in world calculation) **/
@@ -127,6 +127,7 @@ static void initializeServer()
stringFilter = new utils::StringFilter;
ResourceManager::initialize();
+ ScriptManager::initialize(); // Depends on ResourceManager
if (MapManager::initialize(DEFAULT_MAPSDB_FILE) < 1)
{
LOG_FATAL("The Game Server can't find any valid/available maps.");
@@ -139,10 +140,9 @@ static void initializeServer()
StatusManager::initialize(DEFAULT_STATUSDB_FILE);
PermissionManager::initialize(DEFAULT_PERMISSION_FILE);
- const std::string mainScriptFile =
- Configuration::getValue("script_mainFile",
- DEFAULT_GLOBAL_EVENT_SCRIPT_FILE);
- Script::loadGlobalEventScript(mainScriptFile);
+ std::string mainScript = Configuration::getValue("script_mainFile",
+ DEFAULT_MAIN_SCRIPT_FILE);
+ ScriptManager::loadMainScript(mainScript);
// --- Initialize the global handlers
// FIXME: Make the global handlers global vars or part of a bigger
@@ -194,6 +194,7 @@ static void deinitializeServer()
delete itemManager; itemManager = 0;
MapManager::deinitialize();
StatusManager::deinitialize();
+ ScriptManager::deinitialize();
PHYSFS_deinit();
}