summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2013-04-05 18:57:44 +0400
committerAndrey Nazarov <skuller@skuller.net>2013-04-05 19:00:46 +0400
commitb39f8ea8ba472f5f44747be38091b341cb19d425 (patch)
tree965e713ee91668433a1f03adef8704be48417bc3 /src
parent50fcb41bebc280bd2ea01652129a109b19a01aff (diff)
Fix handling of empty menu lists.
Diffstat (limited to 'src')
-rw-r--r--src/client/ui/menu.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/client/ui/menu.c b/src/client/ui/menu.c
index 7dd5f20..ce45b25 100644
--- a/src/client/ui/menu.c
+++ b/src/client/ui/menu.c
@@ -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;
}
@@ -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;
@@ -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;
}