From 7fa0abda262a027d46208ad6e7d69e246973ec9c Mon Sep 17 00:00:00 2001 From: terminx Date: Wed, 7 Mar 2018 04:20:50 +0000 Subject: [PATCH] Add gamefunc for switching to your last used weapon git-svn-id: https://svn.eduke32.com/eduke32@6723 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/_functio.h | 5 ++++- source/duke3d/src/function.h | 5 +++-- source/duke3d/src/game.cpp | 1 + source/duke3d/src/player.cpp | 12 ++++++++++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/source/duke3d/src/_functio.h b/source/duke3d/src/_functio.h index ad8168556..a4aeef36e 100644 --- a/source/duke3d/src/_functio.h +++ b/source/duke3d/src/_functio.h @@ -111,11 +111,12 @@ char gamefunctions[NUMGAMEFUNCTIONS][MAXGAMEFUNCLEN] = "Dpad_Select", "Dpad_Aiming", "Alternate_Weapon", + "Last_Used_Weapon" }; #ifdef __SETUP__ -#define NUMKEYENTRIES 57 +#define NUMKEYENTRIES 58 const char keydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN] = { @@ -176,6 +177,7 @@ const char keydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN] = "", "", "", "", "", "", + "", "", }; const char oldkeydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN] = @@ -237,6 +239,7 @@ const char oldkeydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN] = "", "", "", "", "", "", + "", "", }; static const char * mousedefaults[MAXMOUSEBUTTONS] = diff --git a/source/duke3d/src/function.h b/source/duke3d/src/function.h index d4ad5fc36..4da4f19b9 100644 --- a/source/duke3d/src/function.h +++ b/source/duke3d/src/function.h @@ -34,8 +34,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. extern "C" { #endif -#define NUMKEYENTRIES 57 -#define NUMGAMEFUNCTIONS 57 +#define NUMKEYENTRIES 58 +#define NUMGAMEFUNCTIONS 58 #define MAXGAMEFUNCLEN 32 extern char gamefunctions[NUMGAMEFUNCTIONS][MAXGAMEFUNCLEN]; @@ -101,6 +101,7 @@ enum GameFunction_t gamefunc_Dpad_Select, gamefunc_Dpad_Aiming, gamefunc_Alt_Weapon, + gamefunc_Last_Weapon, }; #ifdef __cplusplus } diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 0bbbe2608..49bdcdd06 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -7152,4 +7152,5 @@ static void G_SetupGameButtons(void) CONTROL_DefineFlag(gamefunc_Next_Weapon,FALSE); CONTROL_DefineFlag(gamefunc_Previous_Weapon,FALSE); CONTROL_DefineFlag(gamefunc_Alt_Weapon,FALSE); + CONTROL_DefineFlag(gamefunc_Last_Weapon, FALSE); } diff --git a/source/duke3d/src/player.cpp b/source/duke3d/src/player.cpp index dd6121bbe..161e6a40b 100644 --- a/source/duke3d/src/player.cpp +++ b/source/duke3d/src/player.cpp @@ -2811,6 +2811,7 @@ enddisplayweapon: int32_t g_myAimMode = 0, g_myAimStat = 0, g_oldAimStat = 0; int32_t mouseyaxismode = -1; int32_t g_emuJumpTics = 0; +int32_t g_lastWeapon = 0; void P_GetInput(int playerNum) { @@ -2974,6 +2975,9 @@ void P_GetInput(int playerNum) if (BUTTON(gamefunc_Alt_Weapon)) weaponSelection = 13; + if (BUTTON(gamefunc_Last_Weapon)) + weaponSelection = g_lastWeapon + 1; + if (BUTTON(gamefunc_Jump) && pPlayer->on_ground) g_emuJumpTics = 4; @@ -3344,13 +3348,17 @@ static void P_ChangeWeapon(DukePlayer_t * const pPlayer, int const weaponNum) pPlayer->last_weapon = -1; } -#ifdef __ANDROID__ if (currentWeapon != pPlayer->curr_weapon && // p->last_weapon != -1 && !(PWEAPON(playerNum, currentWeapon, WorksLike) == HANDREMOTE_WEAPON && PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) == HANDBOMB_WEAPON) && !(PWEAPON(playerNum, currentWeapon, WorksLike) == HANDBOMB_WEAPON && PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) == HANDREMOTE_WEAPON)) - CONTROL_Android_SetLastWeapon(PWEAPON(playerNum, currentWeapon, WorksLike) == HANDREMOTE_WEAPON ? (int)HANDBOMB_WEAPON : currentWeapon); + { + g_lastWeapon = PWEAPON(playerNum, currentWeapon, WorksLike) == HANDREMOTE_WEAPON ? (int) HANDBOMB_WEAPON : currentWeapon; + if (g_lastWeapon == GROW_WEAPON) g_lastWeapon = SHRINKER_WEAPON; +#ifdef __ANDROID__ + CONTROL_Android_SetLastWeapon(g_lastWeapon); #endif + } pPlayer->kickback_pic = 0;