Beispiel #1
0
/*
* G_Teams_ExecuteChallengersQueue
*/
void G_Teams_ExecuteChallengersQueue( void )
{
	edict_t *ent;
	edict_t **challengers;
	bool restartmatch = false;

	// Medar fixme: this is only really makes sense, if playerlimit per team is one
	if( GS_MatchState() == MATCH_STATE_PLAYTIME )
		return;

	if( !GS_HasChallengers() )
		return;

	if( game.realtime < level.spawnedTimeStamp + G_CHALLENGERS_MIN_JOINTEAM_MAPTIME )
	{
		static int time, lasttime;
		time = (int)( ( G_CHALLENGERS_MIN_JOINTEAM_MAPTIME - ( game.realtime - level.spawnedTimeStamp ) )*0.001 );
		if( lasttime && time == lasttime )
			return;
		lasttime = time;
		if( lasttime )
			G_CenterPrintFormatMsg( NULL, "Waiting... %s", va( "%i", lasttime ), NULL );
		else
			G_CenterPrintMsg( NULL, "" );
		return;
	}

	// pick players in join order and try to put them in the
	// game until we get the first refused one.
	challengers = G_Teams_ChallengersQueue();
	if( challengers )
	{
		int i;

		for( i = 0; challengers[i]; i++ )
		{
			ent = challengers[i];
			if( !G_Teams_JoinAnyTeam( ent, true ) )
				break;

			// if we successfully execute the challengers queue during the countdown, revert to warmup
			if( GS_MatchState() == MATCH_STATE_COUNTDOWN )
			{
				restartmatch = true;
			}
		}
	}

	if( restartmatch == true )
	{
		G_Match_Autorecord_Cancel();
		G_Match_LaunchState( MATCH_STATE_WARMUP );
	}
}
Beispiel #2
0
void G_ScoreboardMessage_AddSpectators( void )
{
	char entry[MAX_TOKEN_CHARS];
	int i, clstate;
	edict_t	*e;
	edict_t **challengers;
	size_t len;

	len = strlen( scoreboardString );
	if( !len )
		return;

	if( GS_HasChallengers() && (challengers = G_Teams_ChallengersQueue()) != NULL )
	{
		// add the challengers
		Q_strncpyz( entry, "&w ", sizeof(entry) );
		ADD_SCOREBOARD_ENTRY( scoreboardString, len, entry );

		for( i = 0; challengers[i]; i++ )
		{
			e = challengers[i];

			//spectator tab entry
			if( !( e->r.client->connecting == true || trap_GetClientState( PLAYERNUM( e ) ) < CS_SPAWNED ) )
			{
				Q_snprintfz( entry, sizeof( entry ), "%i %i ",
					PLAYERNUM( e ),
					e->r.client->r.ping > 999 ? 999 : e->r.client->r.ping );
				ADD_SCOREBOARD_ENTRY( scoreboardString, len, entry );
			}
		}
	}

	// add spectator team
	Q_strncpyz( entry, "&s ", sizeof(entry) );
	ADD_SCOREBOARD_ENTRY( scoreboardString, len, entry );

	for( i = 0; i < teamlist[TEAM_SPECTATOR].numplayers; i++ )
	{
		e = game.edicts + teamlist[TEAM_SPECTATOR].playerIndices[i];

		if( e->r.client->connecting == true || trap_GetClientState( PLAYERNUM( e ) ) < CS_SPAWNED )
			continue;

		if( !e->r.client->queueTimeStamp )
		{	
			// not in challenger queue
			Q_snprintfz( entry, sizeof( entry ), "%i %i ",
				PLAYERNUM( e ),
				e->r.client->r.ping > 999 ? 999 : e->r.client->r.ping );
			ADD_SCOREBOARD_ENTRY( scoreboardString, len, entry );
		}
	}

	// add connecting spectators
	for( i = 0; i < teamlist[TEAM_SPECTATOR].numplayers; i++ )
	{
		e = game.edicts + teamlist[TEAM_SPECTATOR].playerIndices[i];

		// spectator tab entry
		clstate = trap_GetClientState( PLAYERNUM( e ) );
		if( e->r.client->connecting == true || ( clstate >= CS_CONNECTED && clstate < CS_SPAWNED ) )
		{
			Q_snprintfz( entry, sizeof( entry ), "%i %i ", PLAYERNUM( e ), -1 );
			ADD_SCOREBOARD_ENTRY( scoreboardString, len, entry );
		}
	}
}