From: Holger Schemel Date: Mon, 4 Feb 2019 21:11:51 +0000 (+0100) Subject: improved some code with more compact variant of same functionality X-Git-Tag: 4.1.2.0~32 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=54d132a180d8c428eb05c41b72b410ff1623994f;p=rocksndiamonds.git improved some code with more compact variant of same functionality --- diff --git a/src/screens.c b/src/screens.c index 5195cacd..8defaee4 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1690,14 +1690,9 @@ static void gotoTopLevelDir(void) { int num_leveldirs = numTreeInfoInGroup(leveldir_current); int leveldir_pos = posTreeInfo(leveldir_current); - int num_page_entries; + int num_page_entries = MIN(num_leveldirs, NUM_MENU_ENTRIES_ON_SCREEN); int cl_first, cl_cursor; - if (num_leveldirs <= NUM_MENU_ENTRIES_ON_SCREEN) - num_page_entries = num_leveldirs; - else - num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN; - cl_first = MAX(0, leveldir_pos - num_page_entries + 1); cl_cursor = leveldir_pos - cl_first; @@ -4182,14 +4177,9 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, int y = ti->cl_cursor; int step = (button == 1 ? 1 : button == 2 ? 5 : 10); int num_entries = numTreeInfoInGroup(ti); - int num_page_entries; + int num_page_entries = MIN(num_entries, NUM_MENU_ENTRIES_ON_SCREEN); boolean position_set_by_scrollbar = (dx == 999); - if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN) - num_page_entries = num_entries; - else - num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN; - if (button == MB_MENU_INITIALIZE) { int num_entries = numTreeInfoInGroup(ti);