diff --git a/source/network/NetHost.cpp b/source/network/NetHost.cpp index 7de5997c1a..e5875f6f6e 100644 --- a/source/network/NetHost.cpp +++ b/source/network/NetHost.cpp @@ -67,3 +67,14 @@ ENetPacket* CNetHost::CreatePacket(const CNetMessage* message) return packet; } + +void CNetHost::Initialize() +{ + int ret = enet_initialize(); + debug_assert(ret == 0); +} + +void CNetHost::Deinitialize() +{ + enet_deinitialize(); +} \ No newline at end of file diff --git a/source/network/NetHost.h b/source/network/NetHost.h index 5f64d20db1..41a0e0c52a 100644 --- a/source/network/NetHost.h +++ b/source/network/NetHost.h @@ -57,6 +57,17 @@ public: * @return NULL on failure */ static ENetPacket* CreatePacket(const CNetMessage* message); + + /** + * Initialize ENet. + * This must be called before any other networking code. + */ + static void Initialize(); + + /** + * Deinitialize ENet. + */ + static void Deinitialize(); }; #endif // NETHOST_H diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index c4b97378e3..1b082a0e7f 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -618,6 +618,8 @@ void Shutdown(int UNUSED(flags)) TIMER_BEGIN(L"shutdown misc"); timer_DisplayClientTotals(); + CNetHost::Deinitialize(); + // should be last, since the above use them SAFE_DELETE(g_Logger); delete &g_Profiler; @@ -700,6 +702,8 @@ void Init(const CmdLineArgs& args, int flags) // and fonts are set later in InitPs()) g_Console = new CConsole(); + CNetHost::Initialize(); + if(setup_vmode) InitSDL();