add seclevel to menu items

This commit is contained in:
Andrew Pamment 2017-04-16 19:04:29 +10:00
parent b5c1ca9184
commit e8777eae69

View File

@ -53,6 +53,7 @@ struct menu_item {
char hotkey;
int command;
char *data;
int seclevel;
};
int menu_system(char *menufile) {
@ -104,6 +105,7 @@ int menu_system(char *menufile) {
menu[menu_items-1] = (struct menu_item *)malloc(sizeof(struct menu_item));
menu[menu_items-1]->hotkey = buffer[7];
menu[menu_items-1]->data = NULL;
menu[menu_items-1]->seclevel = 0;
} else if (strncasecmp(buffer, "COMMAND", 7) == 0 && menu_items > 0) {
if (strncasecmp(&buffer[8], "SUBMENU", 7) == 0) {
menu[menu_items-1]->command = MENU_SUBMENU;
@ -180,6 +182,8 @@ int menu_system(char *menufile) {
} else if (strncasecmp(&buffer[8], "DOSCRIPT", 8) == 0) {
menu[menu_items-1]->command = MENU_DOSCRIPT;
}
} else if (strncasecmp(buffer, "SECLEVEL", 8) == 0) {
menu[menu_items-1]->seclevel = atoi(&buffer[9]);
} else if (strncasecmp(buffer, "DATA", 4) == 0) {
menu[menu_items-1]->data = strdup(&buffer[5]);
} else if (strncasecmp(buffer, "LUASCRIPT", 9) == 0) {
@ -251,6 +255,7 @@ int menu_system(char *menufile) {
for (i=0;i<menu_items;i++) {
if (tolower(menu[i]->hotkey) == tolower(c)) {
if (menu[i]->seclevel <= gUser->sec_level) {
switch(menu[i]->command) {
case MENU_SUBMENU:
doquit = menu_system(menu[i]->data);
@ -431,6 +436,7 @@ int menu_system(char *menufile) {
}
}
}
}
// free menus;
return doquit;