mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-29 13:00:43 +00:00
- use new bitmask for weapon selection in Duke.
This commit is contained in:
parent
36d676ca20
commit
e768a2bf24
3 changed files with 50 additions and 16 deletions
|
@ -5,6 +5,20 @@
|
||||||
#include "tflags.h"
|
#include "tflags.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum ESyncBits_ : uint32_t
|
||||||
|
{
|
||||||
|
SB_FIRST_WEAPON_BIT = 1 << 0,
|
||||||
|
|
||||||
|
SB_WEAPONMASK_BITS = (15u * SB_FIRST_WEAPON_BIT), // Weapons take up 4 bits
|
||||||
|
|
||||||
|
SB_INTERFACE_BITS = (SB_WEAPONMASK_BITS)
|
||||||
|
};
|
||||||
|
|
||||||
|
// enforce type safe operations on the input bits.
|
||||||
|
using ESyncBits = TFlags<ESyncBits_, uint32_t>;
|
||||||
|
DEFINE_TFLAGS_OPERATORS(ESyncBits)
|
||||||
|
|
||||||
|
|
||||||
// Blood flags
|
// Blood flags
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -13,7 +27,7 @@ enum
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum ESyncBits_ : uint32_t
|
enum EDukeSyncBits_ : uint32_t
|
||||||
{
|
{
|
||||||
SKB_JUMP = 1 << 0,
|
SKB_JUMP = 1 << 0,
|
||||||
SKB_CROUCH = 1 << 1,
|
SKB_CROUCH = 1 << 1,
|
||||||
|
@ -45,8 +59,7 @@ enum ESyncBits_ : uint32_t
|
||||||
SKB_INVENTORY = 1 << 30,
|
SKB_INVENTORY = 1 << 30,
|
||||||
SKB_ESCAPE = 1u << 31,
|
SKB_ESCAPE = 1u << 31,
|
||||||
|
|
||||||
SKB_WEAPONMASK_BITS = (15u * SKB_FIRST_WEAPON_BIT),
|
SKB_INTERFACE_BITS = (SKB_STEROIDS | SKB_NIGHTVISION | SKB_MEDKIT | SKB_QUICK_KICK | \
|
||||||
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_HOLSTER | SKB_INV_LEFT | SKB_PAUSE | SKB_HOLODUKE | SKB_JETPACK | SKB_INV_RIGHT | \
|
||||||
SKB_TURNAROUND | SKB_OPEN | SKB_INVENTORY | SKB_ESCAPE),
|
SKB_TURNAROUND | SKB_OPEN | SKB_INVENTORY | SKB_ESCAPE),
|
||||||
|
|
||||||
|
@ -56,7 +69,7 @@ enum ESyncBits_ : uint32_t
|
||||||
};
|
};
|
||||||
|
|
||||||
// enforce type safe operations on the input bits.
|
// enforce type safe operations on the input bits.
|
||||||
using EDukeSyncBits = TFlags<ESyncBits_, uint32_t>;
|
using EDukeSyncBits = TFlags<EDukeSyncBits_, uint32_t>;
|
||||||
DEFINE_TFLAGS_OPERATORS(EDukeSyncBits)
|
DEFINE_TFLAGS_OPERATORS(EDukeSyncBits)
|
||||||
|
|
||||||
union SYNCFLAGS
|
union SYNCFLAGS
|
||||||
|
@ -175,6 +188,7 @@ struct InputPacket
|
||||||
fix16_t q16horz;
|
fix16_t q16horz;
|
||||||
fix16_t q16aimvel; // only used by SW
|
fix16_t q16aimvel; // only used by SW
|
||||||
fix16_t q16ang; // only used by SW
|
fix16_t q16ang; // only used by SW
|
||||||
|
ESyncBits actions;
|
||||||
|
|
||||||
// Making this a union lets some constructs fail. Since these names are transitional only the added memory use doesn't really matter.
|
// Making this a union lets some constructs fail. Since these names are transitional only the added memory use doesn't really matter.
|
||||||
// for Duke
|
// for Duke
|
||||||
|
@ -188,4 +202,14 @@ struct InputPacket
|
||||||
|
|
||||||
// For Exhumed
|
// For Exhumed
|
||||||
uint16_t buttons;
|
uint16_t buttons;
|
||||||
|
|
||||||
|
int getNewWeapon() const
|
||||||
|
{
|
||||||
|
return (actions & SB_WEAPONMASK_BITS).GetValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetNewWeapon(int weap)
|
||||||
|
{
|
||||||
|
actions = (actions & ~SB_WEAPONMASK_BITS) | (ESyncBits::FromInt(weap) & SB_WEAPONMASK_BITS);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -136,6 +136,16 @@ inline EDukeSyncBits PlayerInputBits(int pl, EDukeSyncBits bits)
|
||||||
return (sync[pl].sbits & bits);
|
return (sync[pl].sbits & bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline ESyncBits PlayerInputBits(int pl, ESyncBits bits)
|
||||||
|
{
|
||||||
|
return (sync[pl].actions & bits);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int PlayerNewWeapon(int pl)
|
||||||
|
{
|
||||||
|
return sync[pl].getNewWeapon();
|
||||||
|
}
|
||||||
|
|
||||||
inline int PlayerInputSideVel(int pl)
|
inline int PlayerInputSideVel(int pl)
|
||||||
{
|
{
|
||||||
return sync[pl].svel;
|
return sync[pl].svel;
|
||||||
|
|
|
@ -195,7 +195,7 @@ void hud_input(int snum)
|
||||||
}
|
}
|
||||||
if (!PlayerInput(snum, SKB_QUICK_KICK)) p->quick_kick_msg = false;
|
if (!PlayerInput(snum, SKB_QUICK_KICK)) p->quick_kick_msg = false;
|
||||||
|
|
||||||
if (!PlayerInputBits(snum, SKB_INTERFACE_BITS))
|
if (!PlayerInputBits(snum, SKB_INTERFACE_BITS) && ! PlayerInputBits(snum, SB_INTERFACE_BITS))
|
||||||
p->interface_toggle_flag = 0;
|
p->interface_toggle_flag = 0;
|
||||||
else if (p->interface_toggle_flag == 0)
|
else if (p->interface_toggle_flag == 0)
|
||||||
{
|
{
|
||||||
|
@ -339,7 +339,7 @@ void hud_input(int snum)
|
||||||
if (dainv >= 1 && dainv < 8) FTA(invquotes[dainv - 1], p);
|
if (dainv >= 1 && dainv < 8) FTA(invquotes[dainv - 1], p);
|
||||||
}
|
}
|
||||||
|
|
||||||
j = (PlayerInputBits(snum, SKB_WEAPONMASK_BITS) / SKB_FIRST_WEAPON_BIT) - 1;
|
j = PlayerNewWeapon(snum) - 1;
|
||||||
if (j >= 0)
|
if (j >= 0)
|
||||||
{
|
{
|
||||||
int a = 0;
|
int a = 0;
|
||||||
|
@ -664,8 +664,8 @@ static void processInputBits(player_struct *p, ControlInfo &info)
|
||||||
if (buttonMap.ButtonDown(gamefunc_Dpad_Select) && info.dz > 0) j = 11;
|
if (buttonMap.ButtonDown(gamefunc_Dpad_Select) && info.dz > 0) j = 11;
|
||||||
if (buttonMap.ButtonDown(gamefunc_Dpad_Select) && info.dz < 0) j = 12;
|
if (buttonMap.ButtonDown(gamefunc_Dpad_Select) && info.dz < 0) j = 12;
|
||||||
|
|
||||||
if (j && (loc.sbits & SKB_WEAPONMASK_BITS) == 0)
|
if (j && (loc.actions & SB_WEAPONMASK_BITS) == 0)
|
||||||
loc.sbits |= EDukeSyncBits::FromInt(j * SKB_FIRST_WEAPON_BIT);
|
loc.SetNewWeapon(j);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue