Exemple #1
0
/*
==================
SV_RunClients
==================
*/
void SV_RunClients (void)
{
	int				i;
	
	for (i=0, host_client = svs.clients ; i<svs.maxclients ; i++, host_client++)
	{
		if (!host_client->active)
			continue;
	
		sv_player = host_client->edict;

		if (!SV_ReadClientMessage ())
		{
			SV_DropClient (false);	// client misbehaved...
			continue;
		}

		if (!host_client->spawned)
		{
		// clear client movement until a new packet is received
			memset (&host_client->cmd, 0, sizeof(host_client->cmd));
			continue;
		}

// always pause in single player if in console or menus
		if (!sv.paused && (svs.maxclients > 1 || key_dest == key_game) )
			SV_ClientThink ();
	}
	//qmb :globot
	SV_RunBots ();
}
Exemple #2
0
/*
================
SV_Physics

================
*/
void SV_Physics (void)
{
    int		i;
    edict_t	*ent;

    if (sv.state != ss_game)
        return;

    if (sv.old_time)
    {
        // don't bother running a frame if sv_mintic seconds haven't passed
        sv_frametime = sv.time - sv.old_time;
        if (sv_frametime < sv_mintic.value)
            return;
        if (sv_frametime > sv_maxtic.value)
            sv_frametime = sv_maxtic.value;
        sv.old_time = sv.time;
    }
    else
        sv_frametime = 0.1;		// initialization frame

    if (pr_nqprogs)
        NQP_Reset ();

    PR_GLOBAL(frametime) = sv_frametime;

    SV_ProgStartFrame ();

//
// treat each object in turn
// even the world gets a chance to think
//
    ent = sv.edicts;
    for (i=0 ; i<sv.num_edicts ; i++, ent = NEXT_EDICT(ent))
    {
        if (!ent->inuse)
            continue;

        if (PR_GLOBAL(force_retouch))
            SV_LinkEdict (ent, true);	// force retouch even for stationary

        if (i > 0 && i <= MAX_CLIENTS)
            continue;		// clients are run directly from packets

        SV_RunEntity (ent);
        SV_RunNewmis ();
    }

    if (PR_GLOBAL(force_retouch))
        PR_GLOBAL(force_retouch)--;

    SV_RunBots ();
}
Exemple #3
0
/*
==================
SV_Frame

==================
*/
void SV_Frame (double time)
{
	static double	start, end;

	start = Sys_DoubleTime ();
	svs.stats.idle += start - end;
	
// keep the random time dependent
	rand ();

// decide the simulation time
	if (!sv_paused.value)
	{
		svs.realtime += time;
		sv.time += time;
	}

// check timeouts
	SV_CheckTimeouts ();

// toggle the log buffer if full
	SV_CheckLog ();

// move autonomous things around if enough time has passed
	if (!sv_paused.value)
		SV_Physics ();
	else
		SV_RunBots ();	// just update network stuff, but don't run physics

// get packets
	SV_ReadPackets ();

	if (dedicated)
	{
	// check for commands typed to the host
		SV_GetConsoleCommands ();
		
	// process console commands
		Cbuf_Execute ();
	}

	SV_CheckVars ();

// send messages back to the clients that had packets read this frame
	SV_SendClientMessages ();

// send a heartbeat to the master if needed
	Master_Heartbeat ();

// collect timing statistics
	end = Sys_DoubleTime ();
	svs.stats.active += end-start;
	if (++svs.stats.count == STATFRAMES)
	{
		svs.stats.latched_active = svs.stats.active;
		svs.stats.latched_idle = svs.stats.idle;
		svs.stats.latched_packets = svs.stats.packets;
		svs.stats.active = 0;
		svs.stats.idle = 0;
		svs.stats.packets = 0;
		svs.stats.count = 0;
	}
}