Exemplo n.º 1
0
/*
* G_ClientUpdateScoreBoardMessage
* 
* Show the scoreboard messages if the scoreboards are active
*/
void G_UpdateScoreBoardMessages( void )
{
	static int nexttime = 0;
	int i;
	edict_t	*ent;
	gclient_t *client;
	bool forcedUpdate = false;
	char command[MAX_STRING_CHARS];
	size_t maxlen, staticlen;

	// fixme : mess of copying
	maxlen = MAX_STRING_CHARS - ( strlen( "scb \"\"" + 4 ) );

	if( game.asEngine != NULL )
		GT_asCallScoreboardMessage( maxlen );
	else
		G_Gametype_GENERIC_ScoreboardMessage();

	G_ScoreboardMessage_AddSpectators();

	staticlen = strlen( scoreboardString );

update:
	// send to players who have scoreboard visible
	for( i = 0; i < gs.maxclients; i++ )
	{
		ent = game.edicts + 1 + i;
		if( !ent->r.inuse || !ent->r.client )
			continue;

		client = ent->r.client;

		if( game.realtime <= client->level.scoreboard_time + scoreboardInterval )
			continue;

		if( forcedUpdate || ( client->ps.stats[STAT_LAYOUTS] & STAT_LAYOUT_SCOREBOARD ) )
		{
			scoreboardString[staticlen] = '\0';
			if( client->resp.chase.active )
				G_ScoreboardMessage_AddChasers( client->resp.chase.target, ENTNUM( ent ) );
			else
				G_ScoreboardMessage_AddChasers( ENTNUM( ent ), ENTNUM( ent ) );
			Q_snprintfz( command, sizeof( command ), "scb \"%s\"", scoreboardString );

			client->level.scoreboard_time = game.realtime + scoreboardInterval - ( game.realtime%scoreboardInterval );
			trap_GameCmd( ent, command );
			trap_GameCmd( ent, G_PlayerStatsMessage( ent ) );
		}
	}

	if( !forcedUpdate )
	{
		// every 10 seconds, send everyone the scoreboard
		nexttime -= game.snapFrameTime;
		if( nexttime > 0 )
			return;

		do
		{
			nexttime += 10000;
		}
		while( nexttime <= 0 );

		forcedUpdate = true;
		goto update;
	}
}
Exemplo n.º 2
0
/*
* G_ClientUpdateScoreBoardMessage
* 
* Show the scoreboard messages if the scoreboards are active
*/
void G_UpdateScoreBoardMessages( void )
{
	static int nexttime = 0;
	int i;
	edict_t	*ent;
	gclient_t *client;
	char *scoreBoardMessage = "";
	qboolean forcedUpdate = qfalse;
	char string[MAX_STRING_CHARS];
	size_t maxlen;

	// fixme : mess of copying
	maxlen = MAX_STRING_CHARS - ( strlen( "scb \"\"" + 4 ) );

	if( level.gametype.asEngineHandle >= 0 )
		scoreBoardMessage = G_asCallScoreboardMessage( maxlen );
	else
		scoreBoardMessage = G_Gametype_GENERIC_ScoreboardMessage();

	G_ScoreboardMessage_AddSpectators();

	Q_strncpyz( string, scoreBoardMessage ? scoreBoardMessage : "", maxlen );
	Q_snprintfz( scoreboardString, sizeof( scoreboardString ), "scb \"%s\"", string );
	scoreBoardMessage = scoreboardString;

update:
	// send to players who have scoreboard visible
	for( i = 0; i < gs.maxclients; i++ )
	{
		ent = game.edicts + 1 + i;
		if( !ent->r.inuse || !ent->r.client )
			continue;

		client = ent->r.client;

		if( game.realtime <= client->level.scoreboard_time + scoreboardInterval )
			continue;

		if( forcedUpdate || ( client->ps.stats[STAT_LAYOUTS] & STAT_LAYOUT_SCOREBOARD ) )
		{
			client->level.scoreboard_time = game.realtime + scoreboardInterval - ( game.realtime%scoreboardInterval );
			trap_GameCmd( ent, scoreBoardMessage );
			trap_GameCmd( ent, G_PlayerStatsMessage( ent ) );
		}
	}

	if( !forcedUpdate )
	{
		// every 10 seconds, send everyone the scoreboard
		nexttime -= game.snapFrameTime;
		if( nexttime > 0 )
			return;

		do
		{
			nexttime += 10000;
		}
		while( nexttime <= 0 );

		forcedUpdate = qtrue;
		goto update;
	}
}