Exemple #1
0
/*
* G_RunFrame
* Advances the world
*/
void G_RunFrame( unsigned int msec, unsigned int serverTime )
{
	G_CheckCvars();

	game.localTime = time( NULL );

	game.serverTime = serverTime;
	G_UpdateFrameTime( msec );

	if( !g_snapStarted )
		G_StartFrameSnap();

	G_CallVotes_Think();

	// "freeze" match clock
	if( GS_MatchWaiting() || GS_MatchPaused() )
	{
		gs.gameState.longstats[GAMELONG_MATCHSTART] += msec;
	}

	if( GS_MatchPaused() )
	{
		edict_t *ent;

		// "freeze" linear projectiles
		for( ent = game.edicts + gs.maxclients; ENTNUM( ent ) < game.numentities; ent++ )
		{
			if( ent->s.linearProjectile )
				ent->s.linearProjectileTimeStamp += msec;
		}

		G_RunClients();
		G_RunGametype();
		G_LevelGarbageCollect();
		return;
	}

	level.framenum++;
	level.time += msec;
	level.think_client_entity = G_GetNextThinkClient( level.think_client_entity );

	G_SpawnQueue_Think();

	// run the world
	G_asCallMapPreThink();
	G_RunClients();
	G_RunEntities();
	G_RunGametype();
	G_asCallMapPostThink();
	GClip_BackUpCollisionFrame();

	G_LevelGarbageCollect();
}
/*
* G_Match_CheckStateAbort
*/
static void G_Match_CheckStateAbort( void )
{
	bool any = false;
	bool enough;

	if( GS_MatchState() <= MATCH_STATE_NONE || GS_MatchState() >= MATCH_STATE_POSTMATCH
		|| level.gametype.mathAbortDisabled )
	{
		GS_GamestatSetFlag( GAMESTAT_FLAG_WAITING, false );
		return;
	}

	if( GS_TeamBasedGametype() )
	{
		int team, emptyteams = 0;

		for( team = TEAM_ALPHA; team < GS_MAX_TEAMS; team++ )
		{
			if( !teamlist[team].numplayers )
				emptyteams++;
			else
				any = true;
		}

		enough = ( emptyteams == 0 );
	}
	else
	{
		enough = ( teamlist[TEAM_PLAYERS].numplayers > 1 );
		any = ( teamlist[TEAM_PLAYERS].numplayers > 0 );
	}

	// if waiting, turn on match states when enough players joined
	if( GS_MatchWaiting() && enough )
	{
		GS_GamestatSetFlag( GAMESTAT_FLAG_WAITING, false );
		G_UpdatePlayersMatchMsgs();
	}
	// turn off active match states if not enough players left
	else if( GS_MatchState() == MATCH_STATE_WARMUP && !enough && GS_MatchDuration() )
	{
		GS_GamestatSetFlag( GAMESTAT_FLAG_WAITING, true );
		G_UpdatePlayersMatchMsgs();
	}
	else if( GS_MatchState() == MATCH_STATE_COUNTDOWN && !enough )
	{
		if( any ) {
			G_PrintMsg( NULL, "Not enough players left. Countdown aborted.\n" );
			G_CenterPrintMsg( NULL, "COUNTDOWN ABORTED" );
		}
		G_Match_Autorecord_Cancel();
		G_Match_LaunchState( MATCH_STATE_WARMUP );
		GS_GamestatSetFlag( GAMESTAT_FLAG_WAITING, true );
		G_UpdatePlayersMatchMsgs();
	}
	// match running, but not enough players left
	else if( GS_MatchState() == MATCH_STATE_PLAYTIME && !enough )
	{
		if( any ) {
			G_PrintMsg( NULL, "Not enough players left. Match aborted.\n" );
			G_CenterPrintMsg( NULL, "MATCH ABORTED" );
		}
		G_EndMatch();
	}
}