diff --git a/source/duke3d/src/config.cpp b/source/duke3d/src/config.cpp index 07701714a..114f6630d 100644 --- a/source/duke3d/src/config.cpp +++ b/source/duke3d/src/config.cpp @@ -122,6 +122,9 @@ void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN]) for (size_t i=0; i < ARRAY_SIZE(keydefaults); i+=2) { + if (gamefunctions[i][0] == '\0') + continue; + f = CONFIG_FunctionNameToNum(gamefunctions[i>>1]); if (f == -1) continue; ud.config.KeyboardKeys[f][0] = KB_StringToScanCode(keyptr[i]); diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 1a3caa01a..50f627e35 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -6139,6 +6139,9 @@ int app_main(int argc, char const * const * argv) hash_init(&h_gamefuncs); for (bssize_t i=NUMGAMEFUNCTIONS-1; i>=0; i--) { + if (gamefunctions[i][0] == '\0') + continue; + char *str = Bstrtolower(Xstrdup(gamefunctions[i])); hash_add(&h_gamefuncs,gamefunctions[i],i,0); hash_add(&h_gamefuncs,str,i,0); diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index 2e1f0e035..965d08e82 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -6105,11 +6105,14 @@ static void C_AddDefaultDefinitions(void) { int32_t j; - if (!Bstrcmp(gamefunctions[i],"Show_Console")) continue; + if (gamefunctions[i][0] == '\0') + continue; - Bsprintf(tempbuf,"GAMEFUNC_%s", gamefunctions[i]); + // if (!Bstrcmp(gamefunctions[i],"Show_Console")) continue; - for (j=Bstrlen(tempbuf); j>=0; j--) + j = Bsprintf(tempbuf,"GAMEFUNC_%s", gamefunctions[i]); + + for (; j>=0; j--) tempbuf[j] = Btoupper(tempbuf[j]); C_AddDefinition(tempbuf, i, LABEL_DEFINE); diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp index 8431fcc26..f8929c543 100644 --- a/source/duke3d/src/menus.cpp +++ b/source/duke3d/src/menus.cpp @@ -236,7 +236,8 @@ static MenuOptionSet_t MEOS_YesNo = MAKE_MENUOPTIONSET( MEOSN_YesNo, NULL, 0x3 ) static char MenuGameFuncs[NUMGAMEFUNCTIONS][MAXGAMEFUNCLEN]; static char const *MenuGameFuncNone = " -None-"; static char const *MEOSN_Gamefuncs[NUMGAMEFUNCTIONS+1]; -static MenuOptionSet_t MEOS_Gamefuncs = MAKE_MENUOPTIONSET( MEOSN_Gamefuncs, NULL, 0x1 ); +static int32_t MEOSV_Gamefuncs[NUMGAMEFUNCTIONS+1]; +static MenuOptionSet_t MEOS_Gamefuncs = MAKE_MENUOPTIONSET( MEOSN_Gamefuncs, MEOSV_Gamefuncs, 0x1 ); @@ -1426,6 +1427,9 @@ void Menu_Init(void) } // prepare gamefuncs and keys + MEOSN_Gamefuncs[0] = MenuGameFuncNone; + MEOSV_Gamefuncs[0] = -1; + k = 1; for (i = 0; i < NUMGAMEFUNCTIONS; ++i) { Bstrcpy(MenuGameFuncs[i], gamefunctions[i]); @@ -1434,9 +1438,15 @@ void Menu_Init(void) if (MenuGameFuncs[i][j] == '_') MenuGameFuncs[i][j] = ' '; - MEOSN_Gamefuncs[i] = MenuGameFuncs[i]; + if (gamefunctions[i][0] != '\0') + { + MEOSN_Gamefuncs[k] = MenuGameFuncs[i]; + MEOSV_Gamefuncs[k] = i; + ++k; + } } - MEOSN_Gamefuncs[NUMGAMEFUNCTIONS] = MenuGameFuncNone; + MEOS_Gamefuncs.numOptions = k; + for (i = 0; i < NUMKEYS; ++i) MEOSN_Keys[i] = key_names[i]; MEOSN_Keys[NUMKEYS-1] = MenuKeyNone; @@ -1543,16 +1553,22 @@ void Menu_Init(void) } // prepare input + k = 0; for (i = 0; i < NUMGAMEFUNCTIONS; ++i) { - MEL_KEYBOARDSETUPFUNCS[i] = &ME_KEYBOARDSETUPFUNCS[i]; - ME_KEYBOARDSETUPFUNCS[i] = ME_KEYBOARDSETUPFUNCS_TEMPLATE; - ME_KEYBOARDSETUPFUNCS[i].name = MenuGameFuncs[i]; - ME_KEYBOARDSETUPFUNCS[i].entry = &MEO_KEYBOARDSETUPFUNCS[i]; - MEO_KEYBOARDSETUPFUNCS[i] = MEO_KEYBOARDSETUPFUNCS_TEMPLATE; - MEO_KEYBOARDSETUPFUNCS[i].column[0] = &ud.config.KeyboardKeys[i][0]; - MEO_KEYBOARDSETUPFUNCS[i].column[1] = &ud.config.KeyboardKeys[i][1]; + if (MenuGameFuncs[i][0] == '\0') + continue; + + MEL_KEYBOARDSETUPFUNCS[k] = &ME_KEYBOARDSETUPFUNCS[k]; + ME_KEYBOARDSETUPFUNCS[k] = ME_KEYBOARDSETUPFUNCS_TEMPLATE; + ME_KEYBOARDSETUPFUNCS[k].name = MenuGameFuncs[i]; + ME_KEYBOARDSETUPFUNCS[k].entry = &MEO_KEYBOARDSETUPFUNCS[k]; + MEO_KEYBOARDSETUPFUNCS[k] = MEO_KEYBOARDSETUPFUNCS_TEMPLATE; + MEO_KEYBOARDSETUPFUNCS[k].column[0] = &ud.config.KeyboardKeys[i][0]; + MEO_KEYBOARDSETUPFUNCS[k].column[1] = &ud.config.KeyboardKeys[i][1]; + ++k; } + M_KEYBOARDKEYS.numEntries = k; for (i = 0; i < MENUMOUSEFUNCTIONS; ++i) { MEL_MOUSESETUPBTNS[i] = &ME_MOUSESETUPBTNS[i]; diff --git a/source/duke3d/src/osdcmds.cpp b/source/duke3d/src/osdcmds.cpp index 5d24a1d33..c8e09e33a 100644 --- a/source/duke3d/src/osdcmds.cpp +++ b/source/duke3d/src/osdcmds.cpp @@ -1700,6 +1700,9 @@ int32_t registerosdcommands(void) char *t; int32_t j; + if (gamefunctions[i][0] == '\0') + continue; + // if (!Bstrcmp(gamefunctions[i],"Show_Console")) continue; Bsprintf(tempbuf,"gamefunc_%s",gamefunctions[i]);