mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 15:21:48 +00:00
- weapon selection offloaded and cleaned up.
This commit is contained in:
parent
43c4c5eb5e
commit
7ba4e4de97
3 changed files with 40 additions and 37 deletions
|
@ -217,8 +217,7 @@ enum dukeinvicon_t
|
|||
ICON_MAX
|
||||
};
|
||||
|
||||
// And yet another bit field that was for all intents and purposes undocumented, depending on numeric literals again.
|
||||
// And again, the symbolic names are from EDuke32.
|
||||
|
||||
enum ESyncVals
|
||||
{
|
||||
// Todo: Make this bit masks - cannot be done before eliminating all old code using it
|
||||
|
@ -230,10 +229,6 @@ enum ESyncVals
|
|||
SK_LOOK_LEFT = 6 ,
|
||||
SK_LOOK_RIGHT = 7 ,
|
||||
// weapons take up 4 bits...
|
||||
SK_WEAPON_BITS = 8 ,
|
||||
SK_WEAPON_BITS1 = 9 ,
|
||||
SK_WEAPON_BITS2 = 10,
|
||||
SK_WEAPON_BITS3 = 11,
|
||||
SK_LOOK_UP = 13,
|
||||
SK_LOOK_DOWN = 14,
|
||||
SK_MULTIFLAG = 17,
|
||||
|
@ -254,6 +249,7 @@ enum ESyncBits_ : uint32_t
|
|||
SKB_RUN = 1 << 5,
|
||||
SKB_LOOK_LEFT = 1 << 6,
|
||||
SKB_LOOK_RIGHT = 1 << 7,
|
||||
SKB_FIRST_WEAPON_BIT = 1 << 8,
|
||||
SKB_STEROIDS = 1 << 12,
|
||||
SKB_LOOK_UP = 1 << 13,
|
||||
SKB_LOOK_DOWN = 1 << 14,
|
||||
|
@ -275,7 +271,7 @@ enum ESyncBits_ : uint32_t
|
|||
SKB_INVENTORY = 1 << 30,
|
||||
SKB_ESCAPE = 1u << 31,
|
||||
|
||||
SKB_WEAPONMASK_BITS = (15u << int(SK_WEAPON_BITS)),
|
||||
SKB_WEAPONMASK_BITS = (15u * SKB_FIRST_WEAPON_BIT),
|
||||
SKB_INTERFACE_BITS = (SKB_WEAPONMASK_BITS | SKB_STEROIDS | SKB_NIGHTVISION | SKB_MEDKIT | SKB_QUICK_KICK | \
|
||||
SKB_HOLSTER | SKB_INV_LEFT | SKB_PAUSE | SKB_HOLODUKE | SKB_JETPACK | SKB_INV_RIGHT | \
|
||||
SKB_TURNAROUND | SKB_OPEN | SKB_INVENTORY | SKB_ESCAPE),
|
||||
|
|
|
@ -428,7 +428,7 @@ void hud_input(int snum)
|
|||
if (dainv >= 1 && dainv < 8) FTA(invquotes[dainv - 1], p);
|
||||
}
|
||||
|
||||
j = (PlayerInputBits(snum, SKB_WEAPONMASK_BITS) >> SK_WEAPON_BITS) - 1;
|
||||
j = (PlayerInputBits(snum, SKB_WEAPONMASK_BITS) / SKB_FIRST_WEAPON_BIT) - 1;
|
||||
if (j > 0 && p->kickback_pic > 0)
|
||||
p->wantweaponfire = j;
|
||||
|
||||
|
@ -740,6 +740,40 @@ void processCommonInput(input_t &input)
|
|||
input.svel = 0;
|
||||
input.q16avel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// weapon selection bits.
|
||||
// This should all be remapped to CCMDs, except for the controller check
|
||||
// For the next and prev weapon functions this is particularly necessary
|
||||
// due to how the mouse wheel works.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void processSelectWeapon(input_t& input)
|
||||
{
|
||||
int j = 0;
|
||||
if (buttonMap.ButtonPressed(gamefunc_Weapon_1)) j = 1;
|
||||
if (buttonMap.ButtonPressed(gamefunc_Weapon_2)) j = 2;
|
||||
if (buttonMap.ButtonPressed(gamefunc_Weapon_3)) j = 3;
|
||||
if (buttonMap.ButtonPressed(gamefunc_Weapon_4)) j = 4;
|
||||
if (buttonMap.ButtonPressed(gamefunc_Weapon_5)) j = 5;
|
||||
if (buttonMap.ButtonPressed(gamefunc_Weapon_6)) j = 6;
|
||||
|
||||
if (!VOLUMEONE)
|
||||
{
|
||||
if (buttonMap.ButtonPressed(gamefunc_Weapon_7)) j = 7;
|
||||
if (buttonMap.ButtonPressed(gamefunc_Weapon_8)) j = 8;
|
||||
if (buttonMap.ButtonPressed(gamefunc_Weapon_9)) j = 9;
|
||||
if (buttonMap.ButtonPressed(gamefunc_Weapon_10)) j = 10;
|
||||
}
|
||||
|
||||
if (buttonMap.ButtonPressed(gamefunc_Previous_Weapon) || (buttonMap.ButtonDown(gamefunc_Dpad_Select) && input.fvel < 0)) j = 11;
|
||||
if (buttonMap.ButtonPressed(gamefunc_Next_Weapon) || (buttonMap.ButtonDown(gamefunc_Dpad_Select) && input.fvel < 0)) j = 12;
|
||||
|
||||
if ((localInput.bits & SKB_WEAPONMASK_BITS) == 0)
|
||||
localInput.bits |= ESyncBits::FromInt(j * SKB_FIRST_WEAPON_BIT);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ BEGIN_DUKE_NS
|
|||
|
||||
fix16_t GetDeltaQ16Angle(fix16_t ang1, fix16_t ang2);
|
||||
void processCommonInput(input_t& input);
|
||||
void processSelectWeapon(input_t& input);
|
||||
int motoApplyTurn(player_struct* p, int turnl, int turnr, int bike_turn, bool goback, double factor);
|
||||
int boatApplyTurn(player_struct* p, int turnl, int turnr, int bike_turn, double factor);
|
||||
|
||||
|
@ -210,36 +211,8 @@ void P_GetInput(int const playerNum)
|
|||
}
|
||||
}
|
||||
|
||||
int weaponSelection;
|
||||
processSelectWeapon(input);
|
||||
|
||||
for (weaponSelection = gamefunc_Weapon_10; weaponSelection >= gamefunc_Weapon_1; --weaponSelection)
|
||||
{
|
||||
if (buttonMap.ButtonDown(weaponSelection))
|
||||
{
|
||||
weaponSelection -= (gamefunc_Weapon_1 - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Last_Weapon))
|
||||
weaponSelection = 14;
|
||||
else if (buttonMap.ButtonDown(gamefunc_Alt_Weapon))
|
||||
weaponSelection = 13;
|
||||
else if (buttonMap.ButtonPressed(gamefunc_Next_Weapon) || (buttonMap.ButtonDown(gamefunc_Dpad_Select) && input.fvel > 0))
|
||||
{
|
||||
weaponSelection = 12;
|
||||
buttonMap.ClearButton(gamefunc_Next_Weapon);
|
||||
}
|
||||
else if (buttonMap.ButtonPressed(gamefunc_Previous_Weapon) || (buttonMap.ButtonDown(gamefunc_Dpad_Select) && input.fvel < 0))
|
||||
{
|
||||
weaponSelection = 11;
|
||||
buttonMap.ClearButton(gamefunc_Previous_Weapon);
|
||||
}
|
||||
else if (weaponSelection == gamefunc_Weapon_1-1)
|
||||
weaponSelection = 0;
|
||||
|
||||
if ((localInput.bits & SKB_WEAPONMASK_BITS) == 0)
|
||||
localInput.bits |= (weaponSelection << SK_WEAPON_BITS);
|
||||
|
||||
int const sectorLotag = pPlayer->cursectnum != -1 ? sector[pPlayer->cursectnum].lotag : 0;
|
||||
int const crouchable = sectorLotag != 2 && (sectorLotag != 1 || pPlayer->spritebridge);
|
||||
|
|
Loading…
Reference in a new issue