From 7e99514fed578576009747b27befe3fa8694da90 Mon Sep 17 00:00:00 2001 From: Rochet2 Date: Tue, 16 Sep 2014 19:51:34 +0300 Subject: [PATCH] Eluna: Separate eluna init and running scripts for startup load orders --- HookMgr.h | 4 ++-- LuaEngine.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/HookMgr.h b/HookMgr.h index 3117157..7986bdc 100644 --- a/HookMgr.h +++ b/HookMgr.h @@ -61,8 +61,8 @@ namespace HookMgr WORLD_EVENT_ON_SHUTDOWN = 15, // (event) // Eluna - ELUNA_EVENT_ON_LUA_STATE_CLOSE = 16, // (event) - ELUNA_EVENT_ON_LUA_STATE_OPEN = 33, // (event) - Possibly change hook ID for increments? Not implemented on TC/Cmangos + ELUNA_EVENT_ON_LUA_STATE_CLOSE = 16, // (event) - triggers just before shutting down eluna (on shutdown and restart) + ELUNA_EVENT_ON_LUA_STATE_OPEN = 33, // (event) - triggers after all scripts are loaded // Map MAP_EVENT_ON_CREATE = 17, // (event, map) diff --git a/LuaEngine.cpp b/LuaEngine.cpp index d3a5e27..e238a55 100644 --- a/LuaEngine.cpp +++ b/LuaEngine.cpp @@ -71,6 +71,9 @@ void Eluna::ReloadEluna() Uninitialize(); Initialize(); + // in multithread foreach: run scripts + sEluna->RunScripts(); + #ifdef TRINITY // Re initialize creature AI restoring C++ AI or applying lua AI { @@ -124,11 +127,6 @@ playerGossipBindings(new EntryBind("GossipEvents (player) // Set event manager. Must be after setting sEluna eventMgr = new EventMgr(); eventMgr->globalProcessor = new ElunaEventProcessor(NULL); - - // run scripts - RunScripts(); - - OnLuaStateOpen(); } Eluna::~Eluna() @@ -304,6 +302,8 @@ void Eluna::RunScripts() lua_pop(L, 2); ELUNA_LOG_INFO("[Eluna]: Executed %u Lua scripts in %u ms", count, ElunaUtil::GetTimeDiff(oldMSTime)); + + OnLuaStateOpen(); } void Eluna::RemoveRef(const void* obj)