From 61e1a73f67e6ec767eeaf4b02e8795d3c92bbfad Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sat, 11 Apr 2020 18:35:49 +0200 Subject: [PATCH] try to fix an issue that people do not see their server on the same PC anymore --- src/serverlist.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/serverlist.cpp b/src/serverlist.cpp index 5dba5d74..cf0c7315 100755 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -431,9 +431,22 @@ void CServerListManager::CentralServerQueryServerList ( const CHostAddress& Inet // otherwise, use the supplied details if ( iIdx > iNumPredefinedServers ) { - vecServerInfo[iIdx].HostAddr.InetAddr = - ServerList[iIdx].LHostAddr.InetAddr; + // check for server running on the same PC + if ( vecServerInfo[iIdx].HostAddr.iPort == InetAddr.iPort ) + { + vecServerInfo[iIdx].HostAddr.InetAddr = + QHostAddress ( QHostAddress::LocalHost ); + } + else + { + // we are not on the same PC but in the same local network + vecServerInfo[iIdx].HostAddr.InetAddr = + ServerList[iIdx].LHostAddr.InetAddr; + } + // take the local port number instead of the received port + // number since some NAT (network address translation) might + // have changed the port vecServerInfo[iIdx].HostAddr.iPort = ServerList[iIdx].iLocalPortNumber; }