From 4e81b4e2f080ed3a465c110f0f8c526360f5a0da Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 6 Jul 2019 16:30:43 +0000 Subject: [PATCH] Replace gamefunc_Alt_Weapon with a gamefunc_Alt_Fire that works as expected git-svn-id: https://svn.eduke32.com/eduke32@7761 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/_functio.h | 4 ++-- source/duke3d/src/events_defs.h | 2 +- source/duke3d/src/function.h | 2 +- source/duke3d/src/game.cpp | 12 +++++------- source/duke3d/src/gamedef.cpp | 2 +- source/duke3d/src/player.cpp | 26 +++++++++++--------------- source/duke3d/src/player.h | 2 +- source/duke3d/src/sector.cpp | 3 --- 8 files changed, 22 insertions(+), 31 deletions(-) diff --git a/source/duke3d/src/_functio.h b/source/duke3d/src/_functio.h index 533e2d034..645420c89 100644 --- a/source/duke3d/src/_functio.h +++ b/source/duke3d/src/_functio.h @@ -110,7 +110,7 @@ char gamefunctions[NUMGAMEFUNCTIONS][MAXGAMEFUNCLEN] = #endif "Dpad_Select", "Dpad_Aiming", - "Alternate_Weapon", + "Alt_Fire", "Last_Used_Weapon", "Quick_Save", "Quick_Load", @@ -249,7 +249,7 @@ const char oldkeydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN] = static const char * mousedefaults[MAXMOUSEBUTTONS] = { "Fire", - "MedKit", + "Alt_Fire", "Jetpack", "", "Previous_Weapon", diff --git a/source/duke3d/src/events_defs.h b/source/duke3d/src/events_defs.h index a63129492..2946fca28 100644 --- a/source/duke3d/src/events_defs.h +++ b/source/duke3d/src/events_defs.h @@ -140,7 +140,7 @@ enum GameEvent_t { EVENT_ENDLEVELSCREEN, EVENT_EXITGAMESCREEN, EVENT_EXITPROGRAMSCREEN, - EVENT_ALTWEAPON, + EVENT_ALTFIRE, EVENT_DISPLAYOVERHEADMAPPLAYER, EVENT_MENUCURSORLEFT, EVENT_MENUCURSORRIGHT, diff --git a/source/duke3d/src/function.h b/source/duke3d/src/function.h index 7be4da59a..56934f9ad 100644 --- a/source/duke3d/src/function.h +++ b/source/duke3d/src/function.h @@ -99,7 +99,7 @@ enum GameFunction_t gamefunc_Show_DukeMatch_Scores, gamefunc_Dpad_Select, gamefunc_Dpad_Aiming, - gamefunc_Alt_Weapon, + gamefunc_Alt_Fire, gamefunc_Last_Weapon, gamefunc_Quick_Save, gamefunc_Quick_Load, diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index cfd2e1223..ed69d81e3 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -7032,15 +7032,13 @@ int G_DoMoveThings(void) for (bssize_t TRAVERSE_CONNECT(i)) { - if (g_player[i].inputBits->extbits&(1<<6)) + if (g_player[i].ps->team != g_player[i].pteam && g_gametypeFlags[ud.coop] & GAMETYPE_TDM) { g_player[i].ps->team = g_player[i].pteam; - if (g_gametypeFlags[ud.coop] & GAMETYPE_TDM) - { - actor[g_player[i].ps->i].picnum = APLAYERTOP; - P_QuickKill(g_player[i].ps); - } + actor[g_player[i].ps->i].picnum = APLAYERTOP; + P_QuickKill(g_player[i].ps); } + if (g_gametypeFlags[ud.coop] & GAMETYPE_TDM) g_player[i].ps->palookup = g_player[i].pcolor = G_GetTeamPalette(g_player[i].ps->team); @@ -7256,7 +7254,7 @@ static void G_SetupGameButtons(void) CONTROL_DefineFlag(gamefunc_Quick_Kick,FALSE); CONTROL_DefineFlag(gamefunc_Next_Weapon,FALSE); CONTROL_DefineFlag(gamefunc_Previous_Weapon,FALSE); - CONTROL_DefineFlag(gamefunc_Alt_Weapon,FALSE); + CONTROL_DefineFlag(gamefunc_Alt_Fire,FALSE); CONTROL_DefineFlag(gamefunc_Last_Weapon,FALSE); CONTROL_DefineFlag(gamefunc_Quick_Save, FALSE); CONTROL_DefineFlag(gamefunc_Quick_Load, FALSE); diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index 19c144678..31b35824a 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -967,7 +967,7 @@ const char *EventNames[MAXEVENTS] = "EVENT_ENDLEVELSCREEN", "EVENT_EXITGAMESCREEN", "EVENT_EXITPROGRAMSCREEN", - "EVENT_ALTWEAPON", + "EVENT_ALTFIRE", "EVENT_DISPLAYOVERHEADMAPPLAYER", "EVENT_MENUCURSORLEFT", "EVENT_MENUCURSORRIGHT", diff --git a/source/duke3d/src/player.cpp b/source/duke3d/src/player.cpp index af2b02b04..e1136bfc3 100644 --- a/source/duke3d/src/player.cpp +++ b/source/duke3d/src/player.cpp @@ -2895,8 +2895,7 @@ void P_GetInput(int const playerNum) Bmemset(&localInput, 0, sizeof(input_t)); localInput.bits = (((int32_t)g_gameQuit) << SK_GAMEQUIT); - localInput.extbits = (g_player[playerNum].pteam != pPlayer->team) << 6; - localInput.extbits |= (1 << 7); + localInput.extbits |= (1<<7); return; } @@ -3032,8 +3031,6 @@ void P_GetInput(int const playerNum) } if (BUTTON(gamefunc_Last_Weapon)) - weaponSelection = 14; - else if (BUTTON(gamefunc_Alt_Weapon)) weaponSelection = 13; else if (BUTTON(gamefunc_Next_Weapon) || (BUTTON(gamefunc_Dpad_Select) && input.fvel > 0)) weaponSelection = 12; @@ -3090,15 +3087,9 @@ void P_GetInput(int const playerNum) localInput.extbits |= (BUTTON(gamefunc_Move_Backward) || (input.fvel < 0)) << 1; localInput.extbits |= (BUTTON(gamefunc_Strafe_Left) || (input.svel > 0)) << 2; localInput.extbits |= (BUTTON(gamefunc_Strafe_Right) || (input.svel < 0)) << 3; - - if (VM_HaveEvent(EVENT_PROCESSINPUT) || VM_HaveEvent(EVENT_TURNLEFT)) - localInput.extbits |= BUTTON(gamefunc_Turn_Left)<<4; - - if (VM_HaveEvent(EVENT_PROCESSINPUT) || VM_HaveEvent(EVENT_TURNRIGHT)) - localInput.extbits |= BUTTON(gamefunc_Turn_Right)<<5; - - // used for changing team - localInput.extbits |= (g_player[playerNum].pteam != pPlayer->team)<<6; + localInput.extbits |= BUTTON(gamefunc_Turn_Left)<<4; + localInput.extbits |= BUTTON(gamefunc_Turn_Right)<<5; + localInput.extbits |= BUTTON(gamefunc_Alt_Fire)<<6; if (ud.scrollmode && ud.overhead_on) { @@ -3945,9 +3936,11 @@ static void P_ProcessWeapon(int playerNum) pPlayer->rapid_fire_hold = 0; } + int const doAltFire = g_player[playerNum].inputBits->extbits & (1<<6); + if (playerShrunk || pPlayer->tipincs || pPlayer->access_incs) playerBits &= ~BIT(SK_FIRE); - else if ((playerBits & (1 << 2)) && (*weaponFrame) == 0 && pPlayer->fist_incs == 0 && + else if ((playerBits & BIT(SK_FIRE) || doAltFire) && (*weaponFrame) == 0 && pPlayer->fist_incs == 0 && pPlayer->last_weapon == -1 && (pPlayer->weapon_pos == 0 || pPlayer->holster_weapon == 1)) { pPlayer->crack_time = PCRACKTIME; @@ -3965,7 +3958,10 @@ static void P_ProcessWeapon(int playerNum) { P_SetWeaponGamevars(playerNum, pPlayer); - if (VM_OnEvent(EVENT_FIRE, pPlayer->i, playerNum) == 0) + if (doAltFire) + VM_OnEvent(EVENT_ALTFIRE, pPlayer->i, playerNum); + + if (playerBits & BIT(SK_FIRE) && VM_OnEvent(EVENT_FIRE, pPlayer->i, playerNum) == 0) { // this event is deprecated VM_OnEvent(EVENT_FIREWEAPON, pPlayer->i, playerNum); diff --git a/source/duke3d/src/player.h b/source/duke3d/src/player.h index 2408d8c21..fcbef7f91 100644 --- a/source/duke3d/src/player.h +++ b/source/duke3d/src/player.h @@ -126,7 +126,7 @@ typedef struct { uint32_t bits; int16_t fvel, svel; fix16_t q16avel, q16horz; - int8_t extbits; + uint8_t extbits; } input_t; #pragma pack(push,1) diff --git a/source/duke3d/src/sector.cpp b/source/duke3d/src/sector.cpp index c3505e10a..9186df371 100644 --- a/source/duke3d/src/sector.cpp +++ b/source/duke3d/src/sector.cpp @@ -2655,9 +2655,6 @@ CHECKINV1: weaponNum = VM_OnEventWithReturn(EVENT_NEXTWEAPON,pPlayer->i,playerNum, weaponNum); break; case 12: - weaponNum = VM_OnEventWithReturn(EVENT_ALTWEAPON,pPlayer->i,playerNum, weaponNum); - break; - case 13: weaponNum = VM_OnEventWithReturn(EVENT_LASTWEAPON,pPlayer->i,playerNum, weaponNum); break; }