aboutsummaryrefslogtreecommitdiffstats
path: root/menu/menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'menu/menu.c')
-rw-r--r--menu/menu.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/menu/menu.c b/menu/menu.c
index 26d6b17f..e786b924 100644
--- a/menu/menu.c
+++ b/menu/menu.c
@@ -338,23 +338,25 @@ void unreg_handler()
int add_menu(const char *title) // Create a new menu and return its position
{
- const int num = (unsigned char)menusystem.nummenus;
+ t_menu *m;
- if (num >= MAXMENUS) return -1;
- menusystem.menus[num].numitems = 0;
- menusystem.menus[num].menuwidth = 0;
- if (title)
- {
+ if (menusystem.nummenus >= MAXMENUS)
+ return -1;
+
+ m = &menusystem.menus[(unsigned int)menusystem.nummenus];
+
+ m->numitems = 0;
+ if (title) {
if (strlen(title) > MENULEN - 2) {
- strcpy(menusystem.menus[num].title," TITLE TOO LONG ");
+ strcpy(m->title," TITLE TOO LONG ");
} else {
- strcpy(menusystem.menus[num].title,title);
+ strcpy(m->title,title);
}
+ } else {
+ strcpy(m->title,"");
}
- else
- {
- strcpy(menusystem.menus[num].title,"");
- }
+
+ m->menuwidth = strlen(m->title);
return menusystem.nummenus++;
}