mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 15:21:44 +00:00
Iterate once through menu item list
Avoids any infinite loop cases.
This commit is contained in:
parent
c6f6a17176
commit
c03f4fd094
1 changed files with 21 additions and 41 deletions
|
@ -329,7 +329,7 @@ Menu_AddItem(menuframework_s *menu, void *item)
|
|||
void
|
||||
Menu_AdjustCursor(menuframework_s *m, int dir)
|
||||
{
|
||||
menucommon_s *citem;
|
||||
menucommon_s *citem = NULL;
|
||||
|
||||
/* see if it's in a valid spot */
|
||||
if ((m->cursor >= 0) && (m->cursor < m->nitems))
|
||||
|
@ -346,9 +346,9 @@ Menu_AdjustCursor(menuframework_s *m, int dir)
|
|||
|
||||
/* it's not in a valid spot, so crawl in the direction
|
||||
indicated until we find a valid spot */
|
||||
if (dir == 1)
|
||||
{
|
||||
while (1)
|
||||
int cursor = m->nitems;
|
||||
|
||||
while (cursor-- > 0)
|
||||
{
|
||||
citem = Menu_ItemAtCursor(m);
|
||||
|
||||
|
@ -367,31 +367,12 @@ Menu_AdjustCursor(menuframework_s *m, int dir)
|
|||
{
|
||||
m->cursor = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
citem = Menu_ItemAtCursor(m);
|
||||
|
||||
if (citem)
|
||||
{
|
||||
if (citem->type != MTYPE_SEPARATOR &&
|
||||
(citem->flags & QMF_INACTIVE) != QMF_INACTIVE)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m->cursor += dir;
|
||||
|
||||
if (m->cursor < 0)
|
||||
{
|
||||
m->cursor = m->nitems - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -431,9 +412,8 @@ Menu_Draw(menuframework_s *menu)
|
|||
SpinControl_Draw((menulist_s *)menu->items[i]);
|
||||
break;
|
||||
case MTYPE_BITMAP:
|
||||
{
|
||||
Bitmap_Draw(( menubitmap_s * )menu->items[i]);
|
||||
} break;
|
||||
break;
|
||||
case MTYPE_ACTION:
|
||||
Action_Draw((menuaction_s *)menu->items[i]);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue