From c96855f59c378bd9be338c685f70524ed65bbfc3 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 1 May 2022 21:01:19 -0400 Subject: [PATCH] Use newer CVar setting code Fixes weirdness with the named values in fpscap --- src/command.c | 44 ++++++++++++++++++++++++++++++-------------- src/r_fps.c | 2 +- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/command.c b/src/command.c index 95fd5ef46..319baa577 100644 --- a/src/command.c +++ b/src/command.c @@ -1231,7 +1231,7 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth) // search for other 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->string = var->PossibleValue[i].strvalue; @@ -1616,6 +1616,9 @@ void CV_AddValue(consvar_t *var, INT32 increment) { INT32 newvalue, max; + if (!increment) + return; + // count pointlimit better /*if (var == &cv_pointlimit && (gametype == GT_MATCH)) 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 INT32 oldvalue = var->value - 1, gt; gt = cv_newgametype.value; - if (increment != 0) // Going up! { newvalue = var->value - 1; do @@ -1670,21 +1672,35 @@ void CV_AddValue(consvar_t *var, INT32 increment) { INT32 currentindice = -1, newindice; 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; - CV_SetValue(var, newvalue); + if (var->PossibleValue[max].value == 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 - CV_Set(var, var->PossibleValue[newindice].strvalue); + CV_Set(var, var->PossibleValue[currentindice].strvalue); } else CV_SetValue(var, newvalue); diff --git a/src/r_fps.c b/src/r_fps.c index 98e39bf69..e50a51d6c 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -35,7 +35,7 @@ static CV_PossibleValue_t fpscap_cons_t[] = { {0, "Match refresh rate"}, {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) {