From eb8cef41e425a210a4c0f99f4a67b25fcd8e3d10 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sun, 1 Sep 2019 23:04:07 +0200 Subject: [PATCH] shorten RA intro & allow to restart with pause --- src/d_netcmd.c | 8 +++++++- src/g_game.c | 22 ++++++++++++++++------ src/m_menu.c | 3 +-- src/m_menu.h | 3 +++ src/p_tick.c | 5 ++++- src/p_user.c | 2 +- 6 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 7dff1231..708c91a0 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2688,11 +2688,17 @@ static void Command_Pause(void) if (cv_pause.value || server || (IsPlayerAdmin(consoleplayer))) { - if (!paused && (modeattacking || !(gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING || gamestate == GS_WAITINGPLAYERS))) + if (!paused && (!(gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING || gamestate == GS_WAITINGPLAYERS))) { CONS_Printf(M_GetText("You can't pause here.\n")); return; } + else if (modeattacking) // in time attack, pausing restarts the map + { + M_ModeAttackRetry(0); // directly call from m_menu; + return; + } + SendNetXCmd(XD_PAUSE, &buf, 2); } else diff --git a/src/g_game.c b/src/g_game.c index b8a1a3bf..a11b877b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2320,6 +2320,12 @@ void G_Ticker(boolean run) UINT32 i; INT32 buf; ticcmd_t *cmd; + UINT32 ra_timeskip = (modeattacking && !demo.playback && leveltime < starttime - TICRATE*4) ? 0 : (starttime - TICRATE*4 - 1); + // starttime - TICRATE*4 is where we want RA to start when we PLAY IT, so we will loop the main thinker on RA start to get it to this point, + // the reason this is done is to ensure that ghosts won't look out of synch with other map elements (objects, moving platforms...) + // when we REPLAY, don't skip, let the camera spin, do its thing etc~ + + // also the -1 is to ensure that the thinker runs in the loop below. P_MapStart(); // do player reborns if needed @@ -2392,12 +2398,16 @@ void G_Ticker(boolean run) switch (gamestate) { case GS_LEVEL: - if (demo.title) - F_TitleDemoTicker(); - P_Ticker(run); // tic the game - ST_Ticker(); - AM_Ticker(); - HU_Ticker(); + + for (; ra_timeskip < starttime - TICRATE*4; ra_timeskip++) // this looks weird but this is done to not break compability with older demos for now. + { + if (demo.title) + F_TitleDemoTicker(); + P_Ticker(run); // tic the game + ST_Ticker(); + AM_Ticker(); + HU_Ticker(); + } break; case GS_INTERMISSION: diff --git a/src/m_menu.c b/src/m_menu.c index 97b1ce9b..62997a56 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -231,7 +231,6 @@ static void M_HandleStaffReplay(INT32 choice); static void M_ReplayTimeAttack(INT32 choice); static void M_ChooseTimeAttack(INT32 choice); //static void M_ChooseNightsAttack(INT32 choice); -static void M_ModeAttackRetry(INT32 choice); static void M_ModeAttackEndGame(INT32 choice); static void M_SetGuestReplay(INT32 choice); //static void M_ChoosePlayer(INT32 choice); @@ -8085,7 +8084,7 @@ static void M_SetGuestReplay(INT32 choice) which(0); } -static void M_ModeAttackRetry(INT32 choice) +void M_ModeAttackRetry(INT32 choice) { (void)choice; G_CheckDemoStatus(); // Cancel recording diff --git a/src/m_menu.h b/src/m_menu.h index 62c852e4..c2543509 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -54,6 +54,9 @@ void M_SortServerList(void); // Draws a box with a texture inside as background for messages void M_DrawTextBox(INT32 x, INT32 y, INT32 width, INT32 boxlines); +// Used in d_netcmd to restart time attack +void M_ModeAttackRetry(INT32 choice); + // the function to show a message box typing with the string inside // string must be static (not in the stack) // routine is a function taking a INT32 in parameter diff --git a/src/p_tick.c b/src/p_tick.c index 2502c721..08fbda72 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -689,7 +689,10 @@ void P_Ticker(boolean run) if (run) leveltime++; - timeinmap++; + + // as this is mostly used for HUD stuff, add the record attack specific hack to it as well! + if (!(modeattacking && !demo.playback) || leveltime >= starttime - TICRATE*4) + timeinmap++; /*if (G_TagGametype()) P_DoTagStuff(); diff --git a/src/p_user.c b/src/p_user.c index ced8b2da..84e43581 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7426,7 +7426,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall const INT32 timeovercam = max(0, min(180, (player->kartstuff[k_timeovercam] - 2*TICRATE)*15)); camrotate += timeovercam; } - else if (leveltime < introtime) // Whoooshy camera! + else if (leveltime < introtime && !(modeattacking && !demo.playback)) // Whoooshy camera! (don't do this in RA when we PLAY, still do it in replays however~) { const INT32 introcam = (introtime - leveltime); camrotate += introcam*5;