Beispiel #1
0
/*
==================
CL_SystemInfoChanged

The systeminfo configstring has been changed, so parse
new information out of it.  This will happen at every
gamestate, and possibly during gameplay.
==================
*/
void CL_SystemInfoChanged( void ) {
    char			*systemInfo;
    const char		*s, *t;
    char			key[BIG_INFO_KEY];
    char			value[BIG_INFO_VALUE];
    qboolean		gameSet;

    systemInfo = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SYSTEMINFO ];
    // NOTE TTimo:
    // when the serverId changes, any further messages we send to the server will use this new serverId
    // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=475
    // in some cases, outdated cp commands might get sent with this new serverId
    cl.serverId = atoi( Info_ValueForKey( systemInfo, "sv_serverid" ) );

    // don't set any vars when playing a demo
    if ( clc.demoplaying ) {
        return;
    }

    s = Info_ValueForKey( systemInfo, "sv_cheats" );
    cl_connectedToCheatServer = atoi( s );
    if ( !cl_connectedToCheatServer )
    {
        Cvar_SetCheatState();
    }

    // check pure server string
    s = Info_ValueForKey( systemInfo, "sv_paks" );
    t = Info_ValueForKey( systemInfo, "sv_pakNames" );
    FS_PureServerSetLoadedPaks( s, t );

    s = Info_ValueForKey( systemInfo, "sv_referencedPaks" );
    t = Info_ValueForKey( systemInfo, "sv_referencedPakNames" );
    FS_PureServerSetReferencedPaks( s, t );

    gameSet = qfalse;
    // scan through all the variables in the systeminfo and locally set cvars to match
    s = systemInfo;
    while ( s ) {
        Info_NextPair( &s, key, value );
        if ( !key[0] ) {
            break;
        }
        // ehw!
        if ( !Q_stricmp( key, "fs_game" ) ) {
            if(FS_CheckDirTraversal(value))
            {
                Com_Printf(S_COLOR_YELLOW "WARNING: Server sent invalid fs_game value %s\n", value);
                continue;
            }

            if(!FS_FilenameCompare(value, BASEGAME))
            {
                Com_Printf(S_COLOR_YELLOW "WARNING: Server sent \"%s\" fs_game value, clearing.\n", value);
                Q_strncpyz(value, "", sizeof(value));
            }

            gameSet = qtrue;
        }
        Cvar_Server_Set( key, value );
    }
    // if game folder should not be set and it is set at the client side
    if ( !gameSet && *Cvar_VariableString("fs_game") ) {
        Cvar_Set( "fs_game", "" );
    }
    cl_connectedToPureServer = Cvar_VariableValue( "sv_pure" );
}
Beispiel #2
0
/*
==================
CL_SystemInfoChanged

The systeminfo configstring has been changed, so parse
new information out of it.  This will happen at every
gamestate, and possibly during gameplay.
==================
*/
void CL_SystemInfoChanged( void ) {
	char			*systemInfo;
	const char		*s, *t;
	char			key[BIG_INFO_KEY];
	char			value[BIG_INFO_VALUE];
	qboolean		gameSet;

	systemInfo = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SYSTEMINFO ];
	// NOTE TTimo:
	// when the serverId changes, any further messages we send to the server will use this new serverId
	// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=475
	// in some cases, outdated cp commands might get sent with this news serverId
	cl.serverId = atoi( Info_ValueForKey( systemInfo, "sv_serverid" ) );

#ifdef USE_VOIP
	s = Info_ValueForKey( systemInfo, "sv_voipProtocol" );
	clc.voipEnabled = !Q_stricmp(s, "opus");
#endif

	// don't set any vars when playing a demo
	if ( clc.demoplaying ) {
		return;
	}

	s = Info_ValueForKey( systemInfo, "sv_cheats" );
	cl_connectedToCheatServer = atoi( s );
	if ( !cl_connectedToCheatServer ) {
		Cvar_SetCheatState();
	}

	// check pure server string
	s = Info_ValueForKey( systemInfo, "sv_paks" );
	t = Info_ValueForKey( systemInfo, "sv_pakNames" );
	FS_PureServerSetLoadedPaks( s, t );

	s = Info_ValueForKey( systemInfo, "sv_referencedPaks" );
	t = Info_ValueForKey( systemInfo, "sv_referencedPakNames" );
	FS_PureServerSetReferencedPaks( s, t );

	gameSet = qfalse;
	// scan through all the variables in the systeminfo and locally set cvars to match
	s = systemInfo;
	while ( s ) {
		Info_NextPair( &s, key, value );
		if ( !key[0] ) {
			break;
		}
		
		// ehw!
		if (!Q_stricmp(key, "fs_game"))
		{
			char filename[MAX_QPATH];
			char *title;

			if ( gameSet )
				continue;

			if(FS_CheckDirTraversal(value))
			{
				Com_Printf(S_COLOR_YELLOW "WARNING: Server sent invalid fs_game value %s\n", value);
				continue;
			}

			// create game title file if does not exist
			title = Info_ValueForKey( systemInfo, "sv_gameTitle" );
			Com_sprintf( filename, sizeof ( filename ), "%s/description.txt", value );
			if ( ( cl_allowDownload->integer & DLF_ENABLE ) && *title && !FS_SV_RW_FileExists( filename ) ) {
				fileHandle_t f = FS_SV_FOpenFileWrite( filename );
				FS_Write( s, strlen( title ), f );
				FS_FCloseFile( f );
			}

			gameSet = qtrue;
		}

		Cvar_Server_Set(key, value);
	}
	// game folder must be set
	if ( !gameSet ) {
		Com_Error( ERR_DROP, "fs_game not set on server" );
	}
}