diff --git a/src/engine/server.h b/src/engine/server.h index 31134ca9d..f3c9ca7c9 100644 --- a/src/engine/server.h +++ b/src/engine/server.h @@ -25,6 +25,7 @@ public: int Tick() const { return m_CurrentGameTick; } int TickSpeed() const { return m_TickSpeed; } + virtual int MaxClients() const = 0; virtual const char *ClientName(int ClientID) = 0; virtual const char *ClientClan(int ClientID) = 0; virtual int ClientCountry(int ClientID) = 0; diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index d253d3fce..a904f4665 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -390,6 +390,11 @@ bool CServer::ClientIngame(int ClientID) return ClientID >= 0 && ClientID < MAX_CLIENTS && m_aClients[ClientID].m_State == CServer::CClient::STATE_INGAME; } +int CServer::MaxClients() const +{ + return m_NetServer.MaxClients(); +} + int CServer::SendMsg(CMsgPacker *pMsg, int Flags, int ClientID) { return SendMsgEx(pMsg, Flags, ClientID, false); diff --git a/src/engine/server/server.h b/src/engine/server/server.h index 916eb37de..4c450a48b 100644 --- a/src/engine/server/server.h +++ b/src/engine/server/server.h @@ -163,6 +163,7 @@ public: const char *ClientClan(int ClientID); int ClientCountry(int ClientID); bool ClientIngame(int ClientID); + int MaxClients() const; virtual int SendMsg(CMsgPacker *pMsg, int Flags, int ClientID); int SendMsgEx(CMsgPacker *pMsg, int Flags, int ClientID, bool System); diff --git a/src/engine/shared/network.h b/src/engine/shared/network.h index a9ace4e37..ca460d675 100644 --- a/src/engine/shared/network.h +++ b/src/engine/shared/network.h @@ -317,7 +317,7 @@ public: // status requests NETADDR ClientAddr(int ClientID) const { return m_aSlots[ClientID].m_Connection.PeerAddress(); } NETSOCKET Socket() const { return m_Socket; } - int NetType() { return m_Socket.type; } + int NetType() const { return m_Socket.type; } int MaxClients() const { return m_MaxClients; } // diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index b59a7244c..dc993bfd7 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -802,7 +802,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) else { char aBuf[128]; - str_format(aBuf, sizeof(aBuf), "Only %d active players are allowed", g_Config.m_SvMaxClients-g_Config.m_SvSpectatorSlots); + str_format(aBuf, sizeof(aBuf), "Only %d active players are allowed", Server()->MaxClients()-g_Config.m_SvSpectatorSlots); SendBroadcast(aBuf, ClientID); } } diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index f8d418c31..3d5829914 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -595,7 +595,7 @@ bool IGameController::CanJoinTeam(int Team, int NotThisID) } } - return (aNumplayers[0] + aNumplayers[1]) < g_Config.m_SvMaxClients-g_Config.m_SvSpectatorSlots; + return (aNumplayers[0] + aNumplayers[1]) < Server()->MaxClients()-g_Config.m_SvSpectatorSlots; } bool IGameController::CheckTeamBalance()