- Duke: abstracted all checks for TILE_APLAYER with an isPlayer method.

This commit is contained in:
Christoph Oelckers 2021-12-31 18:47:00 +01:00
parent 84ca96c52c
commit cd599a7a15
9 changed files with 51 additions and 46 deletions

View file

@ -1325,7 +1325,7 @@ void movetongue(DDukeActor *actor, int tongue, int jaw)
actor->spr.ang = Owner->spr.ang;
actor->spr.pos.X = Owner->spr.pos.X;
actor->spr.pos.Y = Owner->spr.pos.Y;
if (Owner->spr.picnum == TILE_APLAYER)
if (Owner->isPlayer())
actor->spr.pos.Z = Owner->spr.pos.Z - (34 << 8);
for (int k = 0; k < actor->temp_data[0]; k++)
{
@ -2712,7 +2712,7 @@ void handle_se00(DDukeActor* actor, int LASERLINE)
if (act2->spr.statnum != 3 && act2->spr.statnum != 4)
if (LASERLINE < 0 || act2->spr.picnum != LASERLINE)
{
if (act2->spr.picnum == TILE_APLAYER && act2->GetOwner())
if (act2->isPlayer() && act2->GetOwner())
{
continue;
}
@ -3960,7 +3960,7 @@ void handle_se18(DDukeActor *actor, bool morecheck)
DukeSectIterator it(actor->sector());
while (auto a2 = it.Next())
{
if (a2->spr.picnum == TILE_APLAYER && a2->GetOwner())
if (a2->isPlayer() && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1) ps[a2->PlayerIndex()].pos.Z += sc->extra;
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && a2->spr.statnum != STAT_PROJECTILE)
{
@ -3997,7 +3997,7 @@ void handle_se18(DDukeActor *actor, bool morecheck)
DukeSectIterator it(actor->sector());
while (auto a2 = it.Next())
{
if (a2->spr.picnum == TILE_APLAYER && a2->GetOwner())
if (a2->isPlayer() && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1) ps[a2->PlayerIndex()].pos.Z -= sc->extra;
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && a2->spr.statnum != STAT_PROJECTILE)
{
@ -4689,7 +4689,7 @@ void handle_se31(DDukeActor* actor, bool choosedir)
DukeSectIterator it(actor->sector());
while (auto a2 = it.Next())
{
if (a2->spr.picnum == TILE_APLAYER && a2->GetOwner())
if (a2->isPlayer() && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1)
ps[a2->PlayerIndex()].pos.Z += l;
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
@ -4718,7 +4718,7 @@ void handle_se31(DDukeActor* actor, bool choosedir)
DukeSectIterator it(actor->sector());
while (auto a2 = it.Next())
{
if (a2->spr.picnum == TILE_APLAYER && a2->GetOwner())
if (a2->isPlayer() && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1)
ps[a2->PlayerIndex()].pos.Z += l;
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
@ -4749,7 +4749,7 @@ void handle_se31(DDukeActor* actor, bool choosedir)
DukeSectIterator it(actor->sector());
while (auto a2 = it.Next())
{
if (a2->spr.picnum == TILE_APLAYER && a2->GetOwner())
if (a2->isPlayer() && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1)
ps[a2->PlayerIndex()].pos.Z += l;
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
@ -4777,7 +4777,7 @@ void handle_se31(DDukeActor* actor, bool choosedir)
DukeSectIterator it(actor->sector());
while (auto a2 = it.Next())
{
if (a2->spr.picnum ==TILE_APLAYER && a2->GetOwner())
if (a2->isPlayer() && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1)
ps[a2->PlayerIndex()].pos.Z -= l;
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
@ -4825,14 +4825,14 @@ void getglobalz(DDukeActor* actor)
ssp(actor, CLIPMASK0);
}
}
else if(lz.actor()->spr.picnum == TILE_APLAYER && badguy(actor) )
else if(lz.actor()->isPlayer() && badguy(actor) )
{
actor->aflags |= SFLAG_NOFLOORSHADOW;
//actor->dispicnum = -4; // No shadows on actors
actor->spr.xvel = -256;
ssp(actor, CLIPMASK0);
}
else if(actor->spr.statnum == STAT_PROJECTILE && lz.actor()->spr.picnum == TILE_APLAYER && actor->GetOwner() == actor)
else if(actor->spr.statnum == STAT_PROJECTILE && lz.actor()->isPlayer() && actor->GetOwner() == actor)
{
actor->ceilingz = actor->sector()->ceilingz;
actor->floorz = actor->sector()->floorz;
@ -4950,7 +4950,7 @@ int furthestangle(DDukeActor *actor, int angs)
greatestd = -(1 << 30);
angincs = 2048 / angs;
if (actor->spr.picnum != TILE_APLAYER)
if (!actor->isPlayer())
if ((actor->temp_data[0] & 63) > 2) return(actor->spr.ang + 1024);
for (j = actor->spr.ang; j < (2048 + actor->spr.ang); j += angincs)
@ -5037,7 +5037,7 @@ void alterang(int ang, DDukeActor* actor, int playernum)
else actor->SetOwner(ps[playernum].GetActor());
auto Owner = actor->GetOwner();
if (Owner->spr.picnum == TILE_APLAYER)
if (Owner->isPlayer())
goalang = getangle(actor->ovel.X - actor->spr.pos.X, actor->ovel.Y - actor->spr.pos.Y);
else
goalang = getangle(Owner->spr.pos.X - actor->spr.pos.X, Owner->spr.pos.Y - actor->spr.pos.Y);
@ -5125,14 +5125,14 @@ void fall_common(DDukeActor *actor, int playernum, int JIBS6, int DRONE, int BLO
{
actor->spr.pos.Z = actor->floorz - FOURSLEIGHT;
if (badguy(actor) || (actor->spr.picnum == TILE_APLAYER && actor->GetOwner()))
if (badguy(actor) || (actor->isPlayer() && actor->GetOwner()))
{
if (actor->spr.zvel > 3084 && actor->spr.extra <= 1)
{
if (actor->spr.pal != 1 && actor->spr.picnum != DRONE)
{
if (actor->spr.picnum == TILE_APLAYER && actor->spr.extra > 0)
if (actor->isPlayer() && actor->spr.extra > 0)
goto SKIPJIBS;
if (sphit)
{

View file

@ -1567,7 +1567,7 @@ int ParseState::parse(void)
case concmd_ifdead:
{
j = g_ac->spr.extra;
if (g_ac->spr.picnum == TILE_APLAYER)
if (g_ac->isPlayer())
j--;
parseifelse(j < 0);
}
@ -1707,7 +1707,7 @@ int ParseState::parse(void)
break;
case concmd_getlastpal:
insptr++;
if (g_ac->spr.picnum == TILE_APLAYER)
if (g_ac->isPlayer())
g_ac->spr.pal = ps[g_ac->spr.yvel].palookup;
else
{
@ -1736,12 +1736,12 @@ int ParseState::parse(void)
case concmd_pkick:
insptr++;
if (ud.multimode > 1 && g_ac->spr.picnum == TILE_APLAYER)
if (ud.multimode > 1 && g_ac->isPlayer())
{
if (ps[otherp].quick_kick == 0)
ps[otherp].quick_kick = 14;
}
else if (g_ac->spr.picnum != TILE_APLAYER && ps[g_p].quick_kick == 0)
else if (!g_ac->isPlayer() && ps[g_p].quick_kick == 0)
ps[g_p].quick_kick = 14;
break;
case concmd_sizeto:
@ -1757,7 +1757,7 @@ int ParseState::parse(void)
insptr++;
if ((g_ac->spr.picnum == TILE_APLAYER && g_ac->spr.yrepeat < 36) || *insptr < g_ac->spr.yrepeat || ((g_ac->spr.yrepeat * (tileHeight(g_ac->spr.picnum) + 8)) << 2) < (g_ac->floorz - g_ac->ceilingz))
if ((g_ac->isPlayer() && g_ac->spr.yrepeat < 36) || *insptr < g_ac->spr.yrepeat || ((g_ac->spr.yrepeat * (tileHeight(g_ac->spr.picnum) + 8)) << 2) < (g_ac->floorz - g_ac->ceilingz))
{
j = ((*insptr) - g_ac->spr.yrepeat) << 1;
if (abs(j)) g_ac->spr.yrepeat += Sgn(j);
@ -2446,7 +2446,7 @@ int ParseState::parse(void)
j = 1;
else if( (l& pfacing) )
{
if (g_ac->spr.picnum == TILE_APLAYER && ud.multimode > 1)
if (g_ac->isPlayer() && ud.multimode > 1)
j = getincangle(ps[otherp].angle.ang.asbuild(), getangle(ps[g_p].pos.X - ps[otherp].pos.X, ps[g_p].pos.Y - ps[otherp].pos.Y));
else
j = getincangle(ps[g_p].angle.ang.asbuild(), getangle(g_ac->spr.pos.X - ps[g_p].pos.X, g_ac->spr.pos.Y - ps[g_p].pos.Y));
@ -2533,7 +2533,7 @@ int ParseState::parse(void)
case concmd_spritepal:
insptr++;
if(g_ac->spr.picnum != TILE_APLAYER)
if(!g_ac->isPlayer())
g_ac->tempang = g_ac->spr.pal;
g_ac->spr.pal = *insptr;
insptr++;

View file

@ -68,7 +68,7 @@ void PlayerColorChanged(void)
{
pp.palookup = ud.user_pals[myconnectindex] = playercolor2lookup(playercolor);
}
if (pp.GetActor()->spr.picnum == TILE_APLAYER && pp.GetActor()->spr.pal != 1)
if (pp.GetActor()->isPlayer() && pp.GetActor()->spr.pal != 1)
pp.GetActor()->spr.pal = ud.user_pals[myconnectindex];
}
@ -171,7 +171,7 @@ int hits(DDukeActor* actor)
int zoff;
HitInfo hit{};
if (actor->spr.picnum == TILE_APLAYER) zoff = isRR() ? PHEIGHT_RR : PHEIGHT_DUKE;
if (actor->isPlayer()) zoff = isRR() ? PHEIGHT_RR : PHEIGHT_DUKE;
else zoff = 0;
hitscan(actor->spr.pos, actor->sector(), { bcos(actor->spr.ang), bsin(actor->spr.ang), 0 }, hit, CLIPMASK1);
@ -191,7 +191,7 @@ int hitasprite(DDukeActor* actor, DDukeActor** hitsp)
if (badguy(actor))
zoff = (42 << 8);
else if (actor->spr.picnum == TILE_APLAYER) zoff = (39 << 8);
else if (actor->isPlayer()) zoff = (39 << 8);
else zoff = 0;
hitscan({ actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - zoff }, actor->sector(), { bcos(actor->spr.ang), bsin(actor->spr.ang), 0 }, hit, CLIPMASK1);
@ -237,7 +237,7 @@ DDukeActor* aim(DDukeActor* actor, int aang)
a = actor->spr.ang;
// Autoaim from DukeGDX.
if (actor->spr.picnum == TILE_APLAYER)
if (actor->isPlayer())
{
auto* plr = &ps[actor->spr.yvel];
int autoaim = Autoaim(actor->spr.yvel);
@ -281,7 +281,7 @@ DDukeActor* aim(DDukeActor* actor, int aang)
}
}
DDukeActor* aimed = nullptr;
// if(actor->spr.picnum == TILE_APLAYER && ps[actor->spr.yvel].aim_mode) return -1;
// if(actor->isPlayer() && ps[actor->spr.yvel].aim_mode) return -1;
if (isRR())
{
@ -290,13 +290,13 @@ DDukeActor* aim(DDukeActor* actor, int aang)
}
else if (isWW2GI())
{
gotshrinker = actor->spr.picnum == TILE_APLAYER && aplWeaponWorksLike(ps[actor->spr.yvel].curr_weapon, actor->spr.yvel) == SHRINKER_WEAPON;
gotfreezer = actor->spr.picnum == TILE_APLAYER && aplWeaponWorksLike(ps[actor->spr.yvel].curr_weapon, actor->spr.yvel) == FREEZE_WEAPON;
gotshrinker = actor->isPlayer() && aplWeaponWorksLike(ps[actor->spr.yvel].curr_weapon, actor->spr.yvel) == SHRINKER_WEAPON;
gotfreezer = actor->isPlayer() && aplWeaponWorksLike(ps[actor->spr.yvel].curr_weapon, actor->spr.yvel) == FREEZE_WEAPON;
}
else
{
gotshrinker = actor->spr.picnum == TILE_APLAYER && ps[actor->spr.yvel].curr_weapon == SHRINKER_WEAPON;
gotfreezer = actor->spr.picnum == TILE_APLAYER && ps[actor->spr.yvel].curr_weapon == FREEZE_WEAPON;
gotshrinker = actor->isPlayer() && ps[actor->spr.yvel].curr_weapon == SHRINKER_WEAPON;
gotfreezer = actor->isPlayer() && ps[actor->spr.yvel].curr_weapon == FREEZE_WEAPON;
}
smax = 0x7fffffff;
@ -320,12 +320,12 @@ DDukeActor* aim(DDukeActor* actor, int aang)
if (act->spr.xrepeat > 0 && act->spr.extra >= 0 && (act->spr.cstat & (CSTAT_SPRITE_BLOCK_ALL | CSTAT_SPRITE_INVISIBLE)) == CSTAT_SPRITE_BLOCK_ALL)
if (badguy(act) || k < 2)
{
if (badguy(act) || act->spr.picnum == TILE_APLAYER)
if (badguy(act) || act->isPlayer())
{
if (act->spr.picnum == TILE_APLAYER &&
if (act->isPlayer() &&
(isRR() && ud.ffire == 0) &&
ud.coop == 1 &&
actor->spr.picnum == TILE_APLAYER &&
actor->isPlayer() &&
actor != act)
continue;
@ -342,7 +342,7 @@ DDukeActor* aim(DDukeActor* actor, int aang)
sdist = MulScale(dx3, xv, 14) + MulScale(dy3, yv, 14);
if (sdist > 512 && sdist < smax)
{
if (actor->spr.picnum == TILE_APLAYER)
if (actor->isPlayer())
a = (abs(Scale(act->spr.pos.Z - actor->spr.pos.Z, 10, sdist) - ps[actor->spr.yvel].horizon.sum().asbuild()) < 100);
else a = 1;
@ -394,7 +394,7 @@ void dokneeattack(int snum, const std::initializer_list<int> & respawnlist)
fi.operaterespawns(p->actorsqu->spr.yvel);
}
if (p->actorsqu->spr.picnum == TILE_APLAYER)
if (p->actorsqu->isPlayer())
{
quickkill(&ps[p->actorsqu->spr.yvel]);
ps[p->actorsqu->spr.yvel].frag_ps = snum;

View file

@ -437,7 +437,7 @@ static void shootweapon(DDukeActor *actor, int p, int sx, int sy, int sz, int sa
if (hit.actor())
{
fi.checkhitsprite(hit.actor(), spark);
if (hit.actor()->spr.picnum == TILE_APLAYER && (ud.coop != 1 || ud.ffire == 1))
if (hit.actor()->isPlayer() && (ud.coop != 1 || ud.ffire == 1))
{
spark->spr.xrepeat = spark->spr.yrepeat = 0;
auto jib = spawn(spark, JIBS6);
@ -541,7 +541,7 @@ static void shootweapon(DDukeActor *actor, int p, int sx, int sy, int sz, int sa
if (hit.actor())
{
fi.checkhitsprite(hit.actor(), spark);
if (hit.actor()->spr.picnum != TILE_APLAYER)
if (!hit.actor()->isPlayer())
spawn(spark, SMALLSMOKE);
else spark->spr.xrepeat = spark->spr.yrepeat = 0;
}
@ -1000,7 +1000,7 @@ void shoot_d(DDukeActor* actor, int atwith)
{
int l, j;
int sx, sy, sz, sa, p, vel, zvel, x, dal;
if (actor->spr.picnum == TILE_APLAYER)
if (actor->isPlayer())
{
p = actor->spr.yvel;
}
@ -1021,7 +1021,7 @@ void shoot_d(DDukeActor* actor, int atwith)
auto sect = actor->sector();
zvel = 0;
if (actor->spr.picnum == TILE_APLAYER)
if (actor->isPlayer())
{
sx = ps[p].pos.X;
sy = ps[p].pos.Y;

View file

@ -329,7 +329,7 @@ static void shootweapon(DDukeActor* actor, int p, int sx, int sy, int sz, int sa
if (hit.actor()->spr.picnum == 1930)
return;
fi.checkhitsprite(hit.actor(), spark);
if (hit.actor()->spr.picnum == TILE_APLAYER && (ud.coop != 1 || ud.ffire == 1))
if (hit.actor()->isPlayer() && (ud.coop != 1 || ud.ffire == 1))
{
auto l = spawn(spark, JIBS6);
spark->spr.xrepeat = spark->spr.yrepeat = 0;
@ -436,7 +436,7 @@ static void shootweapon(DDukeActor* actor, int p, int sx, int sy, int sz, int sa
if (hit.actor())
{
fi.checkhitsprite(hit.actor(), spark);
if (hit.actor()->spr.picnum != TILE_APLAYER)
if (!hit.actor()->isPlayer())
spawn(spark, SMALLSMOKE);
else spark->spr.xrepeat = spark->spr.yrepeat = 0;
}
@ -833,7 +833,7 @@ void shoot_r(DDukeActor* actor, int atwith)
auto const sect = actor->sector();
zvel = 0;
if (actor->spr.picnum == TILE_APLAYER)
if (actor->isPlayer())
{
p = actor->spr.yvel;

View file

@ -587,7 +587,7 @@ static void handle_st09(sectortype* sptr, DDukeActor* actor)
static void handle_st15(sectortype* sptr, DDukeActor* actor)
{
if (actor->spr.picnum != TILE_APLAYER) return;
if (!actor->isPlayer()) return;
DukeSectIterator it(sptr);
DDukeActor* a2;

View file

@ -265,7 +265,7 @@ static int GetPositionInfo(DDukeActor* actor, int soundNum, sectortype* sect,
FVector3 sndorg = GetSoundPos(pos);
FVector3 campos = GetSoundPos(cam);
if (actor->spr.picnum != TILE_APLAYER || actor->spr.yvel != screenpeek)
if (!actor->isPlayer() || actor->spr.yvel != screenpeek)
{
orgsndist = sndist = int(16 * (sndorg - campos).Length());
@ -442,7 +442,7 @@ int S_PlaySound3D(int sndnum, DDukeActor* actor, const vec3_t* pos, int channel,
if (userflags & SF_TALK)
{
if (snd_speech == 0 || (ud.multimode > 1 && actor->spr.picnum == TILE_APLAYER && actor->spr.yvel != screenpeek && ud.coop != 1)) return -1;
if (snd_speech == 0 || (ud.multimode > 1 && actor->isPlayer() && actor->spr.yvel != screenpeek && ud.coop != 1)) return -1;
bool foundone = soundEngine->EnumerateChannels([&](FSoundChan* chan)
{
auto sid = chan->OrgID;

View file

@ -428,7 +428,7 @@ void initshell(DDukeActor* actj, DDukeActor* act, bool isshell)
{
int snum, a;
if (actj->spr.picnum == TILE_APLAYER)
if (actj->isPlayer())
{
snum = actj->spr.yvel;
a = ps[snum].angle.ang.asbuild() - (krand() & 63) + 8; //Fine tune

View file

@ -97,6 +97,11 @@ public:
return spr.yvel;
}
bool isPlayer() const
{
return spr.picnum == TILE_APLAYER;
}
void Serialize(FSerializer& arc) override;
};