* Fix cv_pointlimit's weird behaviour in match mode by standardising the switching between "named" and "range" values in CV_AddValue.
* Optimise M_ChangeCvar.
This commit is contained in:
parent
3185a66191
commit
aa9bc574da
|
@ -1525,6 +1525,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;
|
||||||
|
@ -1553,7 +1556,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
|
||||||
|
@ -1597,22 +1599,40 @@ 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)
|
{
|
||||||
|
if (var->PossibleValue[max].value == newvalue)
|
||||||
|
{
|
||||||
|
increment = 0;
|
||||||
currentindice = max;
|
currentindice = max;
|
||||||
|
}
|
||||||
|
else if (var->PossibleValue[max].value == var->value)
|
||||||
|
currentindice = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (increment)
|
||||||
|
{
|
||||||
|
increment = (increment > 0) ? 1 : -1;
|
||||||
if (currentindice == -1 && max != MAXVAL+1)
|
if (currentindice == -1 && max != MAXVAL+1)
|
||||||
newindice = ((increment > 0) ? MAXVAL : max) + increment;
|
newindice = ((increment > 0) ? MAXVAL : max) + increment;
|
||||||
else
|
else
|
||||||
newindice = currentindice + increment;
|
newindice = currentindice + increment;
|
||||||
|
|
||||||
if (newindice >= max || newindice <= MAXVAL)
|
if (newindice >= max || newindice <= MAXVAL)
|
||||||
|
{
|
||||||
|
if (var == &cv_pointlimit && (gametype == GT_MATCH) && increment > 0)
|
||||||
|
CV_SetValue(var, 50);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
newvalue = var->PossibleValue[((increment > 0) ? MINVAL : MAXVAL)].value;
|
newvalue = var->PossibleValue[((increment > 0) ? MINVAL : MAXVAL)].value;
|
||||||
CV_SetValue(var, newvalue);
|
CV_SetValue(var, newvalue);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
CV_Set(var, var->PossibleValue[newindice].strvalue);
|
CV_Set(var, var->PossibleValue[newindice].strvalue);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
CV_Set(var, var->PossibleValue[currentindice].strvalue);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
CV_SetValue(var, newvalue);
|
CV_SetValue(var, newvalue);
|
||||||
}
|
}
|
||||||
|
|
20
src/m_menu.c
20
src/m_menu.c
|
@ -2788,32 +2788,20 @@ static void M_ChangeCvar(INT32 choice)
|
||||||
|
|
||||||
choice = (choice<<1) - 1;
|
choice = (choice<<1) - 1;
|
||||||
|
|
||||||
|
if (cv->flags & CV_FLOAT)
|
||||||
|
{
|
||||||
if (((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_SLIDER)
|
if (((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_SLIDER)
|
||||||
||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_INVISSLIDER)
|
||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_INVISSLIDER)
|
||||||
||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_NOMOD))
|
||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_NOMOD)
|
||||||
{
|
|| !(currentMenu->menuitems[itemOn].status & IT_CV_INTEGERSTEP))
|
||||||
if (cv->flags & CV_FLOAT && (currentMenu->menuitems[itemOn].status & IT_CV_FLOATSLIDER) == IT_CV_FLOATSLIDER)
|
|
||||||
{
|
{
|
||||||
char s[20];
|
char s[20];
|
||||||
sprintf(s,"%f",FIXED_TO_FLOAT(cv->value)+(choice)*(1.0f/16.0f));
|
sprintf(s,"%f",FIXED_TO_FLOAT(cv->value)+(choice)*(1.0f/16.0f));
|
||||||
CV_Set(cv,s);
|
CV_Set(cv,s);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CV_SetValue(cv,cv->value+(choice));
|
|
||||||
}
|
|
||||||
else if (cv->flags & CV_FLOAT)
|
|
||||||
{
|
|
||||||
if (currentMenu->menuitems[itemOn].status & IT_CV_INTEGERSTEP)
|
|
||||||
{
|
|
||||||
CV_SetValue(cv,FIXED_TO_FLOAT(cv->value)+(choice));
|
CV_SetValue(cv,FIXED_TO_FLOAT(cv->value)+(choice));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
char s[20];
|
|
||||||
sprintf(s,"%f",FIXED_TO_FLOAT(cv->value)+(choice)*(1.0f/16.0f));
|
|
||||||
CV_Set(cv,s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
CV_AddValue(cv,choice);
|
CV_AddValue(cv,choice);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue