- Duke: Clean up player/actor accesses in ifhitbyweapon_r().

This commit is contained in:
Mitchell Richters 2023-10-02 21:24:05 +11:00
parent 8584745ce4
commit 6c72a2a1fa

View file

@ -160,7 +160,6 @@ void lotsoffeathers_r(DDukeActor *actor, int n)
int ifhitbyweapon_r(DDukeActor *actor)
{
int p;
auto hitowner = actor->GetHitOwner();
if (actor->hitextra >= 0)
@ -172,7 +171,7 @@ int ifhitbyweapon_r(DDukeActor *actor)
{
if (ud.god) return -1;
p = actor->PlayerIndex();
const auto p = getPlayer(actor->PlayerIndex());
if (hitowner &&
hitowner->isPlayer() &&
@ -187,24 +186,23 @@ int ifhitbyweapon_r(DDukeActor *actor)
if (actor->spr.extra <= 0 && !(adef->flags2 & SFLAG2_FREEZEDAMAGE))
{
actor->spr.extra = 0;
p->wackedbyactor = hitowner;
getPlayer(p)->wackedbyactor = hitowner;
if (hitowner->isPlayer() && p != hitowner->PlayerIndex())
if (hitowner->isPlayer() && p != getPlayer(hitowner->PlayerIndex()))
{
getPlayer(p)->frag_ps = hitowner->PlayerIndex();
p->frag_ps = hitowner->PlayerIndex();
}
actor->SetHitOwner(getPlayer(p)->GetActor());
actor->SetHitOwner(actor);
}
}
if (adef->flags2 & SFLAG2_DOUBLEDMGTHRUST)
{
getPlayer(p)->vel.XY() += actor->hitang.ToVector() * actor->hitextra * 0.25;
p->vel.XY() += actor->hitang.ToVector() * actor->hitextra * 0.25;
}
else
{
getPlayer(p)->vel.XY() += actor->hitang.ToVector() * actor->hitextra * 0.125;
p->vel.XY() += actor->hitang.ToVector() * actor->hitextra * 0.125;
}
}
else