diff --git a/src/d_netcmd.c b/src/d_netcmd.c index dbf06cc39..b3453f999 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4110,7 +4110,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) CON_LogMessage(M_GetText("Speeding off to level...\n")); } - demo.savemode = (cv_recordmultiplayerdemos.value == 2) ? DSM_WILLAUTOSAVE : DSM_NOTSAVING; + demo.savemode = (G_DemoWillAutoSave()) ? DSM_WILLAUTOSAVE : DSM_NOTSAVING; demo.savebutton = 0; // clear this demo before recording a new one diff --git a/src/g_demo.c b/src/g_demo.c index 24980f8f5..c4987c24c 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -56,8 +56,15 @@ #include "k_grandprix.h" #include "k_vote.h" -static CV_PossibleValue_t recordmultiplayerdemos_cons_t[] = {{0, "Disabled"}, {1, "Manual Save"}, {2, "Auto Save"}, {0, NULL}}; -consvar_t cv_recordmultiplayerdemos = CVAR_INIT ("netdemo_record", "Manual Save", CV_SAVE, recordmultiplayerdemos_cons_t, NULL); +static CV_PossibleValue_t recordmultiplayerdemos_cons_t[] = { + {DEMOSAVE_NONE, "Disabled"}, + {DEMOSAVE_MANUAL, "Manual Save"}, + {DEMOSAVE_AUTO_NETONLY, "Auto Save Online"}, + {DEMOSAVE_AUTO, "Auto Save All"}, + {0, NULL}}; + +consvar_t cv_recordmultiplayerdemos = + CVAR_INIT("netdemo_record", "Manual Save", CV_SAVE, recordmultiplayerdemos_cons_t, NULL); static CV_PossibleValue_t netdemosyncquality_cons_t[] = {{1, "MIN"}, {35, "MAX"}, {0, NULL}}; consvar_t cv_netdemosyncquality = CVAR_INIT ("netdemo_syncquality", "1", CV_SAVE, netdemosyncquality_cons_t, NULL); @@ -190,6 +197,23 @@ static ticcmd_t oldcmd[MAXPLAYERS]; #define FZT_SCALE 0x10 // different scale to object // spare FZT slots 0x20 to 0x80 +// +// Checks if auto-saving demos is allowed. +// +boolean G_DemoWillAutoSave(void) +{ + if (cv_recordmultiplayerdemos.value == DEMOSAVE_AUTO_NETONLY) + { + return (netgame); + } + else if (cv_recordmultiplayerdemos.value == DEMOSAVE_AUTO) + { + return true; + } + + return false; +} + typedef struct { char *filename; @@ -4614,7 +4638,7 @@ boolean G_DemoTitleResponder(event_t *ev) // Only ESC and non-keyboard keys abort connection if (ch == KEY_ESCAPE) { - demo.savemode = (cv_recordmultiplayerdemos.value == 2) ? DSM_WILLAUTOSAVE : DSM_NOTSAVING; + demo.savemode = (G_DemoWillAutoSave()) ? DSM_WILLAUTOSAVE : DSM_NOTSAVING; return true; } diff --git a/src/g_demo.h b/src/g_demo.h index 65ac075db..5c2cb856c 100644 --- a/src/g_demo.h +++ b/src/g_demo.h @@ -28,6 +28,13 @@ extern "C" { // DEMO playback/recording related stuff. // ====================================== +typedef enum { + DEMOSAVE_NONE = 0, + DEMOSAVE_MANUAL, + DEMOSAVE_AUTO_NETONLY, + DEMOSAVE_AUTO +} demosavemode_e; + extern consvar_t cv_recordmultiplayerdemos, cv_netdemosyncquality, cv_netdemosize; extern consvar_t cv_resyncdemo; @@ -183,6 +190,7 @@ extern demoghost *ghosts; #define DFILE_ERROR_CANNOTLOAD 0x04 // Files are missing and cannot be loaded. #define DFILE_ERROR_EXTRAFILES 0x05 // Extra files outside of the replay's file list are loaded. +boolean G_DemoWillAutoSave(void); void G_DeferedPlayDemo(const char *demo); void G_DoPlayDemo(char *defdemoname); void G_SetupDemoPlayer(INT32 i);