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
char keydefaults[NUMGAMEFUNCTIONS*3][MAXGAMEFUNCLEN] =
const char keydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN] =
{
"Move_Forward", "W", "Kpad8",
"Move_Backward", "S", "Kpad2",
"Turn_Left", "Left", "Kpad4",
"Turn_Right", "Right", "KPad6",
"Strafe", "LAlt", "RAlt",
"Fire", "", "RCtrl",
"Open", "E", "",
"Run", "LShift", "RShift",
"AutoRun", "CapLck", "",
"Jump", "Space", "/",
"Crouch", "LCtrl", "",
"Look_Up", "PgUp", "Kpad9",
"Look_Down", "PgDn", "Kpad3",
"Look_Left", "Insert", "Kpad0",
"Look_Right", "Delete", "Kpad.",
"Strafe_Left", "A", "",
"Strafe_Right", "D", "",
"Aim_Up", "Home", "KPad7",
"Aim_Down", "End", "Kpad1",
"Weapon_1", "1", "",
"Weapon_2", "2", "",
"Weapon_3", "3", "",
"Weapon_4", "4", "",
"Weapon_5", "5", "",
"Weapon_6", "6", "",
"Weapon_7", "7", "",
"Weapon_8", "8", "",
"Weapon_9", "9", "",
"Weapon_10", "0", "",
"Inventory", "Enter", "KpdEnt",
"Inventory_Left", "[", "",
"Inventory_Right", "]", "",
"Holo_Duke", "H", "",
"Jetpack", "J", "",
"NightVision", "N", "",
"MedKit", "M", "",
"TurnAround", "BakSpc", "",
"SendMessage", "T", "",
"Map", "Tab", "",
"Shrink_Screen", "-", "Kpad-",
"Enlarge_Screen", "=", "Kpad+",
"Center_View", "KPad5", "",
"Holster_Weapon", "ScrLck", "",
"Show_Opponents_Weapon", "Y", "",
"Map_Follow_Mode", "F", "",
"See_Coop_View", "K", "",
"Mouse_Aiming", "U", "",
"Toggle_Crosshair", "I", "",
"Steroids", "R", "",
"Quick_Kick", "Q", "",
"Next_Weapon", "'", "",
"Previous_Weapon", ";", "",
"Show_Console", "`", "",
"Show_DukeMatch_Scores", "", "",
"Dpad_Select", "", "",
"Dpad_Aiming", "", "",
"W", "Kpad8",
"S", "Kpad2",
"Left", "Kpad4",
"Right", "KPad6",
"LAlt", "RAlt",
"", "RCtrl",
"E", "",
"LShift", "RShift",
"CapLck", "",
"Space", "/",
"LCtrl", "",
"PgUp", "Kpad9",
"PgDn", "Kpad3",
"Insert", "Kpad0",
"Delete", "Kpad.",
"A", "",
"D", "",
"Home", "KPad7",
"End", "Kpad1",
"1", "",
"2", "",
"3", "",
"4", "",
"5", "",
"6", "",
"7", "",
"8", "",
"9", "",
"0", "",
"Enter", "KpdEnt",
"[", "",
"]", "",
"H", "",
"J", "",
"N", "",
"M", "",
"BakSpc", "",
"T", "",
"Tab", "",
"-", "Kpad-",
"=", "Kpad+",
"KPad5", "",
"ScrLck", "",
"Y", "",
"F", "",
"K", "",
"U", "",
"I", "",
"R", "",
"Q", "",
"'", "",
";", "",
"`", "",
"", "",
"", "",
"", "",
};
const char oldkeydefaults[NUMGAMEFUNCTIONS*3][MAXGAMEFUNCLEN] =
const char oldkeydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN] =
{
"Move_Forward", "Up", "Kpad8",
"Move_Backward", "Down", "Kpad2",
"Turn_Left", "Left", "Kpad4",
"Turn_Right", "Right", "KPad6",
"Strafe", "LAlt", "RAlt",
"Fire", "LCtrl", "RCtrl",
"Open", "Space", "",
"Run", "LShift", "RShift",
"AutoRun", "CapLck", "",
"Jump", "A", "/",
"Crouch", "Z", "",
"Look_Up", "PgUp", "Kpad9",
"Look_Down", "PgDn", "Kpad3",
"Look_Left", "Insert", "Kpad0",
"Look_Right", "Delete", "Kpad.",
"Strafe_Left", ",", "",
"Strafe_Right", ".", "",
"Aim_Up", "Home", "KPad7",
"Aim_Down", "End", "Kpad1",
"Weapon_1", "1", "",
"Weapon_2", "2", "",
"Weapon_3", "3", "",
"Weapon_4", "4", "",
"Weapon_5", "5", "",
"Weapon_6", "6", "",
"Weapon_7", "7", "",
"Weapon_8", "8", "",
"Weapon_9", "9", "",
"Weapon_10", "0", "",
"Inventory", "Enter", "KpdEnt",
"Inventory_Left", "[", "",
"Inventory_Right", "]", "",
"Holo_Duke", "H", "",
"Jetpack", "J", "",
"NightVision", "N", "",
"MedKit", "M", "",
"TurnAround", "BakSpc", "",
"SendMessage", "T", "",
"Map", "Tab", "",
"Shrink_Screen", "-", "Kpad-",
"Enlarge_Screen", "=", "Kpad+",
"Center_View", "KPad5", "",
"Holster_Weapon", "ScrLck", "",
"Show_Opponents_Weapon", "W", "",
"Map_Follow_Mode", "F", "",
"See_Coop_View", "K", "",
"Mouse_Aiming", "U", "",
"Toggle_Crosshair", "I", "",
"Steroids", "R", "",
"Quick_Kick", "`", "",
"Next_Weapon", "'", "",
"Previous_Weapon", ";", "",
"Show_Console", "C", "",
"Show_DukeMatch_Scores", "", "",
"Dpad_Select", "", "",
"Dpad_Aiming", "", "",
"Up", "Kpad8",
"Down", "Kpad2",
"Left", "Kpad4",
"Right", "KPad6",
"LAlt", "RAlt",
"LCtrl", "RCtrl",
"Space", "",
"LShift", "RShift",
"CapLck", "",
"A", "/",
"Z", "",
"PgUp", "Kpad9",
"PgDn", "Kpad3",
"Insert", "Kpad0",
"Delete", "Kpad.",
",", "",
".", "",
"Home", "KPad7",
"End", "Kpad1",
"1", "",
"2", "",
"3", "",
"4", "",
"5", "",
"6", "",
"7", "",
"8", "",
"9", "",
"0", "",
"Enter", "KpdEnt",
"[", "",
"]", "",
"H", "",
"J", "",
"N", "",
"M", "",
"BakSpc", "",
"T", "",
"Tab", "",
"-", "Kpad-",
"=", "Kpad+",
"KPad5", "",
"ScrLck", "",
"W", "",
"F", "",
"K", "",
"U", "",
"I", "",
"R", "",
"`", "",
"'", "",
";", "",
"C", "",
"", "",
"", "",
"", "",
};
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])
{
int32_t i,f;
int32_t f;
Bmemset(ud.config.KeyboardKeys, 0xff, sizeof(ud.config.KeyboardKeys));
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;
ud.config.KeyboardKeys[f][0] = KB_StringToScanCode(keyptr[i+1]);
ud.config.KeyboardKeys[f][1] = KB_StringToScanCode(keyptr[i+2]);
ud.config.KeyboardKeys[f][0] = KB_StringToScanCode(keyptr[i]);
ud.config.KeyboardKeys[f][1] = KB_StringToScanCode(keyptr[i+1]);
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);
@ -262,7 +262,7 @@ void CONFIG_SetDefaults(void)
// JBF 20031211
CONFIG_SetDefaultKeys((const char (*)[MAXGAMEFUNCLEN])keydefaults);
CONFIG_SetDefaultKeys(keydefaults);
memset(ud.config.MouseFunctions, -1, sizeof(ud.config.MouseFunctions));
for (i=0; i<MAXMOUSEBUTTONS; i++)

View file

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

View file

@ -2424,7 +2424,6 @@ void C_DefineGameFuncName(int32_t idx, const char *name)
assert((unsigned)idx < NUMGAMEFUNCTIONS);
Bstrncpyz(gamefunctions[idx], name, MAXGAMEFUNCLEN);
Bstrncpyz(keydefaults[3*idx], name, MAXGAMEFUNCLEN);
hash_add(&h_gamefuncs, gamefunctions[idx], idx, 0);
}
@ -5392,7 +5391,6 @@ repeatcase:
while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0)
{
gamefunctions[j][i] = *textptr;
keydefaults[j*3][i] = *textptr;
textptr++,i++;
if (EDUKE32_PREDICT_FALSE(*textptr != 0x0a && *textptr != 0x0d && ispecial(*textptr)))
{
@ -5412,7 +5410,6 @@ repeatcase:
}
}
gamefunctions[j][i] = '\0';
keydefaults[j*3][i] = '\0';
hash_add(&h_gamefuncs,gamefunctions[j],j,0);
{
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);
}
else if (entry == &ME_KEYBOARDSETUP_RESET)
CONFIG_SetDefaultKeys((const char (*)[MAXGAMEFUNCLEN])keydefaults);
CONFIG_SetDefaultKeys(keydefaults);
else if (entry == &ME_KEYBOARDSETUP_RESETCLASSIC)
CONFIG_SetDefaultKeys(oldkeydefaults);
else if (entry == &ME_NETHOST_LAUNCH)