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 ); } } }
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); } } } }