Skip to content

Commit

Permalink
set console command can read cvars. Don't dump console settings file …
Browse files Browse the repository at this point in the history
…when console isn't allowed.
  • Loading branch information
JadingTsunami committed Feb 9, 2024
1 parent 669a0ec commit ba5682a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
3 changes: 2 additions & 1 deletion prboom2/src/SDL/i_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,8 @@ static void I_Quit (void)
if (demorecording)
G_CheckDemoStatus();
M_SaveDefaults ();
C_SaveSettings();
if (!netgame && !demorecording && !demoplayback && !gameaction == ga_playdemo)
C_SaveSettings();
I_DemoExShutdown();
}

Expand Down
37 changes: 27 additions & 10 deletions prboom2/src/c_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,20 +892,37 @@ static void C_set(char* cmd)

int num_args = C_ParseArgs(cmd, args, 2);

if (num_args < 2) {
doom_printf("Usage: set <variable> <value>");
if (num_args < 1) {
doom_printf("Usage: set <variable> [value]");
return;
}

key = args[0];
svalue = C_StripSpaces(args[1]);

status = C_CvarCreateOrUpdate(key, svalue, 0);

if (status == CVAR_STATUS_OK)
doom_printf("Set CVAR %s=%s", key, svalue);
else
doom_printf("Error setting CVAR %s: %s", key, C_CvarErrorToString(status));
if (num_args == 2) {
svalue = C_StripSpaces(args[1]);
status = C_CvarCreateOrUpdate(key, svalue, 0);
if (status == CVAR_STATUS_OK)
doom_printf("Set CVAR %s=%s", key, svalue);
else
doom_printf("Error setting CVAR %s: %s", key, C_CvarErrorToString(status));
} else if (C_CvarExists(key)) {
switch (C_CvarGetType(key, NULL)) {
case CVAR_TYPE_INT:
doom_printf("CVAR %s=%d", key, C_CvarGetAsInt(key, NULL));
break;
case CVAR_TYPE_FLOAT:
doom_printf("CVAR %s=%f", key, C_CvarGetAsFloat(key, NULL));
break;
case CVAR_TYPE_STRING:
doom_printf("CVAR %s=%s", key, C_CvarGetAsString(key, NULL));
break;
default:
doom_printf("CVAR %s has unknown type", key);
break;
}
} else {
doom_printf("No CVAR named %s", key);
}
}

static void C_unset(char* cmd)
Expand Down

0 comments on commit ba5682a

Please sign in to comment.