Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement reload / go to next level while demo playing #1107

Merged
merged 5 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/doom/g_game.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//

Check notice on line 1 in src/doom/g_game.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

Run clang-format on src/doom/g_game.c

File src/doom/g_game.c does not conform to Custom style guidelines. (lines 3383, 3393)
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005-2014 Simon Howard
//
Expand Down Expand Up @@ -90,7 +90,6 @@

void G_DoLoadLevel (void);
void G_DoNewGame (void);
void G_DoPlayDemo (void);
void G_DoCompleted (void);
void G_DoVictory (void);
void G_DoWorldDone (void);
Expand Down Expand Up @@ -3374,5 +3373,23 @@
return false;
}

//
// G_DemoGotoNextLevel
// [crispy] fast forward to next level while demo playback
//

boolean demo_gotonextlvl;

void G_DemoGotoNextLevel (boolean start)
{
// disable screen rendering while fast forwarding
nodrawers = start;

// switch to fast tics running mode if not in -timedemo
if (!timingdemo)
{
singletics = start;
}
}


6 changes: 6 additions & 0 deletions src/doom/g_game.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//

Check notice on line 1 in src/doom/g_game.h

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

Run clang-format on src/doom/g_game.h

File src/doom/g_game.h does not conform to Custom style guidelines. (lines 62, 64, 65)
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005-2014 Simon Howard
//
Expand Down Expand Up @@ -58,6 +58,12 @@
void G_TimeDemo (char* name);
boolean G_CheckDemoStatus (void);

// [crispy] fast forward to next level while demo playback
extern boolean netdemo;
extern boolean demo_gotonextlvl;
void G_DoPlayDemo (void);
void G_DemoGotoNextLevel (boolean start);

void G_ExitLevel (void);
void G_SecretExitLevel (void);

Expand Down
26 changes: 24 additions & 2 deletions src/doom/m_menu.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//

Check notice on line 1 in src/doom/m_menu.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

Run clang-format on src/doom/m_menu.c

File src/doom/m_menu.c does not conform to Custom style guidelines. (lines 2749, 2751, 2752, 2753, 2754, 2755, 2756, 2757, 2758, 2759, 2760, 2761, 2762, 2763, 2769, 2770, 2771, 2772, 2773, 2774, 2775, 2776)
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005-2014 Simon Howard
//
Expand Down Expand Up @@ -2745,13 +2745,35 @@
}
// [crispy] those two can be considered as shortcuts for the IDCLEV cheat
// and should be treated as such, i.e. add "if (!netgame)"
else if (!netgame && key != 0 && key == key_menu_reloadlevel)
// hovewer, allow while multiplayer demos
else if ((!netgame || netdemo) && key != 0 && key == key_menu_reloadlevel)
{
if (demoplayback)
{
if (crispy->demowarp)
{
// [crispy] enable screen render back before replaying
nodrawers = false;
singletics = false;
}
// [crispy] replay demo lump or file
G_DoPlayDemo();
return true;
}
else
if (G_ReloadLevel())
return true;
}
else if (!netgame && key != 0 && key == key_menu_nextlevel)
else if ((!netgame || netdemo) && key != 0 && key == key_menu_nextlevel)
{
if (demoplayback)
{
// [crispy] go to next level
demo_gotonextlvl = true;
G_DemoGotoNextLevel(true);
return true;
}
else
if (G_GotoNextLevel())
return true;
}
Expand Down
8 changes: 8 additions & 0 deletions src/doom/p_mobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "s_musinfo.h" // [crispy] S_ParseMusInfo()
#include "i_swap.h" // [crispy] SHORT()
#include "w_wad.h" // [crispy] W_CacheLumpNum()
#include "g_game.h" // [crispy] demo_gotonextlvl

#include "doomstat.h"

Expand Down Expand Up @@ -889,6 +890,13 @@ void P_SpawnPlayer (mapthing_t* mthing)

int i;

// [crispy] stop fast forward after entering new level while demo playback
if (demo_gotonextlvl)
{
demo_gotonextlvl = false;
G_DemoGotoNextLevel(false);
}

if (mthing->type == 0)
{
return;
Expand Down
5 changes: 3 additions & 2 deletions src/doom/s_sound.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//

Check notice on line 1 in src/doom/s_sound.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

Run clang-format on src/doom/s_sound.c

File src/doom/s_sound.c does not conform to Custom style guidelines. (lines 444, 937)
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005-2014 Simon Howard
//
Expand Down Expand Up @@ -37,6 +37,7 @@
#include "p_local.h"
#include "w_wad.h"
#include "z_zone.h"
#include "g_game.h" // [crispy] demo_gotonextlvl

// when to clip out sounds
// Does not fit the large outdoor areas.
Expand Down Expand Up @@ -440,7 +441,7 @@
{
const short curmap = (gameepisode << 8) + gamemap;

if (prevmap == curmap || (nodrawers && singletics))
if (prevmap == curmap || (nodrawers && singletics && !demo_gotonextlvl))
return;

prevmap = curmap;
Expand Down Expand Up @@ -933,7 +934,7 @@
musinfo.current_item = -1;

// [crispy] play no music if this is not the right map
if (nodrawers && singletics)
if (nodrawers && singletics && !demo_gotonextlvl)
return;

// [crispy] restart current music if IDMUS00 is entered
Expand Down
2 changes: 1 addition & 1 deletion src/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,7 @@ static void SetVideoMode(void)
}

// Turn on vsync if we aren't in a -timedemo
if (!singletics && mode.refresh_rate > 0)
if ((!singletics && mode.refresh_rate > 0) || crispy->demowarp)
{
if (crispy->vsync) // [crispy] uncapped vsync
{
Expand Down
Loading