Beispiel #1
0
// Sends a player's stats to the requesting client.
void G_statsPrint( gentity_t *ent, int nType ) {
	int pid;
	char *cmd = ( nType == 0 ) ? "ws" : ( ( nType == 1 ) ? "wws" : "gstats" );   // Yes, not the cleanest
	char arg[MAX_TOKEN_CHARS];

	if ( !ent || ( ent->r.svFlags & SVF_BOT ) ) {
		return;
	}

	// If requesting stats for self, its easy.
	if ( trap_Argc() < 2 ) {
		if ( ent->client->sess.sessionTeam != TEAM_SPECTATOR ) {
			CP( va( "%s %s\n", cmd, G_createStats( ent ) ) );
			// Specs default to players they are chasing
		} else if ( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) {
			CP( va( "%s %s\n", cmd, G_createStats( g_entities + ent->client->sess.spectatorClient ) ) );
		} else {
			CP( "cpm \"Type ^3\\stats <player_id>^7 to see stats on an active player.\n\"" );
			return;
		}
	} else {
		// Find the player to poll stats.
		trap_Argv( 1, arg, sizeof( arg ) );
		if ( ( pid = ClientNumberFromString( ent, arg ) ) == -1 ) {
			return;
		}

		CP( va( "%s %s\n", cmd, G_createStats( g_entities + pid ) ) );
	}
}
Beispiel #2
0
// ************** STATSALL
//
// Shows all players' stats to the requesting client.
// forty - #607 - Merge in Density's damage received display code
void G_statsall_cmd(gentity_t *ent, unsigned int dwCommand, qboolean fDump)
{
	int i;
	gentity_t *player;

	for(i=0; i<level.numConnectedClients; i++) {
		player = &g_entities[level.sortedClients[i]];
		if(player->client->sess.sessionTeam == TEAM_SPECTATOR) continue;
		CP(va("ws %s\n", G_createStats(player, ent)));
	}
}
Beispiel #3
0
// Dumps end-of-match info
void G_matchInfoDump(unsigned int dwDumpType)
{
	int       i, ref;
	gentity_t *ent;
	gclient_t *cl;

	for (i = 0; i < level.numConnectedClients; i++)
	{
		ref = level.sortedClients[i];
		ent = &g_entities[ref];
		cl  = ent->client;

		if (cl->pers.connected != CON_CONNECTED)
		{
			continue;
		}

		if (dwDumpType == EOM_WEAPONSTATS)
		{
			// If client wants to write stats to a file, don't auto send this stuff
			if (!(cl->pers.clientFlags & CGF_STATSDUMP))
			{
				if ((cl->pers.autoaction & AA_STATSALL)
#ifdef FEATURE_MULTIVIEW
				    || cl->pers.mvCount > 0
#endif
				    )
				{
					G_statsall_cmd(ent, 0, qfalse);
				}
				else if (cl->sess.sessionTeam != TEAM_SPECTATOR)
				{
					if (cl->pers.autoaction & AA_STATSTEAM)
					{
						G_statsall_cmd(ent, cl->sess.sessionTeam, qfalse);                // Currently broken.. need to support the overloading of dwCommandID
					}
					else
					{
						CP(va("ws %s\n", G_createStats(ent)));
					}

				}
				else if (cl->sess.spectatorState != SPECTATOR_FREE)
				{
					int pid = cl->sess.spectatorClient;

					if ((cl->pers.autoaction & AA_STATSTEAM))
					{
						G_statsall_cmd(ent, level.clients[pid].sess.sessionTeam, qfalse); // Currently broken.. need to support the overloading of dwCommandID
					}
					else
					{
						CP(va("ws %s\n", G_createStats(g_entities + pid)));
					}
				}
			}

			// Log it
			if (cl->sess.sessionTeam != TEAM_SPECTATOR)
			{
				G_LogPrintf("WeaponStats: %s\n", G_createStats(ent));
			}

		}
		else if (dwDumpType == EOM_MATCHINFO)
		{
			if (!(cl->pers.clientFlags & CGF_STATSDUMP))
			{
				G_printMatchInfo(ent);
			}
			if (g_gametype.integer == GT_WOLF_STOPWATCH)
			{
				if (g_currentRound.integer == 1)       // We've already missed the switch
				{
					CP(va("print \">>> ^3Clock set to: %d:%02d\n\n\n\"",
					      g_nextTimeLimit.integer,
					      (int)(60.0 * (float)(g_nextTimeLimit.value - g_nextTimeLimit.integer))));
				}
				else
				{
					float val = (float)((level.timeCurrent - (level.startTime + level.time - level.intermissiontime)) / 60000.0);

					if (val < g_timelimit.value)
					{
						CP(va("print \">>> ^3Objective reached at %d:%02d (original: %d:%02d)\n\n\n\"",
						      (int)val,
						      (int)(60.0 * (val - (int)val)),
						      g_timelimit.integer,
						      (int)(60.0 * (float)(g_timelimit.value - g_timelimit.integer))));
					}
					else
					{
						CP(va("print \">>> ^3Objective NOT reached in time (%d:%02d)\n\n\n\"",
						      g_timelimit.integer,
						      (int)(60.0 * (float)(g_timelimit.value - g_timelimit.integer))));
					}
				}
			}
		}
	}
}
Beispiel #4
0
/*
================
G_WriteClientSessionData

Called on game shutdown
================
*/
void G_WriteClientSessionData(gclient_t *client, qboolean restart)
{
#ifdef FEATURE_MULTIVIEW
	int mvc = G_smvGenerateClientList(g_entities + (client - level.clients));
#endif
	const char *s;

	// stats reset check
	//if (level.fResetStats)
	//{
	G_deleteStats(client - level.clients);
	//}

#ifdef FEATURE_MULTIVIEW
#ifdef FEATURE_RATING
	s = va("%i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %f %f %f %f %i %i %i %i %i %i %i %i",
#else
	s = va("%i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i",
#endif
#else
#ifdef FEATURE_RATING
	s = va("%i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %f %f %f %f %i %i %i %i %i %i",
#else
	s = va("%i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i",
#endif
#endif
	       client->sess.sessionTeam,
	       client->sess.spectatorTime,
	       client->sess.spectatorState,
	       client->sess.spectatorClient,
	       client->sess.playerType,
	       client->sess.playerWeapon,
	       client->sess.playerWeapon2,
	       client->sess.latchPlayerType,
	       client->sess.latchPlayerWeapon,
	       client->sess.latchPlayerWeapon2,

	       client->sess.coach_team,
	       client->sess.referee,
	       client->sess.spec_invite,
	       client->sess.spec_team,
	       client->sess.kills,
	       client->sess.deaths,
	       client->sess.gibs,
	       client->sess.self_kills,
	       client->sess.team_kills,
	       client->sess.team_gibs,

	       client->sess.time_axis,
	       client->sess.time_allies,
	       client->sess.time_played,
#ifdef FEATURE_RATING
	       client->sess.mu,
	       client->sess.sigma,
	       client->sess.oldmu,
	       client->sess.oldsigma,
#endif
#ifdef FEATURE_MULTIVIEW
	       (mvc & 0xFFFF),
	       ((mvc >> 16) & 0xFFFF),
#endif
	       // Damage and rounds played rolled in with weapon stats (below)

	       client->sess.muted,
	       client->sess.ignoreClients[0],
	       client->sess.ignoreClients[1],
	       client->pers.enterTime,
	       restart ? client->sess.spawnObjectiveIndex : 0,
	       client->sess.uci
	       );

	trap_Cvar_Set(va("session%i", (int)(client - level.clients)), s);

	// store the clients stats (7) and medals (7)
	// addition: but only if it isn't a forced map_restart (done by someone on the console)
	if (!(restart && !level.warmupTime))
	{
		s = va("%.2f %.2f %.2f %.2f %.2f %.2f %.2f %i %i %i %i %i %i %i",
		       client->sess.skillpoints[0],
		       client->sess.skillpoints[1],
		       client->sess.skillpoints[2],
		       client->sess.skillpoints[3],
		       client->sess.skillpoints[4],
		       client->sess.skillpoints[5],
		       client->sess.skillpoints[6],
		       client->sess.medals[0],
		       client->sess.medals[1],
		       client->sess.medals[2],
		       client->sess.medals[3],
		       client->sess.medals[4],
		       client->sess.medals[5],
		       client->sess.medals[6]
		       );

		trap_Cvar_Set(va("sessionstats%i", (int)(client - level.clients)), s);
	}

	// save weapon stats too
	if (!level.fResetStats)
	{
		trap_Cvar_Set(va("wstats%i", (int)(client - level.clients)), G_createStats(&g_entities[client - level.clients]));
	}
}
Beispiel #5
0
/*
================
G_WriteClientSessionData

Called on game shutdown
================
*/
void G_WriteClientSessionData( gclient_t *client, qboolean restart )
{
	int mvc = G_smvGenerateClientList(g_entities + (client - level.clients));
	const char	*s;

	// OSP -- stats reset check
	if(level.fResetStats) G_deleteStats(client - level.clients);

	s = va("%i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i",
		client->sess.sessionTeam,
		client->sess.spectatorTime,
		client->sess.spectatorState,
		client->sess.spectatorClient,
		client->sess.playerType,			// DHM - Nerve
		client->sess.playerWeapon,			// DHM - Nerve
		client->sess.playerWeapon2,
		client->sess.latchPlayerType,		// DHM - Nerve
		client->sess.latchPlayerWeapon,		// DHM - Nerve
		client->sess.latchPlayerWeapon2,

		// OSP
		client->sess.coach_team,
		client->sess.deaths,
		client->sess.game_points,
		client->sess.kills,
		client->sess.referee,
		client->sess.spec_invite,
		client->sess.spec_team,
		client->sess.suicides,
		client->sess.team_kills,
		(mvc & 0xFFFF),
		((mvc >> 16) & 0xFFFF)
		// Damage and rounds played rolled in with weapon stats (below)
		// OSP

		, 
//		client->sess.experience,
		client->sess.muted,
		client->sess.ignoreClients[0],
		client->sess.ignoreClients[1],
		client->pers.enterTime,
		restart ? client->sess.spawnObjectiveIndex : 0
		);

	trap_Cvar_Set( va( "session%i", client - level.clients ), s );

	// Arnout: store the clients stats (7) and medals (7)
	// addition: but only if it isn't a forced map_restart (done by someone on the console)
	if( !(restart && !level.warmupTime) ) {
		s = va( "%.2f %.2f %.2f %.2f %.2f %.2f %.2f %i %i %i %i %i %i %i",
			client->sess.skillpoints[0],
			client->sess.skillpoints[1],
			client->sess.skillpoints[2],
			client->sess.skillpoints[3],
			client->sess.skillpoints[4],
			client->sess.skillpoints[5],
			client->sess.skillpoints[6],
			client->sess.medals[0],
			client->sess.medals[1],
			client->sess.medals[2],
			client->sess.medals[3],
			client->sess.medals[4],
			client->sess.medals[5],
			client->sess.medals[6]
			);

		trap_Cvar_Set( va( "sessionstats%i", client - level.clients ), s );
	}

	// OSP -- save weapon stats too
	if(!level.fResetStats)
		trap_Cvar_Set(va("wstats%i", client - level.clients), G_createStats(&g_entities[client - level.clients]));
	// OSP
}