Exemple #1
0
static void CG_ConfigStringModified( void ) {
	const char	*str;
	int		num;

	num = atoi( CG_Argv( 1 ) );

	// get the gamestate from the client system, which will have the
	// new configstring already integrated
	trap->GetGameState( &cgs.gameState );

	// look up the individual string that was modified
	str = CG_ConfigString( num );

	// do something with it if necessary
	if ( num == CS_MUSIC ) {
		CG_StartMusic( qtrue );
	} else if ( num == CS_SERVERINFO ) {
		CG_ParseServerinfo();
	} else if ( num == CS_WARMUP ) {
		CG_ParseWarmup();
	} else if ( num == CS_SCORES1 ) {
		cgs.scores1 = atoi( str );
	} else if ( num == CS_SCORES2 ) {
		cgs.scores2 = atoi( str );
	} else if ( num == CS_CLIENT_JEDIMASTER ) {
		cgs.jediMaster = atoi ( str );
	}
	else if ( num == CS_CLIENT_DUELWINNER )
	{
		cgs.duelWinner = atoi ( str );
	}
	else if ( num == CS_CLIENT_DUELISTS )
	{
		char buf[64];
		int c = 0;
		int i = 0;

		while (str[i] && str[i] != '|')
		{
			buf[c] = str[i];
			c++;
			i++;
		}
		buf[c] = 0;

		cgs.duelist1 = atoi ( buf );
		c = 0;

		i++;
		while (str[i] && str[i] != '|')
		{
			buf[c] = str[i];
			c++;
			i++;
		}
		buf[c] = 0;

		cgs.duelist2 = atoi ( buf );

		if (str[i])
		{
			c = 0;
			i++;

			while (str[i])
			{
				buf[c] = str[i];
				c++;
				i++;
			}
			buf[c] = 0;

			cgs.duelist3 = atoi(buf);
		}
	}
	else if ( num == CS_CLIENT_DUELHEALTHS ) {	// nmckenzie: DUEL_HEALTH
		SetDuelistHealthsFromConfigString(str);
	}
	else if ( num == CS_LEVEL_START_TIME ) {
		cgs.levelStartTime = atoi( str );
	} else if ( num == CS_VOTE_TIME ) {
		cgs.voteTime = atoi( str );
		cgs.voteModified = qtrue;
	} else if ( num == CS_VOTE_YES ) {
		cgs.voteYes = atoi( str );
		cgs.voteModified = qtrue;
	} else if ( num == CS_VOTE_NO ) {
		cgs.voteNo = atoi( str );
		cgs.voteModified = qtrue;
	} else if ( num == CS_VOTE_STRING ) {
		Q_strncpyz( cgs.voteString, str, sizeof( cgs.voteString ) );
	} else if ( num >= CS_TEAMVOTE_TIME && num <= CS_TEAMVOTE_TIME + 1) {
		cgs.teamVoteTime[num-CS_TEAMVOTE_TIME] = atoi( str );
		cgs.teamVoteModified[num-CS_TEAMVOTE_TIME] = qtrue;
	} else if ( num >= CS_TEAMVOTE_YES && num <= CS_TEAMVOTE_YES + 1) {
		cgs.teamVoteYes[num-CS_TEAMVOTE_YES] = atoi( str );
		cgs.teamVoteModified[num-CS_TEAMVOTE_YES] = qtrue;
	} else if ( num >= CS_TEAMVOTE_NO && num <= CS_TEAMVOTE_NO + 1) {
		cgs.teamVoteNo[num-CS_TEAMVOTE_NO] = atoi( str );
		cgs.teamVoteModified[num-CS_TEAMVOTE_NO] = qtrue;
	} else if ( num >= CS_TEAMVOTE_STRING && num <= CS_TEAMVOTE_STRING + 1) {
		Q_strncpyz( cgs.teamVoteString[num-CS_TEAMVOTE_STRING], str, sizeof( cgs.teamVoteString ) );
	} else if ( num == CS_INTERMISSION ) {
		cg.intermissionStarted = atoi( str );
	} else if ( num >= CS_MODELS && num < CS_MODELS+MAX_MODELS ) {
		char modelName[MAX_QPATH];
		strcpy(modelName, str);
		if (strstr(modelName, ".glm") || modelName[0] == '$')
		{ //Check to see if it has a custom skin attached.
			CG_HandleAppendedSkin(modelName);
			CG_CacheG2AnimInfo(modelName);
		}

		if (modelName[0] != '$' && modelName[0] != '@')
		{ //don't register vehicle names and saber names as models.
			cgs.gameModels[ num-CS_MODELS ] = trap->R_RegisterModel( modelName );
		}
		else
		{
            cgs.gameModels[ num-CS_MODELS ] = 0;
		}
// GHOUL2 Insert start
		/*
	} else if ( num >= CS_CHARSKINS && num < CS_CHARSKINS+MAX_CHARSKINS ) {
		cgs.skins[ num-CS_CHARSKINS ] = trap->R_RegisterSkin( str );
		*/
		//rww - removed and replaced with CS_G2BONES
// Ghoul2 Insert end
	} else if ( num >= CS_SOUNDS && num < CS_SOUNDS+MAX_SOUNDS ) {
		if ( str[0] != '*' ) {	// player specific sounds don't register here
			cgs.gameSounds[ num-CS_SOUNDS] = trap->S_RegisterSound( str );
		}
		else if (str[1] == '$')
		{ //an NPC soundset
			CG_PrecacheNPCSounds(str);
		}
	} else if ( num >= CS_EFFECTS && num < CS_EFFECTS+MAX_FX ) {
		if (str[0] == '*')
		{ //it's a special global weather effect
			CG_ParseWeatherEffect(str);
			cgs.gameEffects[ num-CS_EFFECTS] = 0;
		}
		else
		{
			cgs.gameEffects[ num-CS_EFFECTS] = trap->FX_RegisterEffect( str );
		}
	}
	else if ( num >= CS_SIEGE_STATE && num < CS_SIEGE_STATE+1 )
	{
		if (str[0])
		{
			CG_ParseSiegeState(str);
		}
	}
	else if ( num >= CS_SIEGE_WINTEAM && num < CS_SIEGE_WINTEAM+1 )
	{
		if (str[0])
		{
			cg_siegeWinTeam = atoi(str);
		}
	}
	else if ( num >= CS_SIEGE_OBJECTIVES && num < CS_SIEGE_OBJECTIVES+1 )
	{
		CG_ParseSiegeObjectiveStatus(str);
	}
	else if (num >= CS_SIEGE_TIMEOVERRIDE && num < CS_SIEGE_TIMEOVERRIDE+1)
	{
		cg_beatingSiegeTime = atoi(str);
		CG_SetSiegeTimerCvar ( cg_beatingSiegeTime );
	}
	else if ( num >= CS_PLAYERS && num < CS_PLAYERS+MAX_CLIENTS )
	{
		CG_NewClientInfo( num - CS_PLAYERS, qtrue);
		CG_BuildSpectatorString();
	} else if ( num == CS_FLAGSTATUS ) {
		if( cgs.gametype == GT_CTF || cgs.gametype == GT_CTY ) {
			// format is rb where its red/blue, 0 is at base, 1 is taken, 2 is dropped
			int redflagId = str[0] - '0', blueflagId = str[1] - '0';

			if ( redflagId >= 0 && redflagId < ARRAY_LEN( ctfFlagStatusRemap ) )
				cgs.redflag = ctfFlagStatusRemap[redflagId];

			if ( blueflagId >= 0 && blueflagId < ARRAY_LEN( ctfFlagStatusRemap ) )
				cgs.blueflag = ctfFlagStatusRemap[blueflagId];
		}
	}
	else if ( num == CS_SHADERSTATE ) {
		CG_ShaderStateChanged();
	}
	else if ( num >= CS_LIGHT_STYLES && num < CS_LIGHT_STYLES + (MAX_LIGHT_STYLES * 3))
	{
		CG_SetLightstyle(num - CS_LIGHT_STYLES);
	}

}
Exemple #2
0
void CG_InitSiegeMode( void ) {
	char levelname[MAX_QPATH] = {};
	char btime[1024] = {};
	char teams[2048] = {};
	char teamIcon[MAX_QPATH] = {};
	const char *s;
	int len = 0, i = 0, j = 0;
	siegeClass_t *cl;
	siegeTeam_t *sTeam;
	fileHandle_t f;

	s = CG_ConfigString( CS_SIEGE_STATE );
	if ( s[0] ) {
		CG_ParseSiegeState( s );
	}

	s = CG_ConfigString( CS_SIEGE_WINTEAM );
	if ( s[0] ) {
		cg_siegeWinTeam = atoi( s );
	}

	if ( cgs.gametype == GT_SIEGE ) {
		CG_ParseSiegeObjectiveStatus( CG_ConfigString( CS_SIEGE_OBJECTIVES ) );
		cg_beatingSiegeTime = atoi( CG_ConfigString( CS_SIEGE_TIMEOVERRIDE ) );
		if ( cg_beatingSiegeTime ) {
			CG_SetSiegeTimerCvar( cg_beatingSiegeTime );
		}
	}

	if ( cgs.gametype != GT_SIEGE ) {
		goto failure;
	}

	// grab the .siege file
	Com_sprintf( levelname, sizeof(levelname), "maps/%s.siege", cgs.mapnameClean );

	len = trap->FS_Open( levelname, &f, FS_READ );
	if ( !f || len <= 0 || len >= MAX_SIEGE_INFO_SIZE ) {
		goto failure;
	}

	trap->FS_Read( siege_info, len, f );
	trap->FS_Close( f );

	siege_valid = qtrue;

	if ( BG_SiegeGetValueGroup( siege_info, "Teams", teams ) ) {
		char buf[1024];

		trap->Cvar_VariableStringBuffer( "cg_siegeTeam1", buf, sizeof(buf) );
		if ( buf[0] && Q_stricmp( buf, "none" ) ) {
			Q_strncpyz( team1, buf, sizeof(team1) );
		}
		else {
			BG_SiegeGetPairedValue( teams, "team1", team1 );
		}

		if ( team1[0] == '@' ) {
			// it's a damn stringed reference.
			char b[256];
			trap->SE_GetStringTextString( team1 + 1, b, sizeof(b) );
			trap->Cvar_Set( "cg_siegeTeam1Name", b );
		}
		else {
			trap->Cvar_Set( "cg_siegeTeam1Name", team1 );
		}

		trap->Cvar_VariableStringBuffer( "cg_siegeTeam2", buf, sizeof(buf) );
		if ( buf[0] && Q_stricmp( buf, "none" ) ) {
			Q_strncpyz( team2, buf, sizeof(team2) );
		}
		else {
			BG_SiegeGetPairedValue( teams, "team2", team2 );
		}

		if ( team2[0] == '@' ) {
			// it's a damn stringed reference.
			char b[256];
			trap->SE_GetStringTextString( team2 + 1, b, sizeof(b) );
			trap->Cvar_Set( "cg_siegeTeam2Name", b );
		}
		else {
			trap->Cvar_Set( "cg_siegeTeam2Name", team2 );
		}
	}
	else {
		trap->Error( ERR_DROP, "Siege teams not defined" );
	}

	static char teamInfo[MAX_SIEGE_INFO_SIZE] = {};
	teamInfo[0] = '\0';
	if ( BG_SiegeGetValueGroup( siege_info, team1, teamInfo ) ) {
		if ( BG_SiegeGetPairedValue( teamInfo, "TeamIcon", teamIcon ) )
			trap->Cvar_Set( "team1_icon", teamIcon );

		if ( BG_SiegeGetPairedValue( teamInfo, "Timed", btime ) ) {
			team1Timed = atoi( btime ) * 1000;
			CG_SetSiegeTimerCvar( team1Timed );
		}
		else {
			team1Timed = 0;
		}
	}
	else {
		trap->Error( ERR_DROP, "No team entry for '%s'\n", team1 );
	}

	if ( BG_SiegeGetPairedValue( siege_info, "mapgraphic", teamInfo ) ) {
		trap->Cvar_Set( "siege_mapgraphic", teamInfo );
	}
	else {
		trap->Cvar_Set( "siege_mapgraphic", "gfx/mplevels/siege1_hoth" );
	}

	if ( BG_SiegeGetPairedValue( siege_info, "missionname", teamInfo ) ) {
		trap->Cvar_Set( "siege_missionname", teamInfo );
	}
	else {
		trap->Cvar_Set( "siege_missionname", " " );
	}

	if ( BG_SiegeGetValueGroup( siege_info, team2, teamInfo ) ) {
		if ( BG_SiegeGetPairedValue( teamInfo, "TeamIcon", teamIcon ) ) {
			trap->Cvar_Set( "team2_icon", teamIcon );
		}

		if ( BG_SiegeGetPairedValue( teamInfo, "Timed", btime ) ) {
			team2Timed = atoi( btime ) * 1000;
			CG_SetSiegeTimerCvar( team2Timed );
		}
		else {
			team2Timed = 0;
		}
	}
	else {
		trap->Error( ERR_DROP, "No team entry for '%s'\n", team2 );
	}

	//Load the player class types
	BG_SiegeLoadClasses( NULL );

	if ( !bgNumSiegeClasses ) {
		trap->Error( ERR_DROP, "Couldn't find any player classes for Siege" );
	}

	//Now load the teams since we have class data.
	BG_SiegeLoadTeams();

	if ( !bgNumSiegeTeams ) {
		trap->Error( ERR_DROP, "Couldn't find any player teams for Siege" );
	}

	// Get and set the team themes for each team. This will control which classes can be used on each team.
	if ( BG_SiegeGetValueGroup( siege_info, team1, teamInfo ) ) {
		if ( BG_SiegeGetPairedValue( teamInfo, "UseTeam", btime ) ) {
			BG_SiegeSetTeamTheme( SIEGETEAM_TEAM1, btime );
		}
		if ( BG_SiegeGetPairedValue( teamInfo, "FriendlyShader", btime ) ) {
			cgSiegeTeam1PlShader = trap->R_RegisterShaderNoMip( btime );
		}
		else {
			cgSiegeTeam1PlShader = 0;
		}
	}
	if ( BG_SiegeGetValueGroup( siege_info, team2, teamInfo ) ) {
		if ( BG_SiegeGetPairedValue( teamInfo, "UseTeam", btime ) ) {
			BG_SiegeSetTeamTheme( SIEGETEAM_TEAM2, btime );
		}
		if ( BG_SiegeGetPairedValue( teamInfo, "FriendlyShader", btime ) ) {
			cgSiegeTeam2PlShader = trap->R_RegisterShaderNoMip( btime );
		}
		else {
			cgSiegeTeam2PlShader = 0;
		}
	}

	//Now go through the classes used by the loaded teams and try to precache any forced models or forced skins.
	for ( i = SIEGETEAM_TEAM1; i <= SIEGETEAM_TEAM2; i++ ) {
		sTeam = BG_SiegeFindThemeForTeam( i );

		if ( !sTeam ) {
			continue;
		}

		//Get custom team shaders while we're at it.
		if ( i == SIEGETEAM_TEAM1 )
			cgSiegeTeam1PlShader = sTeam->friendlyShader;
		else if ( i == SIEGETEAM_TEAM2 )
			cgSiegeTeam2PlShader = sTeam->friendlyShader;

		for ( j = 0; j < sTeam->numClasses; j++ ) {
			cl = sTeam->classes[j];

			if ( cl->forcedModel[0] ) {
				// This class has a forced model, so precache it.
				trap->R_RegisterModel( va( "models/players/%s/model.glm", cl->forcedModel ) );

				if ( cl->forcedSkin[0] ) {
					// also has a forced skin, precache it.
					char useSkinName[MAX_QPATH];

					if ( strchr( cl->forcedSkin, '|' ) ) {
						Com_sprintf( useSkinName, sizeof(useSkinName), "models/players/%s/|%s",
							cl->forcedModel, cl->forcedSkin );
					}
					else {
						Com_sprintf( useSkinName, sizeof(useSkinName), "models/players/%s/model_%s.skin",
							cl->forcedModel, cl->forcedSkin );
					}

					trap->R_RegisterSkin( useSkinName );
				}
			}
		}
	}

	//precache saber data for classes that use sabers on both teams
	BG_PrecacheSabersForSiegeTeam( SIEGETEAM_TEAM1 );
	BG_PrecacheSabersForSiegeTeam( SIEGETEAM_TEAM2 );

	CG_PrecachePlayersForSiegeTeam( SIEGETEAM_TEAM1 );
	CG_PrecachePlayersForSiegeTeam( SIEGETEAM_TEAM2 );

	CG_PrecachePlayersForSiegeTeam( SIEGETEAM_TEAM1 );
	CG_PrecachePlayersForSiegeTeam( SIEGETEAM_TEAM2 );

	CG_PrecacheSiegeObjectiveAssetsForTeam( SIEGETEAM_TEAM1 );
	CG_PrecacheSiegeObjectiveAssetsForTeam( SIEGETEAM_TEAM2 );

	return;
failure:
	siege_valid = qfalse;
}