Menus: Wrap Menu_Find in Menu_FindFiltered to factor out id filtering for all cases that need it.

git-svn-id: https://svn.eduke32.com/eduke32@6315 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2017-07-05 05:37:46 +00:00
parent d032721aa1
commit d372800b3c

View file

@ -3436,6 +3436,14 @@ static Menu_t* Menu_Find(MenuID_t query)
return Menu_BinarySearch(query, 0, numMenus-1); return Menu_BinarySearch(query, 0, numMenus-1);
} }
static Menu_t* Menu_FindFiltered(MenuID_t query)
{
if ((g_player[myconnectindex].ps->gm&MODE_GAME) && query == MENU_MAIN)
query = MENU_MAIN_INGAME;
return Menu_Find(query);
}
MenuAnimation_t m_animation; MenuAnimation_t m_animation;
int32_t Menu_Anim_SinOutRight(MenuAnimation_t *animdata) int32_t Menu_Anim_SinOutRight(MenuAnimation_t *animdata)
@ -3525,10 +3533,7 @@ int Menu_Change(MenuID_t cm)
Menu_Close(myconnectindex); Menu_Close(myconnectindex);
else if (cm >= 0) else if (cm >= 0)
{ {
if ((g_player[myconnectindex].ps->gm&MODE_GAME) && cm == MENU_MAIN) search = Menu_FindFiltered(cm);
cm = MENU_MAIN_INGAME;
search = Menu_Find(cm);
if (search == NULL) if (search == NULL)
return 0; // intentional, so that users don't use any random value as "don't change" return 0; // intentional, so that users don't use any random value as "don't change"
@ -3547,7 +3552,7 @@ int Menu_Change(MenuID_t cm)
while (parent != NULL && parent->menuID != MENU_OPTIONS && parent->menuID != MENU_MAIN && parent->menuID != MENU_MAIN_INGAME) while (parent != NULL && parent->menuID != MENU_OPTIONS && parent->menuID != MENU_MAIN && parent->menuID != MENU_MAIN_INGAME)
{ {
result = parent = Menu_Find(parent->parentID); result = parent = Menu_FindFiltered(parent->parentID);
} }
m_parentMenu = result; m_parentMenu = result;