From cfaafcede7863c8e7920c646608a3981a9b9b64b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 26 Oct 2019 00:32:49 +0200 Subject: [PATCH] - everything compiles again (not tested yet.) --- source/CMakeLists.txt | 1 + source/blood/src/_functio.h | 352 +++--------------- source/blood/src/blood.cpp | 14 +- source/blood/src/config.cpp | 131 +------ source/blood/src/config.h | 10 +- source/blood/src/controls.cpp | 42 +-- source/blood/src/function.h | 106 ------ source/blood/src/gamemenu.cpp | 1 - source/blood/src/input.cpp | 2 +- source/blood/src/menu.cpp | 15 +- source/blood/src/messages.cpp | 3 +- source/blood/src/osdcmd.cpp | 34 +- source/blood/src/startwin.game.cpp | 2 +- source/common/fonts/v_text.cpp | 1 + source/common/gamecontrol.cpp | 291 +++++++++++++++ source/common/gamecontrol.h | 105 ++++++ source/common/utility/tarray.h | 17 +- source/duke3d/src/_functio.h | 218 ----------- source/duke3d/src/config.cpp | 124 +----- source/duke3d/src/config.h | 7 +- source/duke3d/src/duke3d.h | 2 +- source/duke3d/src/function.h | 112 ------ source/duke3d/src/game.cpp | 15 +- source/duke3d/src/game.h | 1 - source/duke3d/src/gamedef.cpp | 158 ++------ source/duke3d/src/gamedef.h | 4 +- source/duke3d/src/gameexec.cpp | 6 +- source/duke3d/src/gamestructures.cpp | 2 +- source/duke3d/src/input.cpp | 2 +- source/duke3d/src/menus.cpp | 36 +- source/duke3d/src/osdcmds.cpp | 39 +- source/duke3d/src/startwin.game.cpp | 2 +- source/mact/include/_control.h | 3 - source/mact/include/control.h | 39 +- source/mact/src/control.cpp | 20 +- source/rr/src/_functio.h | 202 ---------- source/rr/src/config.cpp | 147 +------- source/rr/src/config.h | 7 +- source/rr/src/duke3d.h | 2 +- source/rr/src/function.h | 111 ------ source/rr/src/game.cpp | 18 +- source/rr/src/game.h | 3 +- source/rr/src/gamedef.cpp | 2 +- source/rr/src/gamedef.h | 2 - source/rr/src/input.cpp | 2 +- source/rr/src/menus.cpp | 58 +-- source/rr/src/osdcmds.cpp | 37 +- source/rr/src/startwin.game.cpp | 2 +- source/sw/src/_functio.h | 165 -------- source/sw/src/anim.cpp | 2 +- source/sw/src/cheats.cpp | 2 +- source/sw/src/config.cpp | 77 +--- source/sw/src/config.h | 6 +- source/sw/src/console.cpp | 2 +- source/sw/src/demo.cpp | 6 +- source/sw/src/draw.cpp | 2 +- source/sw/src/function.h | 99 ----- source/sw/src/game.cpp | 2 +- source/sw/src/jplayer.cpp | 2 +- source/sw/src/menus.cpp | 25 +- source/sw/src/menus.h | 7 - source/sw/src/player.cpp | 2 +- source/sw/src/predict.cpp | 2 +- source/sw/src/setup.cpp | 13 +- source/sw/src/swconfig.cpp | 2 +- wadsrc/static/filter/game-blood/defbinds.txt | 55 +++ wadsrc/static/filter/game-blood/origbinds.txt | 55 +++ wadsrc/static/filter/game-duke/defbinds.txt | 63 ++++ wadsrc/static/filter/game-duke/origbinds.txt | 63 ++++ .../static/filter/game-ionfury/defbinds.txt | 57 +++ .../static/filter/game-ionfury/origbinds.txt | 57 +++ wadsrc/static/filter/game-nam/defbinds.txt | 63 ++++ wadsrc/static/filter/game-nam/origbinds.txt | 63 ++++ .../static/filter/game-redneck/defbinds.txt | 62 +++ .../static/filter/game-redneck/origbinds.txt | 63 ++++ .../filter/game-redneckrides/defbinds.txt | 62 +++ .../filter/game-redneckrides/origbinds.txt | 63 ++++ .../filter/game-shadowwarrior/defbinds.txt | 50 +++ .../filter/game-shadowwarrior/origbinds.txt | 50 +++ wadsrc/static/filter/game-ww2gi/defbinds.txt | 63 ++++ wadsrc/static/filter/game-ww2gi/origbinds.txt | 63 ++++ 81 files changed, 1626 insertions(+), 2252 deletions(-) delete mode 100644 source/blood/src/function.h create mode 100644 source/common/gamecontrol.cpp create mode 100644 source/common/gamecontrol.h delete mode 100644 source/duke3d/src/function.h delete mode 100644 source/rr/src/function.h delete mode 100644 source/sw/src/function.h create mode 100644 wadsrc/static/filter/game-blood/defbinds.txt create mode 100644 wadsrc/static/filter/game-blood/origbinds.txt create mode 100644 wadsrc/static/filter/game-duke/defbinds.txt create mode 100644 wadsrc/static/filter/game-duke/origbinds.txt create mode 100644 wadsrc/static/filter/game-ionfury/defbinds.txt create mode 100644 wadsrc/static/filter/game-ionfury/origbinds.txt create mode 100644 wadsrc/static/filter/game-nam/defbinds.txt create mode 100644 wadsrc/static/filter/game-nam/origbinds.txt create mode 100644 wadsrc/static/filter/game-redneck/defbinds.txt create mode 100644 wadsrc/static/filter/game-redneck/origbinds.txt create mode 100644 wadsrc/static/filter/game-redneckrides/defbinds.txt create mode 100644 wadsrc/static/filter/game-redneckrides/origbinds.txt create mode 100644 wadsrc/static/filter/game-shadowwarrior/defbinds.txt create mode 100644 wadsrc/static/filter/game-shadowwarrior/origbinds.txt create mode 100644 wadsrc/static/filter/game-ww2gi/defbinds.txt create mode 100644 wadsrc/static/filter/game-ww2gi/origbinds.txt diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 99d7067f2..7454fe932 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -786,6 +786,7 @@ set (PCH_SOURCES common/rts.cpp common/gameconfigfile.cpp common/gamecvars.cpp + common/gamecontrol.cpp common/2d/v_2ddrawer.cpp common/2d/v_draw.cpp diff --git a/source/blood/src/_functio.h b/source/blood/src/_functio.h index fe4fcd337..77af00c35 100644 --- a/source/blood/src/_functio.h +++ b/source/blood/src/_functio.h @@ -9,7 +9,7 @@ NBlood is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. -This program is distributed in the hope that it will be useful, +This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. @@ -35,194 +35,17 @@ BEGIN_BLD_NS #ifndef function_private_h_ #define function_private_h_ -// KEEPINSYNC lunatic/con_lang.lua -char gamefunctions[NUMGAMEFUNCTIONS][MAXGAMEFUNCLEN] = - { - "Move_Forward", - "Move_Backward", - "Turn_Left", - "Turn_Right", - "Turn_Around", - "Strafe", - "Strafe_Left", - "Strafe_Right", - "Jump", - "Crouch", - "Run", - "AutoRun", - "Open", - "Weapon_Fire", - "Weapon_Special_Fire", - "Aim_Up", - "Aim_Down", - "Aim_Center", - "Look_Up", - "Look_Down", - "Tilt_Left", - "Tilt_Right", - "Weapon_1", - "Weapon_2", - "Weapon_3", - "Weapon_4", - "Weapon_5", - "Weapon_6", - "Weapon_7", - "Weapon_8", - "Weapon_9", - "Weapon_10", - "Inventory_Use", - "Inventory_Left", - "Inventory_Right", - "Map_Toggle", - "Map_Follow_Mode", - "Shrink_Screen", - "Enlarge_Screen", - "Send_Message", - "See_Coop_View", - "See_Chase_View", - "Mouse_Aiming", - "Toggle_Crosshair", - "Next_Weapon", - "Previous_Weapon", - "Holster_Weapon", - "Show_Opponents_Weapon", - "BeastVision", - "CrystalBall", - "JumpBoots", - "MedKit", - "ProximityBombs", - "RemoteBombs", - "Show_Console", - }; #ifdef __SETUP__ -const char keydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN] = - { - "W", "Kpad8", - "S", "Kpad2", - "Left", "Kpad4", - "Right", "KPad6", - "BakSpc", "", - "LAlt", "RAlt", - "A", "", - "D", "", - "Space", "/", - "LCtrl", "", - "LShift", "RShift", - "CapLck", "", - "E", "", - "RCtrl", "", - "X", "", - "Home", "KPad7", - "End", "Kpad1", - "KPad5", "", - "PgUp", "Kpad9", - "PgDn", "Kpad3", - "Insert", "Kpad0", - "Delete", "Kpad.", - "1", "", - "2", "", - "3", "", - "4", "", - "5", "", - "6", "", - "7", "", - "8", "", - "9", "", - "0", "", - "Enter", "KpdEnt", - "[", "", - "]", "", - "Tab", "", - "F", "", - "-", "Kpad-", - "=", "Kpad+", - "T", "", - "K", "", - "F7", "", - "U", "", - "I", "", - "'", "", - ";", "", - "ScrLck", "", - "Y", "", - "B", "", - "C", "", - "J", "", - "M", "", - "P", "", - "R", "", - "`", "", - }; - -const char oldkeydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN] = - { - "Up", "Kpad8", - "Down", "Kpad2", - "Left", "Kpad4", - "Right", "KPad6", - "BakSpc", "", - "LAlt", "RAlt", - ",", "", - ".", "", - "A", "/", - "Z", "", - "LShift", "RShift", - "CapLck", "", - "Space", "", - "LCtrl", "RCtrl", - "X", "", - "Home", "KPad7", - "End", "Kpad1", - "KPad5", "", - "PgUp", "Kpad9", - "PgDn", "Kpad3", - "Insert", "Kpad0", - "Delete", "Kpad.", - "1", "", - "2", "", - "3", "", - "4", "", - "5", "", - "6", "", - "7", "", - "8", "", - "9", "", - "0", "", - "Enter", "KpdEnt", - "[", "", - "]", "", - "Tab", "", - "F", "", - "-", "Kpad-", - "=", "Kpad+", - "T", "", - "K", "", - "F7", "", - "U", "", - "I", "", - "'", "", - ";", "", - "ScrLck", "", - "W", "", - "B", "", - "C", "", - "J", "", - "M", "", - "P", "", - "R", "", - "`", "", - }; - static const char * mousedefaults[MAXMOUSEBUTTONS] = { - "Weapon_Fire", - "Weapon_Special_Fire", - "", - "", - "Previous_Weapon", - "Next_Weapon", + "Weapon_Fire" + "Weapon_Special_Fire" + "" + "" + "Previous_Weapon" + "Next_Weapon" }; @@ -233,8 +56,8 @@ static const char * mouseclickeddefaults[MAXMOUSEBUTTONS] = static const char * mouseanalogdefaults[MAXMOUSEAXES] = { - "analog_turning", - "analog_moving", + "analog_turning" + "analog_moving" }; @@ -242,131 +65,74 @@ static const char * mousedigitaldefaults[MAXMOUSEDIGITAL] = { }; -#if defined(GEKKO) static const char * joystickdefaults[MAXJOYBUTTONSANDHATS] = { - "Open", // A - "Fire", // B - "Run", // 1 - "Map", // 2 - "Previous_Weapon", // - - "Next_Weapon", // + - "", // Home - "Jump", // Z - "Crouch", // C - "Map", // X - "Run", // Y - "Jump", // L - "Quick_Kick", // R - "Crouch", // ZL - "Fire", // ZR - "Quick_Kick", // D-Pad Up - "Inventory_Right", // D-Pad Right - "Inventory", // D-Pad Down - "Inventory_Left", // D-Pad Left + "Fire" + "Strafe" + "Run" + "Open" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "Aim_Down" + "Look_Right" + "Aim_Up" + "Look_Left" }; static const char * joystickclickeddefaults[MAXJOYBUTTONSANDHATS] = { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Inventory", + "" + "Inventory" + "Jump" + "Crouch" }; static const char * joystickanalogdefaults[MAXJOYAXES] = { - "analog_strafing", - "analog_moving", - "analog_turning", - "analog_lookingupanddown", + "analog_turning" + "analog_moving" + "analog_strafing" }; static const char * joystickdigitaldefaults[MAXJOYDIGITAL] = { + "" + "" + "" + "" + "" + "" + "Run" }; -#else -static const char * joystickdefaults[MAXJOYBUTTONSANDHATS] = - { - "Fire", - "Strafe", - "Run", - "Open", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Aim_Down", - "Look_Right", - "Aim_Up", - "Look_Left", - }; - - -static const char * joystickclickeddefaults[MAXJOYBUTTONSANDHATS] = - { - "", - "Inventory", - "Jump", - "Crouch", - }; - - -static const char * joystickanalogdefaults[MAXJOYAXES] = - { - "analog_turning", - "analog_moving", - "analog_strafing", - }; - - -static const char * joystickdigitaldefaults[MAXJOYDIGITAL] = - { - "", - "", - "", - "", - "", - "", - "Run", - }; -#endif #endif #endif diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index ec15bfeb6..a37e6334a 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -1524,18 +1524,6 @@ int app_main(int argc, char const * const * argv) G_AddSearchPaths(); - // used with binds for fast function lookup - 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); - Bfree(str); - } #ifdef STARTUP_SETUP_WINDOW int const readSetup = @@ -1574,7 +1562,7 @@ int app_main(int argc, char const * const * argv) //Bsprintf(tempbuf, HEAD2 " %s", s_buildRev); OSD_SetVersion("Blood", 10, 0); - OSD_SetParameters(0, 0, 0, 12, 2, 12, OSD_ERROR, OSDTEXT_RED, gamefunctions[gamefunc_Show_Console][0] == '\0' ? OSD_PROTECTED : 0); + OSD_SetParameters(0, 0, 0, 12, 2, 12, OSD_ERROR, OSDTEXT_RED, 0); registerosdcommands(); char *const setupFileName = Xstrdup(SetupFilename); diff --git a/source/blood/src/config.cpp b/source/blood/src/config.cpp index b427070d8..bb2e0588d 100644 --- a/source/blood/src/config.cpp +++ b/source/blood/src/config.cpp @@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "hash.h" #include "scriplib.h" #include "renderlayer.h" -#include "function.h" +#include "gamecontrol.h" #include "blood.h" #include "config.h" #include "gamedefs.h" @@ -55,8 +55,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS -hashtable_t h_gamefuncs = { NUMGAMEFUNCTIONS<<1, NULL }; - int32_t MouseFunctions[MAXMOUSEBUTTONS][2]; int32_t MouseDigitalFunctions[MAXMOUSEAXES][2]; int32_t MouseAnalogueAxes[MAXMOUSEAXES]; @@ -67,7 +65,6 @@ int32_t JoystickAnalogueAxes[MAXJOYAXES]; int32_t JoystickAnalogueScale[MAXJOYAXES]; int32_t JoystickAnalogueDead[MAXJOYAXES]; int32_t JoystickAnalogueSaturate[MAXJOYAXES]; -uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2]; int32_t scripthandle; int32_t setupread; int32_t mus_restartonload; @@ -99,34 +96,6 @@ int32_t gDeliriumBlur; int gWeaponsV10x; ///////// -int32_t CONFIG_FunctionNameToNum(const char *func) -{ - int32_t i; - - if (!func) - return -1; - - i = hash_find(&h_gamefuncs,func); - - if (i < 0) - { - char *str = Bstrtolower(Xstrdup(func)); - i = hash_find(&h_gamefuncs,str); - Bfree(str); - - return i; - } - - return i; -} - - -char *CONFIG_FunctionNumToName(int32_t func) -{ - if ((unsigned)func >= (unsigned)NUMGAMEFUNCTIONS) - return NULL; - return gamefunctions[func]; -} int32_t CONFIG_AnalogNameToNum(const char *func) @@ -173,54 +142,6 @@ const char *CONFIG_AnalogNumToName(int32_t func) } -void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN], bool lazy/*=false*/) -{ - static char const s_gamefunc_[] = "gamefunc_"; - int constexpr strlen_gamefunc_ = ARRAY_SIZE(s_gamefunc_) - 1; - - if (!lazy) - { - Bmemset(KeyboardKeys, 0xff, sizeof(KeyboardKeys)); - CONTROL_ClearAllBinds(); - } - - for (int i=0; i < ARRAY_SSIZE(gamefunctions); ++i) - { - if (gamefunctions[i][0] == '\0') - continue; - - auto &key = KeyboardKeys[i]; - - int const default0 = KB_StringToScanCode(keyptr[i<<1]); - int const default1 = KB_StringToScanCode(keyptr[(i<<1)+1]); - - // skip the function if the default key is already used - // or the function is assigned to another key - if (lazy && (key[0] != 0xff || (CONTROL_KeyIsBound(default0) && Bstrlen(CONTROL_KeyBinds[default0].cmdstr) > strlen_gamefunc_ - && CONFIG_FunctionNameToNum(CONTROL_KeyBinds[default0].cmdstr + strlen_gamefunc_) >= 0))) - { -#if 0 // defined(DEBUGGINGAIDS) - if (key[0] != 0xff) - initprintf("Skipping %s bound to %s\n", keyptr[i<<1], CONTROL_KeyBinds[default0].cmdstr); -#endif - continue; - } - - key[0] = default0; - key[1] = default1; - - if (key[0]) - CONTROL_FreeKeyBind(key[0]); - - if (key[1]) - CONTROL_FreeKeyBind(key[1]); - - if (i == gamefunc_Show_Console) - OSD_CaptureKey(key[0]); - else - CONFIG_MapKey(i, key[0], 0, key[1], 0); - } -} void CONFIG_SetDefaults(void) @@ -333,7 +254,7 @@ void CONFIG_SetDefaults(void) Bstrcpy(CommbatMacro[8], "Amateurs!"); Bstrcpy(CommbatMacro[9], "Fool! You are already dead."); - CONFIG_SetDefaultKeys(keydefaults); + CONFIG_SetDefaultKeys("demolition/defbinds.txt"); memset(MouseFunctions, -1, sizeof(MouseFunctions)); memset(MouseDigitalFunctions, -1, sizeof(MouseDigitalFunctions)); @@ -388,54 +309,6 @@ void CONFIG_SetDefaults(void) } -// wrapper for CONTROL_MapKey(), generates key bindings to reflect changes to keyboard setup -void CONFIG_MapKey(int which, kb_scancode key1, kb_scancode oldkey1, kb_scancode key2, kb_scancode oldkey2) -{ - int const keys[] = { key1, key2, oldkey1, oldkey2 }; - char buf[2*MAXGAMEFUNCLEN]; - char tempbuf[128]; - - if (which == gamefunc_Show_Console) - OSD_CaptureKey(key1); - - for (int k = 0; (unsigned)k < ARRAY_SIZE(keys); k++) - { - if (keys[k] == 0xff || !keys[k]) - continue; - - int match = 0; - - for (; sctokeylut[match].key; match++) - { - if (keys[k] == sctokeylut[match].sc) - break; - } - - tempbuf[0] = 0; - - for (int i=NUMGAMEFUNCTIONS-1; i>=0; i--) - { - if (KeyboardKeys[i][0] == keys[k] || KeyboardKeys[i][1] == keys[k]) - { - Bsprintf(buf, "gamefunc_%s; ", CONFIG_FunctionNumToName(i)); - Bstrcat(tempbuf,buf); - } - } - - int const len = Bstrlen(tempbuf); - - if (len >= 2) - { - tempbuf[len-2] = 0; // cut off the trailing "; " - CONTROL_BindKey(keys[k], tempbuf, 1, sctokeylut[match].key ? sctokeylut[match].key : ""); - } - else - { - CONTROL_FreeKeyBind(keys[k]); - } - } -} - void CONFIG_SetupMouse(void) { diff --git a/source/blood/src/config.h b/source/blood/src/config.h index dd618653d..b218b353e 100644 --- a/source/blood/src/config.h +++ b/source/blood/src/config.h @@ -25,12 +25,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define config_public_h_ #include "keyboard.h" -#include "function.h" +#include "gamecontrol.h" #include "control.h" #include "_control.h" #include "gamedefs.h" #include "hash.h" #include "gamecvars.h" +#include "gamecontrol.h" BEGIN_BLD_NS @@ -49,7 +50,6 @@ extern int32_t JoystickAnalogueAxes[MAXJOYAXES]; extern int32_t JoystickAnalogueScale[MAXJOYAXES]; extern int32_t JoystickAnalogueDead[MAXJOYAXES]; extern int32_t JoystickAnalogueSaturate[MAXJOYAXES]; -extern uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2]; extern int32_t scripthandle; extern int32_t setupread; extern int32_t configversion; @@ -72,7 +72,6 @@ extern int32_t gMouseSensitivity; extern bool gNoClip; extern bool gInfiniteAmmo; extern bool gFullMap; -extern hashtable_t h_gamefuncs; extern int32_t gUpscaleFactor; extern int32_t gDeliriumBlur; @@ -85,19 +84,14 @@ void CONFIG_WriteSetup(uint32_t flags); void CONFIG_SetDefaults(void); void CONFIG_SetupMouse(void); void CONFIG_SetupJoystick(void); -void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN], bool lazy=false); int32_t CONFIG_GetMapBestTime(char const *mapname, uint8_t const *mapmd4); int CONFIG_SetMapBestTime(uint8_t const *mapmd4, int32_t tm); -int32_t CONFIG_FunctionNameToNum(const char *func); -char * CONFIG_FunctionNumToName(int32_t func); int32_t CONFIG_AnalogNameToNum(const char *func); const char *CONFIG_AnalogNumToName(int32_t func); -void CONFIG_MapKey(int which, kb_scancode key1, kb_scancode oldkey1, kb_scancode key2, kb_scancode oldkey2); - END_BLD_NS #endif diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index 5fb882adb..d391a76df 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "mouse.h" #include "joystick.h" #include "control.h" -#include "function.h" +#include "gamecontrol.h" #include "common_game.h" #include "blood.h" #include "config.h" @@ -88,7 +88,6 @@ void ctrlInit(void) CONTROL_DefineFlag(gamefunc_Move_Backward, false); CONTROL_DefineFlag(gamefunc_Turn_Left, false); CONTROL_DefineFlag(gamefunc_Turn_Right, false); - CONTROL_DefineFlag(gamefunc_Turn_Around, false); CONTROL_DefineFlag(gamefunc_Strafe, false); CONTROL_DefineFlag(gamefunc_Strafe_Left, false); CONTROL_DefineFlag(gamefunc_Strafe_Right, false); @@ -97,16 +96,11 @@ void ctrlInit(void) CONTROL_DefineFlag(gamefunc_Run, false); CONTROL_DefineFlag(gamefunc_AutoRun, false); CONTROL_DefineFlag(gamefunc_Open, false); - CONTROL_DefineFlag(gamefunc_Weapon_Fire, false); - CONTROL_DefineFlag(gamefunc_Weapon_Special_Fire, false); - CONTROL_DefineFlag(gamefunc_Aim_Up, false); + CONTROL_DefineFlag(gamefunc_Aim_Up, false); CONTROL_DefineFlag(gamefunc_Aim_Down, false); - CONTROL_DefineFlag(gamefunc_Aim_Center, false); - CONTROL_DefineFlag(gamefunc_Look_Up, false); + CONTROL_DefineFlag(gamefunc_Look_Up, false); CONTROL_DefineFlag(gamefunc_Look_Down, false); - CONTROL_DefineFlag(gamefunc_Tilt_Left, false); - CONTROL_DefineFlag(gamefunc_Tilt_Right, false); - CONTROL_DefineFlag(gamefunc_Weapon_1, false); + CONTROL_DefineFlag(gamefunc_Weapon_1, false); CONTROL_DefineFlag(gamefunc_Weapon_2, false); CONTROL_DefineFlag(gamefunc_Weapon_3, false); CONTROL_DefineFlag(gamefunc_Weapon_4, false); @@ -116,15 +110,12 @@ void ctrlInit(void) CONTROL_DefineFlag(gamefunc_Weapon_8, false); CONTROL_DefineFlag(gamefunc_Weapon_9, false); CONTROL_DefineFlag(gamefunc_Weapon_10, false); - CONTROL_DefineFlag(gamefunc_Inventory_Use, false); - CONTROL_DefineFlag(gamefunc_Inventory_Left, false); + CONTROL_DefineFlag(gamefunc_Inventory_Left, false); CONTROL_DefineFlag(gamefunc_Inventory_Right, false); - CONTROL_DefineFlag(gamefunc_Map_Toggle, false); - CONTROL_DefineFlag(gamefunc_Map_Follow_Mode, false); + CONTROL_DefineFlag(gamefunc_Map_Follow_Mode, false); CONTROL_DefineFlag(gamefunc_Shrink_Screen, false); CONTROL_DefineFlag(gamefunc_Enlarge_Screen, false); - CONTROL_DefineFlag(gamefunc_Send_Message, false); - CONTROL_DefineFlag(gamefunc_See_Coop_View, false); + CONTROL_DefineFlag(gamefunc_See_Coop_View, false); CONTROL_DefineFlag(gamefunc_See_Chase_View, false); CONTROL_DefineFlag(gamefunc_Mouse_Aiming, false); CONTROL_DefineFlag(gamefunc_Toggle_Crosshair, false); @@ -132,11 +123,20 @@ void ctrlInit(void) CONTROL_DefineFlag(gamefunc_Previous_Weapon, false); CONTROL_DefineFlag(gamefunc_Holster_Weapon, false); CONTROL_DefineFlag(gamefunc_Show_Opponents_Weapon, false); - CONTROL_DefineFlag(gamefunc_BeastVision, false); - CONTROL_DefineFlag(gamefunc_CrystalBall, false); - CONTROL_DefineFlag(gamefunc_JumpBoots, false); - CONTROL_DefineFlag(gamefunc_MedKit, false); - CONTROL_DefineFlag(gamefunc_ProximityBombs, false); + CONTROL_DefineFlag(gamefunc_MedKit, false); + CONTROL_DefineFlag(gamefunc_Turn_Around, false); + CONTROL_DefineFlag(gamefunc_Weapon_Fire, false); + CONTROL_DefineFlag(gamefunc_Weapon_Special_Fire, false); + CONTROL_DefineFlag(gamefunc_Aim_Center, false); + CONTROL_DefineFlag(gamefunc_Tilt_Left, false); + CONTROL_DefineFlag(gamefunc_Tilt_Right, false); + CONTROL_DefineFlag(gamefunc_Inventory_Use, false); + CONTROL_DefineFlag(gamefunc_Map_Toggle, false); + CONTROL_DefineFlag(gamefunc_Send_Message, false); + CONTROL_DefineFlag(gamefunc_BeastVision, false); + CONTROL_DefineFlag(gamefunc_CrystalBall, false); + CONTROL_DefineFlag(gamefunc_JumpBoots, false); + CONTROL_DefineFlag(gamefunc_ProximityBombs, false); CONTROL_DefineFlag(gamefunc_RemoteBombs, false); } diff --git a/source/blood/src/function.h b/source/blood/src/function.h deleted file mode 100644 index 0a9a4f701..000000000 --- a/source/blood/src/function.h +++ /dev/null @@ -1,106 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 2010-2019 EDuke32 developers and contributors -Copyright (C) 2019 Nuke.YKT - -This file is part of NBlood. - -NBlood is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -//------------------------------------------------------------------------- - -// function.h - -// file created by makehead.exe -// these headers contain default key assignments, as well as -// default button assignments and game function names -// axis defaults are also included - - -#ifndef function_public_h_ -#define function_public_h_ - -BEGIN_BLD_NS - -#define NUMGAMEFUNCTIONS 55 -#define MAXGAMEFUNCLEN 32 - -extern char gamefunctions[NUMGAMEFUNCTIONS][MAXGAMEFUNCLEN]; -extern const char keydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN]; -extern const char oldkeydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN]; - -enum GameFunction_t - { - gamefunc_Move_Forward, - gamefunc_Move_Backward, - gamefunc_Turn_Left, - gamefunc_Turn_Right, - gamefunc_Turn_Around, - gamefunc_Strafe, - gamefunc_Strafe_Left, - gamefunc_Strafe_Right, - gamefunc_Jump, - gamefunc_Crouch, - gamefunc_Run, - gamefunc_AutoRun, - gamefunc_Open, - gamefunc_Weapon_Fire, - gamefunc_Weapon_Special_Fire, - gamefunc_Aim_Up, - gamefunc_Aim_Down, - gamefunc_Aim_Center, - gamefunc_Look_Up, - gamefunc_Look_Down, - gamefunc_Tilt_Left, - gamefunc_Tilt_Right, - gamefunc_Weapon_1, - gamefunc_Weapon_2, - gamefunc_Weapon_3, - gamefunc_Weapon_4, - gamefunc_Weapon_5, - gamefunc_Weapon_6, - gamefunc_Weapon_7, - gamefunc_Weapon_8, - gamefunc_Weapon_9, - gamefunc_Weapon_10, - gamefunc_Inventory_Use, - gamefunc_Inventory_Left, - gamefunc_Inventory_Right, - gamefunc_Map_Toggle, - gamefunc_Map_Follow_Mode, - gamefunc_Shrink_Screen, - gamefunc_Enlarge_Screen, - gamefunc_Send_Message, - gamefunc_See_Coop_View, - gamefunc_See_Chase_View, - gamefunc_Mouse_Aiming, - gamefunc_Toggle_Crosshair, - gamefunc_Next_Weapon, - gamefunc_Previous_Weapon, - gamefunc_Holster_Weapon, - gamefunc_Show_Opponents_Weapon, - gamefunc_BeastVision, - gamefunc_CrystalBall, - gamefunc_JumpBoots, - gamefunc_MedKit, - gamefunc_ProximityBombs, - gamefunc_RemoteBombs, - gamefunc_Show_Console, - }; - -END_BLD_NS - -#endif - diff --git a/source/blood/src/gamemenu.cpp b/source/blood/src/gamemenu.cpp index e5cf066e2..a6e81f806 100644 --- a/source/blood/src/gamemenu.cpp +++ b/source/blood/src/gamemenu.cpp @@ -1127,7 +1127,6 @@ void CGameMenuItemKeyList::Scan(void) bScan = true; } -extern uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2]; void CGameMenuItemKeyList::Draw(void) { char buffer[40], buffer2[40]; diff --git a/source/blood/src/input.cpp b/source/blood/src/input.cpp index 7b2cf0a27..c499b5f86 100644 --- a/source/blood/src/input.cpp +++ b/source/blood/src/input.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "ns.h" // Must come before everything else! //#include "global.h" //#include "game.h" -#include "function.h" +#include "gamecontrol.h" #include "keyboard.h" #include "mouse.h" #include "joystick.h" diff --git a/source/blood/src/menu.cpp b/source/blood/src/menu.cpp index 1e0c5b8cc..7f45fd9db 100644 --- a/source/blood/src/menu.cpp +++ b/source/blood/src/menu.cpp @@ -150,7 +150,7 @@ char zUserMapName[16]; const char *zEpisodeNames[6]; const char *zLevelNames[6][16]; -static char MenuGameFuncs[NUMGAMEFUNCTIONS][MAXGAMEFUNCLEN]; +static FString MenuGameFuncs[NUMGAMEFUNCTIONS]; static char const *MenuGameFuncNone = " -None-"; static char const *pzGamefuncsStrings[NUMGAMEFUNCTIONS + 1]; static int nGamefuncsValues[NUMGAMEFUNCTIONS + 1]; @@ -1304,13 +1304,10 @@ void SetupMenus(void) int k = 1; for (int i = 0; i < NUMGAMEFUNCTIONS; ++i) { - Bstrcpy(MenuGameFuncs[i], gamefunctions[i]); + MenuGameFuncs[i] = CONFIG_FunctionNumToName(i); + MenuGameFuncs[i].Substitute('_', ' '); - for (int j = 0; j < MAXGAMEFUNCLEN; ++j) - if (MenuGameFuncs[i][j] == '_') - MenuGameFuncs[i][j] = ' '; - - if (gamefunctions[i][0] != '\0') + if (MenuGameFuncs[i][0] != '\0') { pzGamefuncsStrings[k] = MenuGameFuncs[i]; nGamefuncsValues[k] = i; @@ -1386,12 +1383,12 @@ void SetCenterHoriz(CGameMenuItemZBool *pItem) void ResetKeys(CGameMenuItemChain *) { - CONFIG_SetDefaultKeys(keydefaults); + CONFIG_SetDefaultKeys("demolition/defbinds.txt"); } void ResetKeysClassic(CGameMenuItemChain *) { - CONFIG_SetDefaultKeys(oldkeydefaults); + CONFIG_SetDefaultKeys("demolition/origbinds.txt"); } //// diff --git a/source/blood/src/messages.cpp b/source/blood/src/messages.cpp index 20e73b3d2..9f1cdaddb 100644 --- a/source/blood/src/messages.cpp +++ b/source/blood/src/messages.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "compat.h" #include "keyboard.h" #include "control.h" -#include "function.h" +#include "gamecontrol.h" #include "common_game.h" #include "blood.h" #include "config.h" @@ -53,7 +53,6 @@ void sub_5A928(void) CONTROL_ClearButton(i); } -extern uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2]; void sub_5A944(char key) { for (int i = 0; i < NUMGAMEFUNCTIONS-1; i++) diff --git a/source/blood/src/osdcmd.cpp b/source/blood/src/osdcmd.cpp index 8c8121745..a53b93102 100644 --- a/source/blood/src/osdcmd.cpp +++ b/source/blood/src/osdcmd.cpp @@ -476,20 +476,6 @@ void onvideomodechange(int32_t newmode) UpdateDacs(gLastPal, false); } -static int osdcmd_button(osdcmdptr_t parm) -{ - static char const s_gamefunc_[] = "gamefunc_"; - int constexpr strlen_gamefunc_ = ARRAY_SIZE(s_gamefunc_) - 1; - - char const *p = parm->name + strlen_gamefunc_; - -// if (g_player[myconnectindex].ps->gm == MODE_GAME) // only trigger these if in game - if (gInputMode == kInputGame) - CONTROL_ButtonFlags[CONFIG_FunctionNameToNum(p)] = 1; // FIXME - - return OSDCMD_OK; -} - const char *const ConsoleButtons[] = { "mouse1", "mouse2", "mouse3", "mouse4", "mwheelup", @@ -631,7 +617,7 @@ static int osdcmd_bind(osdcmdptr_t parm) { KeyboardKeys[j][1] = KeyboardKeys[j][0]; KeyboardKeys[j][0] = sctokeylut[i].sc; -// CONTROL_MapKey(j, sctokeylut[i].sc, ud.config.KeyboardKeys[j][0]); +// CONTROL_MapKey(j, sctokeylut[i].sc, KeyboardKeys[j][0]); if (j == gamefunc_Show_Console) OSD_CaptureKey(sctokeylut[i].sc); @@ -769,8 +755,6 @@ static int osdcmd_inittimer(osdcmdptr_t parm) int32_t registerosdcommands(void) { - char buffer[256]; - OSD_RegisterFunction("changelevel","changelevel : warps to the given level", osdcmd_changelevel); OSD_RegisterFunction("map","map : loads the given user map", osdcmd_map); OSD_RegisterFunction("demo","demo : starts the given demo", osdcmd_demo); @@ -781,22 +765,6 @@ int32_t registerosdcommands(void) OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes the crosshair color", osdcmd_crosshaircolor); OSD_RegisterFunction("crosshairreset", "crosshairreset: restores the original crosshair", osdcmd_resetcrosshair); - for (auto & func : gamefunctions) - { - if (func[0] == '\0') - continue; - -// if (!Bstrcmp(gamefunctions[i],"Show_Console")) continue; - - Bsprintf(buffer, "gamefunc_%s", func); - - char *const t = Bstrtolower(Xstrdup(buffer)); - - Bstrcat(buffer, ": game button"); - - OSD_RegisterFunction(t, Xstrdup(buffer), osdcmd_button); - } - OSD_RegisterFunction("give","give : gives requested item", osdcmd_give); OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god); // OSD_RegisterFunction("activatecheat","activatecheat : activates a cheat code", osdcmd_activatecheat); diff --git a/source/blood/src/startwin.game.cpp b/source/blood/src/startwin.game.cpp index 26059e9bb..764bd8d30 100644 --- a/source/blood/src/startwin.game.cpp +++ b/source/blood/src/startwin.game.cpp @@ -43,7 +43,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "compat.h" #include "control.h" #include "config.h" -//#include "function.h" +//#include "gamecontrol.h" //#include "game.h" //#include "grpscan.h" //#include "inv.h" diff --git a/source/common/fonts/v_text.cpp b/source/common/fonts/v_text.cpp index c0e00ecb5..3270f3986 100644 --- a/source/common/fonts/v_text.cpp +++ b/source/common/fonts/v_text.cpp @@ -38,6 +38,7 @@ #include #include "v_text.h" +#include "v_font.h" #include "utf8.h" diff --git a/source/common/gamecontrol.cpp b/source/common/gamecontrol.cpp new file mode 100644 index 000000000..a5377dfd1 --- /dev/null +++ b/source/common/gamecontrol.cpp @@ -0,0 +1,291 @@ +#include "gamecontrol.h" +#include "tarray.h" +#include "zstring.h" +#include "name.h" +#include "control.h" +#include "keyboard.h" +#include "sc_man.h" + +struct GameFuncNameDesc +{ + int index; + const char *name; +}; + +static const GameFuncNameDesc gamefuncs[] = { + { gamefunc_Move_Forward, "Move_Forward"}, + { gamefunc_Move_Backward, "Move_Backward"}, + { gamefunc_Turn_Left, "Turn_Left"}, + { gamefunc_Turn_Right, "Turn_Right"}, + { gamefunc_Strafe, "Strafe"}, + { gamefunc_Fire, "Fire"}, + { gamefunc_Open, "Open"}, + { gamefunc_Run, "Run"}, + { gamefunc_Alt_Fire, "Alt_Fire"}, + { gamefunc_Jump, "Jump"}, + { gamefunc_Crouch, "Crouch"}, + { gamefunc_Look_Up, "Look_Up"}, + { gamefunc_Look_Down, "Look_Down"}, + { gamefunc_Look_Left, "Look_Left"}, + { gamefunc_Look_Right, "Look_Right"}, + { gamefunc_Strafe_Left, "Strafe_Left"}, + { gamefunc_Strafe_Right, "Strafe_Right"}, + { gamefunc_Aim_Up, "Aim_Up"}, + { gamefunc_Aim_Down, "Aim_Down"}, + { gamefunc_Weapon_1, "Weapon_1"}, + { gamefunc_Weapon_2, "Weapon_2"}, + { gamefunc_Weapon_3, "Weapon_3"}, + { gamefunc_Weapon_4, "Weapon_4"}, + { gamefunc_Weapon_5, "Weapon_5"}, + { gamefunc_Weapon_6, "Weapon_6"}, + { gamefunc_Weapon_7, "Weapon_7"}, + { gamefunc_Weapon_8, "Weapon_8"}, + { gamefunc_Weapon_9, "Weapon_9"}, + { gamefunc_Weapon_10, "Weapon_10"}, + { gamefunc_Inventory, "Inventory"}, + { gamefunc_Inventory_Left, "Inventory_Left"}, + { gamefunc_Inventory_Right, "Inventory_Right"}, + { gamefunc_Holo_Duke, "Holo_Duke"}, + { gamefunc_Jetpack, "Jetpack"}, + { gamefunc_NightVision, "NightVision"}, + { gamefunc_MedKit, "MedKit"}, + { gamefunc_TurnAround, "TurnAround"}, + { gamefunc_SendMessage, "SendMessage"}, + { gamefunc_Map, "Map"}, + { gamefunc_Shrink_Screen, "Shrink_Screen"}, + { gamefunc_Enlarge_Screen, "Enlarge_Screen"}, + { gamefunc_Center_View, "Center_View"}, + { gamefunc_Holster_Weapon, "Holster_Weapon"}, + { gamefunc_Show_Opponents_Weapon, "Show_Opponents_Weapon"}, + { gamefunc_Map_Follow_Mode, "Map_Follow_Mode"}, + { gamefunc_See_Coop_View, "See_Coop_View"}, + { gamefunc_Mouse_Aiming, "Mouse_Aiming"}, + { gamefunc_Toggle_Crosshair, "Toggle_Crosshair"}, + { gamefunc_Steroids, "Steroids"}, + { gamefunc_Quick_Kick, "Quick_Kick"}, + { gamefunc_Next_Weapon, "Next_Weapon"}, + { gamefunc_Previous_Weapon, "Previous_Weapon"}, + { gamefunc_Show_Console, "Show_Console"}, + { gamefunc_Show_DukeMatch_Scores, "Show_DukeMatch_Scores"}, + { gamefunc_Dpad_Select, "Dpad_Select"}, + { gamefunc_Dpad_Aiming, "Dpad_Aiming"}, + { gamefunc_AutoRun, "AutoRun"}, + { gamefunc_Last_Weapon, "Last_Used_Weapon"}, + { gamefunc_Quick_Save, "Quick_Save"}, + { gamefunc_Quick_Load, "Quick_Load"}, + { gamefunc_Alt_Weapon, "Alternate_Weapon"}, // Name in RedNukem + { gamefunc_Alt_Weapon, "Alt_Weapon"}, // Name in EDuke32 + { gamefunc_Third_Person_View, "Third_Person_View"}, + { gamefunc_Toggle_Crouch, "Toggle_Crouch"}, + { gamefunc_See_Chase_View, "See_Chase_View"}, // the following were added by Blood + { gamefunc_Turn_Around, "Turn_Around"}, + { gamefunc_Weapon_Fire, "Weapon_Fire"}, + { gamefunc_Weapon_Special_Fire, "Weapon_Special_Fire"}, + { gamefunc_Aim_Center, "Aim_Center"}, + { gamefunc_Tilt_Left, "Tilt_Left"}, + { gamefunc_Tilt_Right, "Tilt_Right"}, + { gamefunc_Inventory_Use, "Inventory_Use"}, + { gamefunc_Map_Toggle, "Map_Toggle"}, + { gamefunc_Send_Message, "Send_Message"}, + { gamefunc_BeastVision, "BeastVision"}, + { gamefunc_CrystalBall, "CrystalBall"}, + { gamefunc_JumpBoots, "JumpBoots"}, + { gamefunc_ProximityBombs, "ProximityBombs"}, + { gamefunc_RemoteBombs, "RemoteBombs"}, +}; + +static TMap GF_NameToNum; +static TArray GF_NumToName; // This one will preserve the original name for writing to the config (which must be loaded before CON scripts can hack around with the alias array.) +static TArray GF_NumToAlias; // This is for CON scripts to hack apart. + +uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2]; + +static void InitNameToNum() +{ + GF_NumToName.Resize(NUMGAMEFUNCTIONS); + GF_NumToAlias.Resize(NUMGAMEFUNCTIONS); + for(auto &gf : gamefuncs) + { + GF_NameToNum.Insert(gf.name, gf.index); + GF_NumToAlias[gf.index] = GF_NumToName[gf.index] = gf.name; + } +} + +int32_t CONFIG_FunctionNameToNum(const char *func) +{ + if (!func) return -1; + + FName name(func, true); + if (name == NAME_None) return -1; + + auto res = GF_NameToNum.CheckKey(name); + if (!res) return -1; + + return *res; +} + +const char *CONFIG_FunctionNumToName(int32_t func) +{ + if ((unsigned)func >= (unsigned)NUMGAMEFUNCTIONS) + return NULL; + return GF_NumToAlias[func]; +} + +const char *CONFIG_FunctionNumToRealName(int32_t func) +{ + if ((unsigned)func >= (unsigned)NUMGAMEFUNCTIONS) + return NULL; + return GF_NumToName[func]; +} + +void CONFIG_ReplaceButtonName(int num, const char *text) +{ + if ((unsigned)num >= (unsigned)NUMGAMEFUNCTIONS) + return; + GF_NumToAlias[num] = text; + GF_NameToNum.Insert(text, num); +} + +void CONFIG_DeleteButtonName(int num) +{ + if ((unsigned)num >= (unsigned)NUMGAMEFUNCTIONS) + return; + GF_NumToAlias[num] = ""; +} + +// wrapper for CONTROL_MapKey(), generates key bindings to reflect changes to keyboard setup +void CONFIG_MapKey(int which, kb_scancode key1, kb_scancode oldkey1, kb_scancode key2, kb_scancode oldkey2) +{ + int const keys[] = { key1, key2, oldkey1, oldkey2 }; + + if (which == gamefunc_Show_Console) + OSD_CaptureKey(key1); + + for (int k = 0; (unsigned)k < ARRAY_SIZE(keys); k++) + { + if (keys[k] == 0xff || !keys[k]) + continue; + + int match = 0; + + for (; sctokeylut[match].key; match++) + { + if (keys[k] == sctokeylut[match].sc) + break; + } + + FString tempbuf; + + for (int i = NUMGAMEFUNCTIONS - 1; i >= 0; i--) + { + if (KeyboardKeys[i][0] == keys[k] || KeyboardKeys[i][1] == keys[k]) + { + tempbuf.AppendFormat("gamefunc_%s; ", CONFIG_FunctionNumToName(i)); + } + } + + auto len = tempbuf.Len(); + + if (len >= 2) + { + tempbuf.Truncate(len - 2); // cut off the trailing "; " + CONTROL_BindKey(keys[k], tempbuf, 1, sctokeylut[match].key ? sctokeylut[match].key : ""); + } + else + { + CONTROL_FreeKeyBind(keys[k]); + } + } +} + +void CONFIG_SetDefaultKeys(const char *defbinds, bool lazy/*=false*/) +{ + FScanner sc; + + sc.Open(defbinds); + + if (!lazy) + { + memset(KeyboardKeys, 0xff, sizeof(KeyboardKeys)); + CONTROL_ClearAllBinds(); + } + + while (sc.GetToken()) + { + sc.TokenMustBe(TK_StringConst); + int num = CONFIG_FunctionNameToNum(sc.String); + int default0 = -1; + int default1 = -1; + + if (sc.CheckToken(',')) + { + sc.MustGetToken(TK_StringConst); + default0 = KB_StringToScanCode(sc.String); + if (sc.CheckToken(',')) + { + sc.MustGetToken(TK_StringConst); + default1 = KB_StringToScanCode(sc.String); + if (num >= 0 && num < NUMGAMEFUNCTIONS) + { + auto& key = KeyboardKeys[num]; +#if 0 + // skip the function if the default key is already used + // or the function is assigned to another key + if (lazy && (key[0] != 0xff || (CONTROL_KeyIsBound(default0) && Bstrlen(CONTROL_KeyBinds[default0].cmdstr) > strlen_gamefunc_ + && CONFIG_FunctionNameToNum(CONTROL_KeyBinds[default0].cmdstr + strlen_gamefunc_) >= 0))) + { + continue; + } +#endif + key[0] = default0; + key[1] = default1; + + if (key[0]) CONTROL_FreeKeyBind(key[0]); + if (key[1]) CONTROL_FreeKeyBind(key[1]); + + if (num == gamefunc_Show_Console) + OSD_CaptureKey(key[0]); + else + CONFIG_MapKey(num, key[0], 0, key[1], 0); + + CONTROL_DefineFlag(num, false); + + } + } + } + + } +} + +static int osdcmd_button(osdcmdptr_t parm) +{ + static char const s_gamefunc_[] = "gamefunc_"; + int constexpr strlen_gamefunc_ = ARRAY_SIZE(s_gamefunc_) - 1; + + char const *p = parm->name + strlen_gamefunc_; + + //if (gInputMode == kInputGame) // only trigger these if in game (fixme: Ensure it works for all games!) + CONTROL_ButtonFlags[CONFIG_FunctionNameToNum(p)] = 1; // FIXME + + return OSDCMD_OK; +} + +static FString stringStore[2*NUMGAMEFUNCTIONS]; // toss all persistent strings in here so that they stick around until shutdown. +void SetupButtonFunctions() +{ + unsigned index = 0; + // Note: This must run after the CON scripts had a chance to mess around with the game function name array. + for (auto & func : GF_NumToAlias) + { + if (func[0] == '\0') + continue; + + stringStore[index].Format("gamefunc_%s", func); + stringStore[index].ToLower(); + stringStore[index+1] = stringStore[index]; + stringStore[index+1] += ": game button"; + OSD_RegisterFunction(stringStore[index], stringStore[index+1], osdcmd_button); + index += 2; + } + +} \ No newline at end of file diff --git a/source/common/gamecontrol.h b/source/common/gamecontrol.h new file mode 100644 index 000000000..b233c5c6d --- /dev/null +++ b/source/common/gamecontrol.h @@ -0,0 +1,105 @@ +#pragma once + +#include "keyboard.h" + +// Order is that of EDuke32 by necessity because it exposes this array to scripting. +enum GameFunction_t +{ + gamefunc_Move_Forward, + gamefunc_Move_Backward, + gamefunc_Turn_Left, + gamefunc_Turn_Right, + gamefunc_Strafe, + gamefunc_Fire, + gamefunc_Open, + gamefunc_Run, + gamefunc_Alt_Fire, + gamefunc_Jump, + gamefunc_Crouch, + gamefunc_Look_Up, + gamefunc_Look_Down, + gamefunc_Look_Left, + gamefunc_Look_Right, + gamefunc_Strafe_Left, + gamefunc_Strafe_Right, + gamefunc_Aim_Up, + gamefunc_Aim_Down, + gamefunc_Weapon_1, + gamefunc_Weapon_2, + gamefunc_Weapon_3, + gamefunc_Weapon_4, + gamefunc_Weapon_5, + gamefunc_Weapon_6, + gamefunc_Weapon_7, + gamefunc_Weapon_8, + gamefunc_Weapon_9, + gamefunc_Weapon_10, + gamefunc_Inventory, + gamefunc_Inventory_Left, + gamefunc_Inventory_Right, + gamefunc_Holo_Duke, + gamefunc_Jetpack, + gamefunc_NightVision, + gamefunc_Night_Vision = gamefunc_NightVision, + gamefunc_MedKit, + gamefunc_Med_Kit = gamefunc_MedKit, + gamefunc_TurnAround, + gamefunc_SendMessage, + gamefunc_Map, + gamefunc_Shrink_Screen, + gamefunc_Enlarge_Screen, + gamefunc_Center_View, + gamefunc_Holster_Weapon, + gamefunc_Show_Opponents_Weapon, + gamefunc_Map_Follow_Mode, + gamefunc_See_Coop_View, + gamefunc_See_Co_Op_View = gamefunc_See_Coop_View, + gamefunc_Mouse_Aiming, + gamefunc_Toggle_Crosshair, + gamefunc_Steroids, + gamefunc_Quick_Kick, + gamefunc_Next_Weapon, + gamefunc_Previous_Weapon, + gamefunc_Show_Console, + gamefunc_Show_DukeMatch_Scores, + gamefunc_Dpad_Select, + gamefunc_Dpad_Aiming, + gamefunc_AutoRun, + gamefunc_Last_Weapon, + gamefunc_Quick_Save, + gamefunc_Quick_Load, + gamefunc_Alt_Weapon, + gamefunc_Third_Person_View, + gamefunc_Toggle_Crouch, + gamefunc_See_Chase_View, // this was added by Blood + gamefunc_Turn_Around, + gamefunc_Weapon_Fire, + gamefunc_Weapon_Special_Fire, + gamefunc_Aim_Center, + gamefunc_Tilt_Left, + gamefunc_Tilt_Right, + gamefunc_Inventory_Use, + gamefunc_Map_Toggle, + gamefunc_Send_Message, + gamefunc_BeastVision, + gamefunc_CrystalBall, + gamefunc_JumpBoots, + gamefunc_ProximityBombs, + gamefunc_RemoteBombs, + gamefunc_Smoke_Bomb, + gamefunc_Gas_Bomb, + gamefunc_Flash_Bomb, + gamefunc_Caltrops, + + NUMGAMEFUNCTIONS +}; + +extern uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2]; + +void CONFIG_SetDefaultKeys(const char *defbinds, bool lazy=false); +int32_t CONFIG_FunctionNameToNum(const char* func); +const char* CONFIG_FunctionNumToName(int32_t func); +const char* CONFIG_FunctionNumToRealName(int32_t func); +void CONFIG_ReplaceButtonName(int num, const char* text); +void CONFIG_DeleteButtonName(int num); +void CONFIG_MapKey(int which, kb_scancode key1, kb_scancode oldkey1, kb_scancode key2, kb_scancode oldkey2); diff --git a/source/common/utility/tarray.h b/source/common/utility/tarray.h index d8b3defc6..5b39dbceb 100644 --- a/source/common/utility/tarray.h +++ b/source/common/utility/tarray.h @@ -1395,9 +1395,15 @@ public: { } - BitArray(const BitArray & arr) + BitArray(unsigned elem) + : bytes((elem + 7) / 8, true) + { + + } + + BitArray(const BitArray & arr) + : bytes(arr.bytes) { - bytes = arr.bytes; size = arr.size; } @@ -1409,8 +1415,8 @@ public: } BitArray(BitArray && arr) + : bytes(std::move(arr.bytes)) { - bytes = std::move(arr.bytes); size = arr.size; arr.size = 0; } @@ -1428,9 +1434,10 @@ public: return !!(bytes[index >> 3] & (1 << (index & 7))); } - void Set(size_t index) + void Set(size_t index, bool set = true) { - bytes[index >> 3] |= (1 << (index & 7)); + if (!set) Clear(index); + else bytes[index >> 3] |= (1 << (index & 7)); } void Clear(size_t index) diff --git a/source/duke3d/src/_functio.h b/source/duke3d/src/_functio.h index 33fce5ab2..d2e69dc77 100644 --- a/source/duke3d/src/_functio.h +++ b/source/duke3d/src/_functio.h @@ -35,226 +35,8 @@ BEGIN_DUKE_NS #ifndef function_private_h_ #define function_private_h_ -// KEEPINSYNC lunatic/con_lang.lua -char gamefunctions[NUMGAMEFUNCTIONS][MAXGAMEFUNCLEN] = - { - "Move_Forward", - "Move_Backward", - "Turn_Left", - "Turn_Right", - "Strafe", - "Fire", - "Open", - "Run", - "Alt_Fire", - "Jump", - "Crouch", - "Look_Up", - "Look_Down", - "Look_Left", - "Look_Right", - "Strafe_Left", - "Strafe_Right", - "Aim_Up", - "Aim_Down", - "Weapon_1", - "Weapon_2", - "Weapon_3", - "Weapon_4", - "Weapon_5", - "Weapon_6", - "Weapon_7", - "Weapon_8", - "Weapon_9", - "Weapon_10", - "Inventory", - "Inventory_Left", - "Inventory_Right", -#ifndef EDUKE32_STANDALONE - "Holo_Duke", - "Jetpack", - "NightVision", - "MedKit", -#else - "", - "", - "", - "", -#endif - "TurnAround", - "SendMessage", - "Map", - "Shrink_Screen", - "Enlarge_Screen", - "Center_View", - "Holster_Weapon", - "Show_Opponents_Weapon", - "Map_Follow_Mode", - "See_Coop_View", - "Mouse_Aiming", - "Toggle_Crosshair", -#ifndef EDUKE32_STANDALONE - "Steroids", - "Quick_Kick", -#else - "", - "", -#endif - "Next_Weapon", - "Previous_Weapon", - "Show_Console", -#ifndef EDUKE32_STANDALONE - "Show_DukeMatch_Scores", -#else - "Show_Multiplayer_Scores", -#endif - "Dpad_Select", - "Dpad_Aiming", - "AutoRun", - "Last_Used_Weapon", - "Quick_Save", - "Quick_Load", - "Alt_Weapon", - "Third_Person_View", - "Toggle_Crouch", - }; - #ifdef __SETUP__ -const char keydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN] = - { - "W", "Kpad8", - "S", "Kpad2", - "Left", "Kpad4", - "Right", "KPad6", - "LAlt", "RAlt", - "RCtrl", "", - "E", "", - "LShift", "RShift", - "", "", - "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", "", - "", "", - "", "", - "R", "", - "Q", "", - "'", "", - ";", "", - "`", "", - "", "", - "", "", - "", "", - "CapLck", "", - "X", "", - "F6", "", - "F9", "", - "", "", - "F7", "", - "C", "", - }; - -const char oldkeydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN] = - { - "Up", "Kpad8", - "Down", "Kpad2", - "Left", "Kpad4", - "Right", "KPad6", - "LAlt", "RAlt", - "LCtrl", "RCtrl", - "Space", "", - "LShift", "RShift", - "", "", - "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", "", - "", "", - "", "", - "", "", - "CapLck", "", - "", "", - "F6", "", - "F9", "", - "", "", - "F7", "", - "", "", - }; - static const char * mousedefaults[MAXMOUSEBUTTONS] = { "Fire", diff --git a/source/duke3d/src/config.cpp b/source/duke3d/src/config.cpp index db218abca..a116f7f9e 100644 --- a/source/duke3d/src/config.cpp +++ b/source/duke3d/src/config.cpp @@ -42,26 +42,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_DUKE_NS - -hashtable_t h_gamefuncs = { NUMGAMEFUNCTIONS<<1, NULL }; - -int32_t CONFIG_FunctionNameToNum(const char *func) -{ - if (!func) - return -1; - - return hash_findcase(&h_gamefuncs, func); -} - - -static char const * CONFIG_FunctionNumToName(int32_t func) -{ - if ((unsigned)func >= (unsigned)NUMGAMEFUNCTIONS) - return ""; - return gamefunctions[func]; -} - - int32_t CONFIG_AnalogNameToNum(const char *func) { if (!func) @@ -130,56 +110,6 @@ static void CONFIG_SetJoystickAnalogAxisFunction(int i, int function) } -void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN], bool lazy/*=false*/) -{ - static char const s_gamefunc_[] = "gamefunc_"; - int constexpr strlen_gamefunc_ = ARRAY_SIZE(s_gamefunc_) - 1; - - if (!lazy) - { - Bmemset(ud.config.KeyboardKeys, 0xff, sizeof(ud.config.KeyboardKeys)); - CONTROL_ClearAllBinds(); - } - - for (int i=0; i < ARRAY_SSIZE(gamefunctions); ++i) - { - if (gamefunctions[i][0] == '\0') - continue; - - auto &key = ud.config.KeyboardKeys[i]; - - int const default0 = KB_StringToScanCode(keyptr[i<<1]); - int const default1 = KB_StringToScanCode(keyptr[(i<<1)+1]); - - // skip the function if the default key is already used - // or the function is assigned to another key - if (lazy && (key[0] != 0xff || (CONTROL_KeyIsBound(default0) && Bstrlen(CONTROL_KeyBinds[default0].cmdstr) > strlen_gamefunc_ - && CONFIG_FunctionNameToNum(CONTROL_KeyBinds[default0].cmdstr + strlen_gamefunc_) >= 0))) - { -#if 0 // defined(DEBUGGINGAIDS) - if (key[0] != 0xff) - initprintf("Skipping %s bound to %s\n", keyptr[i<<1], CONTROL_KeyBinds[default0].cmdstr); -#endif - continue; - } - - key[0] = default0; - key[1] = default1; - - if (key[0]) - CONTROL_FreeKeyBind(key[0]); - - if (key[1]) - CONTROL_FreeKeyBind(key[1]); - - if (i == gamefunc_Show_Console) - OSD_CaptureKey(key[0]); - else - CONFIG_MapKey(i, key[0], 0, key[1], 0); - } -} - - void CONFIG_SetDefaults(void) { ud.config.scripthandle = -1; @@ -285,7 +215,7 @@ void CONFIG_SetDefaults(void) Bstrcpy(ud.ridecule[9], "AARRRGHHHHH!!!"); #endif - CONFIG_SetDefaultKeys(keydefaults); + CONFIG_SetDefaultKeys("demolition/defbinds.txt"); memset(ud.config.MouseFunctions, -1, sizeof(ud.config.MouseFunctions)); memset(ud.config.MouseDigitalFunctions, -1, sizeof(ud.config.MouseDigitalFunctions)); @@ -349,52 +279,6 @@ void CONFIG_SetDefaults(void) } -// wrapper for CONTROL_MapKey(), generates key bindings to reflect changes to keyboard setup -void CONFIG_MapKey(int which, kb_scancode key1, kb_scancode oldkey1, kb_scancode key2, kb_scancode oldkey2) -{ - int const keys[] = { key1, key2, oldkey1, oldkey2 }; - char buf[2*MAXGAMEFUNCLEN]; - - if (which == gamefunc_Show_Console) - OSD_CaptureKey(key1); - - for (int k = 0; (unsigned)k < ARRAY_SIZE(keys); k++) - { - if (keys[k] == 0xff || !keys[k]) - continue; - - int match = 0; - - for (; match < ARRAY_SSIZE(sctokeylut); ++match) - { - if (keys[k] == sctokeylut[match].sc) - break; - } - - tempbuf[0] = 0; - - for (int i=NUMGAMEFUNCTIONS-1; i>=0; i--) - { - if (ud.config.KeyboardKeys[i][0] == keys[k] || ud.config.KeyboardKeys[i][1] == keys[k]) - { - Bsprintf(buf, "gamefunc_%s; ", CONFIG_FunctionNumToName(i)); - Bstrcat(tempbuf,buf); - } - } - - int const len = Bstrlen(tempbuf); - - if (len >= 2) - { - tempbuf[len-2] = 0; // cut off the trailing "; " - CONTROL_BindKey(keys[k], tempbuf, 1, sctokeylut[match].key ? sctokeylut[match].key : ""); - } - else - { - CONTROL_FreeKeyBind(keys[k]); - } - } -} void CONFIG_SetupMouse(void) @@ -866,7 +750,7 @@ void CONFIG_WriteSettings(void) // save binds and aliases to _settings. for (int i=0; i=0; i--) - { - if (gamefunctions[i][0] == '\0') - continue; - - hash_add(&h_gamefuncs,gamefunctions[i],i,0); - } - #ifdef STARTUP_SETUP_WINDOW int const readSetup = #endif @@ -6516,7 +6505,7 @@ int app_main(int argc, const char * const*argv) Bsprintf(tempbuf, HEAD2 " %s", s_buildRev); OSD_SetVersion(tempbuf, 10,0); - OSD_SetParameters(0, 0, 0, 12, 2, 12, OSD_ERROR, OSDTEXT_RED, /*gamefunctions[gamefunc_Show_Console][0] == '\0' ? OSD_PROTECTED :*/ 0); + OSD_SetParameters(0, 0, 0, 12, 2, 12, OSD_ERROR, OSDTEXT_RED, 0); registerosdcommands(); if (g_networkMode != NET_DEDICATED_SERVER) @@ -6563,7 +6552,7 @@ int app_main(int argc, const char * const*argv) OSD_Exec(tempbuf); OSD_Exec("autoexec.cfg"); - CONFIG_SetDefaultKeys(keydefaults, true); + //CONFIG_SetDefaultKeys("demolition/defbinds.txt", true); system_getcvars(); diff --git a/source/duke3d/src/game.h b/source/duke3d/src/game.h index 0e426b70d..4536d5087 100644 --- a/source/duke3d/src/game.h +++ b/source/duke3d/src/game.h @@ -232,7 +232,6 @@ typedef struct { int32_t JoystickAnalogueInvert[MAXJOYAXES]; int32_t JoystickAnalogueDead[MAXJOYAXES]; int32_t JoystickAnalogueSaturate[MAXJOYAXES]; - uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2]; int32_t scripthandle; int32_t setupread; diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index 05629f30d..ede51ba06 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -2039,92 +2039,6 @@ void C_DefineMusic(int volumeNum, int levelNum, const char *fileName) check_filename_case(pMapInfo->musicfn); } -#ifdef LUNATIC -void C_DefineSound(int32_t sndidx, const char *fn, int32_t args[5]) -{ - Bassert((unsigned)sndidx < MAXSOUNDS); - - { - sound_t *const snd = &g_sounds[sndidx]; - - Xfree(snd->filename); - snd->filename = dup_filename(fn); - check_filename_case(snd->filename); - - snd->ps = args[0]; - snd->pe = args[1]; - snd->pr = args[2]; - snd->m = args[3] & ~SF_ONEINST_INTERNAL; - if (args[3] & SF_LOOP) - snd->m |= SF_ONEINST_INTERNAL; - snd->vo = args[4]; - - if (sndidx > g_highestSoundIdx) - g_highestSoundIdx = sndidx; - } -} - -void C_DefineQuote(int32_t qnum, const char *qstr) -{ - C_AllocQuote(qnum); - Bstrncpyz(apStrings[qnum], qstr, MAXQUOTELEN); -} - -void C_DefineVolumeName(int32_t vol, const char *name) -{ - Bassert((unsigned)vol < MAXVOLUMES); - Bstrncpyz(g_volumeNames[vol], name, sizeof(g_volumeNames[vol])); - g_volumeCnt = vol+1; -} - -void C_DefineSkillName(int32_t skill, const char *name) -{ - Bassert((unsigned)skill < MAXSKILLS); - Bstrncpyz(g_skillNames[skill], name, sizeof(g_skillNames[skill])); - g_skillCnt = max(g_skillCnt, skill+1); // TODO: bring in line with C-CON? -} - -void C_DefineLevelName(int32_t vol, int32_t lev, const char *fn, - int32_t partime, int32_t designertime, - const char *levelname) -{ - Bassert((unsigned)vol < MAXVOLUMES); - Bassert((unsigned)lev < MAXLEVELS); - - { - map_t *const map = &g_mapInfo[(MAXLEVELS*vol)+lev]; - - Xfree(map->filename); - map->filename = dup_filename(fn); - - // TODO: truncate to 32 chars? - Xfree(map->name); - map->name = Xstrdup(levelname); - - map->partime = REALGAMETICSPERSEC * partime; - map->designertime = REALGAMETICSPERSEC * designertime; - } -} - -void C_DefineGameFuncName(int32_t idx, const char *name) -{ - assert((unsigned)idx < NUMGAMEFUNCTIONS); - - Bstrncpyz(gamefunctions[idx], name, MAXGAMEFUNCLEN); - - hash_add(&h_gamefuncs, gamefunctions[idx], idx, 0); -} - -void C_DefineGameType(int32_t idx, int32_t flags, const char *name) -{ - Bassert((unsigned)idx < MAXGAMETYPES); - - g_gametypeFlags[idx] = flags; - Bstrncpyz(g_gametypeNames[idx], name, sizeof(g_gametypeNames[idx])); - g_gametypeCnt = idx+1; -} -#endif - void C_DefineVolumeFlags(int32_t vol, int32_t flags) { Bassert((unsigned)vol < MAXVOLUMES); @@ -2296,7 +2210,8 @@ void C_InitQuotes(void) #ifdef EDUKE32_TOUCH_DEVICES apStrings[QUOTE_DEAD] = 0; #else - char const * const OpenGameFunc = gamefunctions[gamefunc_Open]; + // WTF ?!? + char const * const OpenGameFunc = CONFIG_FunctionNumToName(gamefunc_Open); C_ReplaceQuoteSubstring(QUOTE_DEAD, "SPACE", OpenGameFunc); C_ReplaceQuoteSubstring(QUOTE_DEAD, "OPEN", OpenGameFunc); C_ReplaceQuoteSubstring(QUOTE_DEAD, "USE", OpenGameFunc); @@ -5218,33 +5133,24 @@ repeatcase: } i = 0; - - hash_delete(&h_gamefuncs, gamefunctions[j]); - - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) - { - gamefunctions[j][i] = *textptr; - textptr++,i++; - if (EDUKE32_PREDICT_FALSE(*textptr != 0x0a && *textptr != 0x0d && ispecial(*textptr))) - { - initprintf("%s:%d: warning: invalid character in function name.\n", - g_scriptFileName,g_lineNumber); - g_warningCnt++; - scriptSkipLine(); - break; - } - if (EDUKE32_PREDICT_FALSE(i >= MAXGAMEFUNCLEN-1)) - { - initprintf("%s:%d: warning: truncating function name to %d characters.\n", - g_scriptFileName,g_lineNumber,MAXGAMEFUNCLEN); - g_warningCnt++; - scriptSkipLine(); - break; - } - } - gamefunctions[j][i] = '\0'; - hash_add(&h_gamefuncs,gamefunctions[j],j,0); - + { + TArray build; + while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) + { + build.Push(*textptr); + textptr++, i++; + if (EDUKE32_PREDICT_FALSE(*textptr != 0x0a && *textptr != 0x0d && ispecial(*textptr))) + { + initprintf("%s:%d: warning: invalid character in function name.\n", + g_scriptFileName, g_lineNumber); + g_warningCnt++; + scriptSkipLine(); + break; + } + } + build.Push(0); + CONFIG_ReplaceButtonName(j, build.Data()); + } continue; case CON_UNDEFINEGAMEFUNC: @@ -5262,10 +5168,7 @@ repeatcase: continue; } - hash_delete(&h_gamefuncs, gamefunctions[j]); - - gamefunctions[j][0] = '\0'; - + CONFIG_DeleteButtonName(j); continue; case CON_DEFINESKILLNAME: @@ -5996,25 +5899,6 @@ static void C_AddDefaultDefinitions(void) for (int i=0; i=0; j--) - tempbuf[j] = Btoupper(tempbuf[j]); - - C_AddDefinition(tempbuf, i, LABEL_DEFINE); - } -#endif - static tokenmap_t predefined[] = { { "CLIPMASK0", CLIPMASK0 }, diff --git a/source/duke3d/src/gamedef.h b/source/duke3d/src/gamedef.h index 51f2ce65e..a9aa67294 100644 --- a/source/duke3d/src/gamedef.h +++ b/source/duke3d/src/gamedef.h @@ -83,8 +83,6 @@ extern intptr_t const * insptr; void VM_ScriptInfo(intptr_t const * const ptr, int const range); #endif -extern hashtable_t h_gamefuncs; - extern hashtable_t h_gamevars; extern hashtable_t h_arrays; extern hashtable_t h_labels; @@ -552,7 +550,7 @@ enum UserdefsLabel_t USERDEFS_M_ORIGIN_Y, USERDEFS_PLAYERBEST, USERDEFS_MUSICTOGGLE, - USERDEF_USEVOXELS, + USERDEFS_USEVOXELS, USERDEFS_USEHIGHTILE, USERDEFS_USEMODELS, USERDEFS_GAMETYPEFLAGS, diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index 56a767a86..8a367fbd9 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -3655,13 +3655,13 @@ badindex: VM_ASSERT((unsigned)gameFunc < NUMGAMEFUNCTIONS, "invalid function %d\n", gameFunc); if (funcPos < 2) - Bstrcpy(tempbuf, KB_ScanCodeToString(ud.config.KeyboardKeys[gameFunc][funcPos])); + Bstrcpy(tempbuf, KB_ScanCodeToString(KeyboardKeys[gameFunc][funcPos])); else { - Bstrcpy(tempbuf, KB_ScanCodeToString(ud.config.KeyboardKeys[gameFunc][0])); + Bstrcpy(tempbuf, KB_ScanCodeToString(KeyboardKeys[gameFunc][0])); if (!*tempbuf) - Bstrcpy(tempbuf, KB_ScanCodeToString(ud.config.KeyboardKeys[gameFunc][1])); + Bstrcpy(tempbuf, KB_ScanCodeToString(KeyboardKeys[gameFunc][1])); } if (*tempbuf) diff --git a/source/duke3d/src/gamestructures.cpp b/source/duke3d/src/gamestructures.cpp index 9d652a444..80f6ced97 100644 --- a/source/duke3d/src/gamestructures.cpp +++ b/source/duke3d/src/gamestructures.cpp @@ -1476,7 +1476,7 @@ int32_t __fastcall VM_GetUserdef(int32_t labelNum, int const lParm2) case USERDEFS_M_ORIGIN_Y: labelNum = ud.returnvar[1]; break; case USERDEFS_PLAYERBEST: labelNum = ud.playerbest; break; case USERDEFS_MUSICTOGGLE: labelNum = mus_enabled; break; - case USERDEF_USEVOXELS: labelNum = r_voxels; break; + case USERDEFS_USEVOXELS: labelNum = r_voxels; break; case USERDEFS_USEHIGHTILE: labelNum = hw_hightile; break; case USERDEFS_USEMODELS: labelNum = hw_models; break; case USERDEFS_GAMETYPEFLAGS: labelNum = g_gametypeFlags[ud.coop]; break; diff --git a/source/duke3d/src/input.cpp b/source/duke3d/src/input.cpp index 1958f2846..a0dfb9a77 100644 --- a/source/duke3d/src/input.cpp +++ b/source/duke3d/src/input.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "global.h" #include "game.h" -#include "function.h" +#include "gamecontrol.h" #include "keyboard.h" #include "mouse.h" #include "joystick.h" diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp index 4fb15a524..bac640523 100644 --- a/source/duke3d/src/menus.cpp +++ b/source/duke3d/src/menus.cpp @@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "savegame.h" #include "xxhash.h" #include "gamecvars.h" +#include "gamecontrol.h" #include "../../glbackend/glbackend.h" BEGIN_DUKE_NS @@ -260,7 +261,7 @@ static char const *MEOSN_YesNo[] = { "Yes", "No", }; static MenuOptionSet_t MEOS_YesNo = MAKE_MENUOPTIONSET( MEOSN_YesNo, NULL, 0x3 ); -static char MenuGameFuncs[NUMGAMEFUNCTIONS][MAXGAMEFUNCLEN]; +static FString MenuGameFuncs[NUMGAMEFUNCTIONS]; static char const *MenuGameFuncNone = " -None-"; static char const *MEOSN_Gamefuncs[NUMGAMEFUNCTIONS+1]; static int32_t MEOSV_Gamefuncs[NUMGAMEFUNCTIONS+1]; @@ -1672,15 +1673,12 @@ void Menu_Init(void) k = 1; for (i = 0; i < NUMGAMEFUNCTIONS; ++i) { - Bstrcpy(MenuGameFuncs[i], gamefunctions[i]); + MenuGameFuncs[i] = CONFIG_FunctionNumToName(i); + MenuGameFuncs[i].Substitute('_', ' '); - for (j = 0; j < MAXGAMEFUNCLEN; ++j) - if (MenuGameFuncs[i][j] == '_') - MenuGameFuncs[i][j] = ' '; - - if (gamefunctions[i][0] != '\0') - { - MEOSN_Gamefuncs[k] = MenuGameFuncs[i]; + if (MenuGameFuncs[i][0] != '\0') + { + MEOSN_Gamefuncs[k] = MenuGameFuncs[i]; MEOSV_Gamefuncs[k] = i; ++k; } @@ -1859,8 +1857,8 @@ void Menu_Init(void) 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]; + MEO_KEYBOARDSETUPFUNCS[i].column[0] = &KeyboardKeys[i][0]; + MEO_KEYBOARDSETUPFUNCS[i].column[1] = &KeyboardKeys[i][1]; } M_KEYBOARDKEYS.numEntries = NUMGAMEFUNCTIONS; for (i = 0; i < MENUMOUSEFUNCTIONS; ++i) @@ -2899,10 +2897,10 @@ static void Menu_PreInput(MenuEntry_t *entry) { auto column = (MenuCustom2Col_t*)entry->entry; char key[2]; - key[0] = ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0]; - key[1] = ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1]; + key[0] = KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0]; + key[1] = KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1]; *column->column[M_KEYBOARDKEYS.currentColumn] = 0xff; - CONFIG_MapKey(M_KEYBOARDKEYS.currentEntry, ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0], key[0], ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1], key[1]); + CONFIG_MapKey(M_KEYBOARDKEYS.currentEntry, KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0], key[0], KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1], key[1]); S_PlaySound(KICK_HIT); KB_ClearKeyDown(sc_Delete); } @@ -2959,14 +2957,14 @@ static int32_t Menu_PreCustom2ColScreen(MenuEntry_t *entry) if (sc != sc_None) { char key[2]; - key[0] = ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0]; - key[1] = ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1]; + key[0] = KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0]; + key[1] = KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1]; S_PlaySound(PISTOL_BODYHIT); *column->column[M_KEYBOARDKEYS.currentColumn] = KB_GetLastScanCode(); - CONFIG_MapKey(M_KEYBOARDKEYS.currentEntry, ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0], key[0], ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1], key[1]); + CONFIG_MapKey(M_KEYBOARDKEYS.currentEntry, KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0], key[0], KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1], key[1]); KB_ClearKeyDown(sc); @@ -3728,11 +3726,11 @@ static void Menu_Verify(int32_t input) case MENU_KEYSRESETVERIFY: if (input) - CONFIG_SetDefaultKeys(keydefaults); + CONFIG_SetDefaultKeys("demolition/defbinds.txt"); break; case MENU_KEYSCLASSICVERIFY: if (input) - CONFIG_SetDefaultKeys(oldkeydefaults); + CONFIG_SetDefaultKeys("demolition/origbinds.txt"); break; case MENU_JOYSTANDARDVERIFY: if (input) diff --git a/source/duke3d/src/osdcmds.cpp b/source/duke3d/src/osdcmds.cpp index 33d857b16..ba1208c14 100644 --- a/source/duke3d/src/osdcmds.cpp +++ b/source/duke3d/src/osdcmds.cpp @@ -857,19 +857,6 @@ void onvideomodechange(int32_t newmode) g_crosshairSum = -1; } -static int osdcmd_button(osdcmdptr_t parm) -{ - static char const s_gamefunc_[] = "gamefunc_"; - int constexpr strlen_gamefunc_ = ARRAY_SIZE(s_gamefunc_) - 1; - - char const *p = parm->name + strlen_gamefunc_; - -// if (g_player[myconnectindex].ps->gm == MODE_GAME) // only trigger these if in game - CONTROL_ButtonFlags[CONFIG_FunctionNameToNum(p)] = 1; // FIXME - - return OSDCMD_OK; -} - const char *const ConsoleButtons[] = { "mouse1", "mouse2", "mouse3", "mouse4", "mwheelup", @@ -1008,9 +995,9 @@ static int osdcmd_bind(osdcmdptr_t parm) if (j != -1) { - ud.config.KeyboardKeys[j][1] = ud.config.KeyboardKeys[j][0]; - ud.config.KeyboardKeys[j][0] = sctokeylut[i].sc; -// CONTROL_MapKey(j, sctokeylut[i].sc, ud.config.KeyboardKeys[j][0]); + KeyboardKeys[j][1] = KeyboardKeys[j][0]; + KeyboardKeys[j][0] = sctokeylut[i].sc; +// CONTROL_MapKey(j, sctokeylut[i].sc, KeyboardKeys[j][0]); if (j == gamefunc_Show_Console) OSD_CaptureKey(sctokeylut[i].sc); @@ -1033,7 +1020,7 @@ static int osdcmd_unbindall(osdcmdptr_t UNUSED(parm)) for (int i = 0; i < MAXMOUSEBUTTONS; ++i) CONTROL_FreeMouseBind(i); - for (auto &KeyboardKey : ud.config.KeyboardKeys) + for (auto &KeyboardKey : KeyboardKeys) KeyboardKey[0] = KeyboardKey[1] = 0xff; if (!OSD_ParsingScript()) @@ -1078,7 +1065,7 @@ static int osdcmd_unbound(osdcmdptr_t parm) int const gameFunc = CONFIG_FunctionNameToNum(parm->parms[0]); if (gameFunc != -1) - ud.config.KeyboardKeys[gameFunc][0] = 0; + KeyboardKeys[gameFunc][0] = 0; return OSDCMD_OK; } @@ -1452,22 +1439,6 @@ int32_t registerosdcommands(void) OSD_RegisterFunction("cmenu","cmenu <#>: jumps to menu", osdcmd_cmenu); OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes the crosshair color", osdcmd_crosshaircolor); - for (auto & func : gamefunctions) - { - if (func[0] == '\0') - continue; - -// if (!Bstrcmp(gamefunctions[i],"Show_Console")) continue; - - Bsprintf(tempbuf, "gamefunc_%s", func); - - char *const t = Bstrtolower(Xstrdup(tempbuf)); - - Bstrcat(tempbuf, ": game button"); - - OSD_RegisterFunction(t, Xstrdup(tempbuf), osdcmd_button); - } - OSD_RegisterFunction("give","give : gives requested item", osdcmd_give); OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god); OSD_RegisterFunction("activatecheat","activatecheat : activates a cheat code", osdcmd_activatecheat); diff --git a/source/duke3d/src/startwin.game.cpp b/source/duke3d/src/startwin.game.cpp index 12be45711..6d084bcc2 100644 --- a/source/duke3d/src/startwin.game.cpp +++ b/source/duke3d/src/startwin.game.cpp @@ -41,7 +41,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "common_game.h" #include "compat.h" #include "control.h" -#include "function.h" +#include "gamecontrol.h" #include "game.h" #include "grpscan.h" #include "inv.h" diff --git a/source/mact/include/_control.h b/source/mact/include/_control.h index 403cfa852..b3198bf09 100644 --- a/source/mact/include/_control.h +++ b/source/mact/include/_control.h @@ -78,9 +78,6 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms // NORMAL axis scale #define NORMALAXISSCALE 65536 -#define BUTTONSET(x, value) (CONTROL_ButtonState |= ((uint64_t)value << ((uint64_t)(x)))) -#define BUTTONCLEAR(x) (CONTROL_ButtonState &= ~((uint64_t)1 << ((uint64_t)(x)))) -#define BUTTONHELDSET(x, value) (CONTROL_ButtonHeldState |= (uint64_t)(value << ((uint64_t)(x)))) #define LIMITCONTROL(x) (*x = clamp(*x, -MAXCONTROLVALUE, MAXCONTROLVALUE)) //**************************************************************************** diff --git a/source/mact/include/control.h b/source/mact/include/control.h index affc770a8..09ea7e8f3 100644 --- a/source/mact/include/control.h +++ b/source/mact/include/control.h @@ -36,6 +36,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) #ifndef control_public_h_ #define control_public_h_ +#include "tarray.h" //*************************************************************************** // @@ -43,14 +44,35 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) // //*************************************************************************** -#define MAXGAMEBUTTONS 64 +#define MAXGAMEBUTTONS 80 -#define BUTTON(x) ((CONTROL_ButtonState >> ((uint64_t)(x))) & 1) -#define BUTTONHELD(x) ((CONTROL_ButtonHeldState >> ((uint64_t)(x))) & 1) +extern BitArray CONTROL_ButtonState, CONTROL_ButtonHeldState; + +inline bool BUTTON(int x) +{ + return CONTROL_ButtonState[x]; +} + +inline bool BUTTONHELD(int x) +{ + return CONTROL_ButtonHeldState[x]; +} + +inline bool BUTTONJUSTPRESSED(int x) +{ + return (BUTTON(x) && !BUTTONHELD(x)); +} + +inline bool BUTTONRELEASED(int x) +{ + return (!BUTTON(x) && BUTTONHELD(x)); +} + +inline bool BUTTONSTATECHANGED(int x) +{ + return (BUTTON(x) != BUTTONHELD(x)); +} -#define BUTTONJUSTPRESSED(x) (BUTTON(x) && !BUTTONHELD(x)) -#define BUTTONRELEASED(x) (!BUTTON(x) && BUTTONHELD(x)) -#define BUTTONSTATECHANGED(x) (BUTTON(x) != BUTTONHELD(x)) //*************************************************************************** @@ -174,9 +196,6 @@ extern bool CONTROL_JoyPresent; extern bool CONTROL_MouseEnabled; extern bool CONTROL_JoystickEnabled; -extern uint64_t CONTROL_ButtonState; -extern uint64_t CONTROL_ButtonHeldState; - extern LastSeenInput CONTROL_LastSeenInput; @@ -253,7 +272,7 @@ void CONTROL_ProcessBinds(void); //////////////////// -#define CONTROL_NUM_FLAGS 64 +#define CONTROL_NUM_FLAGS 80 extern int32_t CONTROL_ButtonFlags[CONTROL_NUM_FLAGS]; extern bool CONTROL_SmoothMouse; diff --git a/source/mact/src/control.cpp b/source/mact/src/control.cpp index e0cf0fcbd..c93386ba8 100644 --- a/source/mact/src/control.cpp +++ b/source/mact/src/control.cpp @@ -22,8 +22,8 @@ bool CONTROL_MousePresent = false; bool CONTROL_JoyPresent = false; bool CONTROL_JoystickEnabled = false; -uint64_t CONTROL_ButtonState = 0; -uint64_t CONTROL_ButtonHeldState = 0; +BitArray CONTROL_ButtonState(MAXGAMEBUTTONS); +BitArray CONTROL_ButtonHeldState(MAXGAMEBUTTONS); LastSeenInput CONTROL_LastSeenInput; @@ -743,14 +743,14 @@ void CONTROL_ClearButton(int whichbutton) CONTROL_Android_ClearButton(whichbutton); #endif - BUTTONCLEAR(whichbutton); + CONTROL_ButtonState.Clear(whichbutton); CONTROL_Flags[whichbutton].cleared = TRUE; } void CONTROL_ClearAllButtons(void) { - CONTROL_ButtonHeldState = 0; - CONTROL_ButtonState = 0; + CONTROL_ButtonHeldState.Zero(); + CONTROL_ButtonState.Zero(); for (auto & c : CONTROL_Flags) c.cleared = TRUE; @@ -816,8 +816,8 @@ static void CONTROL_GetFunctionInput(void) CONTROL_ButtonFunctionState(CONTROL_ButtonFlags); CONTROL_AxisFunctionState(CONTROL_ButtonFlags); - CONTROL_ButtonHeldState = CONTROL_ButtonState; - CONTROL_ButtonState = 0; + std::swap(CONTROL_ButtonHeldState, CONTROL_ButtonState); + CONTROL_ButtonState.Zero(); int i = CONTROL_NUM_FLAGS-1; @@ -825,7 +825,7 @@ static void CONTROL_GetFunctionInput(void) { CONTROL_SetFlag(i, /*CONTROL_KeyboardFunctionPressed(i) | */CONTROL_ButtonFlags[i]); - if (CONTROL_Flags[i].cleared == FALSE) BUTTONSET(i, CONTROL_Flags[i].active); + if (CONTROL_Flags[i].cleared == FALSE) CONTROL_ButtonState.Set(i, CONTROL_Flags[i].active); else if (CONTROL_Flags[i].active == FALSE) CONTROL_Flags[i].cleared = 0; } while (i--); @@ -889,8 +889,8 @@ bool CONTROL_Startup(controltype which, int32_t(*TimeFunction)(void), int32_t ti initprintf("CONTROL_Startup: Joystick Present\n"); #endif - CONTROL_ButtonState = 0; - CONTROL_ButtonHeldState = 0; + CONTROL_ButtonState.Zero(); + CONTROL_ButtonHeldState.Zero(); for (auto & CONTROL_Flag : CONTROL_Flags) CONTROL_Flag.used = FALSE; diff --git a/source/rr/src/_functio.h b/source/rr/src/_functio.h index 5cc9c056a..6185a2a72 100644 --- a/source/rr/src/_functio.h +++ b/source/rr/src/_functio.h @@ -34,207 +34,8 @@ BEGIN_RR_NS #ifndef function_private_h_ #define function_private_h_ -// KEEPINSYNC lunatic/con_lang.lua -char gamefunctions[NUMGAMEFUNCTIONS][MAXGAMEFUNCLEN] = - { - "Move_Forward", - "Move_Backward", - "Turn_Left", - "Turn_Right", - "Strafe", - "Fire", - "Open", - "Run", - "AutoRun", - "Jump", - "Crouch", - "Look_Up", - "Look_Down", - "Look_Left", - "Look_Right", - "Strafe_Left", - "Strafe_Right", - "Aim_Up", - "Aim_Down", - "Weapon_1", - "Weapon_2", - "Weapon_3", - "Weapon_4", - "Weapon_5", - "Weapon_6", - "Weapon_7", - "Weapon_8", - "Weapon_9", - "Weapon_10", - "Inventory", - "Inventory_Left", - "Inventory_Right", - "Holo_Duke", - "Jetpack", - "NightVision", - "MedKit", - "TurnAround", - "SendMessage", - "Map", - "Shrink_Screen", - "Enlarge_Screen", - "Center_View", - "Holster_Weapon", - "Show_Opponents_Weapon", - "Map_Follow_Mode", - "See_Coop_View", - "Mouse_Aiming", - "Toggle_Crosshair", - "Steroids", - "Quick_Kick", - "Next_Weapon", - "Previous_Weapon", - "Show_Console", - "Show_DukeMatch_Scores", - "Dpad_Select", - "Dpad_Aiming", - "Alternate_Weapon", - "Last_Used_Weapon", - "Quick_Save", - "Quick_Load", - "Third_Person_View", - "Toggle_Crouch", - }; - #ifdef __SETUP__ -char keydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN] = - { - "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", "", - "", "", - "", "", - "R", "", - "Q", "", - "'", "", - ";", "", - "`", "", - "", "", - "", "", - "", "", - "", "", - "X", "", - "F6", "", - "F9", "", - "F7", "", - "", "", - }; - -char oldkeydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN] = - { - "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", "", - "", "", - "", "", - "", "", - "", "", - "", "", - "F6", "", - "F9", "", - "F7", "", - "", "", - }; - static const char * mousedefaults[MAXMOUSEBUTTONS] = { "Fire", @@ -262,8 +63,6 @@ static const char * mousedigitaldefaults[MAXMOUSEDIGITAL] = { }; -#if defined(GEKKO) -#else static const char * joystickdefaults[MAXJOYBUTTONSANDHATS] = { "Fire", @@ -332,7 +131,6 @@ static const char * joystickdigitaldefaults[MAXJOYDIGITAL] = "", "Run", }; -#endif #endif #endif diff --git a/source/rr/src/config.cpp b/source/rr/src/config.cpp index 9650f639d..4f34e400d 100644 --- a/source/rr/src/config.cpp +++ b/source/rr/src/config.cpp @@ -40,36 +40,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_RR_NS -hashtable_t h_gamefuncs = { NUMGAMEFUNCTIONS<<1, NULL }; - -int32_t CONFIG_FunctionNameToNum(const char *func) -{ - int32_t i; - - if (!func) - return -1; - - i = hash_find(&h_gamefuncs,func); - - if (i < 0) - { - char *str = Bstrtolower(Xstrdup(func)); - i = hash_find(&h_gamefuncs,str); - Bfree(str); - - return i; - } - - return i; -} - - -char *CONFIG_FunctionNumToName(int32_t func) -{ - if ((unsigned)func >= (unsigned)NUMGAMEFUNCTIONS) - return NULL; - return gamefunctions[func]; -} int32_t CONFIG_AnalogNameToNum(const char *func) @@ -116,55 +86,6 @@ const char *CONFIG_AnalogNumToName(int32_t func) } -void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN], bool lazy/*=false*/) -{ - static char const s_gamefunc_[] = "gamefunc_"; - int constexpr strlen_gamefunc_ = ARRAY_SIZE(s_gamefunc_) - 1; - - if (!lazy) - { - Bmemset(ud.config.KeyboardKeys, 0xff, sizeof(ud.config.KeyboardKeys)); - CONTROL_ClearAllBinds(); - } - - for (int i=0; i < ARRAY_SSIZE(gamefunctions); ++i) - { - if (gamefunctions[i][0] == '\0') - continue; - - auto &key = ud.config.KeyboardKeys[i]; - - int const default0 = KB_StringToScanCode(keyptr[i<<1]); - int const default1 = KB_StringToScanCode(keyptr[(i<<1)+1]); - - // skip the function if the default key is already used - // or the function is assigned to another key - if (lazy && (key[0] != 0xff || (CONTROL_KeyIsBound(default0) && Bstrlen(CONTROL_KeyBinds[default0].cmdstr) > strlen_gamefunc_ - && CONFIG_FunctionNameToNum(CONTROL_KeyBinds[default0].cmdstr + strlen_gamefunc_) >= 0))) - { -#if 0 // defined(DEBUGGINGAIDS) - if (key[0] != 0xff) - initprintf("Skipping %s bound to %s\n", keyptr[i<<1], CONTROL_KeyBinds[default0].cmdstr); -#endif - continue; - } - - key[0] = default0; - key[1] = default1; - - if (key[0]) - CONTROL_FreeKeyBind(key[0]); - - if (key[1]) - CONTROL_FreeKeyBind(key[1]); - - if (i == gamefunc_Show_Console) - OSD_CaptureKey(key[0]); - else - CONFIG_MapKey(i, key[0], 0, key[1], 0); - } -} - void CONFIG_SetDefaults(void) { @@ -289,25 +210,8 @@ void CONFIG_SetDefaults(void) // JBF 20031211 - if (RR) - { - Bstrcpy((char*)keydefaults[gamefunc_Holo_Duke<<1], "B"); - Bstrcpy((char*)keydefaults[gamefunc_Jetpack<<1], "C"); - Bstrcpy((char*)keydefaults[gamefunc_NightVision<<1], "Y"); - Bstrcpy((char*)keydefaults[gamefunc_MedKit<<1], "R"); - Bstrcpy((char*)keydefaults[gamefunc_Steroids<<1], "M"); - Bstrcpy((char*)keydefaults[gamefunc_Show_Opponents_Weapon<<1], "V"); - Bstrcpy((char*)oldkeydefaults[gamefunc_Holo_Duke<<1], "B"); - Bstrcpy((char*)oldkeydefaults[gamefunc_Jetpack<<1], "C"); - Bstrcpy((char*)oldkeydefaults[gamefunc_NightVision<<1], "Y"); - Bstrcpy((char*)oldkeydefaults[gamefunc_MedKit<<1], "W"); - Bstrcpy((char*)oldkeydefaults[gamefunc_Steroids<<1], "M"); - Bstrcpy((char*)oldkeydefaults[gamefunc_Show_Opponents_Weapon<<1], "E"); - Bstrcpy((char*)oldkeydefaults[gamefunc_Show_Console<<1], "V"); - } - - CONFIG_SetDefaultKeys(keydefaults); + CONFIG_SetDefaultKeys("demolition/defbinds.txt"); memset(ud.config.MouseFunctions, -1, sizeof(ud.config.MouseFunctions)); for (i=0; i=0; i--) - { - if (ud.config.KeyboardKeys[i][0] == keys[k] || ud.config.KeyboardKeys[i][1] == keys[k]) - { - Bsprintf(buf, "gamefunc_%s; ", CONFIG_FunctionNumToName(i)); - Bstrcat(tempbuf,buf); - } - } - - int const len = Bstrlen(tempbuf); - - if (len >= 2) - { - tempbuf[len-2] = 0; // cut off the trailing "; " - CONTROL_BindKey(keys[k], tempbuf, 1, sctokeylut[match].key ? sctokeylut[match].key : ""); - } - else - { - CONTROL_FreeKeyBind(keys[k]); - } - } -} - - void CONFIG_SetupMouse(void) { int32_t i; diff --git a/source/rr/src/config.h b/source/rr/src/config.h index 6f6a9b73d..a49e1564d 100644 --- a/source/rr/src/config.h +++ b/source/rr/src/config.h @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef config_public_h_ #define config_public_h_ -#include "function.h" +#include "gamecontrol.h" BEGIN_RR_NS @@ -34,15 +34,10 @@ void CONFIG_GetSetupFilename( void ); void CONFIG_WriteSetup(uint32_t flags); void CONFIG_SetupMouse( void ); void CONFIG_SetupJoystick( void ); -void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN], bool lazy=false); int32_t CONFIG_GetMapBestTime(char const * mapname, uint8_t const * mapmd4); int32_t CONFIG_SetMapBestTime(uint8_t const * mapmd4, int32_t tm); -void CONFIG_MapKey(int32_t which, kb_scancode key1, kb_scancode oldkey1, kb_scancode key2, kb_scancode oldkey2); - -int32_t CONFIG_FunctionNameToNum(const char *func); -char *CONFIG_FunctionNumToName(int32_t func); int32_t CONFIG_AnalogNameToNum(const char *func); const char *CONFIG_AnalogNumToName(int32_t func); void CONFIG_SetDefaults(void); diff --git a/source/rr/src/duke3d.h b/source/rr/src/duke3d.h index bd134866f..420fbf008 100644 --- a/source/rr/src/duke3d.h +++ b/source/rr/src/duke3d.h @@ -116,7 +116,7 @@ END_RR_NS #include "common_game.h" #include "config.h" #include "control.h" -#include "function.h" +#include "gamecontrol.h" #include "game.h" #include "gamedef.h" #include "gamedefs.h" diff --git a/source/rr/src/function.h b/source/rr/src/function.h deleted file mode 100644 index 844aae704..000000000 --- a/source/rr/src/function.h +++ /dev/null @@ -1,111 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 2010 EDuke32 developers and contributors - -This file is part of EDuke32. - -EDuke32 is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -//------------------------------------------------------------------------- - -// function.h - -// file created by makehead.exe -// these headers contain default key assignments, as well as -// default button assignments and game function names -// axis defaults are also included - - -#ifndef function_public_h_ -#define function_public_h_ - -BEGIN_RR_NS - -#define NUMGAMEFUNCTIONS 62 -#define MAXGAMEFUNCLEN 32 - -extern char gamefunctions[NUMGAMEFUNCTIONS][MAXGAMEFUNCLEN]; -extern char keydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN]; -extern char oldkeydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN]; - -enum GameFunction_t - { - gamefunc_Move_Forward, - gamefunc_Move_Backward, - gamefunc_Turn_Left, - gamefunc_Turn_Right, - gamefunc_Strafe, - gamefunc_Fire, - gamefunc_Open, - gamefunc_Run, - gamefunc_AutoRun, - gamefunc_Jump, - gamefunc_Crouch, - gamefunc_Look_Up, - gamefunc_Look_Down, - gamefunc_Look_Left, - gamefunc_Look_Right, - gamefunc_Strafe_Left, - gamefunc_Strafe_Right, - gamefunc_Aim_Up, - gamefunc_Aim_Down, - gamefunc_Weapon_1, - gamefunc_Weapon_2, - gamefunc_Weapon_3, - gamefunc_Weapon_4, - gamefunc_Weapon_5, - gamefunc_Weapon_6, - gamefunc_Weapon_7, - gamefunc_Weapon_8, - gamefunc_Weapon_9, - gamefunc_Weapon_10, - gamefunc_Inventory, - gamefunc_Inventory_Left, - gamefunc_Inventory_Right, - gamefunc_Holo_Duke, - gamefunc_Jetpack, - gamefunc_NightVision, - gamefunc_MedKit, - gamefunc_TurnAround, - gamefunc_SendMessage, - gamefunc_Map, - gamefunc_Shrink_Screen, - gamefunc_Enlarge_Screen, - gamefunc_Center_View, - gamefunc_Holster_Weapon, - gamefunc_Show_Opponents_Weapon, - gamefunc_Map_Follow_Mode, - gamefunc_See_Coop_View, - gamefunc_Mouse_Aiming, - gamefunc_Toggle_Crosshair, - gamefunc_Steroids, - gamefunc_Quick_Kick, - gamefunc_Next_Weapon, - gamefunc_Previous_Weapon, - gamefunc_Show_Console, - gamefunc_Show_DukeMatch_Scores, - gamefunc_Dpad_Select, - gamefunc_Dpad_Aiming, - gamefunc_Alt_Weapon, - gamefunc_Last_Weapon, - gamefunc_Quick_Save, - gamefunc_Quick_Load, - gamefunc_Third_Person_View, - gamefunc_Toggle_Crouch, // TODO: Implement properly for mp - }; - -END_RR_NS - -#endif diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index fa22823fb..6c9266cc7 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -7130,7 +7130,6 @@ static void G_Cleanup(void) // Bfree(MusicPtr); hash_free(&h_labels); - hash_free(&h_gamefuncs); hash_loop(&h_dukeanim, G_FreeHashAnim); hash_free(&h_dukeanim); @@ -7714,19 +7713,6 @@ int app_main(int argc, char const * const * argv) if (forcegl) initprintf("GL driver blacklist disabled.\n"); #endif - // used with binds for fast function lookup - 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); - Bfree(str); - } - #ifdef STARTUP_SETUP_WINDOW int const readSetup = #endif @@ -7900,7 +7886,7 @@ int app_main(int argc, char const * const * argv) Bsprintf(tempbuf, HEAD2 " %s", s_buildRev); OSD_SetVersion(tempbuf, 10,0); - OSD_SetParameters(0, 0, 0, 12, 2, 12, OSD_ERROR, OSDTEXT_RED, gamefunctions[gamefunc_Show_Console][0] == '\0' ? OSD_PROTECTED : 0); + OSD_SetParameters(0, 0, 0, 12, 2, 12, OSD_ERROR, OSDTEXT_RED, 0); registerosdcommands(); //if (g_networkMode != NET_DEDICATED_SERVER) @@ -7947,7 +7933,7 @@ int app_main(int argc, char const * const * argv) OSD_Exec(tempbuf); OSD_Exec("autoexec.cfg"); - CONFIG_SetDefaultKeys(keydefaults, true); + //CONFIG_SetDefaultKeys(keydefaults, true); system_getcvars(); diff --git a/source/rr/src/game.h b/source/rr/src/game.h index a334b255b..eaba42765 100644 --- a/source/rr/src/game.h +++ b/source/rr/src/game.h @@ -206,8 +206,7 @@ typedef struct { int32_t JoystickAnalogueScale[MAXJOYAXES]; int32_t JoystickAnalogueDead[MAXJOYAXES]; int32_t JoystickAnalogueSaturate[MAXJOYAXES]; - uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2]; - + int32_t scripthandle; int32_t setupread; diff --git a/source/rr/src/gamedef.cpp b/source/rr/src/gamedef.cpp index 513ec7f65..98c98c440 100644 --- a/source/rr/src/gamedef.cpp +++ b/source/rr/src/gamedef.cpp @@ -944,7 +944,7 @@ void C_InitQuotes(void) #ifdef EDUKE32_TOUCH_DEVICES apStrings[QUOTE_DEAD] = 0; #else - char const * const OpenGameFunc = gamefunctions[gamefunc_Open]; + char const * OpenGameFunc = CONFIG_FunctionNumToName(gamefunc_Open); C_ReplaceQuoteSubstring(QUOTE_DEAD, "SPACE", OpenGameFunc); C_ReplaceQuoteSubstring(QUOTE_DEAD, "OPEN", OpenGameFunc); C_ReplaceQuoteSubstring(QUOTE_DEAD, "USE", OpenGameFunc); diff --git a/source/rr/src/gamedef.h b/source/rr/src/gamedef.h index 851a47713..efc8f2284 100644 --- a/source/rr/src/gamedef.h +++ b/source/rr/src/gamedef.h @@ -66,8 +66,6 @@ enum extern intptr_t const * insptr; extern void VM_ScriptInfo(intptr_t const *ptr, int range); -extern hashtable_t h_gamefuncs; - extern hashtable_t h_labels; extern char g_scriptFileName[BMAX_PATH]; diff --git a/source/rr/src/input.cpp b/source/rr/src/input.cpp index 53fd79f67..46baeca86 100644 --- a/source/rr/src/input.cpp +++ b/source/rr/src/input.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "global.h" #include "game.h" -#include "function.h" +#include "gamecontrol.h" #include "keyboard.h" #include "mouse.h" #include "joystick.h" diff --git a/source/rr/src/menus.cpp b/source/rr/src/menus.cpp index 9a9b2c483..3d1866041 100644 --- a/source/rr/src/menus.cpp +++ b/source/rr/src/menus.cpp @@ -262,7 +262,7 @@ static char const *MEOSN_YesNo[] = { "Yes", "No", }; static MenuOptionSet_t MEOS_YesNo = MAKE_MENUOPTIONSET( MEOSN_YesNo, NULL, 0x3 ); -static char MenuGameFuncs[NUMGAMEFUNCTIONS][MAXGAMEFUNCLEN]; +static FString MenuGameFuncs[NUMGAMEFUNCTIONS]; static char const *MenuGameFuncNone = " -None-"; static char const *MEOSN_Gamefuncs[NUMGAMEFUNCTIONS+1]; static int32_t MEOSV_Gamefuncs[NUMGAMEFUNCTIONS+1]; @@ -1614,28 +1614,28 @@ void Menu_Init(void) k = 1; for (i = 0; i < NUMGAMEFUNCTIONS; ++i) { - Bstrcpy(MenuGameFuncs[i], gamefunctions[i]); - - for (j = 0; j < MAXGAMEFUNCLEN; ++j) - if (MenuGameFuncs[i][j] == '_') - MenuGameFuncs[i][j] = ' '; - - if (gamefunctions[i][0] != '\0') - { - MEOSN_Gamefuncs[k] = MenuGameFuncs[i]; - MEOSV_Gamefuncs[k] = i; - ++k; - } + MenuGameFuncs[i] = CONFIG_FunctionNumToName(i); + MenuGameFuncs[i].Substitute('_', ' '); } if (RR) { - Bstrcpy(MenuGameFuncs[gamefunc_Holo_Duke], "Beer"); - Bstrcpy(MenuGameFuncs[gamefunc_Jetpack], "CowPie"); - Bstrcpy(MenuGameFuncs[gamefunc_NightVision], "Yeehaa"); - Bstrcpy(MenuGameFuncs[gamefunc_MedKit], "Whiskey"); - Bstrcpy(MenuGameFuncs[gamefunc_Steroids], "Moonshine"); - Bstrcpy(MenuGameFuncs[gamefunc_Quick_Kick], "Pee"); + MenuGameFuncs[gamefunc_Holo_Duke] = "Beer"; + MenuGameFuncs[gamefunc_Jetpack] = "CowPie"; + MenuGameFuncs[gamefunc_NightVision] = "Yeehaa"; + MenuGameFuncs[gamefunc_MedKit] = "Whiskey"; + MenuGameFuncs[gamefunc_Steroids] = "Moonshine"; + MenuGameFuncs[gamefunc_Quick_Kick] = "Pee"; } + for (i = 0; i < NUMGAMEFUNCTIONS; ++i) + { + if (MenuGameFuncs[i][0] != '\0') + { + MEOSN_Gamefuncs[k] = MenuGameFuncs[i]; + MEOSV_Gamefuncs[k] = i; + ++k; + } + } + MEOS_Gamefuncs.numOptions = k; for (i = 0; i < NUMKEYS; ++i) @@ -1752,8 +1752,8 @@ void Menu_Init(void) 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]; + MEO_KEYBOARDSETUPFUNCS[i].column[0] = &KeyboardKeys[i][0]; + MEO_KEYBOARDSETUPFUNCS[i].column[1] = &KeyboardKeys[i][1]; } M_KEYBOARDKEYS.numEntries = NUMGAMEFUNCTIONS; for (i = 0; i < MENUMOUSEFUNCTIONS; ++i) @@ -3275,10 +3275,10 @@ static void Menu_PreInput(MenuEntry_t *entry) { auto *column = (MenuCustom2Col_t*)entry->entry; char key[2]; - key[0] = ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0]; - key[1] = ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1]; + key[0] = KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0]; + key[1] = KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1]; *column->column[M_KEYBOARDKEYS.currentColumn] = 0xff; - CONFIG_MapKey(M_KEYBOARDKEYS.currentEntry, ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0], key[0], ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1], key[1]); + CONFIG_MapKey(M_KEYBOARDKEYS.currentEntry, KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0], key[0], KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1], key[1]); S_PlaySound(RR ? 335 : KICK_HIT); KB_ClearKeyDown(sc_Delete); } @@ -3335,14 +3335,14 @@ static int32_t Menu_PreCustom2ColScreen(MenuEntry_t *entry) if (sc != sc_None) { char key[2]; - key[0] = ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0]; - key[1] = ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1]; + key[0] = KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0]; + key[1] = KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1]; S_PlaySound(RR ? 341 : PISTOL_BODYHIT); *column->column[M_KEYBOARDKEYS.currentColumn] = KB_GetLastScanCode(); - CONFIG_MapKey(M_KEYBOARDKEYS.currentEntry, ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0], key[0], ud.config.KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1], key[1]); + CONFIG_MapKey(M_KEYBOARDKEYS.currentEntry, KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0], key[0], KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1], key[1]); KB_ClearKeyDown(sc); @@ -3640,9 +3640,9 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry) videoSetPalette(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); } else if (entry == &ME_KEYBOARDSETUP_RESET) - CONFIG_SetDefaultKeys(keydefaults); + CONFIG_SetDefaultKeys("demolition/defbinds.txt"); else if (entry == &ME_KEYBOARDSETUP_RESETCLASSIC) - CONFIG_SetDefaultKeys(oldkeydefaults); + CONFIG_SetDefaultKeys("demolition/origbinds.txt"); else if (entry == &ME_NETHOST_LAUNCH) { // master does whatever it wants diff --git a/source/rr/src/osdcmds.cpp b/source/rr/src/osdcmds.cpp index 8d6248076..7305d050c 100644 --- a/source/rr/src/osdcmds.cpp +++ b/source/rr/src/osdcmds.cpp @@ -739,19 +739,6 @@ static int osdcmd_name(osdcmdptr_t parm) } #endif -static int osdcmd_button(osdcmdptr_t parm) -{ - static char const s_gamefunc_[] = "gamefunc_"; - int constexpr strlen_gamefunc_ = ARRAY_SIZE(s_gamefunc_) - 1; - - char const *p = parm->name + strlen_gamefunc_; - -// if (g_player[myconnectindex].ps->gm == MODE_GAME) // only trigger these if in game - CONTROL_ButtonFlags[CONFIG_FunctionNameToNum(p)] = 1; // FIXME - - return OSDCMD_OK; -} - const char *const ConsoleButtons[] = { "mouse1", "mouse2", "mouse3", "mouse4", "mwheelup", @@ -890,9 +877,9 @@ static int osdcmd_bind(osdcmdptr_t parm) if (j != -1) { - ud.config.KeyboardKeys[j][1] = ud.config.KeyboardKeys[j][0]; - ud.config.KeyboardKeys[j][0] = sctokeylut[i].sc; -// CONTROL_MapKey(j, sctokeylut[i].sc, ud.config.KeyboardKeys[j][0]); + KeyboardKeys[j][1] = KeyboardKeys[j][0]; + KeyboardKeys[j][0] = sctokeylut[i].sc; +// CONTROL_MapKey(j, sctokeylut[i].sc, KeyboardKeys[j][0]); if (j == gamefunc_Show_Console) OSD_CaptureKey(sctokeylut[i].sc); @@ -915,7 +902,7 @@ static int osdcmd_unbindall(osdcmdptr_t UNUSED(parm)) for (int i = 0; i < MAXMOUSEBUTTONS; ++i) CONTROL_FreeMouseBind(i); - for (auto &KeyboardKey : ud.config.KeyboardKeys) + for (auto &KeyboardKey : KeyboardKeys) KeyboardKey[0] = KeyboardKey[1] = 0xff; if (!OSD_ParsingScript()) @@ -1231,22 +1218,6 @@ int32_t registerosdcommands(void) OSD_RegisterFunction("disconnect","disconnect: disconnects from the local multiplayer game", osdcmd_disconnect); #endif - for (auto & func : gamefunctions) - { - if (func[0] == '\0') - continue; - -// if (!Bstrcmp(gamefunctions[i],"Show_Console")) continue; - - Bsprintf(tempbuf, "gamefunc_%s", func); - - char *const t = Bstrtolower(Xstrdup(tempbuf)); - - Bstrcat(tempbuf, ": game button"); - - OSD_RegisterFunction(t, Xstrdup(tempbuf), osdcmd_button); - } - OSD_RegisterFunction("give","give : gives requested item", osdcmd_give); OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god); OSD_RegisterFunction("activatecheat","activatecheat : activates a cheat code", osdcmd_activatecheat); diff --git a/source/rr/src/startwin.game.cpp b/source/rr/src/startwin.game.cpp index 156f2d9e3..617f00580 100644 --- a/source/rr/src/startwin.game.cpp +++ b/source/rr/src/startwin.game.cpp @@ -40,7 +40,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "common_game.h" #include "compat.h" #include "control.h" -#include "function.h" +#include "gamecontrol.h" #include "game.h" #include "grpscan.h" #include "inv.h" diff --git a/source/sw/src/_functio.h b/source/sw/src/_functio.h index 915b5948e..da0fc9e1f 100644 --- a/source/sw/src/_functio.h +++ b/source/sw/src/_functio.h @@ -37,171 +37,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms BEGIN_SW_NS -const char *gamefunctions[] = -{ - "Move_Forward", - "Move_Backward", - "Turn_Left", - "Turn_Right", - "Strafe", - "Fire", - "Open", - "Run", - "AutoRun", - "Jump", - "Crouch", - "Look_Up", - "Look_Down", - "Strafe_Left", - "Strafe_Right", - "Aim_Up", - "Aim_Down", - "Weapon_1", - "Weapon_2", - "Weapon_3", - "Weapon_4", - "Weapon_5", - "Weapon_6", - "Weapon_7", - "Weapon_8", - "Weapon_9", - "Weapon_10", - "Inventory", - "Inventory_Left", - "Inventory_Right", - "Med_Kit", - "Smoke_Bomb", - "Night_Vision", - "Gas_Bomb", - "Flash_Bomb", - "Caltrops", - "TurnAround", - "SendMessage", - "Map", - "Shrink_Screen", - "Enlarge_Screen", - "Center_View", - "Holster_Weapon", - "Map_Follow_Mode", - "See_Co_Op_View", - "Mouse_Aiming", - "Toggle_Crosshair", - "Next_Weapon", - "Previous_Weapon", - "Show_Menu", - "Show_Console", -}; - -#define NUMKEYENTRIES 50 - -static const char *keydefaults[] = -{ - "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", - "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", "]", "", - "Med_Kit", "M", "", - "Smoke_Bomb", "S", "", - "Night_Vision", "N", "", - "Gas_Bomb", "G", "", - "Flash_Bomb", "F", "", - "Caltrops", "C", "", - "TurnAround", "BakSpc", "", - "SendMessage", "T", "", - "Map", "Tab", "", - "Shrink_Screen", "-", "Kpad-", - "Enlarge_Screen", "=", "Kpad+", - "Center_View", "KPad5", "", - "Holster_Weapon", "ScrLck", "", - "Map_Follow_Mode", "F", "", - "See_Co_Op_View", "K", "", - "Mouse_Aiming", "U", "", - "Toggle_Crosshair", "I", "", - "Next_Weapon", "'", "", - "Previous_Weapon", ";", "", - "Show_Console", "NumLck", "", -}; - -static const char *keydefaults_modern[] = -{ - "Move_Forward", "W", "", - "Move_Backward", "S", "", - "Turn_Left", "", "", - "Turn_Right", "", "", - "Strafe", "", "", - "Fire", "", "", - "Open", "E", "", - "Run", "LShift", "", - "AutoRun", "CapLck", "", - "Jump", "Space", "", - "Crouch", "LAlt", "", - "Look_Up", "", "", - "Look_Down", "", "", - "Strafe_Left", "A", "", - "Strafe_Right", "D", "", - "Aim_Up", "", "", - "Aim_Down", "", "", - "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", "", - "Inventory_Left", "[", "", - "Inventory_Right", "]", "", - "Med_Kit", "M", "", - "Smoke_Bomb", "B", "", - "Night_Vision", "N", "", - "Gas_Bomb", "G", "", - "Flash_Bomb", "F", "", - "Caltrops", "C", "", - "TurnAround", "BakSpc", "", - "SendMessage", "T", "", - "Map", "Tab", "", - "Shrink_Screen", "-", "", - "Enlarge_Screen", "=", "", - "Center_View", "", "", - "Holster_Weapon", "H", "", - "Map_Follow_Mode", "F", "", - "See_Co_Op_View", "K", "", - "Mouse_Aiming", "U", "", - "Toggle_Crosshair", "I", "", - "Next_Weapon", "", "", - "Previous_Weapon", "", "", - "Show_Console", "NumLck", "", -}; - static const char *mousedefaults[] = { diff --git a/source/sw/src/anim.cpp b/source/sw/src/anim.cpp index 224292694..8db5c3d73 100644 --- a/source/sw/src/anim.cpp +++ b/source/sw/src/anim.cpp @@ -39,7 +39,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "control.h" #include "config.h" #include "sounds.h" -#include "function.h" +#include "gamecontrol.h" #include "game.h" #include "colormap.h" diff --git a/source/sw/src/cheats.cpp b/source/sw/src/cheats.cpp index 065b0ba36..7f4612317 100644 --- a/source/sw/src/cheats.cpp +++ b/source/sw/src/cheats.cpp @@ -35,7 +35,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "text.h" #include "control.h" -#include "function.h" +#include "gamecontrol.h" //#include "inv.h" BEGIN_SW_NS diff --git a/source/sw/src/config.cpp b/source/sw/src/config.cpp index 1469105e3..c916d4d7b 100644 --- a/source/sw/src/config.cpp +++ b/source/sw/src/config.cpp @@ -35,7 +35,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "scriplib.h" #include "gamedefs.h" #include "keyboard.h" -#include "function.h" +#include "gamecontrol.h" #include "control.h" #include "fx_man.h" #include "sounds.h" @@ -71,7 +71,6 @@ int32_t NumberPlayers,CommPort,PortSpeed,IrqNumber,UartAddress; int32_t UseMouse = 1, UseJoystick = 0; -uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2]; int32_t MouseButtons[MAXMOUSEBUTTONS]; int32_t MouseButtonsClicked[MAXMOUSEBUTTONS]; int32_t MouseDigitalAxes[MAXMOUSEAXES][2]; @@ -101,49 +100,6 @@ static int32_t scripthandle = -1; -/* -=================== -= -= CONFIG_FunctionNameToNum -= -=================== -*/ - -int32_t CONFIG_FunctionNameToNum(const char *func) -{ - int32_t i; - - if (!func) return -1; - for (i=0; i= (unsigned)NUMGAMEFUNCTIONS) - { - return NULL; - } - else - { - return gamefunctions[func]; - } -} - /* =================== = @@ -283,36 +239,7 @@ void CONFIG_SetDefaults(void) void SetDefaultKeyDefinitions(int style) { - int numkeydefaults; - const char **keydefaultset; - int i, f, k1, k2; - - if (style) - { - numkeydefaults = sizeof(keydefaults_modern) / sizeof(char *) / 3; - keydefaultset = keydefaults_modern; - } - else - { - numkeydefaults = sizeof(keydefaults) / sizeof(char *) / 3; - keydefaultset = keydefaults; - } - - memset(KeyboardKeys, 0xff, sizeof(KeyboardKeys)); - for (i=0; i < numkeydefaults; i++) - { - f = CONFIG_FunctionNameToNum(keydefaultset[3*i+0]); - if (f == -1) continue; - k1 = KB_StringToScanCode(keydefaultset[3*i+1]); - k2 = KB_StringToScanCode(keydefaultset[3*i+2]); -// [JM] Needs to be rewritten, I think. !CHECKME! -#if 0 - CONTROL_MapKey(i, k1, k2); -#endif - - KeyboardKeys[f][0] = k1; - KeyboardKeys[f][1] = k2; - } + CONFIG_SetDefaultKeys(style ? "demolition/defbinds.txt" : "demolition/origbinds.txt"); } void SetMouseDefaults(int style) diff --git a/source/sw/src/config.h b/source/sw/src/config.h index 7f3192f96..6694d672a 100644 --- a/source/sw/src/config.h +++ b/source/sw/src/config.h @@ -29,7 +29,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "compat.h" -#include "function.h" +#include "gamecontrol.h" #include "keyboard.h" #include "control.h" @@ -78,8 +78,6 @@ extern int32_t MouseSensitivity; extern int32_t MouseAiming; extern int32_t MouseAimingFlipped; -extern uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2]; - extern int32_t MouseButtons[MAXMOUSEBUTTONS]; extern int32_t MouseButtonsClicked[MAXMOUSEBUTTONS]; @@ -114,8 +112,6 @@ void CONFIG_WriteSetup(void); void WriteCommitFile(int32_t gametype); void CONFIG_GetSetupFilename(void); -const char *CONFIG_FunctionNumToName(int32_t func); -int32_t CONFIG_FunctionNameToNum(const char *func); const char *CONFIG_AnalogNumToName(int32_t func); int32_t CONFIG_AnalogNameToNum(const char *func); diff --git a/source/sw/src/console.cpp b/source/sw/src/console.cpp index 3178bdcba..d32a2aa93 100644 --- a/source/sw/src/console.cpp +++ b/source/sw/src/console.cpp @@ -44,7 +44,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "quake.h" #include "common_game.h" -#include "function.h" +#include "gamecontrol.h" #include "control.h" #include "trigger.h" diff --git a/source/sw/src/demo.cpp b/source/sw/src/demo.cpp index c50924b0c..ddf18fe17 100644 --- a/source/sw/src/demo.cpp +++ b/source/sw/src/demo.cpp @@ -38,7 +38,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "mytypes.h" #include "control.h" -#include "function.h" +#include "gamecontrol.h" #include "demo.h" #include "player.h" @@ -478,9 +478,9 @@ DemoPlayBack(void) } #endif - if (BUTTON(gamefunc_See_Co_Op_View)) + if (BUTTON(gamefunc_See_Coop_View)) { - CONTROL_ClearButton(gamefunc_See_Co_Op_View); + CONTROL_ClearButton(gamefunc_See_Coop_View); screenpeek = connectpoint2[screenpeek]; diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index 8f0b42108..8990f3a0e 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -41,7 +41,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "mytypes.h" #include "control.h" -#include "function.h" +#include "gamecontrol.h" #include "network.h" #include "pal.h" #include "player.h" diff --git a/source/sw/src/function.h b/source/sw/src/function.h deleted file mode 100644 index e48a87547..000000000 --- a/source/sw/src/function.h +++ /dev/null @@ -1,99 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 1997, 2005 - 3D Realms Entertainment - -This file is part of Shadow Warrior version 1.2 - -Shadow Warrior is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -Original Source: 1997 - Frank Maddin and Jim Norwood -Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms -*/ -//------------------------------------------------------------------------- - -// function.h - -// file created by makehead.exe -// these headers contain default key assignments, as well as -// default button assignments and game function names -// axis defaults are also included - - -#ifndef function_public_ -#define function_public_ -BEGIN_SW_NS - -#define NUMGAMEFUNCTIONS 51 - -extern const char *gamefunctions[]; - -enum -{ - gamefunc_Move_Forward, - gamefunc_Move_Backward, - gamefunc_Turn_Left, - gamefunc_Turn_Right, - gamefunc_Strafe, - gamefunc_Fire, - gamefunc_Open, - gamefunc_Run, - gamefunc_AutoRun, - gamefunc_Jump, - gamefunc_Crouch, - gamefunc_Look_Up, - gamefunc_Look_Down, - gamefunc_Strafe_Left, - gamefunc_Strafe_Right, - gamefunc_Aim_Up, - gamefunc_Aim_Down, - gamefunc_Weapon_1, - gamefunc_Weapon_2, - gamefunc_Weapon_3, - gamefunc_Weapon_4, - gamefunc_Weapon_5, - gamefunc_Weapon_6, - gamefunc_Weapon_7, - gamefunc_Weapon_8, - gamefunc_Weapon_9, - gamefunc_Weapon_10, - gamefunc_Inventory, - gamefunc_Inventory_Left, - gamefunc_Inventory_Right, - gamefunc_Med_Kit, - gamefunc_Smoke_Bomb, - gamefunc_Night_Vision, - gamefunc_Gas_Bomb, - gamefunc_Flash_Bomb, - gamefunc_Caltrops, - gamefunc_TurnAround, - gamefunc_SendMessage, - gamefunc_Map, - gamefunc_Shrink_Screen, - gamefunc_Enlarge_Screen, - gamefunc_Center_View, - gamefunc_Holster_Weapon, - gamefunc_Map_Follow_Mode, - gamefunc_See_Co_Op_View, - gamefunc_Mouse_Aiming, - gamefunc_Toggle_Crosshair, - gamefunc_Next_Weapon, - gamefunc_Previous_Weapon, - gamefunc_Show_Menu, - gamefunc_Show_Console, -}; -END_SW_NS - -#endif diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index 99abf70b3..308c66529 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -70,7 +70,7 @@ Things required to make savegames work: #include "menus.h" #include "control.h" -#include "function.h" +#include "gamecontrol.h" #include "gamedefs.h" #include "config.h" diff --git a/source/sw/src/jplayer.cpp b/source/sw/src/jplayer.cpp index 348074662..832168c11 100644 --- a/source/sw/src/jplayer.cpp +++ b/source/sw/src/jplayer.cpp @@ -42,7 +42,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "quake.h" #include "common_game.h" -#include "function.h" +#include "gamecontrol.h" #include "control.h" #include "trigger.h" diff --git a/source/sw/src/menus.cpp b/source/sw/src/menus.cpp index f6e56a08a..fcb372e3a 100644 --- a/source/sw/src/menus.cpp +++ b/source/sw/src/menus.cpp @@ -44,7 +44,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "pal.h" #include "demo.h" -#include "function.h" +#include "gamecontrol.h" #include "gamedefs.h" #include "config.h" #include "network.h" @@ -829,7 +829,8 @@ SWBOOL MNU_KeySetupCustom(UserCall call, MenuItem *item) for (i=0; i<(int)SIZ(strs); i++) { w = 0; - sprintf(ds,strs[i],gamefunctions[currentkey],col[currentcol]); + auto c = CONFIG_FunctionNumToName(currentkey); + sprintf(ds,strs[i],c,col[currentcol]); for (j=0; ds[j]; j++) if (ds[j] == '_') ds[j] = ' '; MNU_MeasureString(ds, &w, &h); MNU_DrawString((XDIM - w)/2, y, ds, 0, 16); @@ -925,10 +926,11 @@ SWBOOL MNU_KeySetupCustom(UserCall call, MenuItem *item) for (i = topitem; i <= botitem; i++) { - for (j = 0; gamefunctions[i][j]; j++) + auto c = CONFIG_FunctionNumToName(i); + for (j = 0; c[j]; j++) { - if (gamefunctions[i][j] == '_') ds[j] = ' '; - else ds[j] = gamefunctions[i][j]; + if (c[j] == '_') ds[j] = ' '; + else ds[j] = c[j]; } ds[j] = 0; @@ -1047,10 +1049,11 @@ static int MNU_SelectButtonFunction(const char *buttonname, int *currentfunc) } else { - for (j = 0; gamefunctions[i-1][j]; j++) + auto c = CONFIG_FunctionNumToName(i-1); + for (j = 0; c[j]; j++) { - if (gamefunctions[i-1][j] == '_') ds[j] = ' '; - else ds[j] = gamefunctions[i-1][j]; + if (c[j] == '_') ds[j] = ' '; + else ds[j] = c[j]; } ds[j] = 0; } @@ -4657,10 +4660,9 @@ void MNU_DoMenu(CTLType type, PLAYERp pp) MNU_DoSlider(1, ¤tmenu->items[currentmenu->cursor], FALSE); resetitem = TRUE; } - else if (mnu_input.button1 || BUTTON(gamefunc_Show_Menu)) + else if (mnu_input.button1) { static int handle3=0; - CONTROL_ClearButton(gamefunc_Show_Menu); if (!FX_SoundActive(handle3)) handle3 = PlaySound(DIGI_SWORDSWOOSH,&zero,&zero,&zero,v3df_dontpan); MNU_UpLevel(); @@ -4704,10 +4706,9 @@ MNU_CheckForMenus(void) } else { - if ((KEY_PRESSED(KEYSC_ESC) || BUTTON(gamefunc_Show_Menu)) && dimensionmode == 3 && !ConPanel) + if ((KEY_PRESSED(KEYSC_ESC)) && dimensionmode == 3 && !ConPanel) { KEY_PRESSED(KEYSC_ESC) = 0; - CONTROL_ClearButton(gamefunc_Show_Menu); KB_ClearKeysDown(); // setup sliders/buttons MNU_InitMenus(); diff --git a/source/sw/src/menus.h b/source/sw/src/menus.h index 5104af15b..8b2508f99 100644 --- a/source/sw/src/menus.h +++ b/source/sw/src/menus.h @@ -74,13 +74,6 @@ void ResetPalette(PLAYERp pp); void ExitMenus(void); void ResetMenuInput(void); -#define BUTTONSET(x,value) \ - ( \ - ((x)>31) ? \ - (CONTROL_ButtonState2 |= (value<<((x)-32))) : \ - (CONTROL_ButtonState1 |= (value<<(x))) \ - ) - extern SWBOOL BorderAdjust; extern SWBOOL MultiPlayQuitFlag; diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index 3e9f9ef62..e008c7cc2 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -41,7 +41,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "text.h" #include "common_game.h" -#include "function.h" +#include "gamecontrol.h" #include "control.h" #include "trigger.h" diff --git a/source/sw/src/predict.cpp b/source/sw/src/predict.cpp index b35fc95e1..3d4481ab0 100644 --- a/source/sw/src/predict.cpp +++ b/source/sw/src/predict.cpp @@ -38,7 +38,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms //#include "mytypes.h" //#include "control.h" -//#include "function.h" +//#include "gamecontrol.h" #include "network.h" //#include "symutil.h" diff --git a/source/sw/src/setup.cpp b/source/sw/src/setup.cpp index b20135af4..56d9ef240 100644 --- a/source/sw/src/setup.cpp +++ b/source/sw/src/setup.cpp @@ -39,7 +39,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "control.h" #include "config.h" #include "sounds.h" -#include "function.h" +#include "gamecontrol.h" #include "rts.h" @@ -56,8 +56,6 @@ BEGIN_SW_NS void SetupGameButtons(void) { - // processes array from function.h - char * gamefunctions[]; - short gamefunc; for (gamefunc = 0; gamefunc < NUMGAMEFUNCTIONS; gamefunc++) @@ -163,7 +161,7 @@ void TermSetup(void) #include "control.h" #include "config.h" #include "sounds.h" -#include "function.h" +#include "gamecontrol.h" #include "rts.h" #include "timer.h" @@ -370,13 +368,6 @@ void main() printf("x=%6ld y=%6ld z=%6ld yaw=%6ld pitch=%6ld roll=%6ld\n", info.dx,info.dy,info.dz,info.dyaw,info.dpitch,info.droll); // Get Keyboard input and set appropiate game function states - for (i=0; i