Skip to content

Commit

Permalink
Fix handling of empty menu lists.
Browse files Browse the repository at this point in the history
  • Loading branch information
skullernet committed Apr 5, 2013
1 parent 50fcb41 commit b39f8ea
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/client/ui/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,12 @@ SPIN CONTROL
static void SpinControl_Push(menuSpinControl_t *s)
{
int val = s->cvar->integer;
clamp(val, 0, s->numItems - 1);

if (val > s->numItems - 1)
val = s->numItems - 1;
if (val < 0)
val = 0;

s->curvalue = val;
}

Expand Down Expand Up @@ -814,7 +819,10 @@ MenuList_SetValue
*/
void MenuList_SetValue(menuList_t *l, int value)
{
clamp(value, 0, l->numItems - 1);
if (value > l->numItems - 1)
value = l->numItems - 1;
if (value < 0)
value = 0;

if (value != l->curvalue) {
l->curvalue = value;
Expand Down Expand Up @@ -1149,6 +1157,9 @@ static menuSound_t MenuList_Key(menuList_t *l, int key)

case K_END:
case K_KP_END:
if (!l->numItems) {
goto home;
}
if (l->numItems > l->maxItems) {
l->prestep = l->numItems - l->maxItems;
}
Expand Down

0 comments on commit b39f8ea

Please sign in to comment.