|
|
@ -1098,6 +1098,8 @@ void CL_CheckForResend( void ) |
|
|
|
cls.signon = 0; |
|
|
|
cls.signon = 0; |
|
|
|
cls.state = ca_connecting; |
|
|
|
cls.state = ca_connecting; |
|
|
|
Q_strncpy( cls.servername, "localhost", sizeof( cls.servername )); |
|
|
|
Q_strncpy( cls.servername, "localhost", sizeof( cls.servername )); |
|
|
|
|
|
|
|
cls.serveradr.type = NA_LOOPBACK; |
|
|
|
|
|
|
|
|
|
|
|
// we don't need a challenge on the localhost
|
|
|
|
// we don't need a challenge on the localhost
|
|
|
|
CL_SendConnectPacket(); |
|
|
|
CL_SendConnectPacket(); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -1150,6 +1152,7 @@ void CL_CheckForResend( void ) |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cls.serveradr = adr; |
|
|
|
cls.max_fragment_size = Q_max( FRAGMENT_MAX_SIZE, cls.max_fragment_size >> Q_min( 1, cls.connect_retry )); |
|
|
|
cls.max_fragment_size = Q_max( FRAGMENT_MAX_SIZE, cls.max_fragment_size >> Q_min( 1, cls.connect_retry )); |
|
|
|
cls.connect_time = host.realtime; // for retransmit requests
|
|
|
|
cls.connect_time = host.realtime; // for retransmit requests
|
|
|
|
cls.connect_retry++; |
|
|
|
cls.connect_retry++; |
|
|
@ -1501,6 +1504,7 @@ void CL_Disconnect( void ) |
|
|
|
IN_LockInputDevices( false ); // unlock input devices
|
|
|
|
IN_LockInputDevices( false ); // unlock input devices
|
|
|
|
|
|
|
|
|
|
|
|
cls.state = ca_disconnected; |
|
|
|
cls.state = ca_disconnected; |
|
|
|
|
|
|
|
memset( &cls.serveradr, 0, sizeof( cls.serveradr ) ); |
|
|
|
cls.set_lastdemo = false; |
|
|
|
cls.set_lastdemo = false; |
|
|
|
cls.connect_retry = 0; |
|
|
|
cls.connect_retry = 0; |
|
|
|
cls.signon = 0; |
|
|
|
cls.signon = 0; |
|
|
@ -1858,6 +1862,19 @@ void CL_SetupOverviewParams( void ) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
================= |
|
|
|
|
|
|
|
CL_IsFromConnectingServer |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Used for connectionless packets, when netchan may not be ready. |
|
|
|
|
|
|
|
================= |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
static qboolean CL_IsFromConnectingServer( netadr_t from ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return NET_IsLocalAddress( from ) || |
|
|
|
|
|
|
|
NET_CompareAdr( cls.serveradr, from ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
================= |
|
|
|
================= |
|
|
|
CL_ConnectionlessPacket |
|
|
|
CL_ConnectionlessPacket |
|
|
@ -1887,6 +1904,9 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) |
|
|
|
// server connection
|
|
|
|
// server connection
|
|
|
|
if( !Q_strcmp( c, "client_connect" )) |
|
|
|
if( !Q_strcmp( c, "client_connect" )) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if( !CL_IsFromConnectingServer( from )) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if( cls.state == ca_connected ) |
|
|
|
if( cls.state == ca_connected ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Con_DPrintf( S_ERROR "dup connect received. ignored\n"); |
|
|
|
Con_DPrintf( S_ERROR "dup connect received. ignored\n"); |
|
|
@ -1927,21 +1947,19 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) |
|
|
|
// print command from somewhere
|
|
|
|
// print command from somewhere
|
|
|
|
Con_Printf( "%s", MSG_ReadString( msg )); |
|
|
|
Con_Printf( "%s", MSG_ReadString( msg )); |
|
|
|
} |
|
|
|
} |
|
|
|
else if( !Q_strcmp( c, "errormsg" )) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
args = MSG_ReadString( msg ); |
|
|
|
|
|
|
|
if( !Q_strcmp( args, "Server uses protocol version 48.\n" )) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
cls.legacyserver = from; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if( !Q_strcmp( c, "testpacket" )) |
|
|
|
else if( !Q_strcmp( c, "testpacket" )) |
|
|
|
{ |
|
|
|
{ |
|
|
|
byte recv_buf[NET_MAX_FRAGMENT]; |
|
|
|
byte recv_buf[NET_MAX_FRAGMENT]; |
|
|
|
dword crcValue = MSG_ReadLong( msg ); |
|
|
|
dword crcValue; |
|
|
|
int realsize = MSG_GetMaxBytes( msg ) - MSG_GetNumBytesRead( msg ); |
|
|
|
int realsize; |
|
|
|
dword crcValue2 = 0; |
|
|
|
dword crcValue2 = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( !CL_IsFromConnectingServer( from )) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
crcValue = MSG_ReadLong( msg ); |
|
|
|
|
|
|
|
realsize = MSG_GetMaxBytes( msg ) - MSG_GetNumBytesRead( msg ); |
|
|
|
|
|
|
|
|
|
|
|
if( cls.max_fragment_size != MSG_GetMaxBytes( msg )) |
|
|
|
if( cls.max_fragment_size != MSG_GetMaxBytes( msg )) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( cls.connect_retry >= CL_TEST_RETRIES ) |
|
|
|
if( cls.connect_retry >= CL_TEST_RETRIES ) |
|
|
@ -1999,6 +2017,9 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) |
|
|
|
} |
|
|
|
} |
|
|
|
else if( !Q_strcmp( c, "challenge" )) |
|
|
|
else if( !Q_strcmp( c, "challenge" )) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if( !CL_IsFromConnectingServer( from )) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
// challenge from the server we are connecting to
|
|
|
|
// challenge from the server we are connecting to
|
|
|
|
cls.challenge = Q_atoi( Cmd_Argv( 1 )); |
|
|
|
cls.challenge = Q_atoi( Cmd_Argv( 1 )); |
|
|
|
CL_SendConnectPacket(); |
|
|
|
CL_SendConnectPacket(); |
|
|
@ -2006,11 +2027,17 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) |
|
|
|
} |
|
|
|
} |
|
|
|
else if( !Q_strcmp( c, "echo" )) |
|
|
|
else if( !Q_strcmp( c, "echo" )) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if( !CL_IsFromConnectingServer( from )) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
// echo request from server
|
|
|
|
// echo request from server
|
|
|
|
Netchan_OutOfBandPrint( NS_CLIENT, from, "%s", Cmd_Argv( 1 )); |
|
|
|
Netchan_OutOfBandPrint( NS_CLIENT, from, "%s", Cmd_Argv( 1 )); |
|
|
|
} |
|
|
|
} |
|
|
|
else if( !Q_strcmp( c, "disconnect" )) |
|
|
|
else if( !Q_strcmp( c, "disconnect" )) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if( !CL_IsFromConnectingServer( from )) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
// a disconnect message from the server, which will happen if the server
|
|
|
|
// a disconnect message from the server, which will happen if the server
|
|
|
|
// dropped the connection but it is still getting packets from us
|
|
|
|
// dropped the connection but it is still getting packets from us
|
|
|
|
CL_Disconnect_f(); |
|
|
|
CL_Disconnect_f(); |
|
|
@ -2021,6 +2048,48 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) |
|
|
|
memset( &cls.legacyserver, 0, sizeof( cls.legacyserver )); |
|
|
|
memset( &cls.legacyserver, 0, sizeof( cls.legacyserver )); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if( !Q_strcmp( c, "errormsg" )) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( !CL_IsFromConnectingServer( from )) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
args = MSG_ReadString( msg ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( !Q_strcmp( args, "Server uses protocol version 48.\n" )) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
cls.legacyserver = from; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( UI_IsVisible() ) |
|
|
|
|
|
|
|
UI_ShowMessageBox( va("^3Server message^7\n%s", args ) ); |
|
|
|
|
|
|
|
Msg( "%s", args ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if( !Q_strcmp( c, "updatemsg" )) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// got an update message from master server
|
|
|
|
|
|
|
|
// show update dialog from menu
|
|
|
|
|
|
|
|
netadr_t adr; |
|
|
|
|
|
|
|
qboolean preferStore = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( !Q_strcmp( Cmd_Argv( 1 ), "nostore" ) ) |
|
|
|
|
|
|
|
preferStore = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// trust only hardcoded master server
|
|
|
|
|
|
|
|
if( NET_StringToAdr( MASTERSERVER_ADR, &adr ) ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( NET_CompareAdr( from, adr )) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UI_ShowUpdateDialog( preferStore ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// in case we don't have master anymore
|
|
|
|
|
|
|
|
UI_ShowUpdateDialog( preferStore ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else if( !Q_strcmp( c, "f" )) |
|
|
|
else if( !Q_strcmp( c, "f" )) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// serverlist got from masterserver
|
|
|
|
// serverlist got from masterserver
|
|
|
@ -2713,28 +2782,6 @@ void CL_Escape_f( void ) |
|
|
|
else UI_SetActiveMenu( true ); |
|
|
|
else UI_SetActiveMenu( true ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
================= |
|
|
|
|
|
|
|
CL_WarnLostSplitPacket |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
================= |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
void CL_WarnLostSplitPacket( void ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( cls.state != ca_connected ) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( Host_IsLocalClient() ) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( ++cl.lostpackets == 8 ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CL_Disconnect(); |
|
|
|
|
|
|
|
UI_ShowConnectionWarning(); |
|
|
|
|
|
|
|
Con_DPrintf( S_WARN "Too many lost packets! Showing Network options menu\n" ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
================= |
|
|
|
================= |
|
|
|
CL_InitLocal |
|
|
|
CL_InitLocal |
|
|
@ -2744,6 +2791,7 @@ void CL_InitLocal( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
cls.state = ca_disconnected; |
|
|
|
cls.state = ca_disconnected; |
|
|
|
cls.signon = 0; |
|
|
|
cls.signon = 0; |
|
|
|
|
|
|
|
memset( &cls.serveradr, 0, sizeof( cls.serveradr ) ); |
|
|
|
|
|
|
|
|
|
|
|
cl.resourcesneeded.pNext = cl.resourcesneeded.pPrev = &cl.resourcesneeded; |
|
|
|
cl.resourcesneeded.pNext = cl.resourcesneeded.pPrev = &cl.resourcesneeded; |
|
|
|
cl.resourcesonhand.pNext = cl.resourcesonhand.pPrev = &cl.resourcesonhand; |
|
|
|
cl.resourcesonhand.pNext = cl.resourcesonhand.pPrev = &cl.resourcesonhand; |
|
|
|