Revert " refactor: ServerEvent - OnStartup, OnBeforeConfigLoad, OnConfigLoad" (#317)

This commit is contained in:
iThorgrim
2025-09-17 16:43:35 +02:00
committed by GitHub
parent b559d02658
commit 058bc63ea4
5 changed files with 13 additions and 33 deletions

View File

@@ -1123,17 +1123,14 @@ public:
///- Initialize Lua Engine ///- Initialize Lua Engine
LOG_INFO("eluna", "Initialize Eluna Lua Engine..."); LOG_INFO("eluna", "Initialize Eluna Lua Engine...");
Eluna::Initialize(); Eluna::Initialize();
if(sEluna->IsInitialized())
sEluna->RunScripts();
} }
sEluna->OnBeforeConfigLoad(reload); sEluna->OnConfigLoad(reload, true);
} }
void OnAfterConfigLoad(bool reload) override void OnAfterConfigLoad(bool reload) override
{ {
sEluna->OnAfterConfigLoad(reload); sEluna->OnConfigLoad(reload, false);
} }
void OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask) override void OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask) override
@@ -1168,7 +1165,10 @@ public:
void OnBeforeWorldInitialized() override void OnBeforeWorldInitialized() override
{ {
sEluna->OnBeforeWorldInitialized(); ///- Run eluna scripts.
// in multithread foreach: run scripts
sEluna->RunScripts();
sEluna->OnConfigLoad(false, false); // Must be done after Eluna is initialized and scripts have run.
} }
}; };

View File

@@ -114,7 +114,7 @@ namespace Hooks
// World // World
WORLD_EVENT_ON_OPEN_STATE_CHANGE = 8, // (event, open) - Needs core support on Mangos WORLD_EVENT_ON_OPEN_STATE_CHANGE = 8, // (event, open) - Needs core support on Mangos
WORLD_EVENT_ON_AFTER_CONFIG_LOAD = 9, // (event, reload) WORLD_EVENT_ON_CONFIG_LOAD = 9, // (event, reload)
// UNUSED = 10, // UNUSED = 10,
WORLD_EVENT_ON_SHUTDOWN_INIT = 11, // (event, code, mask) WORLD_EVENT_ON_SHUTDOWN_INIT = 11, // (event, code, mask)
WORLD_EVENT_ON_SHUTDOWN_CANCEL = 12, // (event) WORLD_EVENT_ON_SHUTDOWN_CANCEL = 12, // (event)
@@ -158,9 +158,6 @@ namespace Hooks
GAME_EVENT_START = 34, // (event, gameeventid) GAME_EVENT_START = 34, // (event, gameeventid)
GAME_EVENT_STOP = 35, // (event, gameeventid) GAME_EVENT_STOP = 35, // (event, gameeventid)
WORLD_EVENT_ON_BEFORE_WORLD_INITIALIZED = 36, // (event)
WORLD_EVENT_ON_BEFORE_CONFIG_LOAD = 37, // (event, reload)
SERVER_EVENT_COUNT SERVER_EVENT_COUNT
}; };

View File

@@ -565,15 +565,13 @@ public:
/* World */ /* World */
void OnOpenStateChange(bool open); void OnOpenStateChange(bool open);
void OnAfterConfigLoad(bool reload); void OnConfigLoad(bool reload, bool isBefore);
void OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask); void OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask);
void OnShutdownCancel(); void OnShutdownCancel();
void OnStartup(); void OnStartup();
void OnShutdown(); void OnShutdown();
void OnGameEventStart(uint32 eventid); void OnGameEventStart(uint32 eventid);
void OnGameEventStop(uint32 eventid); void OnGameEventStop(uint32 eventid);
void OnBeforeWorldInitialized();
void OnBeforeConfigLoad(bool reload);
/* Battle Ground */ /* Battle Ground */
void OnBGStart(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId); void OnBGStart(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId);
@@ -586,7 +584,7 @@ public:
void OnTicketClose(GmTicket* ticket); void OnTicketClose(GmTicket* ticket);
void OnTicketUpdateLastChange(GmTicket* ticket); void OnTicketUpdateLastChange(GmTicket* ticket);
void OnTicketResolve(GmTicket* ticket); void OnTicketResolve(GmTicket* ticket);
/* Spell */ /* Spell */
void OnSpellPrepare(Unit* caster, Spell* spell, SpellInfo const* spellInfo); void OnSpellPrepare(Unit* caster, Spell* spell, SpellInfo const* spellInfo);
void OnSpellCast(Unit* caster, Spell* spell, SpellInfo const* spellInfo, bool skipCheck); void OnSpellCast(Unit* caster, Spell* spell, SpellInfo const* spellInfo, bool skipCheck);

View File

@@ -227,10 +227,11 @@ void Eluna::OnOpenStateChange(bool open)
CallAllFunctions(ServerEventBindings, key); CallAllFunctions(ServerEventBindings, key);
} }
void Eluna::OnAfterConfigLoad(bool reload) void Eluna::OnConfigLoad(bool reload, bool isBefore)
{ {
START_HOOK(WORLD_EVENT_ON_AFTER_CONFIG_LOAD); START_HOOK(WORLD_EVENT_ON_CONFIG_LOAD);
Push(reload); Push(reload);
Push(isBefore);
CallAllFunctions(ServerEventBindings, key); CallAllFunctions(ServerEventBindings, key);
} }
@@ -277,19 +278,6 @@ void Eluna::OnShutdown()
CallAllFunctions(ServerEventBindings, key); CallAllFunctions(ServerEventBindings, key);
} }
void Eluna::OnBeforeWorldInitialized()
{
START_HOOK(WORLD_EVENT_ON_BEFORE_WORLD_INITIALIZED);
CallAllFunctions(ServerEventBindings, key);
}
void Eluna::OnBeforeConfigLoad(bool reload)
{
START_HOOK(WORLD_EVENT_ON_BEFORE_CONFIG_LOAD);
Push(reload);
CallAllFunctions(ServerEventBindings, key);
}
/* Map */ /* Map */
void Eluna::OnCreate(Map* map) void Eluna::OnCreate(Map* map)
{ {

View File

@@ -654,7 +654,7 @@ namespace LuaGlobalFunctions
* *
* // World * // World
* WORLD_EVENT_ON_OPEN_STATE_CHANGE = 8, // (event, open) - Needs core support on Mangos * WORLD_EVENT_ON_OPEN_STATE_CHANGE = 8, // (event, open) - Needs core support on Mangos
* WORLD_EVENT_ON_AFTER_CONFIG_LOAD = 9, // (event, reload) * WORLD_EVENT_ON_CONFIG_LOAD = 9, // (event, reload)
* // UNUSED = 10, * // UNUSED = 10,
* WORLD_EVENT_ON_SHUTDOWN_INIT = 11, // (event, code, mask) * WORLD_EVENT_ON_SHUTDOWN_INIT = 11, // (event, code, mask)
* WORLD_EVENT_ON_SHUTDOWN_CANCEL = 12, // (event) * WORLD_EVENT_ON_SHUTDOWN_CANCEL = 12, // (event)
@@ -697,9 +697,6 @@ namespace LuaGlobalFunctions
* *
* GAME_EVENT_START = 34, // (event, gameeventid) * GAME_EVENT_START = 34, // (event, gameeventid)
* GAME_EVENT_STOP = 35, // (event, gameeventid) * GAME_EVENT_STOP = 35, // (event, gameeventid)
*
* WORLD_EVENT_ON_BEFORE_WORLD_INITIALIZED = 36, // (event)
* WORLD_EVENT_ON_BEFORE_CONFIG_LOAD = 37, // (event, reload)
* }; * };
* *
* @proto cancel = (event, function) * @proto cancel = (event, function)