From 6d11c01fd7351fbe0a9a20f3035de46902549e2e Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sat, 17 Jun 2017 11:41:54 +0000 Subject: [PATCH] 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 --- source/duke3d/src/_functio.h | 228 +++++++++++++++++----------------- source/duke3d/src/config.cpp | 12 +- source/duke3d/src/function.h | 4 +- source/duke3d/src/gamedef.cpp | 3 - source/duke3d/src/menus.cpp | 2 +- 5 files changed, 123 insertions(+), 126 deletions(-) diff --git a/source/duke3d/src/_functio.h b/source/duke3d/src/_functio.h index 3cef22f19..835542c22 100644 --- a/source/duke3d/src/_functio.h +++ b/source/duke3d/src/_functio.h @@ -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] = diff --git a/source/duke3d/src/config.cpp b/source/duke3d/src/config.cpp index 709298a1e..07701714a 100644 --- a/source/duke3d/src/config.cpp +++ b/source/duke3d/src/config.cpp @@ -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>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)