Пример #1
0
void D_SRB2Loop(void)
{
	tic_t oldentertics = 0, entertic = 0, realtics = 0, rendertimeout = INFTICS;

	if (demorecording)
		G_BeginRecording();

	// user settings
	if (dedicated)
		COM_BufAddText(va("exec \"%s"PATHSEP"adedserv.cfg\"\n", srb2home));
	else
		COM_BufAddText(va("exec \"%s"PATHSEP"autoexec.cfg\" -noerror\n", srb2home));

	if (dedicated)
		server = true;

	if (M_CheckParm("-voodoo")) // 256x256 Texture Limiter
		COM_BufAddText("gr_voodoocompatibility on\n");

	// Pushing of + parameters is now done back in D_SRB2Main, not here.

	// end of loading screen: CONS_Printf() will no more call FinishUpdate()
	con_startup = false;

	CONS_Printf("I_StartupKeyboard...\n");
	I_StartupKeyboard();

#ifdef _WINDOWS
	CONS_Printf("I_StartupMouse...\n");
	I_DoStartupMouse();
#endif

	oldentertics = I_GetTime();

	// make sure to do a d_display to init mode _before_ load a level
	SCR_SetMode(); // change video mode
	SCR_Recalc();

	for (;;)
	{
		// get real tics
		entertic = I_GetTime();
		realtics = entertic - oldentertics;
		oldentertics = entertic;

#ifdef DEBUGFILE
		if (!realtics)
			if (debugload)
				debugload--;
#endif

		if (!realtics && !singletics)
		{
			I_Sleep();
			continue;
		}

#ifdef HW3SOUND
		HW3S_BeginFrameUpdate();
#endif

		// process tics (but maybe not if realtic == 0)
		TryRunTics(realtics);

		if (lastdraw || singletics || gametic > rendergametic)
		{
			rendergametic = gametic;
			rendertimeout = entertic+TICRATE/17;

			// Update display, next frame, with current state.
			D_Display();
			supdate = false;

			if (moviemode)
			{
#ifdef HAVE_PNG
				M_SaveFrame();
#else
				COM_BufAddText("screenshot");
#endif
			}
		}
		else if (rendertimeout < entertic) // in case the server hang or netsplit
		{
			// Lagless camera! Yay!
			if (gamestate == GS_LEVEL && netgame)
			{
				if (splitscreen && camera2.chase)
					P_MoveChaseCamera(&players[secondarydisplayplayer], &camera2, true);
				if (camera.chase)
					P_MoveChaseCamera(&players[displayplayer], &camera, true);
			}
			D_Display();
		}

		// consoleplayer -> displayplayer (hear sounds from viewpoint)
		S_UpdateSounds(); // move positional sounds

		// check for media change, loop music..
		I_UpdateCD();

#ifdef HW3SOUND
		HW3S_EndFrameUpdate();
#endif
	}
}
Пример #2
0
void D_SRB2Loop(void)
{
    tic_t oldentertics = 0, entertic = 0, realtics = 0, rendertimeout = INFTICS;

    if (dedicated)
        server = true;

    if (M_CheckParm("-voodoo")) // 256x256 Texture Limiter
        COM_BufAddText("gr_voodoocompatibility on\n");

    // Pushing of + parameters is now done back in D_SRB2Main, not here.

    CONS_Printf("I_StartupKeyboard()...\n");
    I_StartupKeyboard();

#ifdef _WINDOWS
    CONS_Printf("I_StartupMouse()...\n");
    I_DoStartupMouse();
#endif

    oldentertics = I_GetTime();

    // end of loading screen: CONS_Printf() will no more call FinishUpdate()
    con_startup = false;

    // make sure to do a d_display to init mode _before_ load a level
    SCR_SetMode(); // change video mode
    SCR_Recalc();

    // Check and print which version is executed.
    // Use this as the border between setup and the main game loop being entered.
    CONS_Printf(
        "===========================================================================\n"
        "                   We hope you enjoy this game as\n"
        "                     much as we did making it!\n"
        "                            ...wait. =P\n"
        "===========================================================================\n");

    // hack to start on a nice clear console screen.
    COM_ImmedExecute("cls;version");

    if (rendermode == render_soft)
        V_DrawScaledPatch(0, 0, 0, (patch_t *)W_CacheLumpNum(W_GetNumForName("CONSBACK"), PU_CACHE));
    I_FinishUpdate(); // page flip or blit buffer

    for (;;)
    {
        if (lastwipetic)
        {
            oldentertics = lastwipetic;
            lastwipetic = 0;
        }

        // get real tics
        entertic = I_GetTime();
        realtics = entertic - oldentertics;
        oldentertics = entertic;

#ifdef DEBUGFILE
        if (!realtics)
            if (debugload)
                debugload--;
#endif

        if (!realtics && !singletics)
        {
            I_Sleep();
            continue;
        }

#ifdef HW3SOUND
        HW3S_BeginFrameUpdate();
#endif

        // don't skip more than 10 frames at a time
        // (fadein / fadeout cause massive frame skip!)
        if (realtics > 8)
            realtics = 1;

        // process tics (but maybe not if realtic == 0)
        TryRunTics(realtics);

        if (lastdraw || singletics || gametic > rendergametic)
        {
            rendergametic = gametic;
            rendertimeout = entertic+TICRATE/17;

            // Update display, next frame, with current state.
            D_Display();
            supdate = false;

            if (moviemode)
                M_SaveFrame();
            if (takescreenshot) // Only take screenshots after drawing.
                M_DoScreenShot();
        }
        else if (rendertimeout < entertic) // in case the server hang or netsplit
        {
            // Lagless camera! Yay!
            if (gamestate == GS_LEVEL && netgame)
            {
                if (splitscreen && camera2.chase)
                    P_MoveChaseCamera(&players[secondarydisplayplayer], &camera2, false);
                if (camera.chase)
                    P_MoveChaseCamera(&players[displayplayer], &camera, false);
            }
            D_Display();

            if (moviemode)
                M_SaveFrame();
            if (takescreenshot) // Only take screenshots after drawing.
                M_DoScreenShot();
        }

        // consoleplayer -> displayplayer (hear sounds from viewpoint)
        S_UpdateSounds(); // move positional sounds

        // check for media change, loop music..
        I_UpdateCD();

#ifdef HW3SOUND
        HW3S_EndFrameUpdate();
#endif
    }
}
Пример #3
0
//
// P_Ticker
//
void P_Ticker(boolean run)
{
	INT32 i;

	//Increment jointime even if paused.
	for (i = 0; i < MAXPLAYERS; i++)
		if (playeringame[i])
			++players[i].jointime;

	if (objectplacing)
	{
		if (OP_FreezeObjectplace())
		{
			P_MapStart();
			OP_ObjectplaceMovement(&players[0]);
			P_MoveChaseCamera(&players[0], &camera, false);
			P_MapEnd();
			return;
		}
	}

	// Check for pause or menu up in single player
	if (paused || P_MenuActivePause())
		return;

	postimgtype = postimgtype2 = postimg_none;

	P_MapStart();

	if (run)
	{
		if (demorecording)
			G_WriteDemoTiccmd(&players[consoleplayer].cmd, 0);
		if (demoplayback)
			G_ReadDemoTiccmd(&players[consoleplayer].cmd, 0);

		for (i = 0; i < MAXPLAYERS; i++)
			if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
				P_PlayerThink(&players[i]);
	}

	// Keep track of how long they've been playing!
	totalplaytime++;

	if (!useNightsSS && G_IsSpecialStage(gamemap))
		P_DoSpecialStageStuff();

	if (runemeraldmanager)
		P_EmeraldManager(); // Power stone mode

	if (run)
	{
		P_RunThinkers();

		// Run any "after all the other thinkers" stuff
		for (i = 0; i < MAXPLAYERS; i++)
			if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
				P_PlayerAfterThink(&players[i]);

#ifdef HAVE_BLUA
		LUAh_ThinkFrame();
#endif
	}

	// Run shield positioning
	P_RunShields();

	P_UpdateSpecials();
	P_RespawnSpecials();

	// Lightning, rain sounds, etc.
	P_PrecipitationEffects();

	if (run)
		leveltime++;
	timeinmap++;

	if (G_TagGametype())
		P_DoTagStuff();

	if (G_GametypeHasTeams())
		P_DoCTFStuff();

	if (run)
	{
		if (countdowntimer && --countdowntimer <= 0)
		{
			countdowntimer = 0;
			countdowntimeup = true;
			for (i = 0; i < MAXPLAYERS; i++)
			{
				if (!playeringame[i] || players[i].spectator)
					continue;

				if (!players[i].mo)
					continue;

				P_DamageMobj(players[i].mo, NULL, NULL, 10000);
			}
		}

		if (countdown > 1)
			countdown--;

		if (countdown2)
			countdown2--;

		if (quake.time)
		{
			fixed_t ir = quake.intensity>>1;
			/// \todo Calculate distance from epicenter if set and modulate the intensity accordingly based on radius.
			quake.x = M_RandomRange(-ir,ir);
			quake.y = M_RandomRange(-ir,ir);
			quake.z = M_RandomRange(-ir,ir);
			--quake.time;
		}
		else