コード例 #1
0
ファイル: cg_saga.cpp プロジェクト: Arcadiaprime/japp
void CG_SiegeObjectiveCompleted( centity_t *ent, int won, int objectivenum ) {
	int myTeam, success = 0;
	static char foundobjective[MAX_SIEGE_INFO_SIZE] = { 0 };
	char teamstr[64], objstr[256], appstring[1024], soundstr[1024];
	playerState_t *ps = NULL;

	//Raz: moved to the heap
	foundobjective[0] = '\0';

	if ( !siege_valid ) {
		trap->Error( ERR_DROP, "Siege data does not exist on client!\n" );
		return;
	}

	ps = cg.snap ? &cg.snap->ps : &cg.predictedPlayerState;

	myTeam = ps->persistant[PERS_TEAM];

	if ( myTeam == TEAM_SPECTATOR )
		return;

	if ( won == SIEGETEAM_TEAM1 )
		Com_sprintf( teamstr, sizeof(teamstr), team1 );
	else
		Com_sprintf( teamstr, sizeof(teamstr), team2 );

	if ( BG_SiegeGetValueGroup( siege_info, teamstr, cgParseObjectives ) ) {
		Com_sprintf( objstr, sizeof(objstr), "Objective%i", objectivenum );

		if ( BG_SiegeGetValueGroup( cgParseObjectives, objstr, foundobjective ) ) {
			if ( myTeam == SIEGETEAM_TEAM1 )
				success = BG_SiegeGetPairedValue( foundobjective, "message_team1", appstring );
			else
				success = BG_SiegeGetPairedValue( foundobjective, "message_team2", appstring );

			if ( success )
				CG_DrawSiegeMessageNonMenu( appstring );

			appstring[0] = '\0';
			soundstr[0] = '\0';

			if ( myTeam == SIEGETEAM_TEAM1 )
				Com_sprintf( teamstr, sizeof(teamstr), "sound_team1" );
			else
				Com_sprintf( teamstr, sizeof(teamstr), "sound_team2" );

			if ( BG_SiegeGetPairedValue( foundobjective, teamstr, appstring ) )
				Com_sprintf( soundstr, sizeof(soundstr), appstring );
			if ( soundstr[0] )
				trap->S_StartLocalSound( trap->S_RegisterSound( soundstr ), CHAN_ANNOUNCER );
		}
	}
}
コード例 #2
0
ファイル: g_dynmusic.c プロジェクト: ForcePush/OJPRPFZ
//loads in the DMS data for this map
void LoadDynamicMusicGroup(char *mapname, char *buffer)
{
	char text[MAX_QPATH];
	char MapMusicGroup[DMS_INFO_SIZE];

	//initialize DMSData
	DMSData.valid = qfalse;
	DMSData.actionMusic.valid = qfalse;
	DMSData.exploreMusic.valid = qfalse;
	DMSData.bossMusic.valid = qfalse;

	BG_SiegeGetValueGroup(buffer, "levelmusic", MapMusicGroup);

	if(!BG_SiegeGetValueGroup(MapMusicGroup, mapname, MapMusicGroup))
	{
		G_Printf("LoadDynamicMusicGroup Error:  Couldn't find DMS entry for this map.\n");
		return;
	}

	if(BG_SiegeGetPairedValue(MapMusicGroup, "uses", text))
	{//this map uses the dynamic music set of another map.  Look for that set
		LoadDynamicMusicGroup( text, buffer );
		return;
	}

	//at this point, we have the dynamic music group for this map, init the
	//DMSData data slot.
	DMSData.valid = qtrue;
	DMSData.dmDebounceTime = -1;
	DMSData.dmBeatTime = 0;
	DMSData.dmState = DM_AUTO;
	DMSData.olddmState = DM_AUTO;

	if(BG_SiegeGetPairedValue(MapMusicGroup, "explore", text))
	{//have explore music for this map
		DMSData.exploreMusic.valid = qtrue;
		LoadDMSSongData(buffer, text, &DMSData.exploreMusic, mapname);
	}

	if(BG_SiegeGetPairedValue(MapMusicGroup, "action", text))
	{//have action music for this map
		DMSData.actionMusic.valid = qtrue;
		LoadDMSSongData(buffer, text, &DMSData.actionMusic, mapname);
	}

	if(BG_SiegeGetPairedValue(MapMusicGroup, "boss", text))
	{//have boss music for this map
		DMSData.bossMusic.valid = qtrue;
		LoadDMSSongData(buffer, text, &DMSData.bossMusic, mapname);
	}

	LoadDMSSongLengths();
}
コード例 #3
0
ファイル: cg_saga.c プロジェクト: ForcePush/OJPRPFZ
void CG_SiegeGetObjectiveDescription(int team, int objective, char *buffer)
{
	char teamstr[1024];
	char objectiveStr[8192];

	buffer[0] = 0; //set to 0 ahead of time in case we fail to find the objective group/name

	if (team == SIEGETEAM_TEAM1)
	{
		Com_sprintf(teamstr, sizeof(teamstr), team1);
	}
	else
	{
		Com_sprintf(teamstr, sizeof(teamstr), team2);
	}

	if (BG_SiegeGetValueGroup(siege_info, teamstr, cgParseObjectives))
	{ //found the team group
		if (BG_SiegeGetValueGroup(cgParseObjectives, va("Objective%i", objective), objectiveStr))
		{ //found the objective group
			//Parse the name right into the buffer.
			BG_SiegeGetPairedValue(objectiveStr, "goalname", buffer);
		}
	}
}
コード例 #4
0
ファイル: cg_saga.c プロジェクト: ForcePush/OJPRPFZ
int CG_SiegeGetObjectiveFinal(int team, int objective )
{
	char finalStr[64];
	char teamstr[1024];
	char objectiveStr[8192];

	if (team == SIEGETEAM_TEAM1)
	{
		Com_sprintf(teamstr, sizeof(teamstr), team1);
	}
	else
	{
		Com_sprintf(teamstr, sizeof(teamstr), team2);
	}

	if (BG_SiegeGetValueGroup(siege_info, teamstr, cgParseObjectives))
	{ //found the team group
		if (BG_SiegeGetValueGroup(cgParseObjectives, va("Objective%i", objective), objectiveStr))
		{ //found the objective group
			//Parse the name right into the buffer.
			BG_SiegeGetPairedValue(objectiveStr, "final", finalStr);
			return (atoi( finalStr ));
		}
	}
	return 0;
}
コード例 #5
0
ファイル: cg_saga.cpp プロジェクト: Arcadiaprime/japp
void CG_SiegeRoundOver( centity_t *ent, int won ) {
	int				myTeam, success = 0;
	char			teamstr[64], appstring[1024], soundstr[1024];
	playerState_t	*ps = NULL;

	if ( !siege_valid ) {
		trap->Error( ERR_DROP, "ERROR: Siege data does not exist on client!\n" );
		return;
	}

	// this should always be true, if it isn't though use the predicted ps as a fallback
	ps = cg.snap ? &cg.snap->ps : &cg.predictedPlayerState;

	myTeam = ps->persistant[PERS_TEAM];

	if ( myTeam == TEAM_SPECTATOR )
		return;

	if ( myTeam == SIEGETEAM_TEAM1 )
		Com_sprintf( teamstr, sizeof(teamstr), team1 );
	else
		Com_sprintf( teamstr, sizeof(teamstr), team2 );

	if ( BG_SiegeGetValueGroup( siege_info, teamstr, cgParseObjectives ) ) {
		if ( won == myTeam )
			success = BG_SiegeGetPairedValue( cgParseObjectives, "wonround", appstring );
		else
			success = BG_SiegeGetPairedValue( cgParseObjectives, "lostround", appstring );

		if ( success )
			CG_DrawSiegeMessage( appstring, 0 );

		appstring[0] = '\0';
		soundstr[0] = '\0';

		if ( myTeam == won )
			Com_sprintf( teamstr, sizeof(teamstr), "roundover_sound_wewon" );
		else
			Com_sprintf( teamstr, sizeof(teamstr), "roundover_sound_welost" );

		if ( BG_SiegeGetPairedValue( cgParseObjectives, teamstr, appstring ) )
			Com_sprintf( soundstr, sizeof(soundstr), appstring );

		if ( soundstr[0] )
			trap->S_StartLocalSound( trap->S_RegisterSound( soundstr ), CHAN_ANNOUNCER );
	}
}
コード例 #6
0
ファイル: g_dynmusic.c プロジェクト: ForcePush/OJPRPFZ
void LoadLengthforSong(char *buffer, DynamicMusicSet_t *song)
{//load in the song lengths for the given DMS song
	char TempLength[MAX_QPATH];
	char token[MAX_QPATH];
	int transNum = song->numTransitions;

	//get length for the primary song

	//grab the token name
	char *tokenpointer = strrchr(song->fileName, '/');
	tokenpointer++;
	strcpy(token, tokenpointer);
	tokenpointer = strrchr(token, '.');
	*tokenpointer = '\0';
	

	BG_SiegeGetPairedValue(buffer, token, TempLength);
	song->fileLength = atoi(TempLength) * 1000;

	//find the song length for the transitions
	for(; transNum > 0; transNum--)
	{
		//grab pointer
		tokenpointer = strrchr(song->Transitions[transNum-1].fileName, '/');
		tokenpointer++;
		strcpy(token, tokenpointer);
		tokenpointer = strrchr(token, '.');
		*tokenpointer = '\0';

        if(BG_SiegeGetPairedValue(buffer, token, TempLength))
		{
			song->Transitions[transNum-1].fileLength = (int) (atof(TempLength) * (float) 1000);
		}
		else
		{//couldn't find this music file's length, use default
			G_Printf("LoadLengthforSong Warning: Couldn't find length for %s.\n", 
				token);
			song->Transitions[transNum-1].fileLength = DMS_MUSICFILE_DEFAULT;
		}
	}


}
コード例 #7
0
ファイル: cg_saga.cpp プロジェクト: Arcadiaprime/japp
int CG_SiegeGetObjectiveFinal( int team, int objective ) {
	char finalStr[64], teamstr[1024], objectiveStr[8192];

	if ( team == SIEGETEAM_TEAM1 )
		Com_sprintf( teamstr, sizeof(teamstr), team1 );
	else
		Com_sprintf( teamstr, sizeof(teamstr), team2 );

	if ( BG_SiegeGetValueGroup( siege_info, teamstr, cgParseObjectives ) ) {
		if ( BG_SiegeGetValueGroup( cgParseObjectives, va( "Objective%i", objective ), objectiveStr ) ) {
			BG_SiegeGetPairedValue( objectiveStr, "final", finalStr );
			return atoi( finalStr );
		}
	}
	return 0;
}
コード例 #8
0
ファイル: cg_saga.c プロジェクト: ForcePush/OJPRPFZ
//Tries to adjust the eye position from the data in cfg file if possible.
void CG_AdjustEyePos (const char *modelName)
{
	//eye position
	char	eyepos[MAX_QPATH];

	if ( true_view_valid )
	{
		
		if( BG_SiegeGetPairedValue(true_view_info, (char*) modelName, eyepos) )
		{
			CG_Printf("True View Eye Adjust Loaded for %s.\n", modelName);
			trap_Cvar_Set( "cg_trueeyeposition", eyepos );
		}
		else
		{//Couldn't find an entry for the desired model.  Not nessicarily a bad thing.
			trap_Cvar_Set( "cg_trueeyeposition", "0" );
		}
	}
	else
	{//The model eye position list is messed up.  Default to 0.0 for the eye position
		trap_Cvar_Set( "cg_trueeyeposition", "0" );
	}

}
コード例 #9
0
ファイル: cg_saga.cpp プロジェクト: Arcadiaprime/japp
void CG_PrecacheSiegeObjectiveAssetsForTeam( int myTeam ) {
	char teamstr[64], objstr[256];
	static char foundobjective[MAX_SIEGE_INFO_SIZE];
	foundobjective[0] = '\0';

	if ( !siege_valid ) {
		trap->Error( ERR_DROP, "Siege data does not exist on client!\n" );
		return;
	}

	if ( myTeam == SIEGETEAM_TEAM1 )
		Com_sprintf( teamstr, sizeof(teamstr), team1 );
	else
		Com_sprintf( teamstr, sizeof(teamstr), team2 );

	if ( BG_SiegeGetValueGroup( siege_info, teamstr, cgParseObjectives ) ) {
		int i;
		for ( i = 1; i < 32; i++ ) {
			// eh, just try 32 I guess
			Com_sprintf( objstr, sizeof(objstr), "Objective%i", i );

			if ( BG_SiegeGetValueGroup( cgParseObjectives, objstr, foundobjective ) ) {
				char str[MAX_QPATH];

				if ( BG_SiegeGetPairedValue( foundobjective, "sound_team1", str ) )
					trap->S_RegisterSound( str );
				if ( BG_SiegeGetPairedValue( foundobjective, "sound_team2", str ) )
					trap->S_RegisterSound( str );
				if ( BG_SiegeGetPairedValue( foundobjective, "objgfx", str ) )
					trap->R_RegisterShaderNoMip( str );
				if ( BG_SiegeGetPairedValue( foundobjective, "mapicon", str ) )
					trap->R_RegisterShaderNoMip( str );
				if ( BG_SiegeGetPairedValue( foundobjective, "litmapicon", str ) )
					trap->R_RegisterShaderNoMip( str );
				if ( BG_SiegeGetPairedValue( foundobjective, "donemapicon", str ) )
					trap->R_RegisterShaderNoMip( str );
			}
			else
				break;
		}
	}
}
コード例 #10
0
ファイル: cg_saga.c プロジェクト: ForcePush/OJPRPFZ
void CG_SiegeRoundOver(centity_t *ent, int won)
{
	int				myTeam;
	char			teamstr[64];
	char			appstring[1024];
	char			soundstr[1024];
	int				success = 0;
	playerState_t	*ps = NULL;

	if (!siege_valid)
	{
		CG_Error("ERROR: Siege data does not exist on client!\n");
		return;
	}

	if (cg.snap)
	{ //this should always be true, if it isn't though use the predicted ps as a fallback
		ps = &cg.snap->ps;
	}
	else
	{
		ps = &cg.predictedPlayerState;
	}

	if (!ps)
	{
		assert(0);
		return;
	}

	myTeam = ps->persistant[PERS_TEAM];

	if (myTeam == TEAM_SPECTATOR)
	{
		return;
	}

	if (myTeam == SIEGETEAM_TEAM1)
	{
		Com_sprintf(teamstr, sizeof(teamstr), team1);
	}
	else
	{
		Com_sprintf(teamstr, sizeof(teamstr), team2);
	}

	if (BG_SiegeGetValueGroup(siege_info, teamstr, cgParseObjectives))
	{
		if (won == myTeam)
		{
			success = BG_SiegeGetPairedValue(cgParseObjectives, "wonround", appstring);
		}
		else
		{
			success = BG_SiegeGetPairedValue(cgParseObjectives, "lostround", appstring);
		}

		if (success)
		{
			CG_DrawSiegeMessage(appstring, 0);
		}

		appstring[0] = 0;
		soundstr[0] = 0;

		if (myTeam == won)
		{
			Com_sprintf(teamstr, sizeof(teamstr), "roundover_sound_wewon");
		}
		else
		{
			Com_sprintf(teamstr, sizeof(teamstr), "roundover_sound_welost");
		}

		if (BG_SiegeGetPairedValue(cgParseObjectives, teamstr, appstring))
		{
			Com_sprintf(soundstr, sizeof(soundstr), appstring);
		}
		/*
		else
		{
			if (myTeam != won)
			{
				Com_sprintf(soundstr, sizeof(soundstr), DEFAULT_LOSE_ROUND);
			}
			else
			{
				Com_sprintf(soundstr, sizeof(soundstr), DEFAULT_WIN_ROUND);
			}
		}
		*/

		if (soundstr[0])
		{
			trap_S_StartLocalSound(trap_S_RegisterSound(soundstr), CHAN_ANNOUNCER);
		}
	}
}
コード例 #11
0
ファイル: cg_saga.c プロジェクト: ForcePush/OJPRPFZ
void CG_ParseSiegeObjectiveStatus(const char *str)
{
	int i = 0;
	int	team = SIEGETEAM_TEAM1;
	char *cvarName;
	char *s;
	int objectiveNum = 0;

	if (!str || !str[0])
	{
		return;
	}

	while (str[i])
	{
		if (str[i] == '|')
		{ //switch over to team2, this is the next section
            team = SIEGETEAM_TEAM2;
			objectiveNum = 0;
		}
		else if (str[i] == '-')
		{
			objectiveNum++;
			i++;

			cvarName = va("team%i_objective%i", team, objectiveNum);
			if (str[i] == '1')
			{ //it's completed
				trap_Cvar_Set(cvarName, "1");
			}
			else
			{ //otherwise assume it is not
				trap_Cvar_Set(cvarName, "0");
			}

			s = CG_SiegeObjectiveBuffer(team, objectiveNum);
			if (s && s[0])
			{ //now set the description and graphic cvars to by read by the menu
				char buffer[8192];

				cvarName = va("team%i_objective%i_longdesc", team, objectiveNum);
				if (BG_SiegeGetPairedValue(s, "objdesc", buffer))
				{
					trap_Cvar_Set(cvarName, buffer);
				}
				else
				{
					trap_Cvar_Set(cvarName, "UNSPECIFIED");
				}

				cvarName = va("team%i_objective%i_gfx", team, objectiveNum);
				if (BG_SiegeGetPairedValue(s, "objgfx", buffer))
				{
					trap_Cvar_Set(cvarName, buffer);
				}
				else
				{
					trap_Cvar_Set(cvarName, "UNSPECIFIED");
				}

				cvarName = va("team%i_objective%i_mapicon", team, objectiveNum);
				if (BG_SiegeGetPairedValue(s, "mapicon", buffer))
				{
					trap_Cvar_Set(cvarName, buffer);
				}
				else
				{
					trap_Cvar_Set(cvarName, "UNSPECIFIED");
				}

				cvarName = va("team%i_objective%i_litmapicon", team, objectiveNum);
				if (BG_SiegeGetPairedValue(s, "litmapicon", buffer))
				{
					trap_Cvar_Set(cvarName, buffer);
				}
				else
				{
					trap_Cvar_Set(cvarName, "UNSPECIFIED");
				}

				cvarName = va("team%i_objective%i_donemapicon", team, objectiveNum);
				if (BG_SiegeGetPairedValue(s, "donemapicon", buffer))
				{
					trap_Cvar_Set(cvarName, buffer);
				}
				else
				{
					trap_Cvar_Set(cvarName, "UNSPECIFIED");
				}

				cvarName = va("team%i_objective%i_mappos", team, objectiveNum);
				if (BG_SiegeGetPairedValue(s, "mappos", buffer))
				{
					trap_Cvar_Set(cvarName, buffer);
				}
				else
				{
					trap_Cvar_Set(cvarName, "0 0 32 32");
				}
			}
		}
		i++;
	}

	if (cg.predictedPlayerState.persistant[PERS_TEAM] != TEAM_SPECTATOR)
	{ //update menu cvars
		CG_SiegeBriefingDisplay(cg.predictedPlayerState.persistant[PERS_TEAM], 1);
	}
}
コード例 #12
0
ファイル: cg_saga.c プロジェクト: ForcePush/OJPRPFZ
void CG_InitSiegeMode(void)
{
	char			levelname[MAX_QPATH];
	char			btime[1024];
	char			teams[2048];
	char			teamInfo[MAX_SIEGE_INFO_SIZE];
	int				len = 0;
	int				i = 0;
	int				j = 0;
	siegeClass_t		*cl;
	siegeTeam_t		*sTeam;
	fileHandle_t	f;
	char			teamIcon[128];

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

	Com_sprintf(levelname, sizeof(levelname), "%s\0", cgs.mapname);

	i = strlen(levelname)-1;

	while (i > 0 && levelname[i] && levelname[i] != '.')
	{
		i--;
	}

	if (!i)
	{
		goto failure;
	}

	levelname[i] = '\0'; //kill the ".bsp"

	Com_sprintf(levelname, sizeof(levelname), "%s.siege\0", levelname); 

	if (!levelname || !levelname[0])
	{
		goto failure;
	}

	len = trap_FS_FOpenFile(levelname, &f, FS_READ);

	if (!f || len >= MAX_SIEGE_INFO_SIZE)
	{
		goto failure;
	}

	trap_FS_Read(siege_info, len, f);

	trap_FS_FCloseFile(f);

	siege_valid = 1;

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

		//[SIEGECVARFIX]
		siege_Cvar_VariableStringBuffer("cg_siegeTeam1", buf, 1024);
		//trap_Cvar_VariableStringBuffer("cg_siegeTeam1", buf, 1024);
		//[SIEGECVARFIX]
		if (buf[0] && Q_stricmp(buf, "none"))
		{
			strcpy(team1, buf);
		}
		else
		{
			BG_SiegeGetPairedValue(teams, "team1", team1);
		}

		if (team1[0] == '@')
		{ //it's a damn stringed reference.
			char b[256];
			trap_SP_GetStringTextString(team1+1, b, 256);
			trap_Cvar_Set("cg_siegeTeam1Name", b);
		}
		else
		{
			trap_Cvar_Set("cg_siegeTeam1Name", team1);
		}

		//[SIEGECVARFIX]
		siege_Cvar_VariableStringBuffer("cg_siegeTeam2", buf, 1024);
		//trap_Cvar_VariableStringBuffer("cg_siegeTeam2", buf, 1024);
		//[/SIEGECVARFIX]
		if (buf[0] && Q_stricmp(buf, "none"))
		{
			strcpy(team2, buf);
		}
		else
		{
			BG_SiegeGetPairedValue(teams, "team2", team2);
		}

		if (team2[0] == '@')
		{ //it's a damn stringed reference.
			char b[256];
			trap_SP_GetStringTextString(team2+1, b, 256);
			trap_Cvar_Set("cg_siegeTeam2Name", b);
		}
		else
		{
			trap_Cvar_Set("cg_siegeTeam2Name", team2);
		}
	}
	else
	{
		CG_Error("Siege teams not defined");
	}

	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
	{
		CG_Error("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
	{
		CG_Error("No team entry for '%s'\n", team2);
	}

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

	if (!bgNumSiegeClasses)
	{ //We didn't find any?!
		CG_Error("Couldn't find any player classes for Siege");
	}

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

	if (!bgNumSiegeTeams)
	{ //React same as with classes.
		CG_Error("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.
	i = SIEGETEAM_TEAM1;

	while (i <= SIEGETEAM_TEAM2)
	{
		j = 0;
		sTeam = BG_SiegeFindThemeForTeam(i);

		if (!sTeam)
		{
			i++;
			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;
		}

		while (j < sTeam->numClasses)
		{
			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;

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

					trap_R_RegisterSkin(useSkinName);
				}
			}
			
			j++;
		}
		i++;
	}

	//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 = 0;
}
コード例 #13
0
ファイル: cg_saga.c プロジェクト: ForcePush/OJPRPFZ
void CG_PrecacheSiegeObjectiveAssetsForTeam(int myTeam)
{
	char			teamstr[64];
	char			objstr[256];
	char			foundobjective[MAX_SIEGE_INFO_SIZE];

	if (!siege_valid)
	{
		CG_Error("Siege data does not exist on client!\n");
		return;
	}

	if (myTeam == SIEGETEAM_TEAM1)
	{
		Com_sprintf(teamstr, sizeof(teamstr), team1);
	}
	else
	{
		Com_sprintf(teamstr, sizeof(teamstr), team2);
	}

	if (BG_SiegeGetValueGroup(siege_info, teamstr, cgParseObjectives))
	{
		int i = 1;
		while (i < 32)
		{ //eh, just try 32 I guess
			Com_sprintf(objstr, sizeof(objstr), "Objective%i", i);

			if (BG_SiegeGetValueGroup(cgParseObjectives, objstr, foundobjective))
			{
				char str[MAX_QPATH];

				if (BG_SiegeGetPairedValue(foundobjective, "sound_team1", str))
				{
					trap_S_RegisterSound(str);
				}
				if (BG_SiegeGetPairedValue(foundobjective, "sound_team2", str))
				{
					trap_S_RegisterSound(str);
				}
				if (BG_SiegeGetPairedValue(foundobjective, "objgfx", str))
				{
					trap_R_RegisterShaderNoMip(str);
				}
				if (BG_SiegeGetPairedValue(foundobjective, "mapicon", str))
				{
					trap_R_RegisterShaderNoMip(str);
				}
				if (BG_SiegeGetPairedValue(foundobjective, "litmapicon", str))
				{
					trap_R_RegisterShaderNoMip(str);
				}
				if (BG_SiegeGetPairedValue(foundobjective, "donemapicon", str))
				{
					trap_R_RegisterShaderNoMip(str);
				}
			}
			else
			{ //no more
				break;
			}
			i++;
		}
	}
}
コード例 #14
0
ファイル: bg_saga.c プロジェクト: Razish/jasdk_modbase
void BG_SiegeParseTeamFile(const char *filename)
{
	fileHandle_t f;
	int len;
	char teamInfo[2048];
	char parseBuf[1024];
	char lookString[256];
	int i = 1;
	qboolean success = qtrue;

	len = trap_FS_FOpenFile(filename, &f, FS_READ);

	if (!f || len >= 2048)
	{
		return;
	}

	trap_FS_Read(teamInfo, len, f);

	trap_FS_FCloseFile(f);

	teamInfo[len] = 0;

	if (BG_SiegeGetPairedValue(teamInfo, "name", parseBuf))
	{
		strcpy(bgSiegeTeams[bgNumSiegeTeams].name, parseBuf);
	}
	else
	{
		Com_Error(ERR_DROP, "Siege team with no name definition");
	}

//I don't entirely like doing things this way but it's the easiest way.
#ifdef CGAME
	if (BG_SiegeGetPairedValue(teamInfo, "FriendlyShader", parseBuf))
	{
		bgSiegeTeams[bgNumSiegeTeams].friendlyShader = trap_R_RegisterShaderNoMip(parseBuf);
	}
#else
	bgSiegeTeams[bgNumSiegeTeams].friendlyShader = 0;
#endif

	bgSiegeTeams[bgNumSiegeTeams].numClasses = 0;

	if (BG_SiegeGetValueGroup(teamInfo, "Classes", teamInfo))
	{
		while (success && i < MAX_SIEGE_CLASSES)
		{ //keep checking for group values named class# up to MAX_SIEGE_CLASSES until we can't find one.
			strcpy(lookString, va("class%i", i));

			success = BG_SiegeGetPairedValue(teamInfo, lookString, parseBuf);

			if (!success)
			{
				break;
			}

			bgSiegeTeams[bgNumSiegeTeams].classes[bgSiegeTeams[bgNumSiegeTeams].numClasses] = BG_SiegeFindClassByName(parseBuf);

			if (!bgSiegeTeams[bgNumSiegeTeams].classes[bgSiegeTeams[bgNumSiegeTeams].numClasses])
			{
				Com_Error(ERR_DROP, "Invalid class specified: '%s'", parseBuf);
			}

			bgSiegeTeams[bgNumSiegeTeams].numClasses++;

			i++;
		}
	}

	if (!bgSiegeTeams[bgNumSiegeTeams].numClasses)
	{
		Com_Error(ERR_DROP, "Team defined with no allowable classes\n");
	}

	//If we get here then it was a success, so increment the team number
	bgNumSiegeTeams++;
}
コード例 #15
0
ファイル: cg_holster.cpp プロジェクト: mehmehsomeone/OpenRP
void CG_LoadHolsterData (clientInfo_t *ci)
{//adjusts the manual holster positional data based on the holster.cfg file associated with the model or simply
	//use the default values

	int				i;
	fileHandle_t	f;
	int				fLen = 0;
	char			fileBuffer[MAX_HOLSTER_INFO_SIZE];
	char			holsterTypeValue[MAX_QPATH];
	char			holsterTypeGroup[MAX_HOLSTER_INFO_SIZE];
	char			*s;
	vec3_t			vectorData;

	InitHolsterData(ci);

	if ( !ci->skinName || !Q_stricmp( "default", ci->skinName ) )
	{//try default holster.cfg first
		fLen = trap_FS_FOpenFile(va("models/players/%s/holster.cfg", ci->modelName), &f, FS_READ);

		if( !f )
		{//no file, use kyle's then.
			fLen = trap_FS_FOpenFile("models/players/kyle/holster.cfg", &f, FS_READ);
		}
	}
	else
	{//use the holster.cfg associated with this skin
		fLen = trap_FS_FOpenFile(va("models/players/%s/holster_%s.cfg", ci->modelName, ci->skinName), &f, FS_READ);
		if ( !f )
		{//fall back to default holster.cfg
			fLen = trap_FS_FOpenFile(va("models/players/%s/holster.cfg", ci->modelName), &f, FS_READ);
		}

		if( !f )
		{//still no dice, use kyle's then.
			fLen = trap_FS_FOpenFile("models/players/kyle/holster.cfg", &f, FS_READ);
		}
	}

	if ( !f || !fLen )
	{//couldn't open file or it was empty, just use the defaults
		return;
	}

	if( fLen >= MAX_HOLSTER_INFO_SIZE )
	{
		CG_Printf("Error: holster.cfg for %s is over the holster.cfg filesize limit.\n", ci->modelName);
		trap_FS_FCloseFile( f );
		return;
	}

	trap_FS_Read(fileBuffer, fLen, f);

	trap_FS_FCloseFile( f );

	s = fileBuffer;

	//parse file
	while( (s = BG_GetNextValueGroup(s, holsterTypeGroup)) != NULL )
	{
		if( !BG_SiegeGetPairedValue(holsterTypeGroup, "holsterType", holsterTypeValue) )
		{//couldn't find holster type in group
			CG_Printf("Error:  The holster.cfg for %s appears to be missing a holsterType in one of its define groups.\n", 
				ci->modelName);
			continue;
		}

		i = GetIDForString(holsterTypeTable, holsterTypeValue);

		if( i == -1 )
		{//bad holster type
			CG_Printf("Error:  The holster.cfg for %s has a bad holsterType in one of the define groups.\n", 
				ci->modelName);
			continue;
		}

		if( BG_SiegeGetPairedValue(holsterTypeGroup, "boneIndex", holsterTypeValue) )
		{//have bone index data for this holster type, use it
			if(!Q_stricmp(holsterTypeValue, "disabled") )
			{//disable the rendering of this holster type on this model
				ci->holsterData[i].boneIndex = HOLSTER_NONE;
			}
			else
			{
				ci->holsterData[i].boneIndex = GetIDForString(holsterBoneTable, holsterTypeValue);
			}
		}

		if( BG_SiegeGetPairedValue(holsterTypeGroup, "posOffset", holsterTypeValue) )
		{//parsing positional offset data
			sscanf (holsterTypeValue, "%f, %f, %f", &vectorData[0], &vectorData[1], &vectorData[2]);
			VectorCopy(vectorData, ci->holsterData[i].posOffset);
				
				//&ci->holsterData[i].posOffset[0], &ci->holsterData[i].posOffset[1], 
				//&ci->holsterData[i].posOffset[2]);
		}

		if( BG_SiegeGetPairedValue(holsterTypeGroup, "angOffset", holsterTypeValue) )
		{//parsing angular offset
			sscanf (holsterTypeValue, "%f, %f, %f", &vectorData[0], &vectorData[1], &vectorData[2]);
			VectorCopy(vectorData, ci->holsterData[i].angOffset);
		}
	}
#ifdef _DEBUG
	//CG_Printf("Holstered Weapon Data Loaded for %s.\n", ci->modelName);
#endif
}
コード例 #16
0
ファイル: g_saga.c プロジェクト: DavidZeise/OpenJK
void InitSiegeMode(void)
{
	vmCvar_t		mapname;
	char			levelname[512];
	char			teamIcon[128];
	char			goalreq[64];
	char			teams[2048];
	static char objective[MAX_SIEGE_INFO_SIZE];
	char			objecStr[8192];
	int				len = 0;
	int				i = 0;
//	int				j = 0;
	int				objectiveNumTeam1 = 0;
	int				objectiveNumTeam2 = 0;
	fileHandle_t	f;

	objective[0] = '\0';

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

	//reset
	SiegeSetCompleteData(0);

	//get pers data in case it existed from last level
	if (g_siegeTeamSwitch.integer)
	{
		trap->SiegePersGet(&g_siegePersistant);
		if (g_siegePersistant.beatingTime)
		{
			trap->SetConfigstring(CS_SIEGE_TIMEOVERRIDE, va("%i", g_siegePersistant.lastTime));
		}
		else
		{
			trap->SetConfigstring(CS_SIEGE_TIMEOVERRIDE, "0");
		}
	}
	else
	{ //hmm, ok, nothing.
		trap->SetConfigstring(CS_SIEGE_TIMEOVERRIDE, "0");
	}

	imperial_goals_completed = 0;
	rebel_goals_completed = 0;

	trap->Cvar_Register( &mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM );

	Com_sprintf(levelname, sizeof(levelname), "maps/%s.siege\0", mapname.string);

	if ( !levelname[0] )
	{
		goto failure;
	}

	len = trap->FS_Open(levelname, &f, FS_READ);

	if (!f || len >= MAX_SIEGE_INFO_SIZE)
	{
		goto failure;
	}

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

	trap->FS_Close(f);

	siege_valid = 1;

	//See if players should be specs or ingame preround
	if (BG_SiegeGetPairedValue(siege_info, "preround_state", teams))
	{
		if (teams[0])
		{
			g_preroundState = atoi(teams);
		}
	}

	if (BG_SiegeGetValueGroup(siege_info, "Teams", teams))
	{
		if (g_siegeTeam1.string[0] && Q_stricmp(g_siegeTeam1.string, "none"))
		{ //check for override
			strcpy(team1, g_siegeTeam1.string);
		}
		else
		{ //otherwise use level default
			BG_SiegeGetPairedValue(teams, "team1", team1);
		}

		if (g_siegeTeam2.string[0] && Q_stricmp(g_siegeTeam2.string, "none"))
		{ //check for override
			strcpy(team2, g_siegeTeam2.string);
		}
		else
		{ //otherwise use level default
			BG_SiegeGetPairedValue(teams, "team2", team2);
		}
	}
	else
	{
		trap->Error( ERR_DROP, "Siege teams not defined" );
	}

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

		if (BG_SiegeGetPairedValue(gParseObjectives, "RequiredObjectives", goalreq))
		{
			rebel_goals_required = atoi(goalreq);
		}
		if (BG_SiegeGetPairedValue(gParseObjectives, "Timed", goalreq))
		{
			rebel_time_limit = atoi(goalreq)*1000;
			if (g_siegeTeamSwitch.integer &&
				g_siegePersistant.beatingTime)
			{
				gRebelCountdown = level.time + g_siegePersistant.lastTime;
			}
			else
			{
				gRebelCountdown = level.time + rebel_time_limit;
			}
		}
		if (BG_SiegeGetPairedValue(gParseObjectives, "attackers", goalreq))
		{
			rebel_attackers = atoi(goalreq);
		}
	}

	if (BG_SiegeGetValueGroup(siege_info, team1, gParseObjectives))
	{

		if (BG_SiegeGetPairedValue(gParseObjectives, "TeamIcon", teamIcon))
		{
			trap->Cvar_Set( "team1_icon", teamIcon);
		}

		if (BG_SiegeGetPairedValue(gParseObjectives, "RequiredObjectives", goalreq))
		{
			imperial_goals_required = atoi(goalreq);
		}
		if (BG_SiegeGetPairedValue(gParseObjectives, "Timed", goalreq))
		{
			if (rebel_time_limit)
			{
				Com_Printf("Tried to set imperial time limit, but there's already a rebel time limit!\nOnly one team can have a time limit.\n");
			}
			else
			{
				imperial_time_limit = atoi(goalreq)*1000;
				if (g_siegeTeamSwitch.integer &&
					g_siegePersistant.beatingTime)
				{
					gImperialCountdown = level.time + g_siegePersistant.lastTime;
				}
				else
				{
					gImperialCountdown = level.time + imperial_time_limit;
				}
			}
		}
		if (BG_SiegeGetPairedValue(gParseObjectives, "attackers", goalreq))
		{
			imperial_attackers = atoi(goalreq);
		}
	}

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

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

	/*
	//We could probably just see what teams are used on this level,
	//then see what classes are used by those teams, and then precache
	//all weapons for said classes. However, I'm just going to do them
	//all for now.
	while (i < bgNumSiegeClasses)
	{
		cl = &bgSiegeClasses[i];
		j = 0;

		while (j < WP_NUM_WEAPONS)
		{
			if (cl->weapons & (1 << j))
			{ //we use this weapon so register it.
				RegisterItem(BG_FindItemForWeapon(j));
			}

			j++;
		}

		i++;
	}
	*/
	//Ok, I'm adding inventory item precaching now, so I'm finally going to optimize this
	//to only do weapons/items for the current teams used on the level.

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

	if (!bgNumSiegeTeams)
	{ //React same as with classes.
		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, gParseObjectives))
	{
		if (BG_SiegeGetPairedValue(gParseObjectives, "UseTeam", goalreq))
		{
			BG_SiegeSetTeamTheme(SIEGETEAM_TEAM1, goalreq);
		}

		//Now count up the objectives for this team.
		i = 1;
		strcpy(objecStr, va("Objective%i", i));
		while (BG_SiegeGetValueGroup(gParseObjectives, objecStr, objective))
		{
			objectiveNumTeam1++;
			i++;
			strcpy(objecStr, va("Objective%i", i));
		}
	}
	if (BG_SiegeGetValueGroup(siege_info, team2, gParseObjectives))
	{
		if (BG_SiegeGetPairedValue(gParseObjectives, "UseTeam", goalreq))
		{
			BG_SiegeSetTeamTheme(SIEGETEAM_TEAM2, goalreq);
		}

		//Now count up the objectives for this team.
		i = 1;
		strcpy(objecStr, va("Objective%i", i));
		while (BG_SiegeGetValueGroup(gParseObjectives, objecStr, objective))
		{
			objectiveNumTeam2++;
			i++;
			strcpy(objecStr, va("Objective%i", i));
		}
	}

	//Set the configstring to show status of all current objectives
	strcpy(gObjectiveCfgStr, "t1");
	while (objectiveNumTeam1 > 0)
	{ //mark them all as not completed since we just initialized
		Q_strcat(gObjectiveCfgStr, 1024, "-0");
		objectiveNumTeam1--;
	}
	//Finished doing team 1's objectives, now do team 2's
	Q_strcat(gObjectiveCfgStr, 1024, "|t2");
	while (objectiveNumTeam2 > 0)
	{
		Q_strcat(gObjectiveCfgStr, 1024, "-0");
		objectiveNumTeam2--;
	}

	//And finally set the actual config string
	trap->SetConfigstring(CS_SIEGE_OBJECTIVES, gObjectiveCfgStr);

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

	G_SiegeRegisterWeaponsAndHoldables(SIEGETEAM_TEAM1);
	G_SiegeRegisterWeaponsAndHoldables(SIEGETEAM_TEAM2);

	return;

failure:
	siege_valid = 0;
}
コード例 #17
0
ファイル: cg_saga.cpp プロジェクト: Arcadiaprime/japp
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;
}
コード例 #18
0
ファイル: cg_saga.cpp プロジェクト: Arcadiaprime/japp
void CG_SiegeBriefingDisplay( int team, qboolean dontShow ) {
	char teamstr[64] = {};
	char briefing[8192] = {};
	char properValue[1024] = {};
	char objectiveDesc[1024] = {};
	int i, useTeam = team;
	qboolean primary = qfalse;

	if ( !siege_valid )
		return;

	if ( team == TEAM_SPECTATOR )
		return;

	if ( team == SIEGETEAM_TEAM1 )
		Com_sprintf( teamstr, sizeof(teamstr), team1 );
	else
		Com_sprintf( teamstr, sizeof(teamstr), team2 );

	if ( useTeam != SIEGETEAM_TEAM1 && useTeam != SIEGETEAM_TEAM2 )
		useTeam = SIEGETEAM_TEAM2;

	trap->Cvar_Set( "siege_primobj_inuse", "0" );

	for ( i = 1; i<16; i++ ) {
		//Get the value for this objective on this team
		//Now set the cvar for the menu to display.

		//primary = (CG_SiegeGetObjectiveFinal(useTeam, i)>-1)?qtrue:qfalse;
		primary = (CG_SiegeGetObjectiveFinal( useTeam, i ) > 0) ? qtrue : qfalse;

		properValue[0] = '\0';
		trap->Cvar_VariableStringBuffer( va( "team%i_objective%i", useTeam, i ), properValue, sizeof(properValue) );
		if ( primary )
			trap->Cvar_Set( "siege_primobj", properValue );
		else
			trap->Cvar_Set( va( "siege_objective%i", i ), properValue );

		//Now set the long desc cvar for the menu to display.
		properValue[0] = '\0';
		trap->Cvar_VariableStringBuffer( va( "team%i_objective%i_longdesc", useTeam, i ), properValue, sizeof(properValue) );
		if ( primary )
			trap->Cvar_Set( "siege_primobj_longdesc", properValue );
		else
			trap->Cvar_Set( va( "siege_objective%i_longdesc", i ), properValue );

		//Now set the gfx cvar for the menu to display.
		properValue[0] = '\0';
		trap->Cvar_VariableStringBuffer( va( "team%i_objective%i_gfx", useTeam, i ), properValue, sizeof(properValue) );
		if ( primary )
			trap->Cvar_Set( "siege_primobj_gfx", properValue );
		else
			trap->Cvar_Set( va( "siege_objective%i_gfx", i ), properValue );

		//Now set the mapicon cvar for the menu to display.
		properValue[0] = '\0';
		trap->Cvar_VariableStringBuffer( va( "team%i_objective%i_mapicon", useTeam, i ), properValue, sizeof(properValue) );
		if ( primary )
			trap->Cvar_Set( "siege_primobj_mapicon", properValue );
		else
			trap->Cvar_Set( va( "siege_objective%i_mapicon", i ), properValue );

		//Now set the mappos cvar for the menu to display.
		properValue[0] = '\0';
		trap->Cvar_VariableStringBuffer( va( "team%i_objective%i_mappos", useTeam, i ), properValue, sizeof(properValue) );
		if ( primary )
			trap->Cvar_Set( "siege_primobj_mappos", properValue );
		else
			trap->Cvar_Set( va( "siege_objective%i_mappos", i ), properValue );

		//Now set the description cvar for the objective
		CG_SiegeGetObjectiveDescription( useTeam, i, objectiveDesc );

		if ( objectiveDesc[0] ) {
			// found a valid objective description
			if ( primary ) {
				trap->Cvar_Set( "siege_primobj_desc", objectiveDesc );
				// this one is marked not in use because it gets primobj
				trap->Cvar_Set( va( "siege_objective%i_inuse", i ), "0" );
				trap->Cvar_Set( "siege_primobj_inuse", "1" );
				trap->Cvar_Set( va( "team%i_objective%i_inuse", useTeam, i ), "1" );
			}
			else {
				trap->Cvar_Set( va( "siege_objective%i_desc", i ), objectiveDesc );
				trap->Cvar_Set( va( "siege_objective%i_inuse", i ), "2" );
				trap->Cvar_Set( va( "team%i_objective%i_inuse", useTeam, i ), "2" );
			}
		}
		else {
			// didn't find one, so set the "inuse" cvar to 0 for the objective and mark it non-complete.
			trap->Cvar_Set( va( "siege_objective%i_inuse", i ), "0" );
			trap->Cvar_Set( va( "siege_objective%i", i ), "0" );
			trap->Cvar_Set( va( "team%i_objective%i_inuse", useTeam, i ), "0" );
			trap->Cvar_Set( va( "team%i_objective%i", useTeam, i ), "0" );
			trap->Cvar_Set( va( "siege_objective%i_mappos", i ), "" );
			trap->Cvar_Set( va( "team%i_objective%i_mappos", useTeam, i ), "" );
			trap->Cvar_Set( va( "siege_objective%i_gfx", i ), "" );
			trap->Cvar_Set( va( "team%i_objective%i_gfx", useTeam, i ), "" );
			trap->Cvar_Set( va( "siege_objective%i_mapicon", i ), "" );
			trap->Cvar_Set( va( "team%i_objective%i_mapicon", useTeam, i ), "" );
		}
	}

	if ( dontShow )
		return;

	if ( BG_SiegeGetValueGroup( siege_info, teamstr, cgParseObjectives ) ) {
		if ( BG_SiegeGetPairedValue( cgParseObjectives, "briefing", briefing ) )
			CG_DrawSiegeMessage( briefing, 1 );
	}
}
コード例 #19
0
ファイル: cg_saga.c プロジェクト: ForcePush/OJPRPFZ
void CG_SiegeBriefingDisplay(int team, int dontshow)
{
	char			teamstr[64];
	char			briefing[8192];
	char			properValue[1024];
	char			objectiveDesc[1024];
	int				i = 1;
	int				useTeam = team;
	qboolean		primary = qfalse;

	if (!siege_valid)
	{
		return;
	}

	if (team == TEAM_SPECTATOR)
	{
		return;
	}

	if (team == SIEGETEAM_TEAM1)
	{
		Com_sprintf(teamstr, sizeof(teamstr), team1);
	}
	else
	{
		Com_sprintf(teamstr, sizeof(teamstr), team2);
	}

	if (useTeam != SIEGETEAM_TEAM1 && useTeam != SIEGETEAM_TEAM2)
	{ //This shouldn't be happening. But just fall back to team 2 anyway.
		useTeam = SIEGETEAM_TEAM2;
	}

	//[SIEGECVARFIX]
	siege_Cvar_Set(va("siege_primobj_inuse"), "0");
	//trap_Cvar_Set(va("siege_primobj_inuse"), "0");
	//[/SIEGECVARFIX]

	while (i < 16)
	{ //do up to 16 objectives I suppose
		//Get the value for this objective on this team
		//Now set the cvar for the menu to display.
		
		//primary = (CG_SiegeGetObjectiveFinal(useTeam, i)>-1)?qtrue:qfalse;
		primary = (CG_SiegeGetObjectiveFinal(useTeam, i)>0)?qtrue:qfalse;

		properValue[0] = 0;
		trap_Cvar_VariableStringBuffer(va("team%i_objective%i", useTeam, i), properValue, 1024);
		if (primary)
		{
			//[SIEGECVARFIX]
			siege_Cvar_Set(va("siege_primobj"), properValue);
			//trap_Cvar_Set(va("siege_primobj"), properValue);
			//[/SIEGECVARFIX]
		}
		else
		{
			//[SIEGECVARFIX]
			siege_Cvar_Set(va("siege_objective%i", i), properValue);
			//trap_Cvar_Set(va("siege_objective%i", i), properValue);
			//[/SIEGECVARFIX]
		}

		//Now set the long desc cvar for the menu to display.
		properValue[0] = 0;
		trap_Cvar_VariableStringBuffer(va("team%i_objective%i_longdesc", useTeam, i), properValue, 1024);
		if (primary)
		{
			//[SIEGECVARFIX]
			siege_Cvar_Set(va("siege_primobj_longdesc"), properValue);
			//trap_Cvar_Set(va("siege_primobj_longdesc"), properValue);
			//[/SIEGECVARFIX]
		}
		else
		{
			//[SIEGECVARFIX]
			siege_Cvar_Set(va("siege_objective%i_longdesc", i), properValue);
			//trap_Cvar_Set(va("siege_objective%i_longdesc", i), properValue);
			//[/SIEGECVARFIX]
		}

		//Now set the gfx cvar for the menu to display.
		properValue[0] = 0;
		trap_Cvar_VariableStringBuffer(va("team%i_objective%i_gfx", useTeam, i), properValue, 1024);
		if (primary)
		{
			//[SIEGECVARFIX]
			siege_Cvar_Set(va("siege_primobj_gfx"), properValue);
			//trap_Cvar_Set(va("siege_primobj_gfx"), properValue);
			//[/SIEGECVARFIX]
		}
		else
		{
			//[SIEGECVARFIX]
			siege_Cvar_Set(va("siege_objective%i_gfx", i), properValue);
			//trap_Cvar_Set(va("siege_objective%i_gfx", i), properValue);
			//[/SIEGECVARFIX]
		}

		//Now set the mapicon cvar for the menu to display.
		properValue[0] = 0;
		trap_Cvar_VariableStringBuffer(va("team%i_objective%i_mapicon", useTeam, i), properValue, 1024);
		if (primary)
		{
			//[SIEGECVARFIX]
			siege_Cvar_Set(va("siege_primobj_mapicon"), properValue);
			//trap_Cvar_Set(va("siege_primobj_mapicon"), properValue);
			//[/SIEGECVARFIX]
		}
		else
		{
			//[SIEGECVARFIX]
			siege_Cvar_Set(va("siege_objective%i_mapicon", i), properValue);
			//trap_Cvar_Set(va("siege_objective%i_mapicon", i), properValue);
			//[/SIEGECVARFIX]
		}

		//Now set the mappos cvar for the menu to display.
		properValue[0] = 0;
		trap_Cvar_VariableStringBuffer(va("team%i_objective%i_mappos", useTeam, i), properValue, 1024);
		if (primary)
		{
			//[SIEGECVARFIX]
			siege_Cvar_Set(va("siege_primobj_mappos"), properValue);
			//trap_Cvar_Set(va("siege_primobj_mappos"), properValue);
			//[/SIEGECVARFIX]
		}
		else
		{
			//[SIEGECVARFIX]
			siege_Cvar_Set(va("siege_objective%i_mappos", i), properValue);
			//trap_Cvar_Set(va("siege_objective%i_mappos", i), properValue);
			//[/SIEGECVARFIX]
		}

		//Now set the description cvar for the objective
		CG_SiegeGetObjectiveDescription(useTeam, i, objectiveDesc);

		if (objectiveDesc[0])
		{ //found a valid objective description
			if ( primary )
			{
				//[SIEGECVARFIX]
				siege_Cvar_Set(va("siege_primobj_desc"), objectiveDesc);
				//this one is marked not in use because it gets primobj
				siege_Cvar_Set(va("siege_objective%i_inuse", i), "0");
				siege_Cvar_Set(va("siege_primobj_inuse"), "1");
				//trap_Cvar_Set(va("siege_primobj_desc"), objectiveDesc);
				////this one is marked not in use because it gets primobj
				//trap_Cvar_Set(va("siege_objective%i_inuse", i), "0");
				//trap_Cvar_Set(va("siege_primobj_inuse"), "1");
				//[/SIEGECVARFIX]

				trap_Cvar_Set(va("team%i_objective%i_inuse", useTeam, i), "1");

			}
			else
			{
				//[SIEGECVARFIX]
				siege_Cvar_Set(va("siege_objective%i_desc", i), objectiveDesc);
				siege_Cvar_Set(va("siege_objective%i_inuse", i), "2");
				//trap_Cvar_Set(va("siege_objective%i_desc", i), objectiveDesc);
				//trap_Cvar_Set(va("siege_objective%i_inuse", i), "2");
				//[/SIEGECVARFIX]
				trap_Cvar_Set(va("team%i_objective%i_inuse", useTeam, i), "2");

			}
		}
		//[SIEGECVARFIX]
		else
		{ //didn't find one, so set the "inuse" cvar to 0 for the objective and mark it non-complete.
		  	properValue[0] = 0;
			trap_Cvar_VariableStringBuffer(va("team%i_objective%i", useTeam, i), properValue, 1024);
			if(properValue[0]) {
				//siege_Cvar_Set(va("siege_objective%i_inuse", i), "0");
				//siege_Cvar_Set(va("siege_objective%i", i), "0");
				trap_Cvar_Set(va("team%i_objective%i_inuse", useTeam, i), "0");
				trap_Cvar_Set(va("team%i_objective%i", useTeam, i), "0");
	
				//siege_Cvar_Set(va("siege_objective%i_mappos", i), "");
				trap_Cvar_Set(va("team%i_objective%i_mappos", useTeam, i), "");
				//siege_Cvar_Set(va("siege_objective%i_gfx", i), "");
				trap_Cvar_Set(va("team%i_objective%i_gfx", useTeam, i), "");
				//siege_Cvar_Set(va("siege_objective%i_mapicon", i), "");
				trap_Cvar_Set(va("team%i_objective%i_mapicon", useTeam, i), "");
			} else break;
		}
		/*else
		{ //didn't find one, so set the "inuse" cvar to 0 for the objective and mark it non-complete.
			trap_Cvar_Set(va("siege_objective%i_inuse", i), "0");
			trap_Cvar_Set(va("siege_objective%i", i), "0");
			trap_Cvar_Set(va("team%i_objective%i_inuse", useTeam, i), "0");
			trap_Cvar_Set(va("team%i_objective%i", useTeam, i), "0");

			trap_Cvar_Set(va("siege_objective%i_mappos", i), "");
			trap_Cvar_Set(va("team%i_objective%i_mappos", useTeam, i), "");
			trap_Cvar_Set(va("siege_objective%i_gfx", i), "");
			trap_Cvar_Set(va("team%i_objective%i_gfx", useTeam, i), "");
			trap_Cvar_Set(va("siege_objective%i_mapicon", i), "");
			trap_Cvar_Set(va("team%i_objective%i_mapicon", useTeam, i), "");
		}*/
		//[/SIEGECVARFIX]

		i++;
	}

	if (dontshow)
	{
		return;
	}

	if (BG_SiegeGetValueGroup(siege_info, teamstr, cgParseObjectives))
	{
		if (BG_SiegeGetPairedValue(cgParseObjectives, "briefing", briefing))
		{
			CG_DrawSiegeMessage(briefing, 1);
		}
	}
}
コード例 #20
0
ファイル: g_dynmusic.c プロジェクト: ForcePush/OJPRPFZ
void LoadDMSSongData(char *buffer, char *song, DynamicMusicSet_t *songData, char *mapname)
{
	char SongGroup[DMS_INFO_SIZE];
	char *transition;		//pointer used to advance the checks for transitions
	char transitionGroup[DMS_INFO_SIZE];
	char Value[MAX_QPATH];
	int numTransitions = 0;
	int numExits = 0;						

	BG_SiegeGetValueGroup(buffer, "musicfiles", SongGroup);

	//find our specific song
	if(!BG_SiegeGetValueGroup(SongGroup, song, SongGroup))
	{
		G_Printf("LoadDMSSongData Error: Couldn't find song data for DMS song %s.\n",
			song);
		return;
	}

	//convert/store the name of the music file
	strcpy(songData->fileName, va("music/%s/%s.mp3", mapname, song));	

	songData->numTransitions = 0;	//init the struct's number of transitions.

	//start loading in transition data
	transition = strstr(SongGroup, "exit");
	while(transition)
	{//still have a transition file to add

		if(numTransitions >= MAX_DMS_TRANSITIONS)
		{//too many transitions!
			G_Printf("LoadDMSSongData Error:  Too many transitions found.\n");
			return;
		}

		//setting up the new transition data slot
		songData->Transitions[numTransitions].numExitPoints = 0;

		//grab this transition group
		BG_SiegeGetValueGroup(transition, "exit", transitionGroup);

		//find transition file name
		BG_SiegeGetPairedValue(transitionGroup, "nextfile", Value);
		strcpy(songData->Transitions[numTransitions].fileName, 
			va("music/%s/%s.mp3", mapname, Value));

		//load in exit points for this transition file
		while(BG_SiegeGetPairedValue(transitionGroup, va("time%i", numExits), Value))
		{
			if(numExits >= MAX_DMS_EXITPOINTS)
			{//too many transitions!
				G_Printf("LoadDMSSongData Error:  Too many transitions found.\n");
				return;
			}

			songData->Transitions[numTransitions].exitPoints[numExits] 
			= atoi(Value) * 1000;

			numExits++;
			songData->Transitions[numTransitions].numExitPoints++;
		}
	
		//increase the number of transitions in the songData
		songData->numTransitions++;

		numTransitions++;
		numExits = 0;

		//advance the transition pointer pass the current exit data group
		transition += 4;
		transition = strstr(transition, "exit");
	}
}
コード例 #21
0
ファイル: bg_saga.c プロジェクト: Razish/jasdk_modbase
void BG_SiegeParseClassFile(const char *filename, siegeClassDesc_t *descBuffer)
{
	fileHandle_t f;
	int len;
	int i;
	char classInfo[4096];
	char parseBuf[4096];

	len = trap_FS_FOpenFile(filename, &f, FS_READ);

	if (!f || len >= 4096)
	{
		return;
	}

	trap_FS_Read(classInfo, len, f);

	trap_FS_FCloseFile(f);

	classInfo[len] = 0;

	//first get the description if we have a buffer for it
	if (descBuffer)
	{
		if (!BG_SiegeGetPairedValue(classInfo, "description", descBuffer->desc))
		{
			strcpy(descBuffer->desc, "DESCRIPTION UNAVAILABLE");
		}

		//Hit this assert?  Memory has already been trashed.  Increase
		//SIEGE_CLASS_DESC_LEN.
		assert(strlen(descBuffer->desc) < SIEGE_CLASS_DESC_LEN);
	}

	BG_SiegeGetValueGroup(classInfo, "ClassInfo", classInfo);

	//Parse name
	if (BG_SiegeGetPairedValue(classInfo, "name", parseBuf))
	{
		strcpy(bgSiegeClasses[bgNumSiegeClasses].name, parseBuf);
	}
	else
	{
		Com_Error(ERR_DROP, "Siege class without name entry");
	}

	//Parse forced model
	if (BG_SiegeGetPairedValue(classInfo, "model", parseBuf))
	{
		strcpy(bgSiegeClasses[bgNumSiegeClasses].forcedModel, parseBuf);
	}
	else
	{ //It's ok if there isn't one, it's optional.
		bgSiegeClasses[bgNumSiegeClasses].forcedModel[0] = 0;
	}

	//Parse forced skin
	if (BG_SiegeGetPairedValue(classInfo, "skin", parseBuf))
	{
		strcpy(bgSiegeClasses[bgNumSiegeClasses].forcedSkin, parseBuf);
	}
	else
	{ //It's ok if there isn't one, it's optional.
		bgSiegeClasses[bgNumSiegeClasses].forcedSkin[0] = 0;
	}

	//Parse first saber
	if (BG_SiegeGetPairedValue(classInfo, "saber1", parseBuf))
	{
		strcpy(bgSiegeClasses[bgNumSiegeClasses].saber1, parseBuf);
	}
	else
	{ //It's ok if there isn't one, it's optional.
		bgSiegeClasses[bgNumSiegeClasses].saber1[0] = 0;
	}

	//Parse second saber
	if (BG_SiegeGetPairedValue(classInfo, "saber2", parseBuf))
	{
		strcpy(bgSiegeClasses[bgNumSiegeClasses].saber2, parseBuf);
	}
	else
	{ //It's ok if there isn't one, it's optional.
		bgSiegeClasses[bgNumSiegeClasses].saber2[0] = 0;
	}

	//Parse forced saber stance
	if (BG_SiegeGetPairedValue(classInfo, "saberstyle", parseBuf))
	{
		bgSiegeClasses[bgNumSiegeClasses].saberStance = BG_SiegeTranslateGenericTable(parseBuf, StanceTable, qtrue);
	}
	else
	{ //It's ok if there isn't one, it's optional.
		bgSiegeClasses[bgNumSiegeClasses].saberStance = 0;
	}

	//Parse forced saber color
	if (BG_SiegeGetPairedValue(classInfo, "sabercolor", parseBuf))
	{
		bgSiegeClasses[bgNumSiegeClasses].forcedSaberColor = atoi(parseBuf);
		bgSiegeClasses[bgNumSiegeClasses].hasForcedSaberColor = qtrue;
	}
	else
	{ //It's ok if there isn't one, it's optional.
		bgSiegeClasses[bgNumSiegeClasses].hasForcedSaberColor = qfalse;
	}

	//Parse forced saber2 color
	if (BG_SiegeGetPairedValue(classInfo, "saber2color", parseBuf))
	{
		bgSiegeClasses[bgNumSiegeClasses].forcedSaber2Color = atoi(parseBuf);
		bgSiegeClasses[bgNumSiegeClasses].hasForcedSaber2Color = qtrue;
	}
	else
	{ //It's ok if there isn't one, it's optional.
		bgSiegeClasses[bgNumSiegeClasses].hasForcedSaber2Color = qfalse;
	}

	//Parse weapons
	if (BG_SiegeGetPairedValue(classInfo, "weapons", parseBuf))
	{
		bgSiegeClasses[bgNumSiegeClasses].weapons = BG_SiegeTranslateGenericTable(parseBuf, WPTable, qtrue);
	}
	else
	{
		Com_Error(ERR_DROP, "Siege class without weapons entry");
	}

	if (!(bgSiegeClasses[bgNumSiegeClasses].weapons & (1 << WP_SABER)))
	{ //make sure it has melee if there's no saber
		bgSiegeClasses[bgNumSiegeClasses].weapons |= (1 << WP_MELEE);

		//always give them this too if they are not a saber user
		//bgSiegeClasses[bgNumSiegeClasses].weapons |= (1 << WP_BRYAR_PISTOL);
	}

	//Parse forcepowers
	if (BG_SiegeGetPairedValue(classInfo, "forcepowers", parseBuf))
	{
		BG_SiegeTranslateForcePowers(parseBuf, &bgSiegeClasses[bgNumSiegeClasses]);
	}
	else
	{ //fine, clear out the powers.
		i = 0;
		while (i < NUM_FORCE_POWERS)
		{
			bgSiegeClasses[bgNumSiegeClasses].forcePowerLevels[i] = 0;
			i++;
		}
	}

	//Parse classflags
	if (BG_SiegeGetPairedValue(classInfo, "classflags", parseBuf))
	{
		bgSiegeClasses[bgNumSiegeClasses].classflags = BG_SiegeTranslateGenericTable(parseBuf, bgSiegeClassFlagNames, qtrue);
	}
	else
	{ //fine, we'll 0 it.
		bgSiegeClasses[bgNumSiegeClasses].classflags = 0;
	}

	//Parse maxhealth
	if (BG_SiegeGetPairedValue(classInfo, "maxhealth", parseBuf))
	{
		bgSiegeClasses[bgNumSiegeClasses].maxhealth = atoi(parseBuf);
	}
	else
	{ //It's alright, just default to 100 then.
		bgSiegeClasses[bgNumSiegeClasses].maxhealth = 100;
	}

	//Parse starthealth
	if (BG_SiegeGetPairedValue(classInfo, "starthealth", parseBuf))
	{
		bgSiegeClasses[bgNumSiegeClasses].starthealth = atoi(parseBuf);
	}
	else
	{ //It's alright, just default to 100 then.
		bgSiegeClasses[bgNumSiegeClasses].starthealth = bgSiegeClasses[bgNumSiegeClasses].maxhealth;
	}


	//Parse startarmor
	if (BG_SiegeGetPairedValue(classInfo, "maxarmor", parseBuf))
	{
		bgSiegeClasses[bgNumSiegeClasses].maxarmor = atoi(parseBuf);
	}
	else
	{ //It's alright, just default to 0 then.
		bgSiegeClasses[bgNumSiegeClasses].maxarmor = 0;
	}

	//Parse startarmor
	if (BG_SiegeGetPairedValue(classInfo, "startarmor", parseBuf))
	{
		bgSiegeClasses[bgNumSiegeClasses].startarmor = atoi(parseBuf);
		if (!bgSiegeClasses[bgNumSiegeClasses].maxarmor)
		{ //if they didn't specify a damn max armor then use this.
			bgSiegeClasses[bgNumSiegeClasses].maxarmor = bgSiegeClasses[bgNumSiegeClasses].startarmor;
		}
	}
	else
	{ //default to maxarmor.
		bgSiegeClasses[bgNumSiegeClasses].startarmor = bgSiegeClasses[bgNumSiegeClasses].maxarmor;
	}

	//Parse speed (this is a multiplier value)
	if (BG_SiegeGetPairedValue(classInfo, "speed", parseBuf))
	{
		bgSiegeClasses[bgNumSiegeClasses].speed = atof(parseBuf);
	}
	else
	{ //It's alright, just default to 1 then.
		bgSiegeClasses[bgNumSiegeClasses].speed = 1.0f;
	}

	//Parse shader for ui to use
	if (BG_SiegeGetPairedValue(classInfo, "uishader", parseBuf))
	{
#ifdef QAGAME
		bgSiegeClasses[bgNumSiegeClasses].uiPortraitShader = 0;
		memset(bgSiegeClasses[bgNumSiegeClasses].uiPortrait,0,sizeof(bgSiegeClasses[bgNumSiegeClasses].uiPortrait));
#elif defined CGAME
		bgSiegeClasses[bgNumSiegeClasses].uiPortraitShader = 0;
		memset(bgSiegeClasses[bgNumSiegeClasses].uiPortrait,0,sizeof(bgSiegeClasses[bgNumSiegeClasses].uiPortrait));
#else //ui
		bgSiegeClasses[bgNumSiegeClasses].uiPortraitShader = trap_R_RegisterShaderNoMip(parseBuf);
		memcpy(bgSiegeClasses[bgNumSiegeClasses].uiPortrait,parseBuf,sizeof(bgSiegeClasses[bgNumSiegeClasses].uiPortrait));
#endif
	}
	else
	{ //I guess this is an essential.. we don't want to render bad shaders or anything.
		Com_Error(ERR_DROP, "Siege class without uishader entry");
	}

	//Parse shader for ui to use
	if (BG_SiegeGetPairedValue(classInfo, "class_shader", parseBuf))
	{
#ifdef QAGAME
		bgSiegeClasses[bgNumSiegeClasses].classShader = 0;
#else //cgame, ui
		bgSiegeClasses[bgNumSiegeClasses].classShader = trap_R_RegisterShaderNoMip(parseBuf);
		assert( bgSiegeClasses[bgNumSiegeClasses].classShader );
		if ( !bgSiegeClasses[bgNumSiegeClasses].classShader )
		{
			//Com_Error( ERR_DROP, "ERROR: could not find class_shader %s for class %s\n", parseBuf, bgSiegeClasses[bgNumSiegeClasses].name );
			Com_Printf( "ERROR: could not find class_shader %s for class %s\n", parseBuf, bgSiegeClasses[bgNumSiegeClasses].name );
		}
		// A very hacky way to determine class . . . 
		else
#endif
		{
			// Find the base player class based on the icon name - very bad, I know.
			int titleLength,i,arrayTitleLength;
			char *holdBuf;

			titleLength = strlen(parseBuf);
			for (i=0;i<SPC_MAX;i++)
			{
				// Back up 
				arrayTitleLength = strlen(classTitles[i]);
				if (arrayTitleLength>titleLength)	// Too long
				{
					break;
				}

				holdBuf = parseBuf + ( titleLength - arrayTitleLength);
				if (!strcmp(holdBuf,classTitles[i]))
				{
					bgSiegeClasses[bgNumSiegeClasses].playerClass = i;
					break;
				}
			}

			// In case the icon name doesn't match up
			if (i>=SPC_MAX)
			{
				bgSiegeClasses[bgNumSiegeClasses].playerClass = SPC_INFANTRY;
			}
		}
	}
	else
	{ //No entry!  Bad bad bad
		//Com_Error( ERR_DROP, "ERROR: no class_shader defined for class %s\n", bgSiegeClasses[bgNumSiegeClasses].name );
		Com_Printf( "ERROR: no class_shader defined for class %s\n", bgSiegeClasses[bgNumSiegeClasses].name );
	}

	//Parse holdable items to use
	if (BG_SiegeGetPairedValue(classInfo, "holdables", parseBuf))
	{
		bgSiegeClasses[bgNumSiegeClasses].invenItems = BG_SiegeTranslateGenericTable(parseBuf, HoldableTable, qtrue);
	}
	else
	{ //Just don't start out with any then.
		bgSiegeClasses[bgNumSiegeClasses].invenItems = 0;
	}

	//Parse powerups to use
	if (BG_SiegeGetPairedValue(classInfo, "powerups", parseBuf))
	{
		bgSiegeClasses[bgNumSiegeClasses].powerups = BG_SiegeTranslateGenericTable(parseBuf, PowerupTable, qtrue);
	}
	else
	{ //Just don't start out with any then.
		bgSiegeClasses[bgNumSiegeClasses].powerups = 0;
	}

	//A successful read.
	bgNumSiegeClasses++;
}
コード例 #22
0
ファイル: cg_saga.c プロジェクト: ForcePush/OJPRPFZ
void CG_SiegeObjectiveCompleted(centity_t *ent, int won, int objectivenum)
{
	int				myTeam;
	char			teamstr[64];
	char			objstr[256];
	char			foundobjective[MAX_SIEGE_INFO_SIZE];
	char			appstring[1024];
	char			soundstr[1024];
	int				success = 0;
	playerState_t	*ps = NULL;

	if (!siege_valid)
	{
		CG_Error("Siege data does not exist on client!\n");
		return;
	}

	if (cg.snap)
	{ //this should always be true, if it isn't though use the predicted ps as a fallback
		ps = &cg.snap->ps;
	}
	else
	{
		ps = &cg.predictedPlayerState;
	}

	if (!ps)
	{
		assert(0);
		return;
	}

	myTeam = ps->persistant[PERS_TEAM];

	if (myTeam == TEAM_SPECTATOR)
	{
		return;
	}

	if (won == SIEGETEAM_TEAM1)
	{
		Com_sprintf(teamstr, sizeof(teamstr), team1);
	}
	else
	{
		Com_sprintf(teamstr, sizeof(teamstr), team2);
	}

	if (BG_SiegeGetValueGroup(siege_info, teamstr, cgParseObjectives))
	{
		Com_sprintf(objstr, sizeof(objstr), "Objective%i", objectivenum);

		if (BG_SiegeGetValueGroup(cgParseObjectives, objstr, foundobjective))
		{
			if (myTeam == SIEGETEAM_TEAM1)
			{
				success = BG_SiegeGetPairedValue(foundobjective, "message_team1", appstring);
			}
			else
			{
				success = BG_SiegeGetPairedValue(foundobjective, "message_team2", appstring);
			}

			if (success)
			{
				CG_DrawSiegeMessageNonMenu(appstring);
			}

			appstring[0] = 0;
			soundstr[0] = 0;

			if (myTeam == SIEGETEAM_TEAM1)
			{
				Com_sprintf(teamstr, sizeof(teamstr), "sound_team1");
			}
			else
			{
				Com_sprintf(teamstr, sizeof(teamstr), "sound_team2");
			}

			if (BG_SiegeGetPairedValue(foundobjective, teamstr, appstring))
			{
				Com_sprintf(soundstr, sizeof(soundstr), appstring);
			}
			/*
			else
			{
				if (myTeam != won)
				{
					Com_sprintf(soundstr, sizeof(soundstr), DEFAULT_LOSE_OBJECTIVE);
				}
				else
				{
					Com_sprintf(soundstr, sizeof(soundstr), DEFAULT_WIN_OBJECTIVE);
				}
			}
			*/

			if (soundstr[0])
			{
				trap_S_StartLocalSound(trap_S_RegisterSound(soundstr), CHAN_ANNOUNCER);
			}
		}
	}
}