Don't store redundant copies of default gamefunc names, since the indices are all that matter.

git-svn-id: https://svn.eduke32.com/eduke32@6184 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2017-06-17 11:41:54 +00:00
parent 549ba86e5c
commit 6d11c01fd7
5 changed files with 123 additions and 126 deletions

View file

@ -100,124 +100,124 @@ char gamefunctions[NUMGAMEFUNCTIONS][MAXGAMEFUNCLEN] =
#define NUMKEYENTRIES 56 #define NUMKEYENTRIES 56
char keydefaults[NUMGAMEFUNCTIONS*3][MAXGAMEFUNCLEN] = const char keydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN] =
{ {
"Move_Forward", "W", "Kpad8", "W", "Kpad8",
"Move_Backward", "S", "Kpad2", "S", "Kpad2",
"Turn_Left", "Left", "Kpad4", "Left", "Kpad4",
"Turn_Right", "Right", "KPad6", "Right", "KPad6",
"Strafe", "LAlt", "RAlt", "LAlt", "RAlt",
"Fire", "", "RCtrl", "", "RCtrl",
"Open", "E", "", "E", "",
"Run", "LShift", "RShift", "LShift", "RShift",
"AutoRun", "CapLck", "", "CapLck", "",
"Jump", "Space", "/", "Space", "/",
"Crouch", "LCtrl", "", "LCtrl", "",
"Look_Up", "PgUp", "Kpad9", "PgUp", "Kpad9",
"Look_Down", "PgDn", "Kpad3", "PgDn", "Kpad3",
"Look_Left", "Insert", "Kpad0", "Insert", "Kpad0",
"Look_Right", "Delete", "Kpad.", "Delete", "Kpad.",
"Strafe_Left", "A", "", "A", "",
"Strafe_Right", "D", "", "D", "",
"Aim_Up", "Home", "KPad7", "Home", "KPad7",
"Aim_Down", "End", "Kpad1", "End", "Kpad1",
"Weapon_1", "1", "", "1", "",
"Weapon_2", "2", "", "2", "",
"Weapon_3", "3", "", "3", "",
"Weapon_4", "4", "", "4", "",
"Weapon_5", "5", "", "5", "",
"Weapon_6", "6", "", "6", "",
"Weapon_7", "7", "", "7", "",
"Weapon_8", "8", "", "8", "",
"Weapon_9", "9", "", "9", "",
"Weapon_10", "0", "", "0", "",
"Inventory", "Enter", "KpdEnt", "Enter", "KpdEnt",
"Inventory_Left", "[", "", "[", "",
"Inventory_Right", "]", "", "]", "",
"Holo_Duke", "H", "", "H", "",
"Jetpack", "J", "", "J", "",
"NightVision", "N", "", "N", "",
"MedKit", "M", "", "M", "",
"TurnAround", "BakSpc", "", "BakSpc", "",
"SendMessage", "T", "", "T", "",
"Map", "Tab", "", "Tab", "",
"Shrink_Screen", "-", "Kpad-", "-", "Kpad-",
"Enlarge_Screen", "=", "Kpad+", "=", "Kpad+",
"Center_View", "KPad5", "", "KPad5", "",
"Holster_Weapon", "ScrLck", "", "ScrLck", "",
"Show_Opponents_Weapon", "Y", "", "Y", "",
"Map_Follow_Mode", "F", "", "F", "",
"See_Coop_View", "K", "", "K", "",
"Mouse_Aiming", "U", "", "U", "",
"Toggle_Crosshair", "I", "", "I", "",
"Steroids", "R", "", "R", "",
"Quick_Kick", "Q", "", "Q", "",
"Next_Weapon", "'", "", "'", "",
"Previous_Weapon", ";", "", ";", "",
"Show_Console", "`", "", "`", "",
"Show_DukeMatch_Scores", "", "", "", "",
"Dpad_Select", "", "", "", "",
"Dpad_Aiming", "", "", "", "",
}; };
const char oldkeydefaults[NUMGAMEFUNCTIONS*3][MAXGAMEFUNCLEN] = const char oldkeydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN] =
{ {
"Move_Forward", "Up", "Kpad8", "Up", "Kpad8",
"Move_Backward", "Down", "Kpad2", "Down", "Kpad2",
"Turn_Left", "Left", "Kpad4", "Left", "Kpad4",
"Turn_Right", "Right", "KPad6", "Right", "KPad6",
"Strafe", "LAlt", "RAlt", "LAlt", "RAlt",
"Fire", "LCtrl", "RCtrl", "LCtrl", "RCtrl",
"Open", "Space", "", "Space", "",
"Run", "LShift", "RShift", "LShift", "RShift",
"AutoRun", "CapLck", "", "CapLck", "",
"Jump", "A", "/", "A", "/",
"Crouch", "Z", "", "Z", "",
"Look_Up", "PgUp", "Kpad9", "PgUp", "Kpad9",
"Look_Down", "PgDn", "Kpad3", "PgDn", "Kpad3",
"Look_Left", "Insert", "Kpad0", "Insert", "Kpad0",
"Look_Right", "Delete", "Kpad.", "Delete", "Kpad.",
"Strafe_Left", ",", "", ",", "",
"Strafe_Right", ".", "", ".", "",
"Aim_Up", "Home", "KPad7", "Home", "KPad7",
"Aim_Down", "End", "Kpad1", "End", "Kpad1",
"Weapon_1", "1", "", "1", "",
"Weapon_2", "2", "", "2", "",
"Weapon_3", "3", "", "3", "",
"Weapon_4", "4", "", "4", "",
"Weapon_5", "5", "", "5", "",
"Weapon_6", "6", "", "6", "",
"Weapon_7", "7", "", "7", "",
"Weapon_8", "8", "", "8", "",
"Weapon_9", "9", "", "9", "",
"Weapon_10", "0", "", "0", "",
"Inventory", "Enter", "KpdEnt", "Enter", "KpdEnt",
"Inventory_Left", "[", "", "[", "",
"Inventory_Right", "]", "", "]", "",
"Holo_Duke", "H", "", "H", "",
"Jetpack", "J", "", "J", "",
"NightVision", "N", "", "N", "",
"MedKit", "M", "", "M", "",
"TurnAround", "BakSpc", "", "BakSpc", "",
"SendMessage", "T", "", "T", "",
"Map", "Tab", "", "Tab", "",
"Shrink_Screen", "-", "Kpad-", "-", "Kpad-",
"Enlarge_Screen", "=", "Kpad+", "=", "Kpad+",
"Center_View", "KPad5", "", "KPad5", "",
"Holster_Weapon", "ScrLck", "", "ScrLck", "",
"Show_Opponents_Weapon", "W", "", "W", "",
"Map_Follow_Mode", "F", "", "F", "",
"See_Coop_View", "K", "", "K", "",
"Mouse_Aiming", "U", "", "U", "",
"Toggle_Crosshair", "I", "", "I", "",
"Steroids", "R", "", "R", "",
"Quick_Kick", "`", "", "`", "",
"Next_Weapon", "'", "", "'", "",
"Previous_Weapon", ";", "", ";", "",
"Show_Console", "C", "", "C", "",
"Show_DukeMatch_Scores", "", "", "", "",
"Dpad_Select", "", "", "", "",
"Dpad_Aiming", "", "", "", "",
}; };
static const char * mousedefaults[MAXMOUSEBUTTONS] = static const char * mousedefaults[MAXMOUSEBUTTONS] =

View file

@ -114,18 +114,18 @@ const char *CONFIG_AnalogNumToName(int32_t func)
void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN]) void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN])
{ {
int32_t i,f; int32_t f;
Bmemset(ud.config.KeyboardKeys, 0xff, sizeof(ud.config.KeyboardKeys)); Bmemset(ud.config.KeyboardKeys, 0xff, sizeof(ud.config.KeyboardKeys));
CONTROL_ClearAllBinds(); CONTROL_ClearAllBinds();
for (i=0; i < (int32_t)ARRAY_SIZE(keydefaults); i+=3) for (size_t i=0; i < ARRAY_SIZE(keydefaults); i+=2)
{ {
f = CONFIG_FunctionNameToNum(keyptr[i+0]); f = CONFIG_FunctionNameToNum(gamefunctions[i>>1]);
if (f == -1) continue; if (f == -1) continue;
ud.config.KeyboardKeys[f][0] = KB_StringToScanCode(keyptr[i+1]); ud.config.KeyboardKeys[f][0] = KB_StringToScanCode(keyptr[i]);
ud.config.KeyboardKeys[f][1] = KB_StringToScanCode(keyptr[i+2]); ud.config.KeyboardKeys[f][1] = KB_StringToScanCode(keyptr[i+1]);
if (f == gamefunc_Show_Console) OSD_CaptureKey(ud.config.KeyboardKeys[f][0]); if (f == gamefunc_Show_Console) OSD_CaptureKey(ud.config.KeyboardKeys[f][0]);
else CONFIG_MapKey(f, ud.config.KeyboardKeys[f][0], 0, ud.config.KeyboardKeys[f][1], 0); else CONFIG_MapKey(f, ud.config.KeyboardKeys[f][0], 0, ud.config.KeyboardKeys[f][1], 0);
@ -262,7 +262,7 @@ void CONFIG_SetDefaults(void)
// JBF 20031211 // JBF 20031211
CONFIG_SetDefaultKeys((const char (*)[MAXGAMEFUNCLEN])keydefaults); CONFIG_SetDefaultKeys(keydefaults);
memset(ud.config.MouseFunctions, -1, sizeof(ud.config.MouseFunctions)); memset(ud.config.MouseFunctions, -1, sizeof(ud.config.MouseFunctions));
for (i=0; i<MAXMOUSEBUTTONS; i++) for (i=0; i<MAXMOUSEBUTTONS; i++)

View file

@ -39,8 +39,8 @@ extern "C" {
#define MAXGAMEFUNCLEN 32 #define MAXGAMEFUNCLEN 32
extern char gamefunctions[NUMGAMEFUNCTIONS][MAXGAMEFUNCLEN]; extern char gamefunctions[NUMGAMEFUNCTIONS][MAXGAMEFUNCLEN];
extern char keydefaults[NUMGAMEFUNCTIONS*3][MAXGAMEFUNCLEN]; extern const char keydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN];
extern const char oldkeydefaults[NUMGAMEFUNCTIONS*3][MAXGAMEFUNCLEN]; extern const char oldkeydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN];
enum GameFunction_t enum GameFunction_t
{ {

View file

@ -2424,7 +2424,6 @@ void C_DefineGameFuncName(int32_t idx, const char *name)
assert((unsigned)idx < NUMGAMEFUNCTIONS); assert((unsigned)idx < NUMGAMEFUNCTIONS);
Bstrncpyz(gamefunctions[idx], name, MAXGAMEFUNCLEN); Bstrncpyz(gamefunctions[idx], name, MAXGAMEFUNCLEN);
Bstrncpyz(keydefaults[3*idx], name, MAXGAMEFUNCLEN);
hash_add(&h_gamefuncs, gamefunctions[idx], idx, 0); hash_add(&h_gamefuncs, gamefunctions[idx], idx, 0);
} }
@ -5392,7 +5391,6 @@ repeatcase:
while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0)
{ {
gamefunctions[j][i] = *textptr; gamefunctions[j][i] = *textptr;
keydefaults[j*3][i] = *textptr;
textptr++,i++; textptr++,i++;
if (EDUKE32_PREDICT_FALSE(*textptr != 0x0a && *textptr != 0x0d && ispecial(*textptr))) if (EDUKE32_PREDICT_FALSE(*textptr != 0x0a && *textptr != 0x0d && ispecial(*textptr)))
{ {
@ -5412,7 +5410,6 @@ repeatcase:
} }
} }
gamefunctions[j][i] = '\0'; gamefunctions[j][i] = '\0';
keydefaults[j*3][i] = '\0';
hash_add(&h_gamefuncs,gamefunctions[j],j,0); hash_add(&h_gamefuncs,gamefunctions[j],j,0);
{ {
char *str = Bstrtolower(Xstrdup(gamefunctions[j])); char *str = Bstrtolower(Xstrdup(gamefunctions[j]));

View file

@ -2727,7 +2727,7 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry)
setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0);
} }
else if (entry == &ME_KEYBOARDSETUP_RESET) else if (entry == &ME_KEYBOARDSETUP_RESET)
CONFIG_SetDefaultKeys((const char (*)[MAXGAMEFUNCLEN])keydefaults); CONFIG_SetDefaultKeys(keydefaults);
else if (entry == &ME_KEYBOARDSETUP_RESETCLASSIC) else if (entry == &ME_KEYBOARDSETUP_RESETCLASSIC)
CONFIG_SetDefaultKeys(oldkeydefaults); CONFIG_SetDefaultKeys(oldkeydefaults);
else if (entry == &ME_NETHOST_LAUNCH) else if (entry == &ME_NETHOST_LAUNCH)