M_ChangeCvar: Split out core of function into M_ChangeCvarDirect, to prevent future code duplication

This commit is contained in:
toaster 2023-02-04 11:06:28 +00:00
parent 3ca1c554c4
commit a2fadd2ff4
2 changed files with 7 additions and 4 deletions

View file

@ -576,7 +576,7 @@ boolean M_MenuButtonPressed(UINT8 pid, UINT32 bt);
boolean M_MenuButtonHeld(UINT8 pid, UINT32 bt);
boolean M_ChangeStringCvar(INT32 choice);
void M_ChangeCvarDirect(INT32 choice, consvar_t *cv);
boolean M_NextOpt(void);
boolean M_PrevOpt(void);

View file

@ -132,10 +132,8 @@ static void Dummystaff_OnChange(void)
// BASIC MENU HANDLING
// =========================================================================
static void M_ChangeCvar(INT32 choice)
void M_ChangeCvarDirect(INT32 choice, consvar_t *cv)
{
consvar_t *cv = currentMenu->menuitems[itemOn].itemaction.cvar;
// Backspace sets values to default value
if (choice == -1)
{
@ -170,6 +168,11 @@ static void M_ChangeCvar(INT32 choice)
}
}
static void M_ChangeCvar(INT32 choice)
{
M_ChangeCvarDirect(choice, currentMenu->menuitems[itemOn].itemaction.cvar);
}
boolean M_NextOpt(void)
{
INT16 oldItemOn = itemOn; // prevent infinite loop