diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index bc745f430..2b25f93b1 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -3271,6 +3271,10 @@ void CClient::Run() GameClient()->OnShutdown(); Disconnect(); + // close socket + for(unsigned int i = 0; i < std::size(m_NetClient); i++) + m_NetClient[i].Close(); + delete m_pEditor; m_pGraphics->Shutdown(); diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 2a441490e..4304961d2 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -2246,14 +2246,17 @@ int CGraphics_Threaded::IssueInit() int r = m_pBackend->Init("DDNet Client", &g_Config.m_GfxScreen, &g_Config.m_GfxScreenWidth, &g_Config.m_GfxScreenHeight, &g_Config.m_GfxScreenRefreshRate, g_Config.m_GfxFsaaSamples, Flags, &g_Config.m_GfxDesktopWidth, &g_Config.m_GfxDesktopHeight, &m_ScreenWidth, &m_ScreenHeight, m_pStorage); AddBackEndWarningIfExists(); - m_GLUseTrianglesAsQuad = m_pBackend->UseTrianglesAsQuad(); - m_GLTileBufferingEnabled = m_pBackend->HasTileBuffering(); - m_GLQuadBufferingEnabled = m_pBackend->HasQuadBuffering(); - m_GLQuadContainerBufferingEnabled = m_pBackend->HasQuadContainerBuffering(); - m_GLTextBufferingEnabled = (m_GLQuadContainerBufferingEnabled && m_pBackend->HasTextBuffering()); - m_GLHasTextureArrays = m_pBackend->Has2DTextureArrays(); - m_ScreenHiDPIScale = m_ScreenWidth / (float)g_Config.m_GfxScreenWidth; - m_ScreenRefreshRate = g_Config.m_GfxScreenRefreshRate; + if(r == 0) + { + m_GLUseTrianglesAsQuad = m_pBackend->UseTrianglesAsQuad(); + m_GLTileBufferingEnabled = m_pBackend->HasTileBuffering(); + m_GLQuadBufferingEnabled = m_pBackend->HasQuadBuffering(); + m_GLQuadContainerBufferingEnabled = m_pBackend->HasQuadContainerBuffering(); + m_GLTextBufferingEnabled = (m_GLQuadContainerBufferingEnabled && m_pBackend->HasTextBuffering()); + m_GLHasTextureArrays = m_pBackend->Has2DTextureArrays(); + m_ScreenHiDPIScale = m_ScreenWidth / (float)g_Config.m_GfxScreenWidth; + m_ScreenRefreshRate = g_Config.m_GfxScreenRefreshRate; + } return r; } diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index f0cf11e38..9203229c8 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -2747,6 +2747,8 @@ int CServer::Run() free(Client.m_pPersistentData); } + m_NetServer.Close(); + return ErrorShutdown(); } diff --git a/src/engine/shared/network_client.cpp b/src/engine/shared/network_client.cpp index 08f624c4d..b338a5db6 100644 --- a/src/engine/shared/network_client.cpp +++ b/src/engine/shared/network_client.cpp @@ -23,8 +23,9 @@ bool CNetClient::Open(NETADDR BindAddr) int CNetClient::Close() { - // TODO: implement me - return 0; + if(!m_Socket) + return 0; + return net_udp_close(m_Socket); } int CNetClient::Disconnect(const char *pReason) diff --git a/src/engine/shared/network_server.cpp b/src/engine/shared/network_server.cpp index 50def8e81..349f3b458 100644 --- a/src/engine/shared/network_server.cpp +++ b/src/engine/shared/network_server.cpp @@ -96,8 +96,9 @@ int CNetServer::SetCallbacks(NETFUNC_NEWCLIENT pfnNewClient, NETFUNC_NEWCLIENT_N int CNetServer::Close() { - // TODO: implement me - return 0; + if(!m_Socket) + return 0; + return net_udp_close(m_Socket); } int CNetServer::Drop(int ClientID, const char *pReason) diff --git a/src/game/client/components/controls.cpp b/src/game/client/components/controls.cpp index 916d39587..d0fd13047 100644 --- a/src/game/client/components/controls.cpp +++ b/src/game/client/components/controls.cpp @@ -561,8 +561,8 @@ void CControls::ClampMousePos() { if(m_pClient->m_Snap.m_SpecInfo.m_Active && m_pClient->m_Snap.m_SpecInfo.m_SpectatorID < 0) { - m_MousePos[g_Config.m_ClDummy].x = clamp(m_MousePos[g_Config.m_ClDummy].x, 200.0f, Collision()->GetWidth() * 32 - 200.0f); - m_MousePos[g_Config.m_ClDummy].y = clamp(m_MousePos[g_Config.m_ClDummy].y, 200.0f, Collision()->GetHeight() * 32 - 200.0f); + m_MousePos[g_Config.m_ClDummy].x = clamp(m_MousePos[g_Config.m_ClDummy].x, 0.0f, Collision()->GetWidth() * 32.0f); + m_MousePos[g_Config.m_ClDummy].y = clamp(m_MousePos[g_Config.m_ClDummy].y, 0.0f, Collision()->GetHeight() * 32.0f); } else {