From c99bda3f472ebbed365dd6bd10e1f9a8b7e032f5 Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Wed, 25 Jun 2025 15:49:32 -0400 Subject: [PATCH] [Code] WebInterfaceList Global to Singleton Cleanup (#4935) --- world/clientlist.cpp | 4 +--- world/main.cpp | 5 ++--- world/web_interface.h | 5 +++++ world/zonelist.cpp | 3 +-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/world/clientlist.cpp b/world/clientlist.cpp index afa365aef..f038a5a68 100644 --- a/world/clientlist.cpp +++ b/world/clientlist.cpp @@ -36,8 +36,6 @@ #include "../common/zone_store.h" #include -extern WebInterfaceList web_interface; - extern ZSList zoneserver_list; uint32 numplayers = 0; //this really wants to be a member variable of ClientList... @@ -1613,7 +1611,7 @@ void ClientList::OnTick(EQ::Timer *t) Iterator.Advance(); } - web_interface.SendEvent(out); + WebInterfaceList::Instance()->SendEvent(out); } /** diff --git a/world/main.cpp b/world/main.cpp index 95cd2fa1d..eb4139802 100644 --- a/world/main.cpp +++ b/world/main.cpp @@ -100,7 +100,6 @@ uint32 numclients = 0; uint32 numzones = 0; const WorldConfig *Config; WorldContentService content_service; -WebInterfaceList web_interface; PlayerEventLogs player_event_logs; void CatchSignal(int sig_num); @@ -320,7 +319,7 @@ int main(int argc, char **argv) connection->GetUUID() ); - web_interface.AddConnection(connection); + WebInterfaceList::Instance()->AddConnection(connection); } ); @@ -331,7 +330,7 @@ int main(int argc, char **argv) connection->GetUUID() ); - web_interface.RemoveConnection(connection); + WebInterfaceList::Instance()->RemoveConnection(connection); } ); diff --git a/world/web_interface.h b/world/web_interface.h index fc90265d9..0725c190a 100644 --- a/world/web_interface.h +++ b/world/web_interface.h @@ -42,6 +42,11 @@ public: void SendError(const std::string &uuid, const std::string &message); void SendError(const std::string &uuid, const std::string &message, const std::string &id); + static WebInterfaceList* Instance() + { + static WebInterfaceList instance; + return &instance; + } private: std::map> m_interfaces; }; diff --git a/world/zonelist.cpp b/world/zonelist.cpp index e1e0b16ea..39ada64fd 100644 --- a/world/zonelist.cpp +++ b/world/zonelist.cpp @@ -42,7 +42,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "../common/repositories/buyer_repository.h" extern uint32 numzones; -extern WebInterfaceList web_interface; extern ClientList client_list; volatile bool UCSServerAvailable_ = false; void CatchSignal(int sig_num); @@ -889,7 +888,7 @@ void ZSList::OnTick(EQ::Timer *t) out["data"].append(outzone); } - web_interface.SendEvent(out); + WebInterfaceList::Instance()->SendEvent(out); } const std::list> &ZSList::getZoneServerList() const