diff options
author | Tim Angus <tim@ngus.net> | 2005-12-28 02:32:43 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2005-12-28 02:32:43 +0000 |
commit | 1dc7e94283f026b17c1e793cbf7542872812ffda (patch) | |
tree | 33de56bca208626f1e7c77853255afc2b8244279 /src/client/cl_main.c | |
parent | 4b614e63d7da358a8a30e61a89365add79ecde9c (diff) |
* Added master server to source, based on dpmaster
* Removed gametype, fraglimit and dmflags cvars
* Removed CD key authentication stuff
* Implemented a means to save and restore cmd context
* Bumped protocol version up to 69 (same as 68)
* Removed various references to punkbuster
* Maps on create server menu now sorted by name
* Fixed some warnings
Diffstat (limited to 'src/client/cl_main.c')
-rw-r--r-- | src/client/cl_main.c | 215 |
1 files changed, 24 insertions, 191 deletions
diff --git a/src/client/cl_main.c b/src/client/cl_main.c index bb322b6a..0789ac9b 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -820,116 +820,31 @@ void CL_RequestMotd( void ) { if ( !cl_motd->integer ) { return; } - Com_Printf( "Resolving %s\n", UPDATE_SERVER_NAME ); - if ( !NET_StringToAdr( UPDATE_SERVER_NAME, &cls.updateServer ) ) { + Com_Printf( "Resolving %s\n", MASTER_SERVER_NAME ); + if ( !NET_StringToAdr( MASTER_SERVER_NAME, &cls.updateServer ) ) { Com_Printf( "Couldn't resolve address\n" ); return; } - cls.updateServer.port = BigShort( PORT_UPDATE ); - Com_Printf( "%s resolved to %i.%i.%i.%i:%i\n", UPDATE_SERVER_NAME, + cls.updateServer.port = BigShort( PORT_MASTER ); + Com_Printf( "%s resolved to %i.%i.%i.%i:%i\n", MASTER_SERVER_NAME, cls.updateServer.ip[0], cls.updateServer.ip[1], cls.updateServer.ip[2], cls.updateServer.ip[3], BigShort( cls.updateServer.port ) ); - + info[0] = 0; // NOTE TTimo xoring against Com_Milliseconds, otherwise we may not have a true randomization // only srand I could catch before here is tr_noise.c l:26 srand(1001) // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=382 // NOTE: the Com_Milliseconds xoring only affects the lower 16-bit word, // but I decided it was enough randomization - Com_sprintf( cls.updateChallenge, sizeof( cls.updateChallenge ), "%i", ((rand() << 16) ^ rand()) ^ Com_Milliseconds()); + Com_sprintf( cls.updateChallenge, sizeof( cls.updateChallenge ), + "%i", ((rand() << 16) ^ rand()) ^ Com_Milliseconds()); Info_SetValueForKey( info, "challenge", cls.updateChallenge ); Info_SetValueForKey( info, "renderer", cls.glconfig.renderer_string ); Info_SetValueForKey( info, "version", com_version->string ); - NET_OutOfBandPrint( NS_CLIENT, cls.updateServer, "getmotd \"%s\"\n", info ); -} - -/* -=================== -CL_RequestAuthorization - -Authorization server protocol ------------------------------ - -All commands are text in Q3 out of band packets (leading 0xff 0xff 0xff 0xff). - -Whenever the client tries to get a challenge from the server it wants to -connect to, it also blindly fires off a packet to the authorize server: - -getKeyAuthorize <challenge> <cdkey> - -cdkey may be "demo" - - -#OLD The authorize server returns a: -#OLD -#OLD keyAthorize <challenge> <accept | deny> -#OLD -#OLD A client will be accepted if the cdkey is valid and it has not been used by any other IP -#OLD address in the last 15 minutes. - - -The server sends a: - -getIpAuthorize <challenge> <ip> - -The authorize server returns a: - -ipAuthorize <challenge> <accept | deny | demo | unknown > - -A client will be accepted if a valid cdkey was sent by that ip (only) in the last 15 minutes. -If no response is received from the authorize server after two tries, the client will be let -in anyway. -=================== -*/ -void CL_RequestAuthorization( void ) { - char nums[64]; - int i, j, l; - cvar_t *fs; - - if ( !cls.authorizeServer.port ) { - Com_Printf( "Resolving %s\n", AUTHORIZE_SERVER_NAME ); - if ( !NET_StringToAdr( AUTHORIZE_SERVER_NAME, &cls.authorizeServer ) ) { - Com_Printf( "Couldn't resolve address\n" ); - return; - } - - cls.authorizeServer.port = BigShort( PORT_AUTHORIZE ); - Com_Printf( "%s resolved to %i.%i.%i.%i:%i\n", AUTHORIZE_SERVER_NAME, - cls.authorizeServer.ip[0], cls.authorizeServer.ip[1], - cls.authorizeServer.ip[2], cls.authorizeServer.ip[3], - BigShort( cls.authorizeServer.port ) ); - } - if ( cls.authorizeServer.type == NA_BAD ) { - return; - } - - if ( Cvar_VariableValue( "fs_restrict" ) ) { - Q_strncpyz( nums, "demota", sizeof( nums ) ); - } else { - // only grab the alphanumeric values from the cdkey, to avoid any dashes or spaces - j = 0; - l = strlen( cl_cdkey ); - if ( l > 32 ) { - l = 32; - } - for ( i = 0 ; i < l ; i++ ) { - if ( ( cl_cdkey[i] >= '0' && cl_cdkey[i] <= '9' ) - || ( cl_cdkey[i] >= 'a' && cl_cdkey[i] <= 'z' ) - || ( cl_cdkey[i] >= 'A' && cl_cdkey[i] <= 'Z' ) - ) { - nums[j] = cl_cdkey[i]; - j++; - } - } - nums[j] = 0; - } - - fs = Cvar_Get ("cl_anonymous", "0", CVAR_INIT|CVAR_SYSTEMINFO ); - - NET_OutOfBandPrint(NS_CLIENT, cls.authorizeServer, va("getKeyAuthorize %i %s", fs->integer, nums) ); + NET_OutOfBandPrint( NS_CLIENT, cls.updateServer, "getmotd%s", info ); } /* @@ -1519,9 +1434,6 @@ void CL_CheckForResend( void ) { switch ( cls.state ) { case CA_CONNECTING: // requesting a challenge - if ( !Sys_IsLANAddress( clc.serverAddress ) ) { - CL_RequestAuthorization(); - } NET_OutOfBandPrint(NS_CLIENT, clc.serverAddress, "getchallenge"); break; @@ -1596,27 +1508,24 @@ CL_MotdPacket =================== */ -void CL_MotdPacket( netadr_t from ) { - char *challenge; - char *info; +void CL_MotdPacket( netadr_t from, const char *info ) { + char *v; // if not from our server, ignore it if ( !NET_CompareAdr( from, cls.updateServer ) ) { return; } - info = Cmd_Argv(1); - // check challenge - challenge = Info_ValueForKey( info, "challenge" ); - if ( strcmp( challenge, cls.updateChallenge ) ) { + v = Info_ValueForKey( info, "challenge" ); + if ( strcmp( v, cls.updateChallenge ) ) { return; } - challenge = Info_ValueForKey( info, "motd" ); + v = Info_ValueForKey( info, "motd" ); Q_strncpyz( cls.updateInfoString, info, sizeof( cls.updateInfoString ) ); - Cvar_Set( "cl_motdString", challenge ); + Cvar_Set( "cl_motdString", v ); } /* @@ -1706,7 +1615,7 @@ void CL_ServersResponsePacket( netadr_t from, msg_t *msg ) { addresses[numservers].ip[1], addresses[numservers].ip[2], addresses[numservers].ip[3], - addresses[numservers].port ); + BigShort( addresses[numservers].port ) ); numservers++; if (numservers >= MAX_SERVERSPERPACKET) { @@ -1773,7 +1682,8 @@ Responses to broadcasts, etc */ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) { char *s; - char *c; + char c[ BIG_INFO_STRING ]; + char arg1[ BIG_INFO_STRING ]; MSG_BeginReadingOOB( msg ); MSG_ReadLong( msg ); // skip the -1 @@ -1782,7 +1692,8 @@ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) { Cmd_TokenizeString( s ); - c = Cmd_Argv(0); + Q_strncpyz( c, Cmd_Argv( 0 ), BIG_INFO_STRING ); + Q_strncpyz( arg1, Cmd_Argv( 1 ), BIG_INFO_STRING ); Com_DPrintf ("CL packet %s: %s\n", NET_AdrToString(from), c); @@ -1792,7 +1703,7 @@ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) { Com_Printf( "Unwanted challenge response received. Ignored.\n" ); } else { // start sending challenge repsonse instead of challenge request packets - clc.challenge = atoi(Cmd_Argv(1)); + clc.challenge = atoi(arg1); cls.state = CA_CHALLENGING; clc.connectPacketCount = 0; clc.connectTime = -99999; @@ -1848,19 +1759,13 @@ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) { // echo request from server if ( !Q_stricmp(c, "echo") ) { - NET_OutOfBandPrint( NS_CLIENT, from, "%s", Cmd_Argv(1) ); + NET_OutOfBandPrint( NS_CLIENT, from, "%s", arg1 ); return; } - // cd check - if ( !Q_stricmp(c, "keyAuthorize") ) { - // we don't use these now, so dump them on the floor - return; - } - - // global MOTD from id + // global MOTD from trem master if ( !Q_stricmp(c, "motd") ) { - CL_MotdPacket( from ); + CL_MotdPacket( from, arg1 ); return; } @@ -2003,11 +1908,7 @@ void CL_Frame ( int msec ) { return; } - if ( cls.cddialog ) { - // bring up the cd error dialog if needed - cls.cddialog = qfalse; - VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_NEED_CD ); - } else if ( cls.state == CA_DISCONNECTED && !( cls.keyCatchers & KEYCATCH_UI ) + if ( cls.state == CA_DISCONNECTED && !( cls.keyCatchers & KEYCATCH_UI ) && !com_sv_running->integer ) { // if disconnected, bring up the menu S_StopAllSounds(); @@ -2474,7 +2375,6 @@ static void CL_SetServerInfo(serverInfo_t *server, const char *info, int ping) { server->netType = atoi(Info_ValueForKey(info, "nettype")); server->minPing = atoi(Info_ValueForKey(info, "minping")); server->maxPing = atoi(Info_ValueForKey(info, "maxping")); - server->punkbuster = atoi(Info_ValueForKey(info, "punkbuster")); } server->ping = ping; } @@ -2605,7 +2505,6 @@ void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) { cls.localServers[i].game[0] = '\0'; cls.localServers[i].gameType = 0; cls.localServers[i].netType = from.type; - cls.localServers[i].punkbuster = 0; Q_strncpyz( info, MSG_ReadString( msg ), MAX_INFO_STRING ); if (strlen(info)) { @@ -3260,69 +3159,3 @@ CL_ShowIP_f void CL_ShowIP_f(void) { Sys_ShowIP(); } - -/* -================= -bool CL_CDKeyValidate -================= -*/ -qboolean CL_CDKeyValidate( const char *key, const char *checksum ) { - char ch; - byte sum; - char chs[3]; - int i, len; - - len = strlen(key); - if( len != CDKEY_LEN ) { - return qfalse; - } - - if( checksum && strlen( checksum ) != CDCHKSUM_LEN ) { - return qfalse; - } - - sum = 0; - // for loop gets rid of conditional assignment warning - for (i = 0; i < len; i++) { - ch = *key++; - if (ch>='a' && ch<='z') { - ch -= 32; - } - switch( ch ) { - case '2': - case '3': - case '7': - case 'A': - case 'B': - case 'C': - case 'D': - case 'G': - case 'H': - case 'J': - case 'L': - case 'P': - case 'R': - case 'S': - case 'T': - case 'W': - sum += ch; - continue; - default: - return qfalse; - } - } - - sprintf(chs, "%02x", sum); - - if (checksum && !Q_stricmp(chs, checksum)) { - return qtrue; - } - - if (!checksum) { - return qtrue; - } - - return qfalse; -} - - |