codemp/game/g_arenas.c File Reference

#include "g_local.h"

Go to the source code of this file.

Functions

void UpdateTournamentInfo (void)

Variables

gentity_tpodium1
gentity_tpodium2
gentity_tpodium3


Function Documentation

void UpdateTournamentInfo void   ) 
 

Definition at line 20 of file g_arenas.c.

References gclient_s::accuracy_hits, gclient_s::accuracy_shots, CalculateRanks(), gentity_s::client, level_locals_t::clients, Com_sprintf(), EXEC_APPEND, g_entities, g_gametype, gentity_t, GT_CTF, vmCvar_t::integer, gentity_s::inuse, level, MAX_STRING_CHARS, level_locals_t::maxclients, NULL, level_locals_t::numNonSpectatorClients, PERS_ASSIST_COUNT, PERS_CAPTURES, PERS_DEFEND_COUNT, PERS_EXCELLENT_COUNT, PERS_GAUNTLET_FRAG_COUNT, PERS_IMPRESSIVE_COUNT, PERS_KILLED, PERS_RANK, PERS_SCORE, playerState_s::persistant, gclient_s::ps, qboolean, qfalse, qtrue, gentity_s::r, gclient_s::sess, clientSession_t::sessionTeam, level_locals_t::sortedClients, strcat(), strlen(), SVF_BOT, entityShared_t::svFlags, TEAM_BLUE, TEAM_RED, TEAM_SPECTATOR, level_locals_t::teamScores, level_locals_t::time, and trap_SendConsoleCommand().

00020                                   {
00021         int                     i;
00022         gentity_t       *player;
00023         int                     playerClientNum;
00024         int                     n, accuracy, perfect,   msglen;
00025         int                     buflen;
00026         int                     score1, score2;
00027         qboolean        won;
00028         char            buf[32];
00029         char            msg[MAX_STRING_CHARS];
00030 
00031         // find the real player
00032         player = NULL;
00033         for (i = 0; i < level.maxclients; i++ ) {
00034                 player = &g_entities[i];
00035                 if ( !player->inuse ) {
00036                         continue;
00037                 }
00038                 if ( !( player->r.svFlags & SVF_BOT ) ) {
00039                         break;
00040                 }
00041         }
00042         // this should never happen!
00043         if ( !player || i == level.maxclients ) {
00044                 return;
00045         }
00046         playerClientNum = i;
00047 
00048         CalculateRanks();
00049 
00050         if ( level.clients[playerClientNum].sess.sessionTeam == TEAM_SPECTATOR ) {
00051                 Com_sprintf( msg, sizeof(msg), "postgame %i %i 0 0 0 0 0 0 0 0 0 0 0", level.numNonSpectatorClients, playerClientNum );
00052         }
00053         else {
00054                 if( player->client->accuracy_shots ) {
00055                         accuracy = player->client->accuracy_hits * 100 / player->client->accuracy_shots;
00056                 }
00057                 else {
00058                         accuracy = 0;
00059                 }
00060                 won = qfalse;
00061                 if (g_gametype.integer >= GT_CTF) {
00062                         score1 = level.teamScores[TEAM_RED];
00063                         score2 = level.teamScores[TEAM_BLUE];
00064                         if (level.clients[playerClientNum].sess.sessionTeam     == TEAM_RED) {
00065                                 won = (level.teamScores[TEAM_RED] > level.teamScores[TEAM_BLUE]);
00066                         } else {
00067                                 won = (level.teamScores[TEAM_BLUE] > level.teamScores[TEAM_RED]);
00068                         }
00069                 } else {
00070                         if (&level.clients[playerClientNum] == &level.clients[ level.sortedClients[0] ]) {
00071                                 won = qtrue;
00072                                 score1 = level.clients[ level.sortedClients[0] ].ps.persistant[PERS_SCORE];
00073                                 score2 = level.clients[ level.sortedClients[1] ].ps.persistant[PERS_SCORE];
00074                         } else {
00075                                 score2 = level.clients[ level.sortedClients[0] ].ps.persistant[PERS_SCORE];
00076                                 score1 = level.clients[ level.sortedClients[1] ].ps.persistant[PERS_SCORE];
00077                         }
00078                 }
00079                 if (won && player->client->ps.persistant[PERS_KILLED] == 0) {
00080                         perfect = 1;
00081                 } else {
00082                         perfect = 0;
00083                 }
00084                 Com_sprintf( msg, sizeof(msg), "postgame %i %i %i %i %i %i %i %i %i %i %i %i %i %i", level.numNonSpectatorClients, playerClientNum, accuracy,
00085                         player->client->ps.persistant[PERS_IMPRESSIVE_COUNT], player->client->ps.persistant[PERS_EXCELLENT_COUNT],player->client->ps.persistant[PERS_DEFEND_COUNT],
00086                         player->client->ps.persistant[PERS_ASSIST_COUNT], player->client->ps.persistant[PERS_GAUNTLET_FRAG_COUNT], player->client->ps.persistant[PERS_SCORE],
00087                         perfect, score1, score2, level.time, player->client->ps.persistant[PERS_CAPTURES] );
00088         }
00089 
00090         msglen = strlen( msg );
00091         for( i = 0; i < level.numNonSpectatorClients; i++ ) {
00092                 n = level.sortedClients[i];
00093                 Com_sprintf( buf, sizeof(buf), " %i %i %i", n, level.clients[n].ps.persistant[PERS_RANK], level.clients[n].ps.persistant[PERS_SCORE] );
00094                 buflen = strlen( buf );
00095                 if( msglen + buflen + 1 >= sizeof(msg) ) {
00096                         break;
00097                 }
00098                 strcat( msg, buf );
00099         }
00100         trap_SendConsoleCommand( EXEC_APPEND, msg );
00101 }


Variable Documentation

gentity_t* podium1
 

Definition at line 10 of file g_arenas.c.

gentity_t* podium2
 

Definition at line 11 of file g_arenas.c.

gentity_t* podium3
 

Definition at line 12 of file g_arenas.c.