Skip to content

Commit

Permalink
- use isPlayer function where possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Nov 26, 2022
1 parent e4ef3b6 commit 3a91155
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 69 deletions.
38 changes: 19 additions & 19 deletions source/games/duke/src/actors_d.cpp
Expand Up @@ -179,7 +179,7 @@ bool ifsquished(DDukeActor* actor, int p)
if (isRR()) return false; // this function is a no-op in RR's source.

bool squishme = false;
if (actor->spr.picnum == APLAYER && ud.clipping)
if (actor->isPlayer() && ud.clipping)
return false;

auto sectp = actor->sector();
Expand Down Expand Up @@ -273,7 +273,7 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
{
if (isWorldTour() && Owner)
{
if (Owner->spr.picnum == APLAYER && act2->spr.picnum == APLAYER && ud.coop != 0 && ud.ffire == 0 && Owner != act2)
if (Owner->isPlayer() && act2->isPlayer() && ud.coop != 0 && ud.ffire == 0 && Owner != act2)
{
continue;
}
Expand Down Expand Up @@ -323,7 +323,7 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
{
if (actor->spr.picnum == SHRINKSPARK || actor->spr.picnum == FLAMETHROWERFLAME)
act2-> attackertype = actor->spr.picnum;
else if (actor->spr.picnum != FIREBALL || !Owner || Owner->spr.picnum != APLAYER)
else if (actor->spr.picnum != FIREBALL || !Owner || !Owner->isPlayer())
{
if (actor->spr.picnum == LAVAPOOL)
act2->attackertype = FLAMETHROWERFLAME;
Expand Down Expand Up @@ -365,11 +365,11 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h

if (act2->spr.picnum != RADIUSEXPLOSION && Owner && Owner->spr.statnum < MAXSTATUS)
{
if (act2->spr.picnum == APLAYER)
if (act2->isPlayer())
{
int p = act2->spr.yint;

if (isWorldTour() && act2->attackertype == FLAMETHROWERFLAME && Owner->spr.picnum == APLAYER)
if (isWorldTour() && act2->attackertype == FLAMETHROWERFLAME && Owner->isPlayer())
{
ps[p].numloogs = -1 - actor->spr.yint;
}
Expand Down Expand Up @@ -503,14 +503,14 @@ int ifhitbyweapon_d(DDukeActor *actor)
{
if (actor->spr.extra >= 0)
{
if (actor->spr.picnum == APLAYER)
if (actor->isPlayer())
{
if (ud.god && actor->attackertype != SHRINKSPARK) return -1;

p = actor->PlayerIndex();

if (hitowner &&
hitowner->spr.picnum == APLAYER &&
hitowner->isPlayer() &&
ud.coop == 1 &&
ud.ffire == 0)
return -1;
Expand All @@ -525,7 +525,7 @@ int ifhitbyweapon_d(DDukeActor *actor)

ps[p].wackedbyactor = hitowner;

if (hitowner->spr.picnum == APLAYER && p != hitowner->PlayerIndex())
if (hitowner->isPlayer() && p != hitowner->PlayerIndex())
{
ps[p].frag_ps = hitowner->PlayerIndex();
}
Expand Down Expand Up @@ -570,7 +570,7 @@ int ifhitbyweapon_d(DDukeActor *actor)
|| actor->attackertype != FLAMETHROWERFLAME
|| actor->hitextra >= 0
|| actor->spr.extra > 0
|| actor->spr.picnum != APLAYER
|| !actor->isPlayer()
|| ps[actor->PlayerIndex()].numloogs > 0
|| hitowner == nullptr)
{
Expand All @@ -583,7 +583,7 @@ int ifhitbyweapon_d(DDukeActor *actor)
actor->spr.extra = 0;
ps[p].wackedbyactor = hitowner;

if (hitowner->spr.picnum == APLAYER && hitowner != ps[p].GetActor())
if (hitowner->isPlayer() && hitowner != ps[p].GetActor())
ps[p].frag_ps = hitowner->PlayerIndex(); // set the proper player index here - this previously set the sprite index...

actor->SetHitOwner(ps[p].GetActor());
Expand Down Expand Up @@ -804,7 +804,7 @@ static bool movefireball(DDukeActor* actor)
static bool weaponhitsprite(DDukeActor* proj, DDukeActor *targ, bool fireball)
{
if (proj->spr.picnum == FREEZEBLAST && targ->spr.pal == 1)
if (badguy(targ) || targ->spr.picnum == APLAYER)
if (badguy(targ) || targ->isPlayer())
{
auto spawned = spawn(targ, TRANSPORTERSTAR);
if (spawned)
Expand All @@ -820,12 +820,12 @@ static bool weaponhitsprite(DDukeActor* proj, DDukeActor *targ, bool fireball)
if (!isWorldTour() || proj->spr.picnum != FIREBALL || fireball)
fi.checkhitsprite(targ, proj);

if (targ->spr.picnum == APLAYER)
if (targ->isPlayer())
{
int p = targ->spr.yint;
auto Owner = proj->GetOwner();

if (ud.multimode >= 2 && fireball && Owner && Owner->spr.picnum == APLAYER)
if (ud.multimode >= 2 && fireball && Owner && Owner->isPlayer())
{
ps[p].numloogs = -1 - proj->spr.yint;
}
Expand Down Expand Up @@ -1040,7 +1040,7 @@ static void weaponcommon_d(DDukeActor* proj)
{
if (proj->spr.picnum == COOLEXPLOSION1)
{
if (coll.type == kHitSprite && coll.actor()->spr.picnum != APLAYER)
if (coll.type == kHitSprite && !coll.actor()->isPlayer())
{
return;
}
Expand Down Expand Up @@ -1964,7 +1964,7 @@ static void flamethrowerflame(DDukeActor *actor)
if (coll.type == kHitSprite)
{
fi.checkhitsprite(coll.actor(), actor);
if (coll.actor()->spr.picnum == APLAYER)
if (coll.actor()->isPlayer())
S_PlayActorSound(PISTOL_BODYHIT, coll.actor());
}
else if (coll.type == kHitWall)
Expand Down Expand Up @@ -2078,7 +2078,7 @@ static void heavyhbomb(DDukeActor *actor)
goto DETONATEB;
}

if ( Owner && Owner->spr.picnum == APLAYER)
if ( Owner && Owner->isPlayer())
l = Owner->PlayerIndex();
else l = -1;

Expand Down Expand Up @@ -2180,7 +2180,7 @@ static void heavyhbomb(DDukeActor *actor)
if (ps[p].gotweapon[HANDBOMB_WEAPON] == 0 || Owner == ps[p].GetActor())
fi.addweapon(&ps[p], HANDBOMB_WEAPON, true);

if (!Owner || Owner->spr.picnum != APLAYER)
if (!Owner || !Owner->isPlayer())
{
SetPlayerPal(&ps[p], PalEntry(32, 0, 32, 0));
}
Expand Down Expand Up @@ -2956,7 +2956,7 @@ void move_d(DDukeActor *actor, int playernum, int xvel)
{
if ((badguy(actor) && actor->spr.extra <= 0) || (actor->opos.X != actor->spr.pos.X) || (actor->opos.Y != actor->spr.pos.Y))
{
if (actor->spr.picnum != APLAYER) actor->backupvec2();
if (!actor->isPlayer()) actor->backupvec2();
SetActor(actor, actor->spr.pos);
}
return;
Expand All @@ -2975,7 +2975,7 @@ void move_d(DDukeActor *actor, int playernum, int xvel)
if (a & dodgebullet)
dodge(actor);

if (actor->spr.picnum != APLAYER)
if (!actor->isPlayer())
alterang(a, actor, playernum);

if (abs(actor->vel.X) < 6 / 16.) actor->vel.X = 0;
Expand Down
38 changes: 19 additions & 19 deletions source/games/duke/src/actors_r.cpp
Expand Up @@ -297,7 +297,7 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
if (act2->spr.picnum != RADIUSEXPLOSION &&
Owner && Owner->spr.statnum < MAXSTATUS)
{
if (act2->spr.picnum == APLAYER)
if (act2->isPlayer())
{
int p = act2->PlayerIndex();
if (ps[p].newOwner != nullptr)
Expand Down Expand Up @@ -405,14 +405,14 @@ int ifhitbyweapon_r(DDukeActor *actor)
{
if (actor->spr.extra >= 0)
{
if (actor->spr.picnum == APLAYER)
if (actor->isPlayer())
{
if (ud.god) return -1;

p = actor->PlayerIndex();

if (hitowner &&
hitowner->spr.picnum == APLAYER &&
hitowner->isPlayer() &&
ud.coop == 1 &&
ud.ffire == 0)
return -1;
Expand All @@ -427,7 +427,7 @@ int ifhitbyweapon_r(DDukeActor *actor)

ps[p].wackedbyactor = hitowner;

if (hitowner->spr.picnum == APLAYER && p != hitowner->PlayerIndex())
if (hitowner->isPlayer() && p != hitowner->PlayerIndex())
{
ps[p].frag_ps = hitowner->PlayerIndex();
}
Expand Down Expand Up @@ -678,7 +678,7 @@ static bool weaponhitsprite(DDukeActor *proj, DDukeActor *targ, const DVector3 &
}
}
else if (proj->spr.picnum == FREEZEBLAST && targ->spr.pal == 1)
if (badguy(targ) || targ->spr.picnum == APLAYER)
if (badguy(targ) || targ->isPlayer())
{
auto star = spawn(proj, TRANSPORTERSTAR);
if (star)
Expand All @@ -693,7 +693,7 @@ static bool weaponhitsprite(DDukeActor *proj, DDukeActor *targ, const DVector3 &

fi.checkhitsprite(targ, proj);

if (targ->spr.picnum == APLAYER)
if (targ->isPlayer())
{
int p = targ->PlayerIndex();
S_PlayActorSound(PISTOL_BODYHIT, targ);
Expand Down Expand Up @@ -893,7 +893,7 @@ static void weaponcommon_r(DDukeActor *proj)
chickenarrow(proj);
break;

case RRTILE1790:
case BOATGRENADE:
if (!isRRRA()) break;
if (proj->spr.extra)
{
Expand All @@ -913,7 +913,7 @@ static void weaponcommon_r(DDukeActor *proj)
Collision coll;
movesprite_ex(proj, DVector3(proj->spr.Angles.Yaw.ToVector() * vel, velz), CLIPMASK1, coll);

if ((proj->spr.picnum == RPG || (isRRRA() && isIn(proj->spr.picnum, RPG2, RRTILE1790))) && proj->temp_actor != nullptr)
if ((proj->spr.picnum == RPG || (isRRRA() && isIn(proj->spr.picnum, RPG2, BOATGRENADE))) && proj->temp_actor != nullptr)
if ((proj->spr.pos.XY() - proj->temp_actor->spr.pos.XY()).Length() < 16)
coll.setSprite(proj->temp_actor);

Expand Down Expand Up @@ -977,7 +977,7 @@ static void weaponcommon_r(DDukeActor *proj)
{
if (proj->spr.picnum == RPG) rpgexplode(proj, coll.type, oldpos, EXPLOSION2, -1, -1, RPG_EXPLODE);
else if (isRRRA() && proj->spr.picnum == RPG2) rpgexplode(proj, coll.type, oldpos, EXPLOSION2, -1, 150, 247);
else if (isRRRA() && proj->spr.picnum == RRTILE1790) rpgexplode(proj, coll.type, oldpos, EXPLOSION2, -1, 160, RPG_EXPLODE);
else if (isRRRA() && proj->spr.picnum == BOATGRENADE) rpgexplode(proj, coll.type, oldpos, EXPLOSION2, -1, 160, RPG_EXPLODE);
else if (proj->spr.picnum != FREEZEBLAST && proj->spr.picnum != FIRELASER && proj->spr.picnum != SHRINKSPARK)
{
auto spawned = spawn(proj, 1441);
Expand Down Expand Up @@ -1043,7 +1043,7 @@ void moveweapons_r(void)
}
[[fallthrough]];
case RPG2:
case RRTILE1790:
case BOATGRENADE:
if (!isRRRA()) continue;
[[fallthrough]];
case SHRINKSPARK:
Expand Down Expand Up @@ -1785,7 +1785,7 @@ static void heavyhbomb(DDukeActor *actor)
goto DETONATEB;
}

if (Owner && Owner->spr.picnum == APLAYER)
if (Owner && Owner->isPlayer())
l = Owner->PlayerIndex();
else l = -1;

Expand Down Expand Up @@ -1889,14 +1889,14 @@ static void heavyhbomb(DDukeActor *actor)
if (ps[p].gotweapon[DYNAMITE_WEAPON] == 0 || Owner == ps[p].GetActor())
fi.addweapon(&ps[p], DYNAMITE_WEAPON, true);

if (!Owner || Owner->spr.picnum != APLAYER)
if (!Owner || !Owner->isPlayer())
{
SetPlayerPal(&ps[p], PalEntry(32, 0, 32, 0));
}

if (Owner && (Owner->attackertype != DYNAMITE || ud.respawn_items == 0 || Owner->spr.picnum == APLAYER))
if (Owner && (Owner->attackertype != DYNAMITE || ud.respawn_items == 0 || Owner->isPlayer()))
{
if (actor->spr.picnum == DYNAMITE && Owner->spr.picnum != APLAYER && ud.coop)
if (actor->spr.picnum == DYNAMITE && !Owner->isPlayer() && ud.coop)
return;
actor->Destroy();
return;
Expand Down Expand Up @@ -2779,7 +2779,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
{
if ((badguy(actor) && actor->spr.extra <= 0) || (actor->opos.X != actor->spr.pos.X) || (actor->opos.Y != actor->spr.pos.Y))
{
if (actor->spr.picnum != APLAYER) actor->backupvec2();
if (!actor->isPlayer()) actor->backupvec2();
SetActor(actor, actor->spr.pos);
}
if (badguy(actor) && actor->spr.extra <= 0)
Expand Down Expand Up @@ -2811,7 +2811,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
if (a & dodgebullet)
dodge(actor);

if (actor->spr.picnum != APLAYER)
if (!actor->isPlayer())
alterang(a, actor, pnum);

if (abs(actor->vel.X) < 6 / 16.) actor->vel.X = 0;
Expand Down Expand Up @@ -2992,7 +2992,7 @@ static int fallspecial(DDukeActor *actor, int playernum)
}
else if (actor->sector()->lotag == 802)
{
if (actor->spr.picnum != APLAYER && badguy(actor) && actor->spr.pos.Z == actor->floorz - FOURSLEIGHT_F)
if (!actor->isPlayer() && badguy(actor) && actor->spr.pos.Z == actor->floorz - FOURSLEIGHT_F)
{
spawnguts(actor, PClass::FindActor("DukeJibs6"), 5);
S_PlayActorSound(SQUISHED, actor);
Expand All @@ -3014,15 +3014,15 @@ static int fallspecial(DDukeActor *actor, int playernum)
addspritetodelete();
return 0;
}
if (actor->spr.picnum != APLAYER && (badguy(actor) || actor->spr.picnum == HEN || actor->spr.picnum == COW || actor->spr.picnum == PIG || actor->spr.picnum == DOGRUN || actor->spr.picnum == RABBIT) && (!isRRRA() || actor->spriteextra < 128))
if (!actor->isPlayer() && (badguy(actor) || actor->spr.picnum == HEN || actor->spr.picnum == COW || actor->spr.picnum == PIG || actor->spr.picnum == DOGRUN || actor->spr.picnum == RABBIT) && (!isRRRA() || actor->spriteextra < 128))
{
actor->spr.pos.Z = actor->floorz - FOURSLEIGHT_F;
actor->vel.Z = 8000 / 256.;
actor->spr.extra = 0;
actor->spriteextra++;
sphit = 1;
}
else if (actor->spr.picnum != APLAYER)
else if (!actor->isPlayer())
{
if (!actor->spriteextra)
addspritetodelete();
Expand Down
6 changes: 3 additions & 3 deletions source/games/duke/src/animatesprites_d.cpp
Expand Up @@ -163,7 +163,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi

if (t->statnum == 99) continue;
auto pp = &ps[h->PlayerIndex()];
if (h->spr.statnum != STAT_ACTOR && h->spr.picnum == APLAYER && pp->newOwner == nullptr && h->GetOwner())
if (h->spr.statnum != STAT_ACTOR && h->isPlayer() && pp->newOwner == nullptr && h->GetOwner())
{
t->pos = h->interpolatedpos(interpfrac);
}
Expand Down Expand Up @@ -507,7 +507,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
t->cstat |= CSTAT_SPRITE_XFLIP;
}

if (h->spr.statnum == STAT_DUMMYPLAYER || badguy(h) || (h->spr.picnum == APLAYER && h->GetOwner()))
if (h->spr.statnum == STAT_DUMMYPLAYER || badguy(h) || (h->isPlayer() && h->GetOwner()))
{
if (t->statnum != 99 && h->spr.picnum != EXPLOSION2 && h->spr.picnum != HANGLIGHT && h->spr.picnum != DOMELITE)
{
Expand Down Expand Up @@ -637,7 +637,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
case FRAMEEFFECT1:
if (OwnerAc && OwnerAc->spr.statnum < MAXSTATUS)
{
if (OwnerAc->spr.picnum == APLAYER)
if (OwnerAc->isPlayer())
if (ud.cameraactor == nullptr)
if (screenpeek == OwnerAc->PlayerIndex() && display_mirror == 0)
{
Expand Down
10 changes: 5 additions & 5 deletions source/games/duke/src/animatesprites_r.cpp
Expand Up @@ -142,7 +142,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi

if (t->statnum == 99) continue;
auto pp = &ps[h->PlayerIndex()];
if (h->spr.statnum != STAT_ACTOR && h->spr.picnum == APLAYER && pp->newOwner == nullptr && h->GetOwner())
if (h->spr.statnum != STAT_ACTOR && h->isPlayer() && pp->newOwner == nullptr && h->GetOwner())
{
t->pos = h->interpolatedpos(interpfrac);
h->spr.scale = DVector2(0.375, 0.265625);
Expand Down Expand Up @@ -636,7 +636,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
if (!isRRRA() && h->spr.picnum == SBMOVE)
t->shade = -127;

if (h->spr.statnum == STAT_DUMMYPLAYER || badguy(h) || (h->spr.picnum == APLAYER && h->GetOwner()))
if (h->spr.statnum == STAT_DUMMYPLAYER || badguy(h) || (h->isPlayer() && h->GetOwner()))
{
if ((h->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == 0 && t->statnum != 99)
{
Expand Down Expand Up @@ -691,7 +691,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
switch (h->spr.picnum)
{
case RPG2:
case RRTILE1790:
case BOATGRENADE:
if (!isRRRA()) break;
[[fallthrough]];
case EXPLOSION2:
Expand Down Expand Up @@ -838,7 +838,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
case FRAMEEFFECT1:
if (OwnerAc && OwnerAc->spr.statnum < MAXSTATUS)
{
if (OwnerAc->spr.picnum == APLAYER)
if (OwnerAc->isPlayer())
if (ud.cameraactor == nullptr)
if (screenpeek == OwnerAc->PlayerIndex() && display_mirror == 0)
{
Expand All @@ -847,7 +847,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
}
if ((OwnerAc->spr.cstat & CSTAT_SPRITE_INVISIBLE) == 0)
{
if (OwnerAc->spr.picnum == APLAYER)
if (OwnerAc->isPlayer())
t->picnum = 1554;
else
t->picnum = OwnerAc->dispicnum;
Expand Down

0 comments on commit 3a91155

Please sign in to comment.