From c2bcd3bd4d80ba38a309bb57981f2888df5372a3 Mon Sep 17 00:00:00 2001 From: Learath2 Date: Mon, 4 Nov 2019 01:06:09 +0100 Subject: [PATCH] Fix bug --- src/engine/server/server.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index e208f9518..d7de09067 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -1505,6 +1505,16 @@ void CServer::SendServerInfoConnless(const NETADDR *pAddr, int Token, int Type) SendServerInfo(pAddr, Token, Type, SendClients); } +static inline int GetCacheIndex(int Type, bool SendClient) +{ + if(Type == SERVERINFO_INGAME) + Type = SERVERINFO_VANILLA; + else if(Type == SERVERINFO_EXTENDED_MORE) + Type = SERVERINFO_EXTENDED; + + return Type * 2 + SendClient; +} + CServer::CCache::CCache() { m_lCache.clear(); @@ -1726,7 +1736,7 @@ void CServer::SendServerInfo(const NETADDR *pAddr, int Token, int Type, bool Sen char aBuf[128]; p.Reset(); - CCache *pCache = &m_ServerInfoCache[Type * 2 + SendClients]; + CCache *pCache = &m_ServerInfoCache[GetCacheIndex(Type, SendClients)]; CCache::CCacheChunk &FirstChunk = pCache->m_lCache.front(); #define ADD_RAW(p, x) (p).AddRaw(x, sizeof(x))