mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2025-03-13 22:23:04 +00:00
added net_proxy
This commit is contained in:
parent
1544a61cfc
commit
a47c8c8dd1
4 changed files with 51 additions and 9 deletions
|
@ -4,6 +4,8 @@ See the end of this file for known issues.
|
|||
|
||||
DD Mmm 20 - 1.53
|
||||
|
||||
add: net_proxy <ip> (default: "") is the proxy server to use when establishing client connections
|
||||
|
||||
add: /waitms <milliseconds> to delay command executions by the specified number of milliseconds
|
||||
|
||||
add: r_alphaToCoverageMipBoost <0.0 to 0.5> (default: 0.125) boosts the alpha value of higher mip levels
|
||||
|
|
|
@ -46,6 +46,7 @@ cvar_t *cl_allowDownload;
|
|||
cvar_t *cl_inGameVideo;
|
||||
|
||||
cvar_t *cl_matchAlerts;
|
||||
cvar_t *net_proxy;
|
||||
|
||||
cvar_t *r_khr_debug;
|
||||
|
||||
|
@ -830,13 +831,30 @@ void CL_Disconnect_f( void )
|
|||
}
|
||||
|
||||
|
||||
static void CL_Reconnect_f()
|
||||
static void CL_Reconnect( qbool whileConnectingToProxy )
|
||||
{
|
||||
if ( !strlen( cls.servername ) || !strcmp( cls.servername, "localhost" ) ) {
|
||||
Com_Printf( "Can't reconnect to localhost.\n" );
|
||||
return;
|
||||
}
|
||||
Cbuf_AddText( va("connect %s\n", cls.servername ) );
|
||||
|
||||
// Reconnecting via the same proxy doesn't seem to work with QWFWD
|
||||
// ("illegible server message" drop error),
|
||||
// so we disconnect and wait a bit first to make it work.
|
||||
// One second seems to work well enough but let's pad it a bit.
|
||||
if ( !whileConnectingToProxy &&
|
||||
net_proxy->string[0] != '\0' &&
|
||||
!Q_stricmp( net_proxy->string, cls.proxyname ) ) {
|
||||
Cbuf_AddText( va( "disconnect\nwaitms 1500\nconnect %s\n", cls.servername ) );
|
||||
} else {
|
||||
Cbuf_AddText( va( "connect %s\n", cls.servername ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void CL_Reconnect_f()
|
||||
{
|
||||
CL_Reconnect( qfalse );
|
||||
}
|
||||
|
||||
|
||||
|
@ -850,9 +868,23 @@ static void CL_Connect_f()
|
|||
// clear any previous "server full" type messages
|
||||
clc.serverMessage[0] = 0;
|
||||
|
||||
const char* server = Cmd_Argv(1);
|
||||
const char* const requestedAddress = Cmd_Argv(1);
|
||||
const char* connectionAddress = requestedAddress;
|
||||
|
||||
if ( com_sv_running->integer && !strcmp( server, "localhost" ) ) {
|
||||
// ye old switcheroo
|
||||
if ( net_proxy->string[0] != '\0' && Q_stricmp( net_proxy->string, requestedAddress ) != 0 ) {
|
||||
Cvar_Get( "prx", requestedAddress, CVAR_USERINFO );
|
||||
Cvar_Set( "prx", requestedAddress );
|
||||
connectionAddress = net_proxy->string;
|
||||
Q_strncpyz( cls.proxyname, net_proxy->string, sizeof(cls.proxyname) );
|
||||
} else {
|
||||
// it's not really necessary but it's nice to reflect the changes
|
||||
Cvar_Get( "prx", "", CVAR_USERINFO );
|
||||
Cvar_Set( "prx", "" );
|
||||
cls.proxyname[0] = '\0';
|
||||
}
|
||||
|
||||
if ( com_sv_running->integer && !strcmp( requestedAddress, "localhost" ) ) {
|
||||
// if running a local server, kill it
|
||||
SV_Shutdown( "Server quit" );
|
||||
}
|
||||
|
@ -864,9 +896,9 @@ static void CL_Connect_f()
|
|||
CL_Disconnect( qtrue );
|
||||
Con_Close();
|
||||
|
||||
Q_strncpyz( cls.servername, server, sizeof(cls.servername) );
|
||||
Q_strncpyz( cls.servername, requestedAddress, sizeof(cls.servername) );
|
||||
|
||||
if (!NET_StringToAdr( cls.servername, &clc.serverAddress) ) {
|
||||
if (!NET_StringToAdr( connectionAddress, &clc.serverAddress) ) {
|
||||
Com_Printf ("Bad server address\n");
|
||||
cls.state = CA_DISCONNECTED;
|
||||
return;
|
||||
|
@ -874,7 +906,7 @@ static void CL_Connect_f()
|
|||
if (clc.serverAddress.port == 0) {
|
||||
clc.serverAddress.port = BigShort( PORT_SERVER );
|
||||
}
|
||||
Com_Printf( "%s resolved to %i.%i.%i.%i:%i\n", cls.servername,
|
||||
Com_Printf( "%s resolved to %i.%i.%i.%i:%i\n", connectionAddress,
|
||||
clc.serverAddress.ip[0], clc.serverAddress.ip[1],
|
||||
clc.serverAddress.ip[2], clc.serverAddress.ip[3],
|
||||
BigShort( clc.serverAddress.port ) );
|
||||
|
@ -892,7 +924,7 @@ static void CL_Connect_f()
|
|||
clc.connectPacketCount = 0;
|
||||
|
||||
// server connection string
|
||||
Cvar_Set( "cl_currentServerAddress", server );
|
||||
Cvar_Set( "cl_currentServerAddress", connectionAddress );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1428,7 +1460,7 @@ static void CL_ConnectionlessPacket( const netadr_t& from, msg_t* msg )
|
|||
Q_strncpyz( clc.serverMessage, s, sizeof( clc.serverMessage ) );
|
||||
Com_Printf( "%s", s );
|
||||
if ( !Q_stricmpn(s, "/reconnect ASAP!", 16) ) {
|
||||
CL_Reconnect_f();
|
||||
CL_Reconnect( qtrue );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -2074,6 +2106,7 @@ static const cvarTableItem_t cl_cvars[] =
|
|||
{ NULL, "snaps", "30", CVAR_USERINFO | CVAR_ARCHIVE, CVART_INTEGER }, // documented by the mod
|
||||
{ NULL, "password", "", CVAR_USERINFO, CVART_STRING, NULL, NULL, "used by /" S_COLOR_CMD "connect" },
|
||||
{ &cl_matchAlerts, "cl_matchAlerts", "7", CVAR_ARCHIVE, CVART_BITMASK, "0", XSTRING(MAF_MAX), help_cl_matchAlerts },
|
||||
{ &net_proxy, "net_proxy", "", CVAR_TEMP, CVART_STRING, NULL, NULL, help_net_proxy },
|
||||
{ &r_khr_debug, "r_khr_debug", "2", CVAR_ARCHIVE, CVART_INTEGER, "0", "2", help_r_khr_debug }
|
||||
};
|
||||
|
||||
|
|
|
@ -252,6 +252,7 @@ typedef struct {
|
|||
qbool cddialog; // bring up the cd needed dialog next frame
|
||||
|
||||
char servername[MAX_OSPATH]; // name of server from original connect (used by reconnect)
|
||||
char proxyname[MAX_OSPATH]; // name of proxy from original connect (used by reconnect)
|
||||
|
||||
// when the server clears the hunk, all of these must be restarted
|
||||
qbool rendererStarted;
|
||||
|
|
|
@ -129,3 +129,9 @@ S_COLOR_VAL " 8 " S_COLOR_HELP "= Draws the list of attributes (cvars only)"
|
|||
S_COLOR_VAL " 0 " S_COLOR_HELP "= Forced off\n" \
|
||||
S_COLOR_VAL " 1 " S_COLOR_HELP "= Forced on\n" \
|
||||
S_COLOR_VAL " 2 " S_COLOR_HELP "= On in debug builds only"
|
||||
|
||||
#define help_net_proxy \
|
||||
"proxy server address\n" \
|
||||
"Set this CVar before connecting to a server to join through a proxy.\n" \
|
||||
"It works with /" S_COLOR_CMD "connect" S_COLOR_HELP ", /" S_COLOR_CMD "reconnect" S_COLOR_HELP " and the server browser UI.\n" \
|
||||
"Set it to an empty string to not use a proxy server."
|
||||
|
|
Loading…
Reference in a new issue