Use newer CVar setting code

Fixes weirdness with the named values in fpscap
This commit is contained in:
Sally Coolatta 2022-05-01 21:01:19 -04:00
parent 1ab5a46256
commit c96855f59c
2 changed files with 31 additions and 15 deletions

View File

@ -1231,7 +1231,7 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
// search for other // search for other
for (i = MAXVAL+1; var->PossibleValue[i].strvalue; i++) for (i = MAXVAL+1; var->PossibleValue[i].strvalue; i++)
if (!stricmp(var->PossibleValue[i].strvalue, valstr)) if (v == var->PossibleValue[i].value || !stricmp(var->PossibleValue[i].strvalue, valstr))
{ {
var->value = var->PossibleValue[i].value; var->value = var->PossibleValue[i].value;
var->string = var->PossibleValue[i].strvalue; var->string = var->PossibleValue[i].strvalue;
@ -1616,6 +1616,9 @@ void CV_AddValue(consvar_t *var, INT32 increment)
{ {
INT32 newvalue, max; INT32 newvalue, max;
if (!increment)
return;
// count pointlimit better // count pointlimit better
/*if (var == &cv_pointlimit && (gametype == GT_MATCH)) /*if (var == &cv_pointlimit && (gametype == GT_MATCH))
increment *= 50;*/ increment *= 50;*/
@ -1628,7 +1631,6 @@ void CV_AddValue(consvar_t *var, INT32 increment)
// Special case for the nextmap variable, used only directly from the menu // Special case for the nextmap variable, used only directly from the menu
INT32 oldvalue = var->value - 1, gt; INT32 oldvalue = var->value - 1, gt;
gt = cv_newgametype.value; gt = cv_newgametype.value;
if (increment != 0) // Going up!
{ {
newvalue = var->value - 1; newvalue = var->value - 1;
do do
@ -1670,21 +1672,35 @@ void CV_AddValue(consvar_t *var, INT32 increment)
{ {
INT32 currentindice = -1, newindice; INT32 currentindice = -1, newindice;
for (max = MAXVAL+1; var->PossibleValue[max].strvalue; max++) for (max = MAXVAL+1; var->PossibleValue[max].strvalue; max++)
if (var->PossibleValue[max].value == var->value)
currentindice = max;
if (currentindice == -1 && max != MAXVAL+1)
newindice = ((increment > 0) ? MAXVAL : max) + increment;
else
newindice = currentindice + increment;
if (newindice >= max || newindice <= MAXVAL)
{ {
newvalue = var->PossibleValue[((increment > 0) ? MINVAL : MAXVAL)].value; if (var->PossibleValue[max].value == newvalue)
CV_SetValue(var, newvalue); {
increment = 0;
currentindice = max;
break; // The value we definitely want, stop here.
}
else if (var->PossibleValue[max].value == var->value)
currentindice = max; // The value we maybe want.
}
if (increment)
{
increment = (increment > 0) ? 1 : -1;
if (currentindice == -1 && max != MAXVAL+1)
newindice = ((increment > 0) ? MAXVAL : max) + increment;
else
newindice = currentindice + increment;
if (newindice >= max || newindice <= MAXVAL)
{
newvalue = var->PossibleValue[((increment > 0) ? MINVAL : MAXVAL)].value;
CV_SetValue(var, newvalue);
}
else
CV_Set(var, var->PossibleValue[newindice].strvalue);
} }
else else
CV_Set(var, var->PossibleValue[newindice].strvalue); CV_Set(var, var->PossibleValue[currentindice].strvalue);
} }
else else
CV_SetValue(var, newvalue); CV_SetValue(var, newvalue);

View File

@ -35,7 +35,7 @@ static CV_PossibleValue_t fpscap_cons_t[] = {
{0, "Match refresh rate"}, {0, "Match refresh rate"},
{0, NULL} {0, NULL}
}; };
consvar_t cv_fpscap = {"fpscap", "300", CV_SAVE, fpscap_cons_t, NULL, -1, NULL, NULL, 0, 0, NULL}; consvar_t cv_fpscap = {"fpscap", "Match refresh rate", CV_SAVE, fpscap_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
UINT32 R_GetFramerateCap(void) UINT32 R_GetFramerateCap(void)
{ {