- Exhumed: Clean up player accesses in AddAmmo().

This commit is contained in:
Mitchell Richters 2023-10-04 12:46:23 +11:00 committed by Christoph Oelckers
parent d4b0cb14b4
commit ad5f1d9f7d
4 changed files with 10 additions and 12 deletions

View file

@ -436,7 +436,7 @@ void MoveWeapons(int nPlayer)
if (nWeapon == kWeaponGrenade)
{
BuildGrenade(nPlayer);
AddAmmo(nPlayer, 4, -1);
AddAmmo(pPlayer, 4, -1);
}
else if (nWeapon == kWeaponMummified)
{
@ -866,7 +866,7 @@ loc_flag:
if (nWeapon != kWeaponGrenade)
{
if (WeaponInfo[nWeapon].d) {
AddAmmo(nPlayer, nAmmoType, -1);
AddAmmo(pPlayer, nAmmoType, -1);
}
if (nWeapon == kWeaponM60) {

View file

@ -417,10 +417,8 @@ void StartDeathSeq(int nPlayer, int nVal)
//
//---------------------------------------------------------------------------
int AddAmmo(int nPlayer, int nWeapon, int nAmmoAmount)
int AddAmmo(DExhumedPlayer* const pPlayer, int nWeapon, int nAmmoAmount)
{
const auto pPlayer = getPlayer(nPlayer);
if (!nAmmoAmount)
nAmmoAmount = 1;
@ -752,13 +750,13 @@ static void doPickupWeapon(DExhumedPlayer* pPlayer, DExhumedActor* pPickupActor,
if (pPlayer->nPlayerWeapons & weapFlag)
{
if (currentLevel->gameflags & LEVEL_EX_MULTI)
AddAmmo(pPlayer->pnum, WeaponInfo[nWeapon].nAmmoType, nAmount);
AddAmmo(pPlayer, WeaponInfo[nWeapon].nAmmoType, nAmount);
}
else
{
SetNewWeaponIfBetter(pPlayer, nWeapon);
pPlayer->nPlayerWeapons |= weapFlag;
AddAmmo(pPlayer->pnum, WeaponInfo[nWeapon].nAmmoType, nAmount);
AddAmmo(pPlayer, WeaponInfo[nWeapon].nAmmoType, nAmount);
}
if (nWeapon == 2)
@ -848,7 +846,7 @@ void doPlayerItemPickups(DExhumedPlayer* const pPlayer)
case 6: // Speed Loader
case 7: // Fuel Canister
case 8: // M - 60 Ammo Belt
if (AddAmmo(pPlayer->pnum, ammoArray[nItem - 6], pPickupActor->spr.hitag))
if (AddAmmo(pPlayer, ammoArray[nItem - 6], pPickupActor->spr.hitag))
{
if (nItem == 8) CheckClip(pPlayer->pnum);
doPickupDestroy(pPickupActor, nItem);
@ -859,7 +857,7 @@ void doPlayerItemPickups(DExhumedPlayer* const pPlayer)
case 9: // Grenade
case 27: // May not be grenade, needs confirmation
case 55:
if (AddAmmo(pPlayer->pnum, 4, 1))
if (AddAmmo(pPlayer, 4, 1))
{
if (!(pPlayer->nPlayerWeapons & 0x10))
{
@ -969,7 +967,7 @@ void doPlayerItemPickups(DExhumedPlayer* const pPlayer)
case 37: // Cobra staff ammo
case 38: // Raw Energy
if (AddAmmo(pPlayer->pnum, nItem - 32, (nItem == 38) ? pPickupActor->spr.hitag : 1))
if (AddAmmo(pPlayer, nItem - 32, (nItem == 38) ? pPickupActor->spr.hitag : 1))
{
doPickupDestroy(pPickupActor, nItem);
doPickupNotification(pPlayer, nItem, StaticSound[kSoundAmmoPickup]);

View file

@ -140,7 +140,7 @@ extern int nCurStartSprite;
int GetPlayerFromActor(DExhumedActor* actor);
void SetPlayerMummified(DExhumedPlayer* const pPlayer, int bIsMummified);
int AddAmmo(int nPlayer, int nWeapon, int nAmmoAmount);
int AddAmmo(DExhumedPlayer* const pPlayer, int nWeapon, int nAmmoAmount);
void ShootStaff(int nPlayer);
void updatePlayerTarget(DExhumedPlayer* const pPlayer);

View file

@ -299,7 +299,7 @@ void AIRa::Tick(RunListEvent* ev)
if (pPlayer->nAmmo[kWeaponRing] > 0)
{
runlist_DamageEnemy(pRa->pTarget, getPlayer(pRa->nPlayer)->GetActor(), BulletInfo[kWeaponRing].nDamage);
AddAmmo(pPlayer->pnum, kWeaponRing, -WeaponInfo[kWeaponRing].d);
AddAmmo(pPlayer, kWeaponRing, -WeaponInfo[kWeaponRing].d);
SetQuake(pActor, 100);
}
else