From 892033931e5dd72476ac9815ba2eb618c6438d41 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Sun, 25 Mar 2018 03:26:41 +0300 Subject: [PATCH] Fixed double-increment and use a safer way to fetch a bank names (in case of new bank will be added (or removed) on ADLMIDI side, no need to change the count of banks in "some deep place" of code) --- src/menu/menudef.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp index ea410f571..c0c538088 100644 --- a/src/menu/menudef.cpp +++ b/src/menu/menudef.cpp @@ -1381,7 +1381,11 @@ static void InitCrosshairsList() // Initialize the music configuration submenus // //============================================================================= -extern const char* const banknames[74]; +extern "C" +{ + extern int adl_getBanksCount(); + extern const char *const *adl_getBankNames(); +} static void InitMusicMenus() { @@ -1427,11 +1431,12 @@ static void InitMusicMenus() { if (soundfonts.Size() > 0) { - for(int i=0;i<74;i++) + int adl_banks_count = adl_getBanksCount(); + const char *const *adl_bank_names = adl_getBankNames(); + for(int i=0; i < adl_banks_count; i++) { - auto it = CreateOptionMenuItemCommand(banknames[i], FStringf("adl_bank %d", i), true); + auto it = CreateOptionMenuItemCommand(adl_bank_names[i], FStringf("adl_bank %d", i), true); static_cast(*menu)->mItems.Push(it); - i++; } } }