From 967a13e6926728f97c7bc43d4b7a0705ff077fe9 Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Wed, 25 Jun 2025 15:47:37 -0400 Subject: [PATCH] [Code] WorldEventScheduler and ZoneEventScheduler Global to Singleton Cleanup (#4932) --- world/main.cpp | 3 +-- world/world_boot.cpp | 4 +--- world/world_event_scheduler.h | 6 ++++++ zone/main.cpp | 8 +++----- zone/zone_event_scheduler.h | 6 ++++++ 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/world/main.cpp b/world/main.cpp index e3824bb28..95cd2fa1d 100644 --- a/world/main.cpp +++ b/world/main.cpp @@ -95,7 +95,6 @@ ClientList client_list; GroupLFPList LFPGroupList; ZSList zoneserver_list; LauncherList launcher_list; -WorldEventScheduler event_scheduler; volatile bool RunLoops = true; uint32 numclients = 0; uint32 numzones = 0; @@ -418,7 +417,7 @@ int main(int argc, char **argv) } } - event_scheduler.Process(&zoneserver_list); + WorldEventScheduler::Instance()->Process(&zoneserver_list); client_list.Process(); guild_mgr.Process(); diff --git a/world/world_boot.cpp b/world/world_boot.cpp index 025ae4314..8a01c1dc9 100644 --- a/world/world_boot.cpp +++ b/world/world_boot.cpp @@ -224,8 +224,6 @@ void WorldBoot::RegisterLoginservers() } } -extern WorldEventScheduler event_scheduler; - bool WorldBoot::DatabaseLoadRoutines(int argc, char **argv) { // logging system init @@ -389,7 +387,7 @@ bool WorldBoot::DatabaseLoadRoutines(int argc, char **argv) content_db.LoadCharacterCreateCombos(); LogInfo("Initializing [EventScheduler]"); - event_scheduler.SetDatabase(&database)->LoadScheduledEvents(); + WorldEventScheduler::Instance()->SetDatabase(&database)->LoadScheduledEvents(); LogInfo("Initializing [WorldContentService]"); content_service.SetDatabase(&database) diff --git a/world/world_event_scheduler.h b/world/world_event_scheduler.h index b2a6725df..4819b1400 100644 --- a/world/world_event_scheduler.h +++ b/world/world_event_scheduler.h @@ -7,6 +7,12 @@ class WorldEventScheduler : public ServerEventScheduler { public: void Process(ZSList *zs_list); + + static WorldEventScheduler* Instance() + { + static WorldEventScheduler instance; + return &instance; + } }; #endif //EQEMU_EVENT_SCHEDULER_H diff --git a/zone/main.cpp b/zone/main.cpp index 77787da1a..24f4b6fcd 100644 --- a/zone/main.cpp +++ b/zone/main.cpp @@ -88,7 +88,6 @@ extern volatile bool is_zone_loaded; #include "../common/path_manager.h" #include "../common/database/database_update.h" #include "../common/skill_caps.h" -#include "zone_event_scheduler.h" #include "zone_cli.h" EntityList entity_list; @@ -102,7 +101,6 @@ TitleManager title_manager; QueryServ *QServ = 0; NpcScaleManager *npc_scale_manager; QuestParserCollection *parse = 0; -ZoneEventScheduler event_scheduler; WorldContentService content_service; PlayerEventLogs player_event_logs; @@ -416,7 +414,7 @@ int main(int argc, char **argv) ->SetExpansionContext() ->ReloadContentFlags(); - event_scheduler.SetDatabase(&database)->LoadScheduledEvents(); + ZoneEventScheduler::Instance()->SetDatabase(&database)->LoadScheduledEvents(); EQ::SayLinkEngine::LoadCachedSaylinks(); @@ -482,7 +480,7 @@ int main(int argc, char **argv) QServ->CheckForConnectState(); worldserver.Connect(); - worldserver.SetScheduler(&event_scheduler); + worldserver.SetScheduler(ZoneEventScheduler::Instance()); // sidecar command handler if (ZoneCLI::RanConsoleCommand(argc, argv) @@ -626,7 +624,7 @@ int main(int argc, char **argv) entity_list.MobProcess(); entity_list.BeaconProcess(); entity_list.EncounterProcess(); - event_scheduler.Process(zone, &content_service); + ZoneEventScheduler::Instance()->Process(zone, &content_service); if (zone) { if (!zone->Process()) { diff --git a/zone/zone_event_scheduler.h b/zone/zone_event_scheduler.h index a2e6c67ad..f92442402 100644 --- a/zone/zone_event_scheduler.h +++ b/zone/zone_event_scheduler.h @@ -9,6 +9,12 @@ class ZoneEventScheduler : public ServerEventScheduler { public: void Process(Zone *zone, WorldContentService *content_service); void SyncEventDataWithActiveEvents(); + + static ZoneEventScheduler* Instance() + { + static ZoneEventScheduler instance; + return &instance; + } }; #endif //EQEMU_ZONE_EVENT_SCHEDULER_H