Permalink
Browse files

Avoid inconsistencies between loopback and localhost

  • Loading branch information...
mbasaglia committed Feb 20, 2016
1 parent 0b934df commit 82648841c48f19eefd3faf24a604be3f3b7322bd
@@ -934,7 +934,7 @@ void CL_SetCGameTime()
if ( cl.snap.serverTime < cl.oldFrameServerTime )
{
// Ridah, if this is a localhost, then we are probably loading a savegame
if ( !Q_stricmp( cls.servername, "localhost" ) )
if ( !Q_stricmp( cls.servername, "loopback" ) )
{
// do nothing?
CL_FirstSnapshot();
@@ -986,7 +986,7 @@ void CL_MapLoading()
cls.keyCatchers = 0;
// if we are already connected to the local host, stay connected
if ( cls.state >= connstate_t::CA_CONNECTED && !Q_stricmp( cls.servername, "localhost" ) )
if ( cls.state >= connstate_t::CA_CONNECTED && !Q_stricmp( cls.servername, "loopback" ) )
{
cls.state = connstate_t::CA_CONNECTED; // so the connect screen is drawn
memset( cls.updateInfoString, 0, sizeof( cls.updateInfoString ) );
@@ -1000,7 +1000,7 @@ void CL_MapLoading()
// clear nextmap so the cinematic shutdown doesn't execute it
Cvar_Set( "sv_nextmap", "" );
CL_Disconnect( false );
Q_strncpyz( cls.servername, "localhost", sizeof( cls.servername ) );
Q_strncpyz( cls.servername, "loopback", sizeof( cls.servername ) );
*cls.reconnectCmd = 0; // can't reconnect to this!
cls.state = connstate_t::CA_CHALLENGING; // so the connect screen is drawn
cls.keyCatchers = 0;
@@ -1373,7 +1373,7 @@ void CL_Connect_f()
// clear any previous "server full" type messages
clc.serverMessage[ 0 ] = 0;
if ( com_sv_running->integer && !strcmp( server, "localhost" ) )
if ( com_sv_running->integer && !strcmp( server, "loopback" ) )
{
// if running a local server, kill it
SV_Shutdown( "Server quit\n" );
@@ -610,7 +610,7 @@ void NET_SendPacket( netsrc_t sock, int length, const void *data, netadr_t to )
=============
NET_StringToAdr
Traps "localhost" for loopback, passes everything else to system
Traps "loopback" for loopback, passes everything else to system
return 0 on address not found, 1 on address found with port, 2 on address found without port.
=============
*/
@@ -619,6 +619,14 @@ int NET_StringToAdr( const char *s, netadr_t *a, netadrtype_t family )
char base[ MAX_STRING_CHARS ], *search;
char *port = nullptr;
if ( !strcmp( s, "loopback" ) )
{
Com_Memset( a, 0, sizeof( *a ) );
a->type = netadrtype_t::NA_LOOPBACK;
// as NA_LOOPBACK doesn't require ports report port was given.
return 1;
}
Q_strncpyz( base, s, sizeof( base ) );
if ( *base == '[' || Q_CountChar( base, ':' ) > 1 )
@@ -389,7 +389,7 @@ class ListMapsCmd: public Cmd::StaticCmd
{
public:
ListMapsCmd():
StaticCmd("listmaps", Cmd::SYSTEM, "Lists all available maps")
StaticCmd("listmaps", Cmd::SYSTEM, "Lists all maps available to the server")
{}
void Run(const Cmd::Args&) const OVERRIDE
@@ -422,7 +422,10 @@ class ListMapsCmd: public Cmd::StaticCmd
}
}
};
#if BUILD_SERVER
static ListMapsCmd ListMapsCmdRegistration;
#endif
/*
==================
@@ -104,7 +104,7 @@ void SV_DirectConnect( netadr_t from, const Cmd::Args& args )
if ( NET_IsLocalAddress( from ) )
{
userinfo["ip"] = "localhost";
userinfo["ip"] = "loopback";
}
else
{
@@ -1096,8 +1096,8 @@ void SV_UserinfoChanged( client_t *cl )
}
else
{
// force the "ip" info key to "localhost" for local clients
Info_SetValueForKey( cl->userinfo, "ip", "localhost", false );
// force the "ip" info key to "loopback" for local clients
Info_SetValueForKey( cl->userinfo, "ip", "loopback", false );
#ifdef HAVE_GEOIP
Info_SetValueForKey( cl->userinfo, "geoip", nullptr, false );
#endif

0 comments on commit 8264884

Please sign in to comment.