Add a -allowdesync parameter that will allow individual demos to desync. Warning is still shown, but player position will not be modified.

This commit is contained in:
Arthur 2024-02-21 14:38:11 -05:00
parent a8a92a57a7
commit 716b9527bf
6 changed files with 22 additions and 13 deletions

View file

@ -1664,10 +1664,10 @@ void D_SRB2Main(void)
if (M_CheckParm("-playdemo")) if (M_CheckParm("-playdemo"))
{ {
singledemo = true; // quit after one demo singledemo = true; // quit after one demo
G_DeferedPlayDemo(tmp); G_DeferedPlayDemo(tmp, M_CheckParm("-allowdemodesync") != 0);
} }
else else
G_TimeDemo(tmp); G_TimeDemo(tmp, M_CheckParm("-allowdemodesync") != 0);
G_SetGamestate(GS_NULL); G_SetGamestate(GS_NULL);
wipegamestate = GS_NULL; wipegamestate = GS_NULL;

View file

@ -3513,6 +3513,7 @@ void F_TitleScreenTicker(boolean run)
titledemo = true; titledemo = true;
demofileoverride = DFILE_OVERRIDE_NONE; demofileoverride = DFILE_OVERRIDE_NONE;
demoallowdesync = false;
G_DoPlayDemo(dname); G_DoPlayDemo(dname);
} }
} }

View file

@ -51,6 +51,7 @@ boolean demorecording;
boolean demoplayback; boolean demoplayback;
boolean titledemo; // Title Screen demo can be cancelled by any key boolean titledemo; // Title Screen demo can be cancelled by any key
demo_file_override_e demofileoverride; demo_file_override_e demofileoverride;
boolean demoallowdesync = false; // Allow demo files to de-sync
static UINT8 *demobuffer = NULL; static UINT8 *demobuffer = NULL;
static UINT8 *demo_p, *demotime_p; static UINT8 *demo_p, *demotime_p;
static UINT8 *demoend; static UINT8 *demoend;
@ -660,12 +661,15 @@ void G_ConsGhostTic(void)
CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n")); CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n"));
demosynced = false; demosynced = false;
if (!demoallowdesync)
{
P_UnsetThingPosition(testmo); P_UnsetThingPosition(testmo);
testmo->x = oldghost.x; testmo->x = oldghost.x;
testmo->y = oldghost.y; testmo->y = oldghost.y;
P_SetThingPosition(testmo); P_SetThingPosition(testmo);
testmo->z = oldghost.z; testmo->z = oldghost.z;
} }
}
if (*demo_p == DEMOMARKER) if (*demo_p == DEMOMARKER)
{ {
@ -1975,7 +1979,7 @@ UINT8 G_CmpDemoTime(char *oldname, char *newname)
// //
// G_PlayDemo // G_PlayDemo
// //
void G_DeferedPlayDemo(const char *name) void G_DeferedPlayDemo(const char *name, boolean allowdesync)
{ {
COM_BufAddText("playdemo \""); COM_BufAddText("playdemo \"");
COM_BufAddText(name); COM_BufAddText(name);
@ -2633,7 +2637,7 @@ void G_FreeGhosts(void)
// //
static INT32 restorecv_vidwait; static INT32 restorecv_vidwait;
void G_TimeDemo(const char *name) void G_TimeDemo(const char *name, boolean allowdesync)
{ {
nodrawers = M_CheckParm("-nodraw"); nodrawers = M_CheckParm("-nodraw");
noblit = M_CheckParm("-noblit"); noblit = M_CheckParm("-noblit");
@ -2644,7 +2648,7 @@ void G_TimeDemo(const char *name)
singletics = true; singletics = true;
framecount = 0; framecount = 0;
demostarttime = I_GetTime(); demostarttime = I_GetTime();
G_DeferedPlayDemo(name); G_DeferedPlayDemo(name, allowdesync);
} }
void G_DoPlayMetal(void) void G_DoPlayMetal(void)

View file

@ -35,6 +35,7 @@ typedef enum
} demo_file_override_e; } demo_file_override_e;
extern demo_file_override_e demofileoverride; extern demo_file_override_e demofileoverride;
extern boolean demoallowdesync;
// Quit after playing a demo from cmdline. // Quit after playing a demo from cmdline.
extern boolean singledemo; extern boolean singledemo;
@ -94,9 +95,9 @@ void G_WriteMetalTic(mobj_t *metal);
void G_SaveMetal(UINT8 **buffer); void G_SaveMetal(UINT8 **buffer);
void G_LoadMetal(UINT8 **buffer); void G_LoadMetal(UINT8 **buffer);
void G_DeferedPlayDemo(const char *demo); void G_DeferedPlayDemo(const char *demo, boolean allowdesync);
void G_DoPlayDemo(char *defdemoname); void G_DoPlayDemo(char *defdemoname);
void G_TimeDemo(const char *name); void G_TimeDemo(const char *name, boolean allowdesync);
void G_AddGhost(char *defdemoname); void G_AddGhost(char *defdemoname);
void G_FreeGhosts(void); void G_FreeGhosts(void);
void G_DoPlayMetal(void); void G_DoPlayMetal(void);

View file

@ -10529,6 +10529,7 @@ static void M_StartTimeAttackReplay(INT32 choice)
{ {
M_ClearMenus(true); M_ClearMenus(true);
modeattacking = ATTACKING_RECORD; // set modeattacking before G_DoPlayDemo so the map loader knows modeattacking = ATTACKING_RECORD; // set modeattacking before G_DoPlayDemo so the map loader knows
demoallowdesync = false;
G_DoPlayDemo(ra_demoname); G_DoPlayDemo(ra_demoname);
} }
} }

View file

@ -1596,6 +1596,8 @@ static void Command_Playdemo_f(void)
demofileoverride = DFILE_OVERRIDE_SKIP; demofileoverride = DFILE_OVERRIDE_SKIP;
} }
demoallowdesync = COM_CheckParm("-allowdesync");
// Internal if no extension, external if one exists // Internal if no extension, external if one exists
// If external, convert the file name to a path in SRB2's home directory // If external, convert the file name to a path in SRB2's home directory
if (FIL_CheckExtension(name)) if (FIL_CheckExtension(name))
@ -1643,7 +1645,7 @@ static void Command_Timedemo_f(void)
CONS_Printf(M_GetText("Timing demo '%s'.\n"), timedemo_name); CONS_Printf(M_GetText("Timing demo '%s'.\n"), timedemo_name);
G_TimeDemo(timedemo_name); G_TimeDemo(timedemo_name, COM_CheckParm("-allowdesync"));
} }
// stop current demo // stop current demo