Skip to content

Commit

Permalink
Fixed issue where user console settings were lost after demo recording.
Browse files Browse the repository at this point in the history
  • Loading branch information
JadingTsunami committed Nov 22, 2024
1 parent 9152f2f commit 946ac1a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions prboom2/src/SDL/i_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,13 +457,13 @@ void I_SafeExit(int rc)

static void I_Quit (void)
{
if (!netgame && !demorecording && !demoplayback && gameaction != ga_playdemo)
C_SaveSettings();
if (!demorecording)
I_EndDoom();
if (demorecording)
G_CheckDemoStatus();
M_SaveDefaults ();
if (!netgame && !demorecording && !demoplayback && gameaction != ga_playdemo)
C_SaveSettings();
I_DemoExShutdown();
}

Expand Down
22 changes: 14 additions & 8 deletions prboom2/src/c_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1855,16 +1855,16 @@ dboolean C_ExecuteBind(int keycode, evtype_t evtype)
keybind_t* kb = keybind_head;
dboolean executed = false;

if (netgame) {
doom_printf("Binds not allowed during net play.");
return false;
} else if (demorecording || demoplayback) {
doom_printf("Binds not allowed during demos.");
return false;
}

while (kb) {
if (kb->keycode == keycode && kb->type == evtype) {
if (netgame) {
doom_printf("Binds not allowed during net play.");
return false;
} else if (demorecording || demoplayback) {
doom_printf("Binds not allowed during demos.");
return false;
}

C_ConsoleCommand(kb->cmd);
executed = true;
}
Expand Down Expand Up @@ -1912,6 +1912,11 @@ static char* C_GetConsoleSettingsFile()
#define CONSOLE_CONFIG_LINE_MAX (256)
void C_SaveSettings()
{
/* do nothing if console is disallowed */
if (netgame || demorecording || demoplayback || gameaction == ga_playdemo) {
return;
}

keybind_t* kb = keybind_head;
FILE* bindfile = M_fopen (C_GetConsoleSettingsFile(), "w");

Expand Down Expand Up @@ -1955,6 +1960,7 @@ void C_LoadSettings()

/* skip running user console commands when not allowed */
if (netgame || demorecording || demoplayback || gameaction == ga_playdemo) {
free(linebuffer);
return;
}

Expand Down

0 comments on commit 946ac1a

Please sign in to comment.