Beispiel #1
0
/*
 * ==================
 * SV_Frame
 *
 * ==================
 */
void SV_Frame(int msec)
{
    time_before_game = time_after_game = 0;

    // if server is not active, do nothing
    if (!svs.initialized)
    {
        return;
    }

    svs.realtime += msec;

    // keep the random time dependent
    rand();

    // check timeouts
    SV_CheckTimeouts();

    // get packets from clients
    SV_ReadPackets();

    // move autonomous things around if enough time has passed
    if (!sv_timedemo->value && (svs.realtime < sv.time))
    {
        // never let the time get too far off
        if (sv.time - svs.realtime > 100)
        {
            if (sv_showclamp->value)
            {
                Com_Printf("sv lowclamp\n");
            }
            svs.realtime = sv.time - 100;
        }
        NET_Sleep(sv.time - svs.realtime);
        return;
    }

    // update ping based on the last known frame from all clients
    SV_CalcPings();

    // give the clients some timeslices
    SV_GiveMsec();

    // let everything in the world think and move
    SV_RunGameFrame();

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

    // save the entire world state if recording a serverdemo
    SV_RecordDemoMessage();

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

    // clear teleport flags, etc for next frame
    SV_PrepWorldFrame();
}
Beispiel #2
0
/**
 * @sa Qcommon_Frame
 */
void SV_Frame (int now, void *data)
{
	Com_ReadFromPipe();

	/* change the gametype even if no server is running (e.g. the first time) */
	if (sv_dedicated->integer && sv_gametype->modified) {
		Com_SetGameType();
		sv_gametype->modified = false;
	}

	if (sv_dedicated->integer) {
		const char *s;
		do {
			s = Sys_ConsoleInput();
			if (s)
				Cbuf_AddText(va("%s\n", s));
		} while (s);
	}

	/* if server is not active, do nothing */
	if (!svs.initialized) {
#ifdef DEDICATED_ONLY
		Com_Printf("Starting next map from the mapcycle\n");
		SV_NextMapcycle();
#endif
		return;
	}

	svs.realtime = now;

	/* keep the random time dependent */
	rand();

	SV_CheckSpawnSoldiers();
	SV_CheckStartMatch();
	SV_CheckTimeouts();

	if (!sv_threads->integer)
		SV_RunGameFrame();
	else
		/* signal the game frame thread to wake up */
		SDL_CondSignal(svs.gameFrameCond);
	SV_LogHandleOutput();

	/* next map in the cycle */
	if (sv->endgame && sv_maxclients->integer > 1)
		SV_NextMapcycle();

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

	/* server is empty - so shutdown */
	if (svs.abandon && svs.killserver)
		SV_Shutdown("Server disconnected.", false);
}
/*
==================
SV_Frame

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

	start = Sys_DoubleTime ();
	svs.stats.idle += start - end;

// keep the random time dependent
	rand ();

// decide the simulation time
	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
	SV_Physics ();

// get packets
	SV_ReadPackets ();

// 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;
	}
}
Beispiel #4
0
/**
 * @sa Qcommon_Frame
 */
void SV_Frame (int now, void *data)
{
	/* change the gametype even if no server is running (e.g. the first time) */
	if (sv_dedicated->integer && sv_gametype->modified) {
		Com_SetGameType();
		sv_gametype->modified = qfalse;
	}

	if (sv_dedicated->integer) {
		const char *s;
		do {
			s = Sys_ConsoleInput();
			if (s)
				Cbuf_AddText(va("%s\n", s));
		} while (s);
	}

	/* if server is not active, do nothing */
	if (!svs.initialized)
		return;

	svs.realtime = now;

	/* keep the random time dependent */
	rand();

	SV_CheckGameStart();

	if (!sv_threads->integer)
		SV_RunGameFrame();
	else
		/* signal the game frame thread to wake up */
		SDL_CondSignal(svs.gameFrameCond);

	/* next map in the cycle */
	if (sv->endgame && sv_maxclients->integer > 1)
		SV_NextMapcycle();

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

	/* server is empty - so shutdown */
	if (svs.abandon && svs.killserver)
		SV_Shutdown("Server disconnected.", qfalse);
}
Beispiel #5
0
/*
==================
Host_ServerFrame

==================
*/
void Host_ServerFrame( void )
{
	// if server is not active, do nothing
	if( !svs.initialized ) return;

	svgame.globals->frametime = host.frametime;

	// check timeouts
	SV_CheckTimeouts ();

	// check clients timewindow
	SV_CheckCmdTimes ();

	// read packets from clients
	SV_ReadPackets ();

	// update ping based on the last known frame from all clients
	SV_CalcPings ();

	// refresh serverinfo on the client side
	SV_UpdateServerInfo ();

	// refresh physic movevars on the client side
	SV_UpdateMovevars ( false );

	// let everything in the world think and move
	SV_RunGameFrame ();
		
	// send messages back to the clients that had packets read this frame
	SV_SendClientMessages ();

	// clear edict flags for next frame
	SV_PrepWorldFrame ();

	// send a heartbeat to the master if needed
	Master_Heartbeat ();
}
Beispiel #6
0
/**
 * @sa Qcommon_Frame
 */
void SV_Frame (int now, void* data)
{
    Com_ReadFromPipe();

    /* change the gametype even if no server is running (e.g. the first time) */
    if (sv_dedicated->integer && sv_gametype->modified) {
        Com_SetGameType();
        sv_gametype->modified = false;
    }

    if (sv_dedicated->integer) {
        const char* s;
        do {
            s = Sys_ConsoleInput();
            if (s)
                Cbuf_AddText("%s\n", s);
        } while (s);
    }

    /* if server is not active, do nothing */
    if (!svs.initialized) {
#ifdef DEDICATED_ONLY
        Com_Printf("Starting next map from the mapcycle\n");
        SV_NextMapcycle();
#endif
        return;
    }

    svs.realtime = now;

    /* if time is about to hit the 32nd bit, kick all clients
     * and clear sv.time, rather
     * than checking for negative time wraparound everywhere.
     * 2giga-milliseconds = 23 days, so it won't be too often */
    if (svs.realtime > 0x70000000) {
        SV_Map(true, sv->name, sv->assembly);
        return;
    }

    /* keep the random time dependent */
    rand();

    SV_CheckSpawnSoldiers();
    SV_CheckStartMatch();
    SV_CheckTimeouts();

    if (!sv_threads->integer)
        SV_RunGameFrame();
    else
        /* signal the game frame thread to wake up */
        SDL_CondSignal(svs.gameFrameCond);
    SV_LogHandleOutput();

    /* next map in the cycle */
    if (sv->endgame && sv_maxclients->integer > 1)
        SV_NextMapcycle();

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

    /* server is empty - so shutdown */
    if (svs.abandon && svs.killserver)
        SV_Shutdown("Server disconnected.", false);
}
Beispiel #7
0
void SV_Frame(float msec)
{
	guard(SV_Frame);

	time_before_game = time_after_game = 0;

	// if server is not active, do nothing
	if (!svs.initialized)
		return;

//	SV_DrawTextLeft(va("time: %10d rf: %10.5f d: %10.4f ri:%10d", sv.time, svs.realtimef, msec, svs.realtime));//!!
	svs.realtimef += msec;
	svs.realtime = appFloor(svs.realtimef);

	if (!sv.attractloop)
	{
		// check timeouts
		SV_CheckTimeouts();
	}
	// get packets from clients
	SV_ReadPackets();
	if (sv.state == ss_dead) return;	// server was killed from one of packet (e.g. "rcon killserver")

	int frameTime = 100;	// (sv_fps->integer > 10) ? (1000 / sv_fps->integer) : 100;

	// move autonomous things around if enough time has passed
	if (svs.realtime < sv.time)
	{
		// never let the time get too far off
		if (sv.time - svs.realtime > frameTime)
		{
			if (sv_showclamp->integer)
				appPrintf("sv lowclamp s:%d -- r:%d -> %d\n", sv.time, svs.realtime, sv.time - frameTime);
			svs.realtime  = sv.time - frameTime;
			svs.realtimef = svs.realtime;
		}
		return;
	}

	SV_ClearTexts();

	if (!sv.attractloop)
	{
		// update ping based on the last known frame from all clients
		SV_CalcPings();
		// give the clients some timeslices
		SV_GiveMsec();
	}

	// let everything in the world think and move
	/*-------- SV_RunGameFrame() ---------------*/
	// we always need to bump framenum, even if we
	// don't run the world, otherwise the delta
	// compression can get confused when a client
	// has the "current" frame
	sv.framenum++;
	sv.time += frameTime;	//  = sv.framenum*100; ??

	// don't run if paused
	if (!sv_paused->integer || sv_maxclients->integer > 1)
	{
		time_before_game = appCycles();

		guardGame(ge.RunFrame);
		ge->RunFrame();
		unguardGame;


		// never get more than one tic behind
		if (sv.time < svs.realtime)
		{
			if (sv_showclamp->integer)
				appPrintf("sv highclamp s:%d r:%d -> %d\n", sv.time, svs.realtime, sv.time);
			svs.realtime  = sv.time;
			svs.realtimef = sv.time;
		}
		time_after_game = appCycles();
	}

	// if extended protocol used, recalculate footstep sounds, mdx/mdl/md3 frames etc.
	if (sv_extProtocol->integer && !sv.attractloop)
		SV_PostprocessFrame();

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

	// save the entire world state if recording a serverdemo
	SV_RecordDemoMessage();

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

	// clear teleport flags, etc for next frame
	SV_PrepWorldFrame();

	unguard;
}