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)
This commit is contained in:
Vitaly Novichkov 2018-03-25 03:26:41 +03:00 committed by Christoph Oelckers
parent 79d7067f07
commit f7e45b06b7
1 changed files with 9 additions and 4 deletions

View File

@ -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<DOptionMenuDescriptor*>(*menu)->mItems.Push(it);
i++;
}
}
}