- Exhumed: Clean up player accesses in grenade code.

This commit is contained in:
Mitchell Richters 2023-10-04 13:27:22 +11:00
parent 0411598ee0
commit 27a41121ec
4 changed files with 28 additions and 29 deletions

View file

@ -96,7 +96,7 @@ void FuncFishLimb(int a, int b, int c);
enum { kMaxGrenades = 50 };
void BuildGrenade(int nPlayer);
void BuildGrenade(DExhumedPlayer* const pPlayer);
void ThrowGrenade(int nPlayer, double ecx, double push1);
void FuncGrenade(int, int, int, int);

View file

@ -63,17 +63,17 @@ void BounceGrenade(DExhumedActor* pActor, DAngle nAngle)
//
//---------------------------------------------------------------------------
void ThrowGrenade(int nPlayer, double dz, double push1)
void ThrowGrenade(DExhumedPlayer* const pPlayer, double dz, double push1)
{
if (getPlayer(nPlayer)->pPlayerGrenade == nullptr)
if (pPlayer->pPlayerGrenade == nullptr)
return;
DExhumedActor* pActor = getPlayer(nPlayer)->pPlayerGrenade;
auto pPlayerActor = getPlayer(nPlayer)->GetActor();
DExhumedActor* pActor = pPlayer->pPlayerGrenade;
auto pPlayerActor = pPlayer->GetActor();
DAngle nAngle = pPlayerActor->spr.Angles.Yaw;
ChangeActorSect(pActor, getPlayer(nPlayer)->pPlayerViewSect);
ChangeActorSect(pActor, pPlayer->pPlayerViewSect);
pActor->spr.pos = pPlayerActor->spr.pos;
@ -86,7 +86,7 @@ void ThrowGrenade(int nPlayer, double dz, double push1)
if (push1 <= 23.4375)
{
int nVel = (int)(getPlayer(nPlayer)->totalvel * 512.);
int nVel = (int)(pPlayer->totalvel * 512.);
pActor->nTurn = ((90 - pActor->nIndex2) * (90 - pActor->nIndex2)) + nVel;
pActor->vel.Z = ((32. * push1) - 17);
@ -108,7 +108,7 @@ void ThrowGrenade(int nPlayer, double dz, double push1)
pActor->vec = nAngle.ToVector() * pActor->nTurn / 256;
getPlayer(nPlayer)->pPlayerGrenade = nullptr;
pPlayer->pPlayerGrenade = nullptr;
return;
}
@ -119,11 +119,11 @@ void ThrowGrenade(int nPlayer, double dz, double push1)
//
//---------------------------------------------------------------------------
void BuildGrenade(int nPlayer)
void BuildGrenade(DExhumedPlayer* const pPlayer)
{
auto pActor = insertActor(getPlayer(nPlayer)->pPlayerViewSect, 201);
auto pActor = insertActor(pPlayer->pPlayerViewSect, 201);
auto pPlayerActor = getPlayer(nPlayer)->GetActor();
auto pPlayerActor = pPlayer->GetActor();
pActor->spr.pos = pPlayerActor->spr.pos.plusZ(-15);
pActor->spr.shade = -64;
@ -135,7 +135,7 @@ void BuildGrenade(int nPlayer)
pActor->spr.xoffset = 0;
pActor->spr.yoffset = 0;
pActor->spr.Angles.Yaw = pPlayerActor->spr.Angles.Yaw;
pActor->spr.intowner = nPlayer;
pActor->spr.intowner = pPlayer->pnum;
pActor->vel.X = 0;
pActor->vel.Y = 0;
pActor->vel.Z = 0;
@ -155,7 +155,7 @@ void BuildGrenade(int nPlayer)
pActor->nPhase = runlist_AddRunRec(pActor->spr.lotag - 1, pActor, 0x0F0000);
pActor->nRun = runlist_AddRunRec(NewRun, pActor, 0x0F0000);
getPlayer(nPlayer)->pPlayerGrenade = pActor;
pPlayer->pPlayerGrenade = pActor;
}
//---------------------------------------------------------------------------
@ -169,7 +169,7 @@ void ExplodeGrenade(DExhumedActor* pActor)
FName animFile;
double scale;
int nPlayer = pActor->spr.intowner;
const auto pPlayer = getPlayer(pActor->spr.intowner);
auto pGrenadeSect = pActor->sector();
pActor->nFrame = 1;
@ -199,7 +199,7 @@ void ExplodeGrenade(DExhumedActor* pActor)
if (pActor->nTurn < 0)
{
auto pPlayerActor = getPlayer(nPlayer)->GetActor();
auto pPlayerActor = pPlayer->GetActor();
auto nAngle = pPlayerActor->spr.Angles.Yaw;
DVector2 vect = nAngle.ToVector() * 32;
@ -207,14 +207,14 @@ void ExplodeGrenade(DExhumedActor* pActor)
ChangeActorSect(pActor, pPlayerActor->sector());
if (!getPlayer(nPlayer)->invincibility) {
getPlayer(nPlayer)->nHealth = 1;
if (!pPlayer->invincibility) {
pPlayer->nHealth = 1;
}
}
int nDamage = BulletInfo[kWeaponGrenade].nDamage;
if (getPlayer(nPlayer)->nDouble > 0) {
if (pPlayer->nDouble > 0) {
nDamage *= 2;
}

View file

@ -435,7 +435,7 @@ void MoveWeapons(int nPlayer)
if (nWeapon == kWeaponGrenade)
{
BuildGrenade(nPlayer);
BuildGrenade(pPlayer);
AddAmmo(pPlayer, 4, -1);
}
else if (nWeapon == kWeaponMummified)
@ -834,7 +834,7 @@ loc_flag:
case kWeaponGrenade:
{
ThrowGrenade(nPlayer, nHeight - 10, pPlayerActor->spr.Angles.Pitch.Tan());
ThrowGrenade(pPlayer, nHeight - 10, pPlayerActor->spr.Angles.Pitch.Tan());
break;
}
case kWeaponStaff:

View file

@ -349,24 +349,23 @@ int GrabPlayer()
//
//---------------------------------------------------------------------------
void StartDeathSeq(int nPlayer, int nVal)
static void StartDeathSeq(DExhumedPlayer* const pPlayer, int nVal)
{
const auto pPlayer = getPlayer(nPlayer);
const auto pPlayerActor = pPlayer->GetActor();
const auto pPlayerSect = pPlayerActor->sector();
FreeRa(nPlayer);
FreeRa(pPlayer->pnum);
pPlayer->nHealth = 0;
if (pPlayerSect->lotag > 0)
{
runlist_SignalRun(pPlayerSect->lotag - 1, nPlayer, &ExhumedAI::EnterSector);
runlist_SignalRun(pPlayerSect->lotag - 1, pPlayer->pnum, &ExhumedAI::EnterSector);
}
if (pPlayer->pPlayerGrenade)
{
ThrowGrenade(nPlayer, 0, -10000);
ThrowGrenade(pPlayer, 0, -10000);
}
else
{
@ -635,11 +634,11 @@ void AIPlayer::Damage(RunListEvent* ev)
BuildCreatureChunk(pPlayerActor, joeSeqs->Data(i)->getFirstFrameTexture());
}
StartDeathSeq(nPlayer, 1);
StartDeathSeq(pPlayer, 1);
}
else
{
StartDeathSeq(nPlayer, 0);
StartDeathSeq(pPlayer, 0);
}
}
}
@ -799,7 +798,7 @@ static void doPickupHealth(DExhumedPlayer* pPlayer, DExhumedActor* pPickupActor,
else if (pPlayer->nHealth < 0)
{
nSound = -1;
StartDeathSeq(pPlayer->pnum, 0);
StartDeathSeq(pPlayer, 0);
}
}
@ -1457,7 +1456,7 @@ static void doPlayerUnderwater(DExhumedPlayer* const pPlayer, const bool oUnderw
if (pPlayer->nHealth <= 0)
{
pPlayer->nHealth = 0;
StartDeathSeq(pPlayer->pnum, 0);
StartDeathSeq(pPlayer, 0);
}
pPlayer->nAir = 0;