From aaa6418981c68161b460841774c7dff2dcce665f Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 6 Apr 2019 18:06:02 -0500 Subject: [PATCH] Various fixes and tweaks to rewinds --- src/g_game.c | 25 ++++++++++++++++++------- src/m_menu.c | 12 ++++++++---- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index d3f8d798..701f0673 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -5939,6 +5939,10 @@ void G_PreviewRewind(tic_t previewtime) size_t i, j; fixed_t tweenvalue = 0; rewindinfo_t *info = rewindhead, *next_info = rewindhead; + + if (!info) + return; + while (info->leveltime > previewtime && info->prev) { next_info = info; @@ -5947,6 +5951,7 @@ void G_PreviewRewind(tic_t previewtime) if (info != next_info) tweenvalue = FixedDiv(previewtime - info->leveltime, next_info->leveltime - info->leveltime); + for (i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i] || players[i].spectator) @@ -5998,16 +6003,23 @@ void G_PreviewRewind(tic_t previewtime) void G_ConfirmRewind(tic_t rewindtime) { tic_t i; - boolean oldmenuactive = menuactive, oldsounddisabled = sound_disabled, olddigitaldisabled = digital_disabled; + boolean oldmenuactive = menuactive, oldsounddisabled = sound_disabled; INT32 olddp1 = displayplayer, olddp2 = secondarydisplayplayer, olddp3 = thirddisplayplayer, olddp4 = fourthdisplayplayer; UINT8 oldss = splitscreen; - cv_renderview.value = 0; - menuactive = false; // Prevent loops - sound_disabled = /*digital_disabled =*/ true; // Prevent sound spam - demo.rewinding = true; // may not need later + + CV_StealthSetValue(&cv_renderview, 0); + + if (rewindtime > starttime) + { + sound_disabled = true; // Prevent sound spam + demo.rewinding = true; + } + else + demo.rewinding = false; + G_DoPlayDemo(NULL); // Restart the current demo for (i = 0; i < rewindtime && leveltime < rewindtime; i++) @@ -6019,11 +6031,10 @@ void G_ConfirmRewind(tic_t rewindtime) demo.rewinding = false; menuactive = oldmenuactive; // Bring the menu back up sound_disabled = oldsounddisabled; // Re-enable SFX - digital_disabled = olddigitaldisabled; wipegamestate = gamestate; // No fading back in! - cv_renderview.value = 1; + COM_BufInsertText("renderview on\n"); splitscreen = oldss; displayplayer = olddp1; diff --git a/src/m_menu.c b/src/m_menu.c index 915643ac..c3d2397f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5759,7 +5759,7 @@ static void M_DrawPlaybackMenu(void) else icon = W_CachePatchName("PLAYRANK", PU_CACHE); // temp - if (i == playback_fastforward && cv_playbackspeed.value > 1) + if ((i == playback_fastforward && cv_playbackspeed.value > 1) || (i == playback_rewind && demo.rewinding)) V_DrawMappedPatch(currentMenu->x + currentMenu->menuitems[i].alphaKey, currentMenu->y, 0, icon, R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_SILVER, GTC_MENUCACHE)); else V_DrawMappedPatch(currentMenu->x + currentMenu->menuitems[i].alphaKey, currentMenu->y, 0, icon, (i == itemOn) ? activemap : inactivemap); @@ -5771,6 +5771,8 @@ static void M_DrawPlaybackMenu(void) static void M_PlaybackRewind(INT32 choice) { + static tic_t lastconfirmtime; + (void)choice; if (!demo.rewinding) @@ -5784,11 +5786,13 @@ static void M_PlaybackRewind(INT32 choice) else demo.rewinding = paused = true; } - else + else if (lastconfirmtime + TICRATE/2 < I_GetTime()) + { + lastconfirmtime = I_GetTime(); G_ConfirmRewind(leveltime); + } - // temp - //G_ConfirmRewind(starttime + 90*TICRATE); + CV_SetValue(&cv_playbackspeed, 1); } static void M_PlaybackPause(INT32 choice)