Example #1
0
void G_PlayerAward( edict_t *ent, const char *awardMsg )
{
	edict_t *other;
	char cmd[MAX_STRING_CHARS];
	gameaward_t *ga;
	int i, size;
	score_stats_t *stats;

	if( !awardMsg || !awardMsg[0] || !ent->r.client )
		return;

	Q_snprintfz( cmd, sizeof( cmd ), "aw \"%s\"", awardMsg );
	trap_GameCmd( ent, cmd );

	if( dedicated->integer )
		G_Printf( "%s", COM_RemoveColorTokens( va( "%s receives a '%s' award.\n", ent->r.client->netname, awardMsg ) ) );

	ent->r.client->level.stats.awards++;
	teamlist[ent->s.team].stats.awards++;
	G_Gametype_ScoreEvent( ent->r.client, "award", awardMsg );

	stats = &ent->r.client->level.stats;
	if( !stats->awardAllocator )
		stats->awardAllocator = LinearAllocator( sizeof( gameaward_t ), 0, _G_LevelMalloc, _G_LevelFree );

	// ch : this doesnt work for race right?
	if( GS_MatchState() == MATCH_STATE_PLAYTIME || GS_MatchState() == MATCH_STATE_POSTMATCH )
	{
		// ch : we store this locally to send to MM
		// first check if we already have this one on the clients list
		size = LA_Size( stats->awardAllocator );
		ga = NULL;
		for( i = 0; i < size; i++ )
		{
			ga = ( gameaward_t * )LA_Pointer( stats->awardAllocator, i );
			if( !strncmp( ga->name, awardMsg, sizeof(ga->name)-1 ) )
				break;
		}

		if( i >= size )
		{
			ga = ( gameaward_t * )LA_Alloc( stats->awardAllocator );
			memset( ga, 0, sizeof(*ga) );
			ga->name = G_RegisterLevelString( awardMsg );
		}

		if( ga )
			ga->count++;
	}

	// add it to every player who's chasing this player
	for( other = game.edicts + 1; PLAYERNUM( other ) < gs.maxclients; other++ )
	{
		if( !other->r.client || !other->r.inuse || !other->r.client->resp.chase.active )
			continue;

		if( other->r.client->resp.chase.target == ENTNUM( ent ) )
			trap_GameCmd( other, cmd );
	}
}
Example #2
0
void G_PlayerMetaAward( edict_t *ent, const char *awardMsg )
{
    int i, size;
    gameaward_t *ga;
    score_stats_t *stats;

    /*
    * ch : meta-award is an award that isn't announced but
    * it is sent to MM
    */

    if( !awardMsg || !awardMsg[0] || !ent->r.client )
        return;

    stats = &ent->r.client->level.stats;
    if( !stats->awardAllocator )
        stats->awardAllocator = LinearAllocator( sizeof( gameaward_t ), 0, _G_LevelMalloc, _G_LevelFree );

    // ch : this doesnt work for race right?
    if( GS_MatchState() == MATCH_STATE_PLAYTIME )
    {
        // ch : we store this locally to send to MM
        // first check if we already have this one on the clients list
        size = LA_Size( stats->awardAllocator );
        ga = NULL;
        for( i = 0; i < size; i++ )
        {
            ga = LA_Pointer( stats->awardAllocator, i );
            if( !strncmp( ga->name, awardMsg, sizeof(ga->name)-1 ) )
                break;
        }

        if( i >= size )
        {
            ga = LA_Alloc( stats->awardAllocator );
            memset( ga, 0, sizeof(*ga) );
            ga->name = G_RegisterLevelString( awardMsg );
        }

        if( ga )
            ga->count++;
    }
}
Example #3
0
void G_ListRaces_f( void )
{
    int i, j, size;
    raceRun_t *run;

    if( !game.raceruns || !LA_Size( game.raceruns ) )
    {
        G_Printf("No races to report\n");
        return;
    }

    G_Printf(S_COLOR_RED "  session    " S_COLOR_YELLOW "times\n");
    size = LA_Size( game.raceruns );
    for( i = 0; i < size; i++ )
    {
        run = (raceRun_t*)LA_Pointer( game.raceruns, i );
        G_Printf(S_COLOR_RED "  %d    " S_COLOR_YELLOW, run->owner );
        for( j = 0; j < run->numSectors; j++ )
            G_Printf("%d ", run->times[j] );
        G_Printf(S_COLOR_GREEN "%d\n", run->times[run->numSectors]);	// SAFE!
    }
}
Example #4
0
/*
* Cmd_Awards_f
*/
static void Cmd_Awards_f ( edict_t *ent )
{
	gclient_t *client;
	gameaward_t *ga;
	int i, size;
	static char entry[MAX_TOKEN_CHARS];

	assert( ent && ent->r.client );
	client = ent->r.client;

	Q_snprintfz ( entry, sizeof( entry ), "Awards for %s \n", client->netname );

	if ( client->level.stats.awardAllocator )
	{
		size = LA_Size( client->level.stats.awardAllocator );
		for( i = 0; i < size; i++ )
		{
			ga = ( gameaward_t * )LA_Pointer( client->level.stats.awardAllocator, i );
			Q_strncatz( entry, va( "\t%dx %s\n", ga->count, ga->name ), sizeof( entry ) );
		}
		G_PrintMsg( ent, entry );
	}
}