mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 00:42:08 +00:00
- Duke: Clean up player accesses in weapons code.
This commit is contained in:
parent
2d6930fddc
commit
02f8ac3bb3
7 changed files with 56 additions and 57 deletions
|
@ -132,10 +132,10 @@ void RestoreMinAmmo(int nPlayer);
|
|||
void FillWeapons(int nPlayer);
|
||||
void ResetPlayerWeapons(int nPlayer);
|
||||
void InitWeapons();
|
||||
void SetNewWeapon(int nPlayer, int nWeapon);
|
||||
void SetNewWeaponImmediate(int nPlayer, int nWeapon);
|
||||
void SetNewWeaponIfBetter(int nPlayer, int nWeapon);
|
||||
void SelectNewWeapon(int nPlayer);
|
||||
void SetNewWeapon(DExhumedPlayer* const pPlayer, int nWeapon);
|
||||
void SetNewWeaponImmediate(DExhumedPlayer* const pPlayer, int nWeapon);
|
||||
void SetNewWeaponIfBetter(DExhumedPlayer* const pPlayer, int nWeapon);
|
||||
void SelectNewWeapon(DExhumedPlayer* const pPlayer);
|
||||
void CheckClip(int nPlayer);
|
||||
void MoveWeapons(int nPlayer);
|
||||
void DrawWeapons(DExhumedPlayer* const pPlayer, double interpfrac);
|
||||
|
|
|
@ -448,11 +448,11 @@ MOVEEND:
|
|||
HITSPRITE:
|
||||
if (pActor->spr.pal == 5 && hitactor->spr.statnum == 100)
|
||||
{
|
||||
int nPlayer = GetPlayerFromActor(hitactor);
|
||||
if (!getPlayer(nPlayer)->bIsMummified)
|
||||
const auto pPlayer = getPlayer(GetPlayerFromActor(hitactor));
|
||||
if (!pPlayer->bIsMummified)
|
||||
{
|
||||
getPlayer(nPlayer)->bIsMummified = true;
|
||||
SetNewWeapon(nPlayer, kWeaponMummified);
|
||||
pPlayer->bIsMummified = true;
|
||||
SetNewWeapon(pPlayer, kWeaponMummified);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -267,23 +267,23 @@ void AIGrenade::Tick(RunListEvent* ev)
|
|||
pActor->nIndex2--;
|
||||
if (!pActor->nIndex2)
|
||||
{
|
||||
int nPlayer = pActor->spr.intowner;
|
||||
const auto pPlayer = getPlayer(pActor->spr.intowner);
|
||||
|
||||
if (pActor->nTurn < 0)
|
||||
{
|
||||
getPlayer(nPlayer)->nState = 0;
|
||||
getPlayer(nPlayer)->nWeapFrame = 0;
|
||||
pPlayer->nState = 0;
|
||||
pPlayer->nWeapFrame = 0;
|
||||
|
||||
if (getPlayer(nPlayer)->nAmmo[kWeaponGrenade])
|
||||
if (pPlayer->nAmmo[kWeaponGrenade])
|
||||
{
|
||||
getPlayer(nPlayer)->bIsFiring = false;
|
||||
pPlayer->bIsFiring = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectNewWeapon(nPlayer);
|
||||
SelectNewWeapon(pPlayer);
|
||||
|
||||
getPlayer(nPlayer)->nCurrentWeapon = getPlayer(nPlayer)->nNextWeapon;
|
||||
getPlayer(nPlayer)->nNextWeapon = -1;
|
||||
pPlayer->nCurrentWeapon = pPlayer->nNextWeapon;
|
||||
pPlayer->nNextWeapon = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,37 +141,37 @@ void InitWeapons()
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void SetNewWeapon(int nPlayer, int nWeapon)
|
||||
void SetNewWeapon(DExhumedPlayer* const pPlayer, int nWeapon)
|
||||
{
|
||||
if (nWeapon == kWeaponMummified)
|
||||
{
|
||||
getPlayer(nPlayer)->nLastWeapon = getPlayer(nPlayer)->nCurrentWeapon;
|
||||
getPlayer(nPlayer)->bIsFiring = false;
|
||||
getPlayer(nPlayer)->nState = 5;
|
||||
SetPlayerMummified(nPlayer, true);
|
||||
pPlayer->nLastWeapon = pPlayer->nCurrentWeapon;
|
||||
pPlayer->bIsFiring = false;
|
||||
pPlayer->nState = 5;
|
||||
SetPlayerMummified(pPlayer, true);
|
||||
|
||||
getPlayer(nPlayer)->nWeapFrame = 0;
|
||||
pPlayer->nWeapFrame = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nWeapon < 0)
|
||||
{
|
||||
getPlayer(nPlayer)->nPlayerOldWeapon = getPlayer(nPlayer)->nCurrentWeapon;
|
||||
pPlayer->nPlayerOldWeapon = pPlayer->nCurrentWeapon;
|
||||
}
|
||||
else if (nWeapon != kWeaponGrenade || getPlayer(nPlayer)->nAmmo[kWeaponGrenade] > 0)
|
||||
else if (nWeapon != kWeaponGrenade || pPlayer->nAmmo[kWeaponGrenade] > 0)
|
||||
{
|
||||
int nCurrentWeapon = getPlayer(nPlayer)->nCurrentWeapon;
|
||||
int nCurrentWeapon = pPlayer->nCurrentWeapon;
|
||||
|
||||
if (nCurrentWeapon != kWeaponMummified)
|
||||
{
|
||||
if (getPlayer(nPlayer)->bIsFiring || nWeapon == nCurrentWeapon) {
|
||||
if (pPlayer->bIsFiring || nWeapon == nCurrentWeapon) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
getPlayer(nPlayer)->nCurrentWeapon = nWeapon;
|
||||
getPlayer(nPlayer)->nWeapFrame = 0;
|
||||
pPlayer->nCurrentWeapon = nWeapon;
|
||||
pPlayer->nWeapFrame = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -179,7 +179,7 @@ void SetNewWeapon(int nPlayer, int nWeapon)
|
|||
}
|
||||
}
|
||||
|
||||
getPlayer(nPlayer)->nNextWeapon = nWeapon;
|
||||
pPlayer->nNextWeapon = nWeapon;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -188,20 +188,20 @@ void SetNewWeapon(int nPlayer, int nWeapon)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void SetNewWeaponImmediate(int nPlayer, int nWeapon)
|
||||
void SetNewWeaponImmediate(DExhumedPlayer* const pPlayer, int nWeapon)
|
||||
{
|
||||
SetNewWeapon(nPlayer, nWeapon);
|
||||
SetNewWeapon(pPlayer, nWeapon);
|
||||
|
||||
getPlayer(nPlayer)->nCurrentWeapon = nWeapon;
|
||||
getPlayer(nPlayer)->nNextWeapon = -1;
|
||||
getPlayer(nPlayer)->nWeapFrame = 0;
|
||||
getPlayer(nPlayer)->nState = 0;
|
||||
pPlayer->nCurrentWeapon = nWeapon;
|
||||
pPlayer->nNextWeapon = -1;
|
||||
pPlayer->nWeapFrame = 0;
|
||||
pPlayer->nState = 0;
|
||||
}
|
||||
|
||||
void SetNewWeaponIfBetter(int nPlayer, int nWeapon)
|
||||
void SetNewWeaponIfBetter(DExhumedPlayer* const pPlayer, int nWeapon)
|
||||
{
|
||||
if (nWeapon > getPlayer(nPlayer)->nCurrentWeapon) {
|
||||
SetNewWeapon(nPlayer, nWeapon);
|
||||
if (nWeapon > pPlayer->nCurrentWeapon) {
|
||||
SetNewWeapon(pPlayer, nWeapon);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,11 +211,11 @@ void SetNewWeaponIfBetter(int nPlayer, int nWeapon)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void SelectNewWeapon(int nPlayer)
|
||||
void SelectNewWeapon(DExhumedPlayer* const pPlayer)
|
||||
{
|
||||
int nWeapon = kWeaponRing; // start at the highest weapon number
|
||||
|
||||
uint16_t di = getPlayer(nPlayer)->nPlayerWeapons;
|
||||
uint16_t di = pPlayer->nPlayerWeapons;
|
||||
uint16_t dx = 0x40; // bit 7 turned on
|
||||
|
||||
while (dx)
|
||||
|
@ -223,7 +223,7 @@ void SelectNewWeapon(int nPlayer)
|
|||
if (di & dx)
|
||||
{
|
||||
// we have this weapon
|
||||
if (!WeaponInfo[nWeapon].d || getPlayer(nPlayer)->nAmmo[WeaponInfo[nWeapon].nAmmoType])
|
||||
if (!WeaponInfo[nWeapon].d || pPlayer->nAmmo[WeaponInfo[nWeapon].nAmmoType])
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -234,9 +234,9 @@ void SelectNewWeapon(int nPlayer)
|
|||
if (nWeapon < 0)
|
||||
nWeapon = kWeaponSword;
|
||||
|
||||
getPlayer(nPlayer)->bIsFiring = false;
|
||||
pPlayer->bIsFiring = false;
|
||||
|
||||
SetNewWeapon(nPlayer, nWeapon);
|
||||
SetNewWeapon(pPlayer, nWeapon);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -480,7 +480,7 @@ void MoveWeapons(int nPlayer)
|
|||
|
||||
nWeapon = pPlayer->nCurrentWeapon;
|
||||
|
||||
SetPlayerMummified(nPlayer, false);
|
||||
SetPlayerMummified(pPlayer, false);
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
@ -542,7 +542,7 @@ void MoveWeapons(int nPlayer)
|
|||
}
|
||||
else
|
||||
{
|
||||
SelectNewWeapon(nPlayer);
|
||||
SelectNewWeapon(pPlayer);
|
||||
}
|
||||
|
||||
Ra[nPlayer].nState = 0;
|
||||
|
@ -563,7 +563,7 @@ void MoveWeapons(int nPlayer)
|
|||
}
|
||||
else
|
||||
{
|
||||
SelectNewWeapon(nPlayer);
|
||||
SelectNewWeapon(pPlayer);
|
||||
pPlayer->nState = 5;
|
||||
|
||||
pPlayer->nWeapFrame = getSequence(nSeqFile, WeaponInfo[kWeaponGrenade].b[0])->frames.Size() - 1; // CHECKME
|
||||
|
@ -888,7 +888,7 @@ loc_flag:
|
|||
}
|
||||
else if (nWeapon != kWeaponGrenade)
|
||||
{
|
||||
SelectNewWeapon(nPlayer);
|
||||
SelectNewWeapon(pPlayer);
|
||||
// go to loc_27609:
|
||||
}
|
||||
}
|
||||
|
|
|
@ -399,7 +399,7 @@ void StartDeathSeq(int nPlayer, int nVal)
|
|||
pPlayerActor->oviewzoffset = pPlayerActor->viewzoffset = -55;
|
||||
pPlayerActor->spr.cstat &= ~(CSTAT_SPRITE_INVISIBLE|CSTAT_SPRITE_BLOCK_ALL);
|
||||
|
||||
SetNewWeaponImmediate(nPlayer, -2);
|
||||
SetNewWeaponImmediate(pPlayer, -2);
|
||||
|
||||
if (nTotalPlayers == 1)
|
||||
{
|
||||
|
@ -443,9 +443,8 @@ int AddAmmo(int nPlayer, int nWeapon, int nAmmoAmount)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void SetPlayerMummified(int nPlayer, int bIsMummified)
|
||||
void SetPlayerMummified(DExhumedPlayer* const pPlayer, int bIsMummified)
|
||||
{
|
||||
const auto pPlayer = getPlayer(nPlayer);
|
||||
const auto pPlayerActor = pPlayer->GetActor();
|
||||
|
||||
pPlayerActor->vel.XY().Zero();
|
||||
|
@ -757,7 +756,7 @@ static void doPickupWeapon(DExhumedPlayer* pPlayer, DExhumedActor* pPickupActor,
|
|||
}
|
||||
else
|
||||
{
|
||||
SetNewWeaponIfBetter(pPlayer->pnum, nWeapon);
|
||||
SetNewWeaponIfBetter(pPlayer, nWeapon);
|
||||
pPlayer->nPlayerWeapons |= weapFlag;
|
||||
AddAmmo(pPlayer->pnum, WeaponInfo[nWeapon].nAmmoType, nAmount);
|
||||
}
|
||||
|
@ -865,7 +864,7 @@ void doPlayerItemPickups(DExhumedPlayer* const pPlayer)
|
|||
if (!(pPlayer->nPlayerWeapons & 0x10))
|
||||
{
|
||||
pPlayer->nPlayerWeapons |= 0x10;
|
||||
SetNewWeaponIfBetter(pPlayer->pnum, 4);
|
||||
SetNewWeaponIfBetter(pPlayer, 4);
|
||||
}
|
||||
|
||||
if (nItem == 55)
|
||||
|
@ -1195,7 +1194,7 @@ static void updatePlayerWeapon(DExhumedPlayer* const pPlayer)
|
|||
}
|
||||
while (nextWeap && (!haveWeap || (haveWeap && !pPlayer->nAmmo[nextWeap])));
|
||||
|
||||
SetNewWeapon(pPlayer->pnum, nextWeap);
|
||||
SetNewWeapon(pPlayer, nextWeap);
|
||||
}
|
||||
else if (newWeap == WeaponSel_Alt)
|
||||
{
|
||||
|
@ -1203,7 +1202,7 @@ static void updatePlayerWeapon(DExhumedPlayer* const pPlayer)
|
|||
}
|
||||
else if (pPlayer->nPlayerWeapons & (1 << (newWeap - 1)))
|
||||
{
|
||||
SetNewWeapon(pPlayer->pnum, newWeap - 1);
|
||||
SetNewWeapon(pPlayer, newWeap - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2031,7 +2030,7 @@ static void doPlayerDeathPitch(DExhumedPlayer* const pPlayer)
|
|||
}
|
||||
else if (pPlayerActor->spr.Angles.Pitch.Sgn() >= 0 && !(pPlayerActor->sector()->Flag & kSectUnderwater))
|
||||
{
|
||||
SetNewWeapon(pPlayer->pnum, pPlayer->nDeathType + 8);
|
||||
SetNewWeapon(pPlayer, pPlayer->nDeathType + 8);
|
||||
}
|
||||
|
||||
pPlayer->dVertPan--;
|
||||
|
|
|
@ -139,7 +139,7 @@ extern int nNetStartSprites;
|
|||
extern int nCurStartSprite;
|
||||
|
||||
int GetPlayerFromActor(DExhumedActor* actor);
|
||||
void SetPlayerMummified(int nPlayer, int bIsMummified);
|
||||
void SetPlayerMummified(DExhumedPlayer* const pPlayer, int bIsMummified);
|
||||
int AddAmmo(int nPlayer, int nWeapon, int nAmmoAmount);
|
||||
void ShootStaff(int nPlayer);
|
||||
void updatePlayerTarget(DExhumedPlayer* const pPlayer);
|
||||
|
|
|
@ -305,7 +305,7 @@ void AIRa::Tick(RunListEvent* ev)
|
|||
{
|
||||
Ra[nPlayer].nAction = 3;
|
||||
Ra[nPlayer].nFrame = 0;
|
||||
SelectNewWeapon(nPlayer);
|
||||
SelectNewWeapon(getPlayer(nPlayer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue