From 31cfa9250d9a6ee5bfb6ba817964e981c4fc91a6 Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Sat, 29 Aug 2020 14:14:37 +0200 Subject: [PATCH] Fix server port in teehistorian Official servers weren't affected because they didn't use the default of `sv_port 0`. --- src/engine/server.h | 1 + src/engine/server/server.cpp | 5 +++++ src/engine/server/server.h | 1 + src/game/server/gamecontext.cpp | 2 +- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/engine/server.h b/src/engine/server.h index 3e3e35b1f..98253169a 100644 --- a/src/engine/server.h +++ b/src/engine/server.h @@ -41,6 +41,7 @@ public: int Tick() const { return m_CurrentGameTick; } int TickSpeed() const { return m_TickSpeed; } + virtual int Port() const = 0; virtual int MaxClients() const = 0; virtual int ClientCount() = 0; virtual int DistinctClientCount() = 0; diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index ec0a9451b..f73902cc7 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -618,6 +618,11 @@ bool CServer::ClientAuthed(int ClientID) return ClientID >= 0 && ClientID < MAX_CLIENTS && m_aClients[ClientID].m_Authed; } +int CServer::Port() const +{ + return m_NetServer.Address().port; +} + int CServer::MaxClients() const { return m_NetServer.MaxClients(); diff --git a/src/engine/server/server.h b/src/engine/server/server.h index 6b29dc747..af092cca7 100644 --- a/src/engine/server/server.h +++ b/src/engine/server/server.h @@ -293,6 +293,7 @@ public: int ClientCountry(int ClientID); bool ClientIngame(int ClientID); bool ClientAuthed(int ClientID); + int Port() const; int MaxClients() const; int ClientCount(); int DistinctClientCount(); diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index bb364e4f2..ca47f50cf 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -3096,7 +3096,7 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/) GameInfo.m_pPrngDescription = m_Prng.Description(); GameInfo.m_pServerName = g_Config.m_SvName; - GameInfo.m_ServerPort = g_Config.m_SvPort; + GameInfo.m_ServerPort = Server()->Port(); GameInfo.m_pGameType = m_pController->m_pGameType; GameInfo.m_pConfig = &g_Config;