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)