Example #1
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);
}
Example #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("%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);
}