- Duke: Rename ps[] array to PlayerArray[] and wrap its access.

This commit is contained in:
Mitchell Richters 2023-10-02 13:51:13 +11:00
parent bd9e42bb40
commit 6a367c6184
38 changed files with 950 additions and 945 deletions

View file

@ -55,8 +55,8 @@ void moveactor(DDukeActor* actor, int p, double pdist, const int killit_flag)
if (killit_flag == 1)
{
// if player was set to squish, first stop that..
if (ps[p].actorsqu == actor)
ps[p].actorsqu = nullptr;
if (getPlayer(p)->actorsqu == actor)
getPlayer(p)->actorsqu = nullptr;
actor->flags2 |= SFLAG2_DIENOW;
}
else
@ -138,7 +138,7 @@ void TickActor(DDukeActor* self)
self->flags4 |= SFLAG4_INRUNSTATE;
IFVIRTUALPTR(self, DDukeActor, RunState)
{
VMValue val[] = { self, &ps[p], pdist};
VMValue val[] = { self, getPlayer(p), pdist};
try
{
VMCall(func, val, 3, nullptr, 0);
@ -273,7 +273,7 @@ void checkavailweapon(DukePlayer* player)
weap = player->curr_weapon;
if (player->gotweapon[weap])
{
if (player->ammo_amount[weap] > 0 || (WeaponSwitch(player - ps) & 2) == 0)
if (player->ammo_amount[weap] > 0 || (WeaponSwitch(player - PlayerArray) & 2) == 0)
return;
}
@ -478,19 +478,19 @@ void movedummyplayers(void)
if (!act->GetOwner()) continue;
p = act->GetOwner()->PlayerIndex();
if ((!isRR() && ps[p].on_crane != nullptr) || !ps[p].insector() || ps[p].cursector->lotag != 1 || ps->GetActor()->spr.extra <= 0)
if ((!isRR() && getPlayer(p)->on_crane != nullptr) || !getPlayer(p)->insector() || getPlayer(p)->cursector->lotag != 1 || getPlayer(0)->GetActor()->spr.extra <= 0)
{
ps[p].dummyplayersprite = nullptr;
getPlayer(p)->dummyplayersprite = nullptr;
act->Destroy();
continue;
}
else
{
if (ps[p].on_ground && ps[p].on_warping_sector == 1 && ps[p].cursector->lotag == 1)
if (getPlayer(p)->on_ground && getPlayer(p)->on_warping_sector == 1 && getPlayer(p)->cursector->lotag == 1)
{
act->spr.cstat = CSTAT_SPRITE_BLOCK_ALL;
act->spr.pos.Z = act->sector()->ceilingz + 27;
act->spr.Angles.Yaw = ps[p].GetActor()->spr.Angles.Yaw;
act->spr.Angles.Yaw = getPlayer(p)->GetActor()->spr.Angles.Yaw;
if (act->counter == 8)
act->counter = 0;
else act->counter++;
@ -502,7 +502,7 @@ void movedummyplayers(void)
}
}
act->spr.pos.XY() += ps[p].GetActor()->spr.pos.XY() - ps[p].GetActor()->opos.XY();
act->spr.pos.XY() += getPlayer(p)->GetActor()->spr.pos.XY() - getPlayer(p)->GetActor()->opos.XY();
SetActor(act, act->spr.pos);
}
}
@ -521,7 +521,7 @@ void moveplayers(void)
while (auto act = iti.Next())
{
int pn = act->PlayerIndex();
auto p = &ps[pn];
auto p = getPlayer(pn);
if (act->GetOwner())
{
@ -538,7 +538,7 @@ void moveplayers(void)
if (ud.multimode > 1)
{
otherp = findotherplayer(pn, &other);
auto psp = ps[otherp].GetActor();
auto psp = getPlayer(otherp)->GetActor();
if (psp->spr.extra > 0)
{
if (act->spr.scale.Y > 0.5 && psp->spr.scale.Y < 0.5)
@ -547,7 +547,7 @@ void moveplayers(void)
{
p->knee_incs = 1;
p->weapon_pos = -1;
p->actorsqu = ps[otherp].GetActor();
p->actorsqu = getPlayer(otherp)->GetActor();
}
}
}
@ -1022,7 +1022,7 @@ void gutsdir(DDukeActor* actor, PClassActor* gtype, int n, int p)
auto zvel = -krandf(8) - 2;
// TRANSITIONAL: owned by a player???
CreateActor(actor->sector(), DVector3(actor->spr.pos.XY(), gutz), gtype, -32, DVector2(scale, scale), a, vel, zvel, ps[p].GetActor(), 5);
CreateActor(actor->sector(), DVector3(actor->spr.pos.XY(), gutz), gtype, -32, DVector2(scale, scale), a, vel, zvel, getPlayer(p)->GetActor(), 5);
}
}
@ -1178,12 +1178,12 @@ void hitradius(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int hp4
if (act2->attackertype == DukeFlamethrowerFlameClass && Owner->isPlayer())
{
ps[p].numloogs = -1 - actor->spr.yint;
getPlayer(p)->numloogs = -1 - actor->spr.yint;
}
if (ps[p].newOwner != nullptr)
if (getPlayer(p)->newOwner != nullptr)
{
clearcamera(&ps[p]);
clearcamera(getPlayer(p));
}
}
act2->SetHitOwner(actor->GetOwner());
@ -1298,9 +1298,9 @@ void move(DDukeActor* actor, int pnum, double pdist)
if (a & face_player)
{
if (ps[pnum].newOwner != nullptr)
goalang = (ps[pnum].GetActor()->opos.XY() - actor->spr.pos.XY()).Angle();
else goalang = (ps[pnum].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle();
if (getPlayer(pnum)->newOwner != nullptr)
goalang = (getPlayer(pnum)->GetActor()->opos.XY() - actor->spr.pos.XY()).Angle();
else goalang = (getPlayer(pnum)->GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle();
angdif = deltaangle(actor->spr.Angles.Yaw, goalang) * 0.25;
if (angdif > -DAngle22_5 / 16 && angdif < nullAngle) angdif = nullAngle;
actor->spr.Angles.Yaw += angdif;
@ -1311,18 +1311,18 @@ void move(DDukeActor* actor, int pnum, double pdist)
if (a & face_player_slow)
{
if (ps[pnum].newOwner != nullptr)
goalang = (ps[pnum].GetActor()->opos.XY() - actor->spr.pos.XY()).Angle();
else goalang = (ps[pnum].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle();
if (getPlayer(pnum)->newOwner != nullptr)
goalang = (getPlayer(pnum)->GetActor()->opos.XY() - actor->spr.pos.XY()).Angle();
else goalang = (getPlayer(pnum)->GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle();
angdif = DAngle22_5 * 0.25 * Sgn(deltaangle(actor->spr.Angles.Yaw, goalang).Degrees()); // this looks very wrong...
actor->spr.Angles.Yaw += angdif;
}
if (a & antifaceplayerslow)
{
if (ps[pnum].newOwner != nullptr)
goalang = ((ps[pnum].GetActor()->opos.XY() - actor->spr.pos.XY()).Angle() + DAngle180);
else goalang = ((ps[pnum].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle() + DAngle180);
if (getPlayer(pnum)->newOwner != nullptr)
goalang = ((getPlayer(pnum)->GetActor()->opos.XY() - actor->spr.pos.XY()).Angle() + DAngle180);
else goalang = ((getPlayer(pnum)->GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle() + DAngle180);
angdif = DAngle22_5 * 0.25 * Sgn(deltaangle(actor->spr.Angles.Yaw, goalang).Degrees()); // this looks very wrong...
actor->spr.Angles.Yaw += angdif;
}
@ -1351,7 +1351,7 @@ void move(DDukeActor* actor, int pnum, double pdist)
if (a & face_player_smart)
{
DVector2 newpos = ps[pnum].GetActor()->spr.pos.XY() + (ps[pnum].vel.XY() * (4. / 3.));
DVector2 newpos = getPlayer(pnum)->GetActor()->spr.pos.XY() + (getPlayer(pnum)->vel.XY() * (4. / 3.));
goalang = (newpos - actor->spr.pos.XY()).Angle();
angdif = deltaangle(actor->spr.Angles.Yaw, goalang) * 0.25;
if (angdif > -DAngle22_5 / 16 && angdif < nullAngle) angdif = nullAngle;
@ -1449,16 +1449,16 @@ void move(DDukeActor* actor, int pnum, double pdist)
{
daxvel = -(64 - pdist);
angdif = (ps[pnum].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle();
angdif = (getPlayer(pnum)->GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle();
if (pdist < 32)
{
ps[pnum].vel.X = 0;
ps[pnum].vel.Y = 0;
getPlayer(pnum)->vel.X = 0;
getPlayer(pnum)->vel.Y = 0;
}
else
{
ps[pnum].vel.XY() *= gs.playerfriction - 0.125;
getPlayer(pnum)->vel.XY() *= gs.playerfriction - 0.125;
}
}
else if (!(actor->flags2 & SFLAG2_FLOATING))
@ -1467,12 +1467,12 @@ void move(DDukeActor* actor, int pnum, double pdist)
{
if (actor->opos.Z != actor->spr.pos.Z || (ud.multimode < 2 && ud.player_skill < 2))
{
if ((actor->counter & 1) || ps[pnum].actorsqu == actor) return;
if ((actor->counter & 1) || getPlayer(pnum)->actorsqu == actor) return;
else daxvel *= 2;
}
else
{
if ((actor->counter & 3) || ps[pnum].actorsqu == actor) return;
if ((actor->counter & 3) || getPlayer(pnum)->actorsqu == actor) return;
else daxvel *= 4;
}
}
@ -1628,17 +1628,17 @@ void handle_se00(DDukeActor* actor)
int p;
for (p = connecthead; p >= 0; p = connectpoint2[p])
{
if (ps[p].cursector == actor->sector() && ps[p].on_ground == 1)
if (getPlayer(p)->cursector == actor->sector() && getPlayer(p)->on_ground == 1)
{
ps[p].GetActor()->spr.Angles.Yaw += ang_amount * direction;
getPlayer(p)->GetActor()->spr.Angles.Yaw += ang_amount * direction;
ps[p].GetActor()->spr.pos.Z += zchange;
getPlayer(p)->GetActor()->spr.pos.Z += zchange;
auto result = rotatepoint(Owner->spr.pos, ps[p].GetActor()->spr.pos.XY(), ang_amount * direction);
auto result = rotatepoint(Owner->spr.pos, getPlayer(p)->GetActor()->spr.pos.XY(), ang_amount * direction);
ps[p].bobpos += (result - ps[p].GetActor()->spr.pos.XY());
getPlayer(p)->bobpos += (result - getPlayer(p)->GetActor()->spr.pos.XY());
ps[p].GetActor()->spr.pos.XY() = result;
getPlayer(p)->GetActor()->spr.pos.XY() = result;
}
}
DukeSectIterator itp(actor->sector());
@ -1758,7 +1758,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, PClassActor* RPG)
if (dist2 < 1280)//20480)
{
auto saved_angle = actor->spr.Angles.Yaw;
actor->spr.Angles.Yaw = (actor->spr.pos.XY() - ps[p].GetActor()->spr.pos.XY()).Angle();
actor->spr.Angles.Yaw = (actor->spr.pos.XY() - getPlayer(p)->GetActor()->spr.pos.XY()).Angle();
shoot(actor, RPG);
actor->spr.Angles.Yaw = saved_angle;
}
@ -1773,18 +1773,18 @@ void handle_se14(DDukeActor* actor, bool checkstat, PClassActor* RPG)
if (ud.clipping == 0 && actor->vel.X >= 12)
for (int p = connecthead; p >= 0; p = connectpoint2[p])
{
auto psp = ps[p].GetActor();
auto psp = getPlayer(p)->GetActor();
if (psp->spr.extra > 0)
{
auto sect = ps[p].cursector;
updatesector(ps[p].GetActor()->getPosWithOffsetZ(), &sect);
if ((sect == nullptr && ud.clipping == 0) || (sect == actor->sector() && ps[p].cursector != actor->sector()))
auto sect = getPlayer(p)->cursector;
updatesector(getPlayer(p)->GetActor()->getPosWithOffsetZ(), &sect);
if ((sect == nullptr && ud.clipping == 0) || (sect == actor->sector() && getPlayer(p)->cursector != actor->sector()))
{
ps[p].GetActor()->spr.pos.XY() = actor->spr.pos.XY();
ps[p].setCursector(actor->sector());
getPlayer(p)->GetActor()->spr.pos.XY() = actor->spr.pos.XY();
getPlayer(p)->setCursector(actor->sector());
SetActor(ps[p].GetActor(), actor->spr.pos);
quickkill(&ps[p]);
SetActor(getPlayer(p)->GetActor(), actor->spr.pos);
quickkill(getPlayer(p));
}
}
}
@ -1794,8 +1794,8 @@ void handle_se14(DDukeActor* actor, bool checkstat, PClassActor* RPG)
for (int p = connecthead; p >= 0; p = connectpoint2[p])
{
auto psp = ps[p].GetActor();
if (ps[p].insector() && ps[p].cursector->lotag != 2)
auto psp = getPlayer(p)->GetActor();
if (getPlayer(p)->insector() && getPlayer(p)->cursector->lotag != 2)
{
if (po[p].os == actor->sector())
{
@ -1804,21 +1804,21 @@ void handle_se14(DDukeActor* actor, bool checkstat, PClassActor* RPG)
if (actor->sector() == psp->sector())
{
auto result = rotatepoint(actor->spr.pos.XY(), ps[p].GetActor()->spr.pos.XY(), diffangle);
auto result = rotatepoint(actor->spr.pos.XY(), getPlayer(p)->GetActor()->spr.pos.XY(), diffangle);
ps[p].GetActor()->spr.pos.XY() = result + vec;
getPlayer(p)->GetActor()->spr.pos.XY() = result + vec;
ps[p].bobpos += vec;
getPlayer(p)->bobpos += vec;
ps[p].GetActor()->spr.Angles.Yaw += diffangle;
getPlayer(p)->GetActor()->spr.Angles.Yaw += diffangle;
if (numplayers > 1)
{
ps[p].GetActor()->backupvec2();
getPlayer(p)->GetActor()->backupvec2();
}
if (psp->spr.extra <= 0)
{
psp->spr.pos.XY() = ps[p].GetActor()->spr.pos.XY();
psp->spr.pos.XY() = getPlayer(p)->GetActor()->spr.pos.XY();
}
}
}
@ -1849,18 +1849,18 @@ void handle_se14(DDukeActor* actor, bool checkstat, PClassActor* RPG)
if (ud.clipping == 0 && actor->vel.X >= 12)
for (int p = connecthead; p >= 0; p = connectpoint2[p])
{
if (ps[p].GetActor()->spr.extra > 0)
if (getPlayer(p)->GetActor()->spr.extra > 0)
{
auto k = ps[p].cursector;
updatesector(ps[p].GetActor()->getPosWithOffsetZ(), &k);
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && ps[p].cursector != actor->sector()))
auto k = getPlayer(p)->cursector;
updatesector(getPlayer(p)->GetActor()->getPosWithOffsetZ(), &k);
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && getPlayer(p)->cursector != actor->sector()))
{
ps[p].GetActor()->spr.pos.XY() = actor->spr.pos.XY();
ps[p].GetActor()->backupvec2();
ps[p].setCursector(actor->sector());
getPlayer(p)->GetActor()->spr.pos.XY() = actor->spr.pos.XY();
getPlayer(p)->GetActor()->backupvec2();
getPlayer(p)->setCursector(actor->sector());
SetActor(ps[p].GetActor(), actor->spr.pos);
quickkill(&ps[p]);
SetActor(getPlayer(p)->GetActor(), actor->spr.pos);
quickkill(getPlayer(p));
}
}
}
@ -1951,34 +1951,34 @@ void handle_se30(DDukeActor *actor)
if (ud.clipping == 0)
for (int p = connecthead; p >= 0; p = connectpoint2[p])
{
auto psp = ps[p].GetActor();
auto psp = getPlayer(p)->GetActor();
if (psp->spr.extra > 0)
{
auto k = ps[p].cursector;
updatesector(ps[p].GetActor()->getPosWithOffsetZ(), &k);
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && ps[p].cursector != actor->sector()))
auto k = getPlayer(p)->cursector;
updatesector(getPlayer(p)->GetActor()->getPosWithOffsetZ(), &k);
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && getPlayer(p)->cursector != actor->sector()))
{
ps[p].GetActor()->spr.pos.XY() = actor->spr.pos.XY();
ps[p].setCursector(actor->sector());
getPlayer(p)->GetActor()->spr.pos.XY() = actor->spr.pos.XY();
getPlayer(p)->setCursector(actor->sector());
SetActor(ps[p].GetActor(), actor->spr.pos);
quickkill(&ps[p]);
SetActor(getPlayer(p)->GetActor(), actor->spr.pos);
quickkill(getPlayer(p));
}
}
}
for (int p = connecthead; p >= 0; p = connectpoint2[p])
{
auto psp = ps[p].GetActor();
auto psp = getPlayer(p)->GetActor();
if (psp->sector() == actor->sector())
{
ps[p].GetActor()->spr.pos.XY() += vect;
getPlayer(p)->GetActor()->spr.pos.XY() += vect;
if (numplayers > 1)
{
ps[p].GetActor()->backupvec2();
getPlayer(p)->GetActor()->backupvec2();
}
ps[p].bobpos += vect;
getPlayer(p)->bobpos += vect;
}
if (po[p].os == actor->sector())
@ -2008,19 +2008,19 @@ void handle_se30(DDukeActor *actor)
{
if (ud.clipping == 0)
for (int p = connecthead; p >= 0; p = connectpoint2[p])
if (ps[p].GetActor()->spr.extra > 0)
if (getPlayer(p)->GetActor()->spr.extra > 0)
{
auto k = ps[p].cursector;
updatesector(ps[p].GetActor()->getPosWithOffsetZ(), &k);
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && ps[p].cursector != actor->sector()))
auto k = getPlayer(p)->cursector;
updatesector(getPlayer(p)->GetActor()->getPosWithOffsetZ(), &k);
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && getPlayer(p)->cursector != actor->sector()))
{
ps[p].GetActor()->spr.pos.XY() = actor->spr.pos.XY();
ps[p].GetActor()->backupvec2();
getPlayer(p)->GetActor()->spr.pos.XY() = actor->spr.pos.XY();
getPlayer(p)->GetActor()->backupvec2();
ps[p].setCursector(actor->sector());
getPlayer(p)->setCursector(actor->sector());
SetActor(ps[p].GetActor(), actor->spr.pos);
quickkill(&ps[p]);
SetActor(getPlayer(p)->GetActor(), actor->spr.pos);
quickkill(getPlayer(p));
}
}
@ -2085,7 +2085,7 @@ void handle_se02(DDukeActor* actor)
if ((actor->counter & 31) == 8)
{
ud.earthquaketime = 48;
S_PlayActorSound(EARTHQUAKE, ps[screenpeek].GetActor());
S_PlayActorSound(EARTHQUAKE, getPlayer(screenpeek)->GetActor());
}
if (abs(sc->floorheinum - actor->temp_data[0]) < 8)
@ -2096,10 +2096,10 @@ void handle_se02(DDukeActor* actor)
auto vect = actor->spr.Angles.Yaw.ToVector() * actor->vel.X;
for (int p = connecthead; p >= 0; p = connectpoint2[p])
if (ps[p].cursector == actor->sector() && ps[p].on_ground)
if (getPlayer(p)->cursector == actor->sector() && getPlayer(p)->on_ground)
{
ps[p].GetActor()->spr.pos.XY() += vect;
ps[p].bobpos += vect;
getPlayer(p)->GetActor()->spr.pos.XY() += vect;
getPlayer(p)->bobpos += vect;
}
DukeSectIterator it(actor->sector());
@ -2244,7 +2244,7 @@ void handle_se05(DDukeActor* actor)
if (x < 512)
{
auto ang = actor->spr.Angles.Yaw;
actor->spr.Angles.Yaw = (actor->spr.pos.XY() - ps[p].GetActor()->spr.pos.XY()).Angle();
actor->spr.Angles.Yaw = (actor->spr.pos.XY() - getPlayer(p)->GetActor()->spr.pos.XY()).Angle();
shoot(actor, isRR()? RedneckFirelaserClass : DukeFirelaserClass);
actor->spr.Angles.Yaw = ang;
}
@ -2259,7 +2259,7 @@ void handle_se05(DDukeActor* actor)
auto NewOwner = LocateTheLocator(actor->temp_data[4], nullptr);
if (NewOwner == nullptr) break;
double dist = (ps[p].GetActor()->spr.pos.XY() - NewOwner->spr.pos.XY()).LengthSquared();
double dist = (getPlayer(p)->GetActor()->spr.pos.XY() - NewOwner->spr.pos.XY()).LengthSquared();
if (maxdist > dist)
{
@ -2299,7 +2299,7 @@ void handle_se05(DDukeActor* actor)
else
{
actor->temp_angle +=
deltaangle(actor->temp_angle + DAngle90, (ps[p].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle()) * 0.25;
deltaangle(actor->temp_angle + DAngle90, (getPlayer(p)->GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle()) * 0.25;
sc->ceilingshade = 0;
}
j = fi.ifhitbyweapon(actor);
@ -2309,7 +2309,7 @@ void handle_se05(DDukeActor* actor)
if (actor->temp_data[3] == 5)
{
actor->vel.Z += 4;
FTA(7, &ps[myconnectindex]);
FTA(7, getPlayer(myconnectindex));
}
}
@ -2420,7 +2420,7 @@ void handle_se10(DDukeActor* actor, const int* specialtags)
if ((sc->lotag & 0xff) != ST_27_STRETCH_BRIDGE)
for (int p = connecthead; p >= 0; p = connectpoint2[p])
if (sc->lotag != ST_30_ROTATE_RISE_BRIDGE && sc->lotag != ST_31_TWO_WAY_TRAIN && sc->lotag != ST_0_NO_EFFECT)
if (actor->sector() == ps[p].GetActor()->sector())
if (actor->sector() == getPlayer(p)->GetActor()->sector())
j = 0;
if (j == 1)
@ -2635,10 +2635,10 @@ void handle_se13(DDukeActor* actor)
sc->floorshade = actor->spr.shade;
if (ps[0].one_parallax_sectnum != nullptr)
if (getPlayer(0)->one_parallax_sectnum != nullptr)
{
sc->setceilingtexture(ps[0].one_parallax_sectnum->ceilingtexture);
sc->ceilingshade = ps[0].one_parallax_sectnum->ceilingshade;
sc->setceilingtexture(getPlayer(0)->one_parallax_sectnum->ceilingtexture);
sc->ceilingshade = getPlayer(0)->one_parallax_sectnum->ceilingshade;
}
}
}
@ -2759,9 +2759,9 @@ void handle_se17(DDukeActor* actor)
if (act1->spr.statnum == STAT_PLAYER && act1->GetOwner())
{
int p = act1->spr.yint;
ps[p].GetActor()->spr.pos.Z += q;
ps[p].truefz += q;
ps[p].truecz += q;
getPlayer(p)->GetActor()->spr.pos.Z += q;
getPlayer(p)->truefz += q;
getPlayer(p)->truecz += q;
}
if (act1->spr.statnum != STAT_EFFECTOR && act1->spr.statnum != STAT_PLAYER)
{
@ -2813,19 +2813,19 @@ void handle_se17(DDukeActor* actor)
act3->spr.pos.Z += act2->sector()->floorz - sc->floorz;
act3->opos += act3->spr.pos;
if (q > 0) ps[p].GetActor()->backupz();
if (q > 0) getPlayer(p)->GetActor()->backupz();
act3->floorz = act2->sector()->floorz;
act3->ceilingz = act2->sector()->ceilingz;
ps[p].setbobpos();
getPlayer(p)->setbobpos();
ps[p].truefz = act3->floorz;
ps[p].truecz = act3->ceilingz;
ps[p].bobcounter = 0;
getPlayer(p)->truefz = act3->floorz;
getPlayer(p)->truecz = act3->ceilingz;
getPlayer(p)->bobcounter = 0;
ChangeActorSect(act3, act2->sector());
ps[p].setCursector(act2->sector());
getPlayer(p)->setCursector(act2->sector());
}
else if (act3->spr.statnum != STAT_EFFECTOR)
{
@ -2883,7 +2883,7 @@ void handle_se18(DDukeActor *actor, bool morecheck)
{
if (a2->isPlayer() && a2->GetOwner())
{
if (ps[a2->PlayerIndex()].on_ground == 1) ps[a2->PlayerIndex()].GetActor()->spr.pos.Z += extra;
if (getPlayer(a2->PlayerIndex())->on_ground == 1) getPlayer(a2->PlayerIndex())->GetActor()->spr.pos.Z += extra;
}
if (a2->vel.Z == 0 && a2->spr.statnum != STAT_EFFECTOR && a2->spr.statnum != STAT_PROJECTILE)
{
@ -2922,7 +2922,7 @@ void handle_se18(DDukeActor *actor, bool morecheck)
{
if (a2->isPlayer() && a2->GetOwner())
{
if (ps[a2->PlayerIndex()].on_ground == 1) ps[a2->PlayerIndex()].GetActor()->spr.pos.Z -= extra;
if (getPlayer(a2->PlayerIndex())->on_ground == 1) getPlayer(a2->PlayerIndex())->GetActor()->spr.pos.Z -= extra;
}
if (a2->vel.Z == 0 && a2->spr.statnum != STAT_EFFECTOR && a2->spr.statnum != STAT_PROJECTILE)
{
@ -3025,7 +3025,7 @@ void handle_se19(DDukeActor *actor)
auto hitter = ifhitsectors(actor->sector());
if (hitter)
{
FTA(8, &ps[myconnectindex]);
FTA(8, getPlayer(myconnectindex));
DukeStatIterator it(STAT_EFFECTOR);
while (auto ac = it.Next())
@ -3106,12 +3106,12 @@ void handle_se20(DDukeActor* actor)
dragpoint(wal[1], wal[1]->pos + vec);
for (int p = connecthead; p >= 0; p = connectpoint2[p])
if (ps[p].cursector == actor->sector() && ps[p].on_ground)
if (getPlayer(p)->cursector == actor->sector() && getPlayer(p)->on_ground)
{
ps[p].GetActor()->spr.pos.XY() += vec;
ps[p].GetActor()->backupvec2();
getPlayer(p)->GetActor()->spr.pos.XY() += vec;
getPlayer(p)->GetActor()->backupvec2();
SetActor(ps[p].GetActor(), ps[p].GetActor()->spr.pos);
SetActor(getPlayer(p)->GetActor(), getPlayer(p)->GetActor()->spr.pos);
}
sc->addfloorxpan(-(float)vec.X * 2);
@ -3217,11 +3217,11 @@ void handle_se26(DDukeActor* actor)
}
for (int p = connecthead; p >= 0; p = connectpoint2[p])
if (ps[p].GetActor()->sector() == actor->sector() && ps[p].on_ground)
if (getPlayer(p)->GetActor()->sector() == actor->sector() && getPlayer(p)->on_ground)
{
ps[p].fric.X += vect.X;
ps[p].fric.Y += vect.Y;
ps[p].GetActor()->spr.pos.Z += zvel;
getPlayer(p)->fric.X += vect.X;
getPlayer(p)->fric.Y += vect.Y;
getPlayer(p)->GetActor()->spr.pos.Z += zvel;
}
movesector(actor, actor->temp_data[1], nullAngle);
@ -3245,23 +3245,23 @@ void handle_se27(DDukeActor* actor)
actor->temp_angle = actor->spr.Angles.Yaw;
p = findplayer(actor, &xx);
if (ps[p].GetActor()->spr.extra > 0 && myconnectindex == screenpeek)
if (getPlayer(p)->GetActor()->spr.extra > 0 && myconnectindex == screenpeek)
{
if (actor->counter < 0)
{
ud.cameraactor = actor;
actor->counter++;
}
else if (ud.recstat == 2 && ps[p].newOwner == nullptr)
else if (ud.recstat == 2 && getPlayer(p)->newOwner == nullptr)
{
if (cansee(actor->spr.pos, actor->sector(), ps[p].GetActor()->getPosWithOffsetZ(), ps[p].cursector))
if (cansee(actor->spr.pos, actor->sector(), getPlayer(p)->GetActor()->getPosWithOffsetZ(), getPlayer(p)->cursector))
{
if (xx < sh * maptoworld)
{
ud.cameraactor = actor;
actor->counter = 999;
actor->spr.Angles.Yaw += deltaangle(actor->spr.Angles.Yaw, (ps[p].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle()) * 0.125;
actor->spr.yint = 100 + int((actor->spr.pos.Z - ps[p].GetActor()->getOffsetZ()) * (256. / 257.));
actor->spr.Angles.Yaw += deltaangle(actor->spr.Angles.Yaw, (getPlayer(p)->GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle()) * 0.125;
actor->spr.yint = 100 + int((actor->spr.pos.Z - getPlayer(p)->GetActor()->getOffsetZ()) * (256. / 257.));
}
else if (actor->counter == 999)
@ -3275,7 +3275,7 @@ void handle_se27(DDukeActor* actor)
}
else
{
actor->spr.Angles.Yaw = (ps[p].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle();
actor->spr.Angles.Yaw = (getPlayer(p)->GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle();
if (actor->counter == 999)
{
@ -3338,11 +3338,11 @@ void handle_se24(DDukeActor *actor, bool scroll, double mult)
for (auto p = connecthead; p >= 0; p = connectpoint2[p])
{
if (ps[p].cursector == actor->sector() && ps[p].on_ground)
if (getPlayer(p)->cursector == actor->sector() && getPlayer(p)->on_ground)
{
if (abs(ps[p].GetActor()->getOffsetZ() - ps[p].truefz) < gs.playerheight + 9)
if (abs(getPlayer(p)->GetActor()->getOffsetZ() - getPlayer(p)->truefz) < gs.playerheight + 9)
{
ps[p].fric += vec * (1. / 8.); // keeping the original velocity. to match the animation it should be ~1/24.
getPlayer(p)->fric += vec * (1. / 8.); // keeping the original velocity. to match the animation it should be ~1/24.
}
}
}
@ -3649,8 +3649,8 @@ void handle_se31(DDukeActor* actor, bool choosedir)
while (auto a2 = it.Next())
{
if (a2->isPlayer() && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1)
ps[a2->PlayerIndex()].GetActor()->spr.pos.Z += l;
if (getPlayer(a2->PlayerIndex())->on_ground == 1)
getPlayer(a2->PlayerIndex())->GetActor()->spr.pos.Z += l;
if (a2->vel.Z == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
{
if (!a2->isPlayer()) a2->spr.pos.Z += l;
@ -3678,8 +3678,8 @@ void handle_se31(DDukeActor* actor, bool choosedir)
while (auto a2 = it.Next())
{
if (a2->isPlayer() && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1)
ps[a2->PlayerIndex()].GetActor()->spr.pos.Z += l;
if (getPlayer(a2->PlayerIndex())->on_ground == 1)
getPlayer(a2->PlayerIndex())->GetActor()->spr.pos.Z += l;
if (a2->vel.Z == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
{
if (!a2->isPlayer()) a2->spr.pos.Z += l;
@ -3709,8 +3709,8 @@ void handle_se31(DDukeActor* actor, bool choosedir)
while (auto a2 = it.Next())
{
if (a2->isPlayer() && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1)
ps[a2->PlayerIndex()].GetActor()->spr.pos.Z += l;
if (getPlayer(a2->PlayerIndex())->on_ground == 1)
getPlayer(a2->PlayerIndex())->GetActor()->spr.pos.Z += l;
if (a2->vel.Z == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
{
if (!a2->isPlayer()) a2->spr.pos.Z += l;
@ -3737,8 +3737,8 @@ void handle_se31(DDukeActor* actor, bool choosedir)
while (auto a2 = it.Next())
{
if (a2->isPlayer() && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1)
ps[a2->PlayerIndex()].GetActor()->spr.pos.Z -= l;
if (getPlayer(a2->PlayerIndex())->on_ground == 1)
getPlayer(a2->PlayerIndex())->GetActor()->spr.pos.Z -= l;
if (a2->vel.Z == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
{
if (!a2->isPlayer()) a2->spr.pos.Z -= l;
@ -3982,13 +3982,13 @@ void alterang(int ang, DDukeActor* actor, int playernum)
actor->spr.Angles.Yaw = WindDir;
else if (ang & seekplayer)
{
DDukeActor* holoduke = !isRR()? ps[playernum].holoduke_on.Get() : nullptr;
DDukeActor* holoduke = !isRR()? getPlayer(playernum)->holoduke_on.Get() : nullptr;
// NOTE: looks like 'Owner' is set to target sprite ID...
if (holoduke && cansee(holoduke->spr.pos, holoduke->sector(), actor->spr.pos, actor->sector()))
actor->SetOwner(holoduke);
else actor->SetOwner(ps[playernum].GetActor());
else actor->SetOwner(getPlayer(playernum)->GetActor());
auto Owner = actor->GetOwner();
if (Owner->isPlayer())
@ -4026,7 +4026,7 @@ void alterang(int ang, DDukeActor* actor, int playernum)
{
goalang = furthestangle(actor, j);
actor->spr.Angles.Yaw = goalang;
actor->SetOwner(ps[playernum].GetActor());
actor->SetOwner(getPlayer(playernum)->GetActor());
}
if (ang & fleeenemy)
@ -4247,7 +4247,7 @@ void movefta(void)
ssect = psect = act->sector();
if (ps[p].GetActor()->spr.extra > 0)
if (getPlayer(p)->GetActor()->spr.extra > 0)
{
if (xx < 30000 / 16.)
{
@ -4257,8 +4257,8 @@ void movefta(void)
if (badguy(act))
{
auto xyrand = []() -> double { return (64 - (krand() & 127)) * maptoworld; };
double px = ps[p].GetActor()->opos.X - xyrand();
double py = ps[p].GetActor()->opos.Y - xyrand();
double px = getPlayer(p)->GetActor()->opos.X - xyrand();
double py = getPlayer(p)->GetActor()->opos.Y - xyrand();
updatesector(DVector3(px, py, 0), &psect);
if (psect == nullptr)
{
@ -4275,14 +4275,14 @@ void movefta(void)
{
double r1 = zrand(32);
double r2 = zrand(52);
canseeme = cansee({ sx, sy, act->spr.pos.Z - r2 }, act->sector(), { px, py, ps[p].GetActor()->getPrevOffsetZ() - r1 }, ps[p].cursector);
canseeme = cansee({ sx, sy, act->spr.pos.Z - r2 }, act->sector(), { px, py, getPlayer(p)->GetActor()->getPrevOffsetZ() - r1 }, getPlayer(p)->cursector);
}
}
else
{
int r1 = krand();
int r2 = krand();
canseeme = cansee(act->spr.pos.plusZ(-(r2 & 31)), act->sector(), ps[p].GetActor()->getPrevPosWithOffsetZ().plusZ(-(r1 & 31)), ps[p].cursector);
canseeme = cansee(act->spr.pos.plusZ(-(r2 & 31)), act->sector(), getPlayer(p)->GetActor()->getPrevPosWithOffsetZ().plusZ(-(r1 & 31)), getPlayer(p)->cursector);
}

View file

@ -123,7 +123,7 @@ int ifsquished(DDukeActor* actor, int p)
if (squishme)
{
FTA(QUOTE_SQUISHED, &ps[p]);
FTA(QUOTE_SQUISHED, getPlayer(p));
if (badguy(actor))
actor->vel.X = 0;
@ -176,23 +176,23 @@ int ifhitbyweapon_d(DDukeActor *actor)
{
actor->spr.extra = 0;
ps[p].wackedbyactor = hitowner;
getPlayer(p)->wackedbyactor = hitowner;
if (hitowner->isPlayer() && p != hitowner->PlayerIndex())
{
ps[p].frag_ps = hitowner->PlayerIndex();
getPlayer(p)->frag_ps = hitowner->PlayerIndex();
}
actor->SetHitOwner(ps[p].GetActor());
actor->SetHitOwner(getPlayer(p)->GetActor());
}
}
if (adef->flags2 & SFLAG2_DOUBLEDMGTHRUST)
{
ps[p].vel.XY() += actor->hitang.ToVector() * actor->hitextra * 0.25;
getPlayer(p)->vel.XY() += actor->hitang.ToVector() * actor->hitextra * 0.25;
}
else
{
ps[p].vel.XY() += actor->hitang.ToVector() * actor->hitextra * 0.125;
getPlayer(p)->vel.XY() += actor->hitang.ToVector() * actor->hitextra * 0.125;
}
}
else
@ -228,7 +228,7 @@ int ifhitbyweapon_d(DDukeActor *actor)
|| actor->hitextra >= 0
|| actor->spr.extra > 0
|| !actor->isPlayer()
|| ps[actor->PlayerIndex()].numloogs > 0
|| getPlayer(actor->PlayerIndex())->numloogs > 0
|| hitowner == nullptr)
{
actor->hitextra = -1;
@ -238,12 +238,12 @@ int ifhitbyweapon_d(DDukeActor *actor)
{
p = actor->PlayerIndex();
actor->spr.extra = 0;
ps[p].wackedbyactor = hitowner;
getPlayer(p)->wackedbyactor = hitowner;
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...
if (hitowner->isPlayer() && hitowner != getPlayer(p)->GetActor())
getPlayer(p)->frag_ps = hitowner->PlayerIndex(); // set the proper player index here - this previously set the sprite index...
actor->SetHitOwner(ps[p].GetActor());
actor->SetHitOwner(getPlayer(p)->GetActor());
actor->hitextra = -1;
return 0;
@ -287,11 +287,11 @@ void movetransports_d(void)
{
int p = act2->PlayerIndex();
ps[p].on_warping_sector = 1;
getPlayer(p)->on_warping_sector = 1;
if (ps[p].transporter_hold == 0 && ps[p].jumping_counter == 0)
if (getPlayer(p)->transporter_hold == 0 && getPlayer(p)->jumping_counter == 0)
{
if (ps[p].on_ground && sectlotag == ST_0_NO_EFFECT && onfloorz && ps[p].jetpack_on == 0)
if (getPlayer(p)->on_ground && sectlotag == ST_0_NO_EFFECT && onfloorz && getPlayer(p)->jetpack_on == 0)
{
if (act->spr.pal == 0)
{
@ -300,27 +300,27 @@ void movetransports_d(void)
}
for (int k = connecthead; k >= 0; k = connectpoint2[k])
if (ps[k].cursector == Owner->sector())
if (getPlayer(k)->cursector == Owner->sector())
{
ps[k].frag_ps = p;
ps[k].GetActor()->spr.extra = 0;
getPlayer(k)->frag_ps = p;
getPlayer(k)->GetActor()->spr.extra = 0;
}
ps[p].GetActor()->PrevAngles.Yaw = ps[p].GetActor()->spr.Angles.Yaw = Owner->spr.Angles.Yaw;
getPlayer(p)->GetActor()->PrevAngles.Yaw = getPlayer(p)->GetActor()->spr.Angles.Yaw = Owner->spr.Angles.Yaw;
if (Owner->GetOwner() != Owner)
{
act->counter = 13;
Owner->counter = 13;
ps[p].transporter_hold = 13;
getPlayer(p)->transporter_hold = 13;
}
ps[p].GetActor()->spr.pos = Owner->spr.pos;
ps[p].GetActor()->backuppos();
ps[p].setbobpos();
getPlayer(p)->GetActor()->spr.pos = Owner->spr.pos;
getPlayer(p)->GetActor()->backuppos();
getPlayer(p)->setbobpos();
ChangeActorSect(act2, Owner->sector());
ps[p].setCursector(act2->sector());
getPlayer(p)->setCursector(act2->sector());
if (act->spr.pal == 0)
{
@ -331,25 +331,25 @@ void movetransports_d(void)
break;
}
}
else if (!(sectlotag == ST_1_ABOVE_WATER && ps[p].on_ground == 1)) break;
else if (!(sectlotag == ST_1_ABOVE_WATER && getPlayer(p)->on_ground == 1)) break;
if (onfloorz == 0 && fabs(act->spr.pos.Z - ps[p].GetActor()->getOffsetZ()) < 24)
if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].input.uvel > 0)) ||
(ps[p].jetpack_on && (PlayerInput(p, SB_CROUCH) || ps[p].input.uvel < 0)))
if (onfloorz == 0 && fabs(act->spr.pos.Z - getPlayer(p)->GetActor()->getOffsetZ()) < 24)
if ((getPlayer(p)->jetpack_on == 0) || (getPlayer(p)->jetpack_on && (PlayerInput(p, SB_JUMP) || getPlayer(p)->input.uvel > 0)) ||
(getPlayer(p)->jetpack_on && (PlayerInput(p, SB_CROUCH) || getPlayer(p)->input.uvel < 0)))
{
ps[p].GetActor()->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY();
ps[p].GetActor()->backupvec2();
getPlayer(p)->GetActor()->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY();
getPlayer(p)->GetActor()->backupvec2();
if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11))
ps[p].GetActor()->spr.pos.Z = Owner->spr.pos.Z - 24 + gs.playerheight;
else ps[p].GetActor()->spr.pos.Z = Owner->spr.pos.Z + 24 + gs.playerheight;
ps[p].GetActor()->backupz();
if (getPlayer(p)->jetpack_on && (PlayerInput(p, SB_JUMP) || getPlayer(p)->jetpack_on < 11))
getPlayer(p)->GetActor()->spr.pos.Z = Owner->spr.pos.Z - 24 + gs.playerheight;
else getPlayer(p)->GetActor()->spr.pos.Z = Owner->spr.pos.Z + 24 + gs.playerheight;
getPlayer(p)->GetActor()->backupz();
auto pa = ps[p].GetActor();
pa->opos = ps[p].GetActor()->getPosWithOffsetZ();
auto pa = getPlayer(p)->GetActor();
pa->opos = getPlayer(p)->GetActor()->getPosWithOffsetZ();
ChangeActorSect(act2, Owner->sector());
ps[p].setCursector(Owner->sector());
getPlayer(p)->setCursector(Owner->sector());
break;
}
@ -358,24 +358,24 @@ void movetransports_d(void)
if (ud.mapflags & MFLAG_ALLSECTORTYPES)
{
if (onfloorz && sectlotag == ST_160_FLOOR_TELEPORT && ps[p].GetActor()->getOffsetZ() > sectp->floorz - 48)
if (onfloorz && sectlotag == ST_160_FLOOR_TELEPORT && getPlayer(p)->GetActor()->getOffsetZ() > sectp->floorz - 48)
{
k = 2;
ps[p].GetActor()->spr.pos.Z = Owner->sector()->ceilingz + 7 + gs.playerheight;
ps[p].GetActor()->backupz();
getPlayer(p)->GetActor()->spr.pos.Z = Owner->sector()->ceilingz + 7 + gs.playerheight;
getPlayer(p)->GetActor()->backupz();
}
if (onfloorz && sectlotag == ST_161_CEILING_TELEPORT && ps[p].GetActor()->getOffsetZ() < sectp->ceilingz + 6)
if (onfloorz && sectlotag == ST_161_CEILING_TELEPORT && getPlayer(p)->GetActor()->getOffsetZ() < sectp->ceilingz + 6)
{
k = 2;
if (ps[p].GetActor()->spr.extra <= 0) break;
ps[p].GetActor()->spr.pos.Z = Owner->sector()->floorz - 49 + gs.playerheight;
ps[p].GetActor()->backupz();
if (getPlayer(p)->GetActor()->spr.extra <= 0) break;
getPlayer(p)->GetActor()->spr.pos.Z = Owner->sector()->floorz - 49 + gs.playerheight;
getPlayer(p)->GetActor()->backupz();
}
}
if (onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].on_ground && ps[p].GetActor()->getOffsetZ() > (sectp->floorz - 16) && (PlayerInput(p, SB_CROUCH) || ps[p].input.uvel < 0 || ps[p].vel.Z > 8))
if (onfloorz && sectlotag == ST_1_ABOVE_WATER && getPlayer(p)->on_ground && getPlayer(p)->GetActor()->getOffsetZ() > (sectp->floorz - 16) && (PlayerInput(p, SB_CROUCH) || getPlayer(p)->input.uvel < 0 || getPlayer(p)->vel.Z > 8))
// if( onfloorz && sectlotag == 1 && ps[p].pos.z > (sectp->floorz-(6<<8)) )
{
k = 1;
@ -383,18 +383,18 @@ void movetransports_d(void)
{
FX_StopAllSounds();
}
if (ps[p].GetActor()->spr.extra > 0)
if (getPlayer(p)->GetActor()->spr.extra > 0)
S_PlayActorSound(DUKE_UNDERWATER, act2);
ps[p].GetActor()->spr.pos.Z = Owner->sector()->ceilingz + 7 + gs.playerheight;
ps[p].GetActor()->backupz();
getPlayer(p)->GetActor()->spr.pos.Z = Owner->sector()->ceilingz + 7 + gs.playerheight;
getPlayer(p)->GetActor()->backupz();
// this is actually below the precision óf the original Build coordinate system...
ps[p].vel.X = ((krand() & 8192) ? 1 / 64. : -1 / 64.);
ps[p].vel.Y = ((krand() & 8192) ? 1 / 64. : -1 / 64.);
getPlayer(p)->vel.X = ((krand() & 8192) ? 1 / 64. : -1 / 64.);
getPlayer(p)->vel.Y = ((krand() & 8192) ? 1 / 64. : -1 / 64.);
}
if (onfloorz && sectlotag == ST_2_UNDERWATER && ps[p].GetActor()->getOffsetZ() < (sectp->ceilingz + 6))
if (onfloorz && sectlotag == ST_2_UNDERWATER && getPlayer(p)->GetActor()->getOffsetZ() < (sectp->ceilingz + 6))
{
k = 1;
// if( act2->spr.extra <= 0) break;
@ -404,21 +404,21 @@ void movetransports_d(void)
}
S_PlayActorSound(DUKE_GASP, act2);
ps[p].GetActor()->spr.pos.Z = Owner->sector()->floorz - 7 + gs.playerheight;
ps[p].GetActor()->backupz();
getPlayer(p)->GetActor()->spr.pos.Z = Owner->sector()->floorz - 7 + gs.playerheight;
getPlayer(p)->GetActor()->backupz();
ps[p].jumping_toggle = 1;
ps[p].jumping_counter = 0;
getPlayer(p)->jumping_toggle = 1;
getPlayer(p)->jumping_counter = 0;
}
if (k == 1)
{
ps[p].GetActor()->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY();
ps[p].GetActor()->backupvec2();
getPlayer(p)->GetActor()->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY();
getPlayer(p)->GetActor()->backupvec2();
if (!Owner || Owner->GetOwner() != Owner)
ps[p].transporter_hold = -2;
ps[p].setCursector(Owner->sector());
getPlayer(p)->transporter_hold = -2;
getPlayer(p)->setCursector(Owner->sector());
ChangeActorSect(act2, Owner->sector());
SetActor(act2, act2->spr.pos);
@ -429,18 +429,18 @@ void movetransports_d(void)
if (sectlotag == ST_1_ABOVE_WATER)
for (int l = 0; l < 9; l++)
{
auto q = spawn(ps[p].GetActor(), DukeWaterBubbleClass);
auto q = spawn(getPlayer(p)->GetActor(), DukeWaterBubbleClass);
if (q) q->spr.pos.Z += krandf(64);
}
}
else if (k == 2)
{
ps[p].GetActor()->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY();
ps[p].GetActor()->backupvec2();
getPlayer(p)->GetActor()->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY();
getPlayer(p)->GetActor()->backupvec2();
if (Owner->GetOwner() != Owner)
ps[p].transporter_hold = -2;
ps[p].setCursector(Owner->sector());
getPlayer(p)->transporter_hold = -2;
getPlayer(p)->setCursector(Owner->sector());
ChangeActorSect(act2, Owner->sector());
}
@ -545,7 +545,7 @@ static void handle_se28(DDukeActor* actor)
if (actor->temp_data[2] > actor->temp_data[1])
{
actor->counter = 0;
ps[screenpeek].visibility = ud.const_visibility;
getPlayer(screenpeek)->visibility = ud.const_visibility;
return;
}
else if (actor->temp_data[2] == (actor->temp_data[1] >> 1))
@ -563,13 +563,13 @@ static void handle_se28(DDukeActor* actor)
}
else if (actor->temp_data[2] > (actor->temp_data[1] >> 3) && actor->temp_data[2] < (actor->temp_data[1] >> 2))
{
int j = !!cansee(actor->spr.pos, actor->sector(), ps[screenpeek].GetActor()->getPosWithOffsetZ(), ps[screenpeek].cursector);
int j = !!cansee(actor->spr.pos, actor->sector(), getPlayer(screenpeek)->GetActor()->getPosWithOffsetZ(), getPlayer(screenpeek)->cursector);
if (rnd(192) && (actor->temp_data[2] & 1))
{
if (j) ps[screenpeek].visibility = 0;
if (j) getPlayer(screenpeek)->visibility = 0;
}
else if (j) ps[screenpeek].visibility = ud.const_visibility;
else if (j) getPlayer(screenpeek)->visibility = ud.const_visibility;
DukeStatIterator it(STAT_DEFAULT);
while (auto act2 = it.Next())
@ -583,7 +583,7 @@ static void handle_se28(DDukeActor* actor)
double x;
int p = findplayer(actor, &x);
auto psa = ps[p].GetActor();
auto psa = getPlayer(p)->GetActor();
double dist = (psa->spr.pos.XY() - act2->spr.pos.XY()).LengthSquared();
if (dist < 49*48)
{
@ -591,7 +591,7 @@ static void handle_se28(DDukeActor* actor)
S_PlayActorSound(DUKE_LONGTERM_PAIN, psa);
S_PlayActorSound(SHORT_CIRCUIT, psa);
psa->spr.extra -= 8 + (krand() & 7);
SetPlayerPal(&ps[p], PalEntry(32, 16, 0, 0));
SetPlayerPal(getPlayer(p), PalEntry(32, 16, 0, 0));
}
return;
}

View file

@ -349,14 +349,14 @@ void operatejaildoors(int hitag)
jd.open = 1;
jd.drag = jd.dist;
if (!isRRRA() || jd.sound != 0)
S_PlayActorSound(jd.sound, ps[screenpeek].GetActor());
S_PlayActorSound(jd.sound, getPlayer(screenpeek)->GetActor());
}
if (jd.open == 2)
{
jd.open = 3;
jd.drag = jd.dist;
if (!isRRRA() || jd.sound != 0)
S_PlayActorSound(jd.sound, ps[screenpeek].GetActor());
S_PlayActorSound(jd.sound, getPlayer(screenpeek)->GetActor());
}
}
}
@ -458,7 +458,7 @@ void thunder(void)
int i = 0;
uint8_t shade;
p = &ps[screenpeek];
p = getPlayer(screenpeek);
if (!thunderflash)
{
@ -474,7 +474,7 @@ void thunder(void)
if (seen)
{
if (ps[screenpeek].GetActor()->sector()->ceilingstat & CSTAT_SECTOR_SKY)
if (getPlayer(screenpeek)->GetActor()->sector()->ceilingstat & CSTAT_SECTOR_SKY)
{
g_relvisibility = 0;
if (krand() > 65000)

View file

@ -187,23 +187,23 @@ int ifhitbyweapon_r(DDukeActor *actor)
{
actor->spr.extra = 0;
ps[p].wackedbyactor = hitowner;
getPlayer(p)->wackedbyactor = hitowner;
if (hitowner->isPlayer() && p != hitowner->PlayerIndex())
{
ps[p].frag_ps = hitowner->PlayerIndex();
getPlayer(p)->frag_ps = hitowner->PlayerIndex();
}
actor->SetHitOwner(ps[p].GetActor());
actor->SetHitOwner(getPlayer(p)->GetActor());
}
}
if (adef->flags2 & SFLAG2_DOUBLEDMGTHRUST)
{
ps[p].vel.XY() += actor->hitang.ToVector() * actor->hitextra * 0.25;
getPlayer(p)->vel.XY() += actor->hitang.ToVector() * actor->hitextra * 0.25;
}
else
{
ps[p].vel.XY() += actor->hitang.ToVector() * actor->hitextra * 0.125;
getPlayer(p)->vel.XY() += actor->hitang.ToVector() * actor->hitextra * 0.125;
}
}
else
@ -265,37 +265,37 @@ void movetransports_r(void)
{
int p = act2->PlayerIndex();
ps[p].on_warping_sector = 1;
getPlayer(p)->on_warping_sector = 1;
if (ps[p].transporter_hold == 0 && ps[p].jumping_counter == 0)
if (getPlayer(p)->transporter_hold == 0 && getPlayer(p)->jumping_counter == 0)
{
if (ps[p].on_ground && sectlotag == ST_0_NO_EFFECT && onfloorz && ps[p].jetpack_on == 0)
if (getPlayer(p)->on_ground && sectlotag == ST_0_NO_EFFECT && onfloorz && getPlayer(p)->jetpack_on == 0)
{
spawn(act, DukeTransporterBeamClass);
S_PlayActorSound(TELEPORTER, act);
for (int k = connecthead; k >= 0; k = connectpoint2[k])
if (ps[k].cursector == Owner->sector())
if (getPlayer(k)->cursector == Owner->sector())
{
ps[k].frag_ps = p;
ps[k].GetActor()->spr.extra = 0;
getPlayer(k)->frag_ps = p;
getPlayer(k)->GetActor()->spr.extra = 0;
}
ps[p].GetActor()->PrevAngles.Yaw = ps[p].GetActor()->spr.Angles.Yaw = Owner->spr.Angles.Yaw;
getPlayer(p)->GetActor()->PrevAngles.Yaw = getPlayer(p)->GetActor()->spr.Angles.Yaw = Owner->spr.Angles.Yaw;
if (Owner->GetOwner() != Owner)
{
act->counter = 13;
Owner->counter = 13;
ps[p].transporter_hold = 13;
getPlayer(p)->transporter_hold = 13;
}
ps[p].GetActor()->spr.pos = Owner->spr.pos.plusZ(4);
ps[p].GetActor()->backuppos();
ps[p].setbobpos();
getPlayer(p)->GetActor()->spr.pos = Owner->spr.pos.plusZ(4);
getPlayer(p)->GetActor()->backuppos();
getPlayer(p)->setbobpos();
ChangeActorSect(act2, Owner->sector());
ps[p].setCursector(act2->sector());
getPlayer(p)->setCursector(act2->sector());
auto beam = spawn(Owner, DukeTransporterBeamClass);
if (beam) S_PlayActorSound(TELEPORTER, beam);
@ -305,20 +305,20 @@ void movetransports_r(void)
}
else break;
if (onfloorz == 0 && fabs(act->spr.pos.Z - ps[p].GetActor()->getOffsetZ()) < 24)
if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].input.uvel > 0)) ||
(ps[p].jetpack_on && (PlayerInput(p, SB_CROUCH) || ps[p].input.uvel < 0)))
if (onfloorz == 0 && fabs(act->spr.pos.Z - getPlayer(p)->GetActor()->getOffsetZ()) < 24)
if ((getPlayer(p)->jetpack_on == 0) || (getPlayer(p)->jetpack_on && (PlayerInput(p, SB_JUMP) || getPlayer(p)->input.uvel > 0)) ||
(getPlayer(p)->jetpack_on && (PlayerInput(p, SB_CROUCH) || getPlayer(p)->input.uvel < 0)))
{
ps[p].GetActor()->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY();
ps[p].GetActor()->backupvec2();
getPlayer(p)->GetActor()->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY();
getPlayer(p)->GetActor()->backupvec2();
if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11))
ps[p].GetActor()->spr.pos.Z = Owner->spr.pos.Z - 24 + gs.playerheight;
else ps[p].GetActor()->spr.pos.Z = Owner->spr.pos.Z + 24 + gs.playerheight;
ps[p].GetActor()->backupz();
if (getPlayer(p)->jetpack_on && (PlayerInput(p, SB_JUMP) || getPlayer(p)->jetpack_on < 11))
getPlayer(p)->GetActor()->spr.pos.Z = Owner->spr.pos.Z - 24 + gs.playerheight;
else getPlayer(p)->GetActor()->spr.pos.Z = Owner->spr.pos.Z + 24 + gs.playerheight;
getPlayer(p)->GetActor()->backupz();
ChangeActorSect(act2, Owner->sector());
ps[p].setCursector(Owner->sector());
getPlayer(p)->setCursector(Owner->sector());
break;
}
@ -327,60 +327,60 @@ void movetransports_r(void)
if (ud.mapflags & MFLAG_ALLSECTORTYPES)
{
if (onfloorz && sectlotag == ST_160_FLOOR_TELEPORT && ps[p].GetActor()->getOffsetZ() > sectp->floorz - 48)
if (onfloorz && sectlotag == ST_160_FLOOR_TELEPORT && getPlayer(p)->GetActor()->getOffsetZ() > sectp->floorz - 48)
{
k = 2;
ps[p].GetActor()->spr.pos.Z = Owner->sector()->ceilingz + 7 + gs.playerheight;
ps[p].GetActor()->backupz();
getPlayer(p)->GetActor()->spr.pos.Z = Owner->sector()->ceilingz + 7 + gs.playerheight;
getPlayer(p)->GetActor()->backupz();
}
if (onfloorz && sectlotag == ST_161_CEILING_TELEPORT && ps[p].GetActor()->getOffsetZ() < sectp->ceilingz + 6)
if (onfloorz && sectlotag == ST_161_CEILING_TELEPORT && getPlayer(p)->GetActor()->getOffsetZ() < sectp->ceilingz + 6)
{
k = 2;
if (ps[p].GetActor()->spr.extra <= 0) break;
ps[p].GetActor()->spr.pos.Z = Owner->sector()->floorz - 49 + gs.playerheight;
ps[p].GetActor()->backupz();
if (getPlayer(p)->GetActor()->spr.extra <= 0) break;
getPlayer(p)->GetActor()->spr.pos.Z = Owner->sector()->floorz - 49 + gs.playerheight;
getPlayer(p)->GetActor()->backupz();
}
}
if ((onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].GetActor()->getOffsetZ() > sectp->floorz - 6) ||
(onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].OnMotorcycle))
if ((onfloorz && sectlotag == ST_1_ABOVE_WATER && getPlayer(p)->GetActor()->getOffsetZ() > sectp->floorz - 6) ||
(onfloorz && sectlotag == ST_1_ABOVE_WATER && getPlayer(p)->OnMotorcycle))
{
if (ps[p].OnBoat) break;
if (getPlayer(p)->OnBoat) break;
k = 1;
if (screenpeek == p)
{
FX_StopAllSounds();
}
S_PlayActorSound(DUKE_UNDERWATER, ps[p].GetActor());
ps[p].GetActor()->spr.pos.Z = Owner->sector()->ceilingz + 7 + gs.playerheight;
ps[p].GetActor()->backupz();
if (ps[p].OnMotorcycle)
ps[p].moto_underwater = 1;
S_PlayActorSound(DUKE_UNDERWATER, getPlayer(p)->GetActor());
getPlayer(p)->GetActor()->spr.pos.Z = Owner->sector()->ceilingz + 7 + gs.playerheight;
getPlayer(p)->GetActor()->backupz();
if (getPlayer(p)->OnMotorcycle)
getPlayer(p)->moto_underwater = 1;
}
if (onfloorz && sectlotag == ST_2_UNDERWATER && ps[p].GetActor()->getOffsetZ() < sectp->ceilingz + 6)
if (onfloorz && sectlotag == ST_2_UNDERWATER && getPlayer(p)->GetActor()->getOffsetZ() < sectp->ceilingz + 6)
{
k = 1;
if (ps[p].GetActor()->spr.extra <= 0) break;
if (getPlayer(p)->GetActor()->spr.extra <= 0) break;
if (screenpeek == p)
{
FX_StopAllSounds();
}
S_PlayActorSound(DUKE_GASP, act2);
ps[p].GetActor()->spr.pos.Z = Owner->sector()->floorz - 7 + gs.playerheight;
ps[p].GetActor()->backupz();
getPlayer(p)->GetActor()->spr.pos.Z = Owner->sector()->floorz - 7 + gs.playerheight;
getPlayer(p)->GetActor()->backupz();
}
if (k == 1)
{
ps[p].GetActor()->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY();
ps[p].GetActor()->backupvec2();
getPlayer(p)->GetActor()->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY();
getPlayer(p)->GetActor()->backupvec2();
if (!Owner || Owner->GetOwner() != Owner)
ps[p].transporter_hold = -2;
ps[p].setCursector(Owner->sector());
getPlayer(p)->transporter_hold = -2;
getPlayer(p)->setCursector(Owner->sector());
ChangeActorSect(act2, Owner->sector());
@ -389,12 +389,12 @@ void movetransports_r(void)
}
else if (k == 2)
{
ps[p].GetActor()->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY();
ps[p].GetActor()->backupvec2();
getPlayer(p)->GetActor()->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY();
getPlayer(p)->GetActor()->backupvec2();
if (Owner->GetOwner() != Owner)
ps[p].transporter_hold = -2;
ps[p].setCursector(Owner->sector());
getPlayer(p)->transporter_hold = -2;
getPlayer(p)->setCursector(Owner->sector());
ChangeActorSect(act2, Owner->sector());
}
@ -445,10 +445,10 @@ static void rrra_specialstats()
movesprite_ex(act, DVector3(0, 0, act->spr.extra / 256.), CLIPMASK0, coll);
}
if (ps[screenpeek].MamaEnd > 0)
if (getPlayer(screenpeek)->MamaEnd > 0)
{
ps[screenpeek].MamaEnd--;
if (ps[screenpeek].MamaEnd == 0)
getPlayer(screenpeek)->MamaEnd--;
if (getPlayer(screenpeek)->MamaEnd == 0)
{
CompleteLevel(nullptr);
}

View file

@ -49,7 +49,7 @@ void drawshadows(tspriteArray& tsprites, tspritetype* t, DDukeActor* h)
floorz = h->floorz;
if (h->spr.pos.Z - floorz < 8 && ps[screenpeek].GetActor()->getOffsetZ() < floorz)
if (h->spr.pos.Z - floorz < 8 && getPlayer(screenpeek)->GetActor()->getOffsetZ() < floorz)
{
auto shadowspr = tsprites.newTSprite();
*shadowspr = *t;
@ -74,7 +74,7 @@ void drawshadows(tspriteArray& tsprites, tspritetype* t, DDukeActor* h)
else
{
// Alter the shadow's position so that it appears behind the sprite itself.
auto look = (shadowspr->pos.XY() - ps[screenpeek].GetActor()->spr.pos.XY()).Angle();
auto look = (shadowspr->pos.XY() - getPlayer(screenpeek)->GetActor()->spr.pos.XY()).Angle();
shadowspr->pos.XY() += look.ToVector() * 2;
}
}
@ -219,7 +219,7 @@ void applyanimations(tspritetype* t, DDukeActor* h, const DVector2& viewVec, DAn
{
if (t->spritetexture() == h->spr.spritetexture())
{
ps[screenpeek].visibility = -127;
getPlayer(screenpeek)->visibility = -127;
lastvisinc = PlayClock + 32;
}
}

View file

@ -90,7 +90,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
}
if (t->statnum == STAT_TEMP) continue;
auto pp = &ps[h->PlayerIndex()];
auto pp = getPlayer(h->PlayerIndex());
if ((h->spr.statnum != STAT_ACTOR && h->isPlayer() && pp->newOwner == nullptr && h->GetOwner()) || !(h->flags1 & SFLAG_NOINTERPOLATE))
{
t->pos = h->interpolatedpos(interpfrac);
@ -121,7 +121,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
if (t->pal == 1) t->pos.Z -= 18;
if (ps[p].over_shoulder_on > 0 && ps[p].newOwner == nullptr)
if (getPlayer(p)->over_shoulder_on > 0 && getPlayer(p)->newOwner == nullptr)
{
t->cstat |= CSTAT_SPRITE_TRANSLUCENT;
#if 0 // multiplayer only
@ -134,7 +134,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
#endif
}
if ((display_mirror == 1 || screenpeek != p || !h->GetOwner()) && ud.multimode > 1 && cl_showweapon && ps[p].GetActor()->spr.extra > 0 && ps[p].curr_weapon > 0)
if ((display_mirror == 1 || screenpeek != p || !h->GetOwner()) && ud.multimode > 1 && cl_showweapon && getPlayer(p)->GetActor()->spr.extra > 0 && getPlayer(p)->curr_weapon > 0)
{
auto newtspr = tsprites.newTSprite();
*newtspr = *t;
@ -147,7 +147,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
newtspr->cstat = 0;
const char* texname = nullptr;
switch (ps[p].curr_weapon)
switch (getPlayer(p)->curr_weapon)
{
case PISTOL_WEAPON: texname = "FIRSTGUNSPRITE"; break;
case SHOTGUN_WEAPON: texname = "SHOTGUNSPRITE"; break;
@ -164,9 +164,9 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
}
t->setspritetexture(TexMan.CheckForTexture(texname, ETextureType::Any));
if (h->GetOwner()) newtspr->pos.Z = ps[p].GetActor()->getOffsetZ() - 12;
if (h->GetOwner()) newtspr->pos.Z = getPlayer(p)->GetActor()->getOffsetZ() - 12;
else newtspr->pos.Z = h->spr.pos.Z - 51;
if (ps[p].curr_weapon == HANDBOMB_WEAPON)
if (getPlayer(p)->curr_weapon == HANDBOMB_WEAPON)
{
newtspr->scale = DVector2(0.15625, 0.15625);
}
@ -187,19 +187,19 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
applyRotation1(h, t, viewang, base);
t->pal = ps[p].palookup;
t->pal = getPlayer(p)->palookup;
continue;
}
if (ps[p].on_crane == nullptr && (h->sector()->lotag & 0x7ff) != 1)
if (getPlayer(p)->on_crane == nullptr && (h->sector()->lotag & 0x7ff) != 1)
{
double v = h->spr.pos.Z - ps[p].GetActor()->floorz + 3;
double v = h->spr.pos.Z - getPlayer(p)->GetActor()->floorz + 3;
if (v > 4 && h->spr.scale.Y > 0.5 && h->spr.extra > 0)
h->spr.yoffset = (int8_t)(v / h->spr.scale.Y);
else h->spr.yoffset = 0;
}
if (ud.cameraactor == nullptr && ps[p].newOwner == nullptr)
if (h->GetOwner() && display_mirror == 0 && ps[p].over_shoulder_on == 0)
if (ud.cameraactor == nullptr && getPlayer(p)->newOwner == nullptr)
if (h->GetOwner() && display_mirror == 0 && getPlayer(p)->over_shoulder_on == 0)
if (ud.multimode < 2 || (ud.multimode > 1 && p == screenpeek))
{
t->ownerActor = nullptr;
@ -221,7 +221,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
if (h->spr.statnum == STAT_DUMMYPLAYER || badguy(h) || (h->isPlayer() && h->GetOwner()))
{
drawshadows(tsprites, t, h);
if (ps[screenpeek].heat_amount > 0 && ps[screenpeek].heat_on)
if (getPlayer(screenpeek)->heat_amount > 0 && getPlayer(screenpeek)->heat_on)
{
t->pal = 6;
t->shade = 0;

View file

@ -83,7 +83,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
}
if (t->statnum == STAT_TEMP) continue;
auto pp = &ps[h->PlayerIndex()];
auto pp = getPlayer(h->PlayerIndex());
if (h->spr.statnum != STAT_ACTOR && h->isPlayer() && pp->newOwner == nullptr && h->GetOwner())
{
t->pos = h->interpolatedpos(interpfrac);
@ -120,7 +120,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
if (t->pal == 1) t->pos.Z -= 18;
if (ps[p].over_shoulder_on > 0 && ps[p].newOwner == nullptr)
if (getPlayer(p)->over_shoulder_on > 0 && getPlayer(p)->newOwner == nullptr)
{
t->cstat |= CSTAT_SPRITE_TRANSLUCENT;
#if 0 // multiplayer only
@ -133,7 +133,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
#endif
}
if ((display_mirror == 1 || screenpeek != p || !h->GetOwner()) && ud.multimode > 1 && cl_showweapon && ps[p].GetActor()->spr.extra > 0 && ps[p].curr_weapon > 0)
if ((display_mirror == 1 || screenpeek != p || !h->GetOwner()) && ud.multimode > 1 && cl_showweapon && getPlayer(p)->GetActor()->spr.extra > 0 && getPlayer(p)->curr_weapon > 0)
{
auto newtspr = tsprites.newTSprite();
*newtspr = *t;
@ -146,7 +146,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
newtspr->cstat = 0;
const char* texname = nullptr;
switch (ps[p].curr_weapon)
switch (getPlayer(p)->curr_weapon)
{
case PISTOL_WEAPON: texname = "FIRSTGUNSPRITE"; break;
case SHOTGUN_WEAPON: texname = "SHOTGUNSPRITE"; break;
@ -164,13 +164,13 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
}
t->setspritetexture(TexMan.CheckForTexture(texname, ETextureType::Any));
if (h->GetOwner()) newtspr->pos.Z = ps[p].GetActor()->getOffsetZ() - 12;
if (h->GetOwner()) newtspr->pos.Z = getPlayer(p)->GetActor()->getOffsetZ() - 12;
else newtspr->pos.Z = h->spr.pos.Z - 51;
if (ps[p].curr_weapon == HANDBOMB_WEAPON)
if (getPlayer(p)->curr_weapon == HANDBOMB_WEAPON)
{
newtspr->scale = DVector2(0.15625, 0.15625);
}
else if (ps[p].OnMotorcycle || ps[p].OnBoat)
else if (getPlayer(p)->OnMotorcycle || getPlayer(p)->OnBoat)
{
newtspr->scale = DVector2(0, 0);
}
@ -181,16 +181,16 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
newtspr->pal = 0;
}
if (ps[p].on_crane == nullptr && (h->sector()->lotag & 0x7ff) != 1)
if (getPlayer(p)->on_crane == nullptr && (h->sector()->lotag & 0x7ff) != 1)
{
double v = h->spr.pos.Z - ps[p].GetActor()->floorz + 3;
double v = h->spr.pos.Z - getPlayer(p)->GetActor()->floorz + 3;
if (v > 4 && h->spr.scale.Y > 0.5 && h->spr.extra > 0)
h->spr.yoffset = (int8_t)(v / h->spr.scale.Y);
else h->spr.yoffset = 0;
}
if (ud.cameraactor == nullptr && ps[p].newOwner == nullptr)
if (h->GetOwner() && display_mirror == 0 && ps[p].over_shoulder_on == 0)
if (ud.cameraactor == nullptr && getPlayer(p)->newOwner == nullptr)
if (h->GetOwner() && display_mirror == 0 && getPlayer(p)->over_shoulder_on == 0)
if (ud.multimode < 2 || (ud.multimode > 1 && p == screenpeek))
{
t->ownerActor = nullptr;
@ -201,14 +201,14 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
if (t->pos.Z > h->floorz && t->scale.X < 0.5)
t->pos.Z = h->floorz;
if (ps[p].OnMotorcycle && p == screenpeek)
if (getPlayer(p)->OnMotorcycle && p == screenpeek)
{
t->setspritetexture(TexMan.CheckForTexture("PLAYERONBIKEBACK", ETextureType::Any));
t->scale = DVector2(0.28125, 0.28125);
drawshadows(tsprites, t, h);
continue;
}
else if (ps[p].OnMotorcycle)
else if (getPlayer(p)->OnMotorcycle)
{
t->setspritetexture(TexMan.CheckForTexture("PLAYERONBIKE", ETextureType::Any));
applyRotation2(h, t, viewang);
@ -216,14 +216,14 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
drawshadows(tsprites, t, h);
continue;
}
else if (ps[p].OnBoat && p == screenpeek)
else if (getPlayer(p)->OnBoat && p == screenpeek)
{
t->setspritetexture(TexMan.CheckForTexture("PLAYERONBOATBACK", ETextureType::Any));
t->scale = DVector2(0.5, 0.5);
drawshadows(tsprites, t, h);
continue;
}
else if (ps[p].OnBoat)
else if (getPlayer(p)->OnBoat)
{
t->setspritetexture(TexMan.CheckForTexture("PLAYERONBOAT", ETextureType::Any));
k = angletorotation2(h->spr.Angles.Yaw, viewang);

View file

@ -108,8 +108,8 @@ static int ccmd_spawn(CCmdFuncPtr parm)
}
DDukeActor* spawned;
if (!cls) spawned = spawnsprite(ps[myconnectindex].GetActor(), picno);
else spawned = spawn(ps[myconnectindex].GetActor(), cls);
if (!cls) spawned = spawnsprite(getPlayer(myconnectindex)->GetActor(), picno);
else spawned = spawn(getPlayer(myconnectindex)->GetActor(), cls);
if (spawned)
{
if (set & 1) spawned->spr.pal = (uint8_t)pal;
@ -131,17 +131,17 @@ static int ccmd_spawn(CCmdFuncPtr parm)
void GameInterface::ToggleThirdPerson()
{
if (gamestate != GS_LEVEL) return;
if (!isRRRA() || (!ps[myconnectindex].OnMotorcycle && !ps[myconnectindex].OnBoat))
if (!isRRRA() || (!getPlayer(myconnectindex)->OnMotorcycle && !getPlayer(myconnectindex)->OnBoat))
{
if (ps[myconnectindex].over_shoulder_on)
ps[myconnectindex].over_shoulder_on = 0;
if (getPlayer(myconnectindex)->over_shoulder_on)
getPlayer(myconnectindex)->over_shoulder_on = 0;
else
{
ps[myconnectindex].over_shoulder_on = 1;
getPlayer(myconnectindex)->over_shoulder_on = 1;
cameradist = 0;
cameraclock = INT_MIN;
}
FTA(QUOTE_VIEW_MODE_OFF + ps[myconnectindex].over_shoulder_on, &ps[myconnectindex]);
FTA(QUOTE_VIEW_MODE_OFF + getPlayer(myconnectindex)->over_shoulder_on, getPlayer(myconnectindex));
}
}
@ -159,12 +159,12 @@ void GameInterface::ToggleShowWeapon()
{
if (gamestate != GS_LEVEL) return;
cl_showweapon = cl_showweapon == 0;
FTA(QUOTE_WEAPON_MODE_OFF - cl_showweapon, &ps[screenpeek]);
FTA(QUOTE_WEAPON_MODE_OFF - cl_showweapon, getPlayer(screenpeek));
}
bool GameInterface::WantEscape()
{
return ps[myconnectindex].newOwner != nullptr;
return getPlayer(myconnectindex)->newOwner != nullptr;
}

View file

@ -50,7 +50,7 @@ BEGIN_DUKE_NS
const char *GameInterface::CheckCheatMode()
{
if (sv_cheats && (ud.player_skill == 4 || (isRR() && ud.player_skill > 3) || (isRRRA() && ps[myconnectindex].nocheat)))
if (sv_cheats && (ud.player_skill == 4 || (isRR() && ud.player_skill > 3) || (isRRRA() && getPlayer(myconnectindex)->nocheat)))
{
return quoteMgr.GetQuote(QUOTE_CHEATS_DISABLED);
}
@ -63,7 +63,7 @@ static const char *cheatGod(int myconnectindex, int state)
if (state == -1) state = !ud.god;
ud.god = state;
auto* p = &ps[myconnectindex];
auto* p = getPlayer(myconnectindex);
auto act = p->GetActor();
act->spr.extra = gs.max_player_health;
@ -83,7 +83,7 @@ static const char *cheatGod(int myconnectindex, int state)
act->spr.hitag = 0;
act->spr.lotag = 0;
act->spr.pal =
ps[myconnectindex].palookup;
getPlayer(myconnectindex)->palookup;
return quoteMgr.GetQuote(QUOTE_CHEAT_GODMODE_ON);
}
@ -92,7 +92,7 @@ static const char *cheatGod(int myconnectindex, int state)
ud.god = 0;
act->spr.extra = gs.max_player_health;
act->hitextra = -1;
ps[myconnectindex].last_extra = gs.max_player_health;
getPlayer(myconnectindex)->last_extra = gs.max_player_health;
return quoteMgr.GetQuote(QUOTE_CHEAT_GODMODE_OFF);
}
}
@ -108,10 +108,10 @@ static const char* cheatUnlock()
{
if (j & (0xffff - 16384))
sect.lotag &= (0xffff - 16384);
operatesectors(&sect, ps[myconnectindex].GetActor());
operatesectors(&sect, getPlayer(myconnectindex)->GetActor());
}
}
operateforcefields(ps[myconnectindex].GetActor(), -1);
operateforcefields(getPlayer(myconnectindex)->GetActor(), -1);
return quoteMgr.GetQuote(QUOTE_CHEAT_UNLOCK);
}
@ -119,7 +119,7 @@ static const char *cheatKfc(int player)
{
for (int i = 0; i < 7; i++)
{
auto spr = spawn(ps[player].GetActor(), RedneckHenClass);
auto spr = spawn(getPlayer(player)->GetActor(), RedneckHenClass);
if (spr)
{
spr->spr.pal = 1;
@ -165,24 +165,24 @@ const char* GameInterface::GenericCheat(int player, int cheat)
return nullptr;
case CHT_HYPER:
ps[player].steroids_amount = 399;
getPlayer(player)->steroids_amount = 399;
return quoteMgr.GetQuote(QUOTE_CHEAT_STEROIDS);
case CHT_KILL:
quickkill(&ps[player]);
quickkill(getPlayer(player));
return quoteMgr.GetQuote(QUOTE_CHEAT_KILL);
case CHT_MONSTERS:
return cheatMonsters();
case CHT_BIKE:
OnMotorcycle(&ps[player]);
ps[player].ammo_amount[MOTORCYCLE_WEAPON] = gs.max_ammo_amount[MOTORCYCLE_WEAPON];
OnMotorcycle(getPlayer(player));
getPlayer(player)->ammo_amount[MOTORCYCLE_WEAPON] = gs.max_ammo_amount[MOTORCYCLE_WEAPON];
return quoteMgr.GetQuote(QUOTE_ON_BIKE);
case CHT_BOAT:
OnBoat(&ps[player]);
ps[player].ammo_amount[BOAT_WEAPON] = gs.max_ammo_amount[BOAT_WEAPON];
OnBoat(getPlayer(player));
getPlayer(player)->ammo_amount[BOAT_WEAPON] = gs.max_ammo_amount[BOAT_WEAPON];
return quoteMgr.GetQuote(QUOTE_ON_BOAT);
case CHT_TONY:
@ -195,27 +195,27 @@ const char* GameInterface::GenericCheat(int player, int cheat)
case CHT_RHETT:
ud.god = 0;
memset(ps[player].gotweapon, 0, sizeof(ps[player].gotweapon));
ps[player].curr_weapon = KNEE_WEAPON;
ps[player].nocheat = 1;
ps[player].GetActor()->spr.extra = 1;
memset(getPlayer(player)->gotweapon, 0, sizeof(getPlayer(player)->gotweapon));
getPlayer(player)->curr_weapon = KNEE_WEAPON;
getPlayer(player)->nocheat = 1;
getPlayer(player)->GetActor()->spr.extra = 1;
return quoteMgr.GetQuote(QUOTE_YERFUCKED);
case CHT_AARON:
ps[player].DrugMode = !ps[player].DrugMode;
getPlayer(player)->DrugMode = !getPlayer(player)->DrugMode;
return nullptr;
case CHT_NOCHEAT:
ps[player].nocheat = 1;
getPlayer(player)->nocheat = 1;
return quoteMgr.GetQuote(QUOTE_NOCHEATS);
case CHT_DRINK:
ps[player].drink_amt = ps[player].drink_amt ? 0 : 90;
return quoteMgr.GetQuote(ps[player].drink_amt ? QUOTE_INSTADRUNK : QUOTE_INSTASOBER);
getPlayer(player)->drink_amt = getPlayer(player)->drink_amt ? 0 : 90;
return quoteMgr.GetQuote(getPlayer(player)->drink_amt ? QUOTE_INSTADRUNK : QUOTE_INSTASOBER);
case CHT_SEASICK:
ps[player].sea_sick_stat = !ps[player].sea_sick_stat;
return quoteMgr.GetQuote(ps[player].sea_sick_stat ? QUOTE_BOATMODEON : QUOTE_BOATMODEOFF);
getPlayer(player)->sea_sick_stat = !getPlayer(player)->sea_sick_stat;
return quoteMgr.GetQuote(getPlayer(player)->sea_sick_stat ? QUOTE_BOATMODEON : QUOTE_BOATMODEOFF);
case CHT_KFC:
return cheatKfc(player);
@ -231,11 +231,11 @@ static bool cheatWeapons(int player)
for (int weapon = PISTOL_WEAPON; weapon < weaponLimit; weapon++ )
{
addammo( weapon, &ps[player], gs.max_ammo_amount[weapon] );
ps[player].gotweapon[weapon] = true;;
addammo( weapon, getPlayer(player), gs.max_ammo_amount[weapon] );
getPlayer(player)->gotweapon[weapon] = true;;
}
if (isRRRA())
ps[player].ammo_amount[SLINGBLADE_WEAPON] = 1;
getPlayer(player)->ammo_amount[SLINGBLADE_WEAPON] = 1;
return true;
}
@ -252,22 +252,22 @@ static bool cheatInventory(int player)
}
};
invGet(400, EVENT_CHEATGETSTEROIDS, ps[player].steroids_amount);
if (!isRR()) invGet(1200, EVENT_CHEATGETHEAT, ps[player].heat_amount);
invGet(isRR() ? 2000 : 200, EVENT_CHEATGETBOOT, ps[player].boot_amount);
invGet(100, EVENT_CHEATGETSHIELD, ps[player].shield_amount);
invGet(6400, EVENT_CHEATGETSCUBA, ps[player].scuba_amount);
invGet(2400, EVENT_CHEATGETHOLODUKE, ps[player].holoduke_amount);
invGet(isRR() ? 600 : 1600, EVENT_CHEATGETJETPACK, ps[player].jetpack_amount);
invGet(gs.max_player_health, EVENT_CHEATGETFIRSTAID, ps[player].firstaid_amount);
invGet(400, EVENT_CHEATGETSTEROIDS, getPlayer(player)->steroids_amount);
if (!isRR()) invGet(1200, EVENT_CHEATGETHEAT, getPlayer(player)->heat_amount);
invGet(isRR() ? 2000 : 200, EVENT_CHEATGETBOOT, getPlayer(player)->boot_amount);
invGet(100, EVENT_CHEATGETSHIELD, getPlayer(player)->shield_amount);
invGet(6400, EVENT_CHEATGETSCUBA, getPlayer(player)->scuba_amount);
invGet(2400, EVENT_CHEATGETHOLODUKE, getPlayer(player)->holoduke_amount);
invGet(isRR() ? 600 : 1600, EVENT_CHEATGETJETPACK, getPlayer(player)->jetpack_amount);
invGet(gs.max_player_health, EVENT_CHEATGETFIRSTAID, getPlayer(player)->firstaid_amount);
return true;
}
static bool cheatKeys(int player)
{
ps[player].got_access = 7;
getPlayer(player)->got_access = 7;
if (isRR()) for (int ikey = 0; ikey < 5; ikey++)
ps[player].keys[ikey] = 1;
getPlayer(player)->keys[ikey] = 1;
return true;
}
@ -325,26 +325,26 @@ static bool cheatDebug(cheatseq_t*)
static bool cheatAllen(cheatseq_t*)
{
FTA(79, &ps[myconnectindex]);
FTA(79, getPlayer(myconnectindex));
return true;
}
static bool cheatBeta(cheatseq_t *)
{
FTA(105,&ps[myconnectindex]);
FTA(105,getPlayer(myconnectindex));
return true;
}
static bool cheatTodd(cheatseq_t *)
{
FTA(99,&ps[myconnectindex]);
FTA(99,getPlayer(myconnectindex));
return true;
}
static bool cheatMap(cheatseq_t *)
{
gFullMap = !gFullMap;
FTA(gFullMap? 111 : 1, &ps[myconnectindex]);
FTA(gFullMap? 111 : 1, getPlayer(myconnectindex));
return true;
}
@ -474,7 +474,7 @@ static void cmd_Give(int player, uint8_t** stream, bool skip)
int type = ReadByte(stream);
if (skip) return;
if (numplayers != 1 || gamestate != GS_LEVEL || ps[player].GetActor()->spr.extra <= 0)
if (numplayers != 1 || gamestate != GS_LEVEL || getPlayer(player)->GetActor()->spr.extra <= 0)
{
Printf("give: Cannot give while dead or not in a single-player game.\n");
return;
@ -484,43 +484,43 @@ static void cmd_Give(int player, uint8_t** stream, bool skip)
{
case GIVE_ALL:
cheatStuff(player);
FTA(5, &ps[player]);
FTA(5, getPlayer(player));
break;
case GIVE_HEALTH:
ps[player].GetActor()->spr.extra = gs.max_player_health << 1;
getPlayer(player)->GetActor()->spr.extra = gs.max_player_health << 1;
break;
case GIVE_WEAPONS:
cheatWeapons(player);
FTA(119, &ps[player]);
FTA(119, getPlayer(player));
break;
case GIVE_AMMO:
{
int maxw = isShareware() ? SHRINKER_WEAPON : MAX_WEAPONS;
for (int i = maxw; i >= PISTOL_WEAPON; i--)
addammo(i, &ps[player], gs.max_ammo_amount[i]);
addammo(i, getPlayer(player), gs.max_ammo_amount[i]);
break;
}
case GIVE_ARMOR:
ps[player].shield_amount = 100;
getPlayer(player)->shield_amount = 100;
break;
case GIVE_KEYS:
cheatKeys(player);
FTA(121, &ps[player]);
FTA(121, getPlayer(player));
break;
case GIVE_INVENTORY:
cheatInventory(player);
FTA(120, &ps[player]);
FTA(120, getPlayer(player));
break;
case GIVE_ITEMS:
cheatItems(player);
FTA(5, &ps[player]);
FTA(5, getPlayer(player));
break;
}
}

View file

@ -91,7 +91,7 @@ void GameInterface::MenuSound(EMenuSounds snd)
bool GameInterface::CanSave()
{
if (ud.recstat == 2) return false;
auto pActor = ps[myconnectindex].GetActor();
auto pActor = getPlayer(myconnectindex)->GetActor();
return (pActor && pActor->spr.extra > 0);
}

View file

@ -19,7 +19,7 @@
BEGIN_DUKE_NS
extern DukePlayer ps[MAXPLAYERS];
extern DukePlayer PlayerArray[MAXPLAYERS];
struct GameInterface : public ::GameInterface
{
@ -39,7 +39,7 @@ struct GameInterface : public ::GameInterface
void SerializeGameState(FSerializer& arc) override;
void ExitFromMenu() override;
void DrawPlayerSprite(const DVector2& origin, bool onteam) override;
void reapplyInputBits(InputPacket* const input) override { input->actions |= ps[myconnectindex].input.actions & SB_CENTERVIEW; }
void reapplyInputBits(InputPacket* const input) override { input->actions |= PlayerArray[myconnectindex].input.actions & SB_CENTERVIEW; }
void doPlayerMovement(const float scaleAdjust) override;
unsigned getCrouchState() override;
void UpdateSounds() override;
@ -53,7 +53,7 @@ struct GameInterface : public ::GameInterface
void NewGame(MapRecord* map, int skill, bool) override;
void LevelCompleted(MapRecord* map, int skill) override;
bool DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos, const DAngle cang, const DVector2& xydim, const double czoom, double const interpfrac) override;
DCoreActor* getConsoleActor() override { return ps[myconnectindex].GetActor(); }
DCoreActor* getConsoleActor() override { return PlayerArray[myconnectindex].GetActor(); }
void ToggleThirdPerson() override;
void SwitchCoopView() override;
void ToggleShowWeapon() override;

View file

@ -83,7 +83,7 @@ static void markgcroots()
GC::MarkArray(spriteq, 1024);
GC::Mark(currentCommentarySprite);
GC::Mark(ud.cameraactor);
for (auto& pl : ps)
for (auto& pl : PlayerArray)
{
GC::Mark(pl.actor);
GC::Mark(pl.actorsqu);
@ -408,7 +408,7 @@ void GameInterface::app_init()
ud.wchoice[0][9] = 1;
ud.multimode = 1;
ud.m_monsters_off = userConfig.nomonsters;
ps[0].aim_mode = 1;
getPlayer(0)->aim_mode = 1;
ud.cameraactor = nullptr;
if (fileSystem.FileExists("DUKESW.BIN"))
@ -711,7 +711,7 @@ bool CallShootThis(DDukeActor* clsdef, DDukeActor* actor, int pn, const DVector3
VMReturn ret(&rv);
IFVIRTUALPTR(clsdef, DDukeActor, ShootThis)
{
VMValue val[] = {clsdef, actor, pn >= 0? &ps[pn] : nullptr, spos.X, spos.Y, spos.Z, sang.Degrees()};
VMValue val[] = {clsdef, actor, pn >= 0? getPlayer(pn) : nullptr, spos.X, spos.Y, spos.Z, sang.Degrees()};
VMCall(func, val, 7, &ret, 1);
}
return rv;
@ -905,7 +905,7 @@ CCMD(changewalltexture)
FTextureID tile = TexMan.CheckForTexture(argv[1], ETextureType::Any);
if (!tile.isValid()) tile = tileGetTextureID((int)strtol(argv[1], nullptr, 10));
HitInfoBase hit;
hitscan(ps[0].GetActor()->spr.pos, ps[0].cursector, DVector3(ps[0].GetActor()->spr.Angles.Yaw.ToVector(), 0) * 1024, hit, CLIPMASK1);
hitscan(getPlayer(0)->GetActor()->spr.pos, getPlayer(0)->cursector, DVector3(getPlayer(0)->GetActor()->spr.Angles.Yaw.ToVector(), 0) * 1024, hit, CLIPMASK1);
if (hit.hitWall)
{
hit.hitWall->setwalltexture(tile);

View file

@ -105,7 +105,7 @@ void FTA(int q, DukePlayer* p)
{
p->ftq = q;
auto qu = quoteMgr.GetQuote(q);
if (p == &ps[screenpeek] && qu[0] != '\0')
if (p == getPlayer(screenpeek) && qu[0] != '\0')
{
#if 0
if (q >= 70 && q <= 72)
@ -191,7 +191,7 @@ void V_AddBlend (float r, float g, float b, float a, float v_blend[4])
void drawweapon(double interpfrac)
{
auto pp = &ps[screenpeek];
auto pp = getPlayer(screenpeek);
if (!isRR() && pp->newOwner != nullptr)
cameratext(pp->newOwner);
else
@ -215,7 +215,7 @@ void drawoverlays(double interpfrac)
DVector2 cposxy;
DAngle cang;
pp = &ps[screenpeek];
pp = getPlayer(screenpeek);
// set palette here, in case the 3D view is off.
setgamepalette(setpal(pp));
@ -270,10 +270,10 @@ void drawoverlays(double interpfrac)
DrawStatusBar();
if (ps[myconnectindex].newOwner == nullptr && ud.cameraactor == nullptr)
if (getPlayer(myconnectindex)->newOwner == nullptr && ud.cameraactor == nullptr)
{
auto offsets = pp->Angles.getCrosshairOffsets(interpfrac);
DrawCrosshair(ps[screenpeek].last_extra, offsets.first.X, offsets.first.Y + (pp->over_shoulder_on ? 2.5 : 0), isRR() ? 0.5 : 1, offsets.second);
DrawCrosshair(getPlayer(screenpeek)->last_extra, offsets.first.X, offsets.first.Y + (pp->over_shoulder_on ? 2.5 : 0), isRR() ? 0.5 : 1, offsets.second);
}
if (paused == 2)
@ -377,7 +377,7 @@ bool GameInterface::DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos,
DukeSectIterator it(ii);
while (auto act = it.Next())
{
if (act == ps[screenpeek].GetActor() || (act->spr.cstat & CSTAT_SPRITE_INVISIBLE) || act->spr.cstat == CSTAT_SPRITE_BLOCK_ALL || act->spr.scale.X == 0) continue;
if (act == getPlayer(screenpeek)->GetActor() || (act->spr.cstat & CSTAT_SPRITE_INVISIBLE) || act->spr.cstat == CSTAT_SPRITE_BLOCK_ALL || act->spr.scale.X == 0) continue;
if ((act->spr.cstat & CSTAT_SPRITE_BLOCK_ALL) != 0)
{
@ -410,16 +410,16 @@ bool GameInterface::DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos,
{
if (p == screenpeek || ud.coop == 1)
{
auto& pp = ps[p];
auto act = pp.GetActor();
auto pp = getPlayer(p);
auto act = pp->GetActor();
basetex = basetex + (act->vel.X > 1 && pp.on_ground ? (PlayClock >> 4) & 3 : 0);
double j = clamp(czoom * act->spr.scale.Y + abs(pp.truefz - act->getOffsetZ()) * REPEAT_SCALE, (1. / 3.), 2.);
basetex = basetex + (act->vel.X > 1 && pp->on_ground ? (PlayClock >> 4) & 3 : 0);
double j = clamp(czoom * act->spr.scale.Y + abs(pp->truefz - act->getOffsetZ()) * REPEAT_SCALE, (1. / 3.), 2.);
auto const vec = OutAutomapVector(mxy - cpos, cangvect, czoom, xydim);
auto const daang = -(pp.Angles.getCameraAngles().Yaw - cang).Normalized360().Degrees();
auto const daang = -(pp->Angles.getCameraAngles().Yaw - cang).Normalized360().Degrees();
DrawTexture(twod, basetex, false, vec.X, vec.Y, DTA_TranslationIndex, TRANSLATION(Translation_Remap + setpal(&pp), act->spr.pal), DTA_CenterOffset, true,
DrawTexture(twod, basetex, false, vec.X, vec.Y, DTA_TranslationIndex, TRANSLATION(Translation_Remap + setpal(pp), act->spr.pal), DTA_CenterOffset, true,
DTA_Rotate, daang, DTA_Color, shadeToLight(act->spr.shade), DTA_ScaleX, j, DTA_ScaleY, j, TAG_DONE);
}
}

File diff suppressed because it is too large Load diff

View file

@ -64,8 +64,8 @@ void GameInterface::Ticker(const ticcmd_t* playercmds)
// this must be done before the view is backed up.
for (int i = connecthead; i >= 0; i = connectpoint2[i])
{
ps[i].Angles.resetCameraAngles();
ps[i].input = playercmds[i].ucmd;
getPlayer(i)->Angles.resetCameraAngles();
getPlayer(i)->input = playercmds[i].ucmd;
}
// disable synchronised input if set by game.
@ -83,7 +83,7 @@ void GameInterface::Ticker(const ticcmd_t* playercmds)
for (int i = connecthead; i >= 0; i = connectpoint2[i])
{
auto p = &ps[i];
auto p = getPlayer(i);
if (p->pals.a > 0)
p->pals.a--;
@ -118,7 +118,7 @@ void GameInterface::Ticker(const ticcmd_t* playercmds)
void GameInterface::Startup()
{
ps[myconnectindex].ftq = 0;
getPlayer(myconnectindex)->ftq = 0;
PlayLogos(ga_mainmenunostopsound, ga_mainmenunostopsound, false);
}

View file

@ -268,7 +268,7 @@ void ResetGameVars(void)
{
if (aGameVars[i].dwFlags & (GAMEVAR_FLAG_PERPLAYER))
{
for (auto &pl : ps)
for (auto &pl : PlayerArray)
{
pl.uservars[aGameVars[i].indexValue] = aGameVars[i].defaultValue;
}
@ -307,7 +307,7 @@ GameVarValue GetGameVarID(int id, DDukeActor* sActor, int sPlayer)
{
// for the current player
if (sPlayer >= 0 && sPlayer < MAXPLAYERS)
return ps[sPlayer].uservars[aGameVars[id].indexValue];
return getPlayer(sPlayer)->uservars[aGameVars[id].indexValue];
return aGameVars[id].initValue;
}
@ -367,12 +367,12 @@ void SetGameVarID(int id, GameVarValue lValue, DDukeActor* sActor, int sPlayer)
if (sPlayer >= 0)
{
if (sPlayer < MAXPLAYERS)
ps[sPlayer].uservars[aGameVars[id].indexValue] = lValue;
getPlayer(sPlayer)->uservars[aGameVars[id].indexValue] = lValue;
}
else
{
for (int i = connecthead; i >= 0; i = connectpoint2[i])
ps[i].uservars[aGameVars[id].indexValue] = lValue; // set for all players
getPlayer(i)->uservars[aGameVars[id].indexValue] = lValue; // set for all players
aGameVars[id].initValue = lValue;
}
}
@ -520,21 +520,21 @@ static int i_aplWeaponFireSound[MAX_WEAPONS]; // Sound made when firing (each ti
static int i_aplWeaponSound2Time[MAX_WEAPONS]; // Alternate sound time
static int i_aplWeaponSound2Sound[MAX_WEAPONS]; // Alternate sound sound ID
int aplWeaponClip(int weapon, int player) { return ps[player].uservars[i_aplWeaponClip[weapon]].safeValue(); }
int aplWeaponReload(int weapon, int player) { return ps[player].uservars[i_aplWeaponReload[weapon]].safeValue(); }
int aplWeaponFireDelay(int weapon, int player) { return ps[player].uservars[i_aplWeaponFireDelay[weapon]].safeValue(); }
int aplWeaponHoldDelay(int weapon, int player) { return ps[player].uservars[i_aplWeaponHoldDelay[weapon]].safeValue(); }
int aplWeaponTotalTime(int weapon, int player) { return ps[player].uservars[i_aplWeaponTotalTime[weapon]].safeValue(); }
int aplWeaponFlags(int weapon, int player) { return ps[player].uservars[i_aplWeaponFlags[weapon]].safeValue(); }
int aplWeaponShoots(int weapon, int player) { return ps[player].uservars[i_aplWeaponShoots[weapon]].safeValue(); }
int aplWeaponSpawnTime(int weapon, int player) { return ps[player].uservars[i_aplWeaponSpawnTime[weapon]].safeValue(); }
int aplWeaponSpawn(int weapon, int player) { return ps[player].uservars[i_aplWeaponSpawn[weapon]].safeValue(); }
int aplWeaponShotsPerBurst(int weapon, int player) { return ps[player].uservars[i_aplWeaponShotsPerBurst[weapon]].safeValue(); }
int aplWeaponWorksLike(int weapon, int player) { return ps[player].uservars[i_aplWeaponWorksLike[weapon]].safeValue(); }
int aplWeaponInitialSound(int weapon, int player) { return ps[player].uservars[i_aplWeaponInitialSound[weapon]].safeValue(); }
int aplWeaponFireSound(int weapon, int player) { return ps[player].uservars[i_aplWeaponFireSound[weapon]].safeValue(); }
int aplWeaponSound2Time(int weapon, int player) { return ps[player].uservars[i_aplWeaponSound2Time[weapon]].safeValue(); }
int aplWeaponSound2Sound(int weapon, int player) { return ps[player].uservars[i_aplWeaponSound2Sound[weapon]].safeValue(); }
int aplWeaponClip(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponClip[weapon]].safeValue(); }
int aplWeaponReload(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponReload[weapon]].safeValue(); }
int aplWeaponFireDelay(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponFireDelay[weapon]].safeValue(); }
int aplWeaponHoldDelay(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponHoldDelay[weapon]].safeValue(); }
int aplWeaponTotalTime(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponTotalTime[weapon]].safeValue(); }
int aplWeaponFlags(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponFlags[weapon]].safeValue(); }
int aplWeaponShoots(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponShoots[weapon]].safeValue(); }
int aplWeaponSpawnTime(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponSpawnTime[weapon]].safeValue(); }
int aplWeaponSpawn(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponSpawn[weapon]].safeValue(); }
int aplWeaponShotsPerBurst(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponShotsPerBurst[weapon]].safeValue(); }
int aplWeaponWorksLike(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponWorksLike[weapon]].safeValue(); }
int aplWeaponInitialSound(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponInitialSound[weapon]].safeValue(); }
int aplWeaponFireSound(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponFireSound[weapon]].safeValue(); }
int aplWeaponSound2Time(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponSound2Time[weapon]].safeValue(); }
int aplWeaponSound2Sound(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponSound2Sound[weapon]].safeValue(); }
//---------------------------------------------------------------------------
//
@ -1222,7 +1222,7 @@ void FinalizeGameVars(void)
aGameVars[i].indexValue = actorNdx++;
}
}
for (auto& pl : ps) pl.uservars.Resize(weapNdx);
for (auto& pl : PlayerArray) pl.uservars.Resize(weapNdx);
ResetGameVars();
numActorVars = actorNdx;

View file

@ -46,7 +46,7 @@ DukeGameInfo gs;
int screenpeek;
// serialized
DukePlayer ps[MAXPLAYERS];
DukePlayer PlayerArray[MAXPLAYERS];
//-------------------------------------------------------------------------
//

View file

@ -70,7 +70,7 @@ extern int screenpeek;
// Variables that must be saved
extern int rtsplaying;
extern DukePlayer ps[MAXPLAYERS];
extern DukePlayer PlayerArray[MAXPLAYERS];
extern int spriteqamount;
extern int lastvisinc;
extern animwalltype animwall[MAXANIMWALLS];

View file

@ -141,7 +141,7 @@ static bool animateknuckles(int gs, DukePlayer* p, double xoffset, double yoffse
void displaymasks_d(int snum, int p, double interpfrac)
{
if (ps[snum].scuba_on)
if (getPlayer(snum)->scuba_on)
{
auto scuba0 = TexMan.CheckForTexture("SCUBAMASK", ETextureType::Any);
auto tex0 = TexMan.GetGameTexture(scuba0);
@ -204,7 +204,7 @@ static bool animateaccess(int gs, DukePlayer* p, double xoffset, double yoffset,
void animateshrunken(DukePlayer* p, double xoffset, double yoffset, int8_t shade, int o, double interpfrac)
{
const double fistsign = BobVal(interpolatedvalue<double>(p->ofistsign, p->fistsign, interpfrac)) * 16;
int pal = ps[screenpeek].cursector->floorpal;
int pal = getPlayer(screenpeek)->cursector->floorpal;
if (p->jetpack_on == 0) yoffset += 32 - (p->GetActor()->vel.X * 8);
hud_drawpal(250 + fistsign + xoffset, 258 - fabs(fistsign * 4) + yoffset, "FIST", shade, o, pal, nullAngle);
hud_drawpal(40 - fistsign + xoffset, 200 + fabs(fistsign * 4) + yoffset, "FIST", shade, o | 4, pal, nullAngle);
@ -220,7 +220,7 @@ void animateshrunken(DukePlayer* p, double xoffset, double yoffset, int8_t shade
void displayweapon_d(int snum, double interpfrac)
{
int pal, pal2;
DukePlayer* p = &ps[snum];
DukePlayer* p = getPlayer(snum);
if (p->newOwner != nullptr || ud.cameraactor != nullptr || p->over_shoulder_on > 0 || (p->GetActor()->spr.pal != 1 && p->GetActor()->spr.extra <= 0))
return;

View file

@ -52,7 +52,7 @@ inline static void hud_drawpal(double x, double y, const char* tilenum, int shad
void displaymasks_r(int snum, int p, double interpfrac)
{
if (ps[snum].scuba_on)
if (getPlayer(snum)->scuba_on)
{
auto scuba0 = TexMan.CheckForTexture("SCUBAMASK0", ETextureType::Any);
auto scuba3 = TexMan.CheckForTexture("SCUBAMASK3", ETextureType::Any);
@ -215,7 +215,7 @@ void displayweapon_r(int snum, double interpfrac)
double weapon_sway, gun_pos, hard_landing;
DAngle TiltStatus;
auto p = &ps[snum];
auto p = getPlayer(snum);
auto kb = &p->kickback_pic;
int o = 0;

View file

@ -10,6 +10,11 @@
// all inline functions.
BEGIN_DUKE_NS
inline DukePlayer* getPlayer(int index)
{
return &PlayerArray[index];
}
inline int rnd(int X)
{
return ((krand() >> 8) >= (255 - (X)));
@ -79,7 +84,7 @@ inline int checkcursectnums(sectortype* se)
{
int i;
for(i=connecthead;i>=0;i=connectpoint2[i])
if(ps[i].GetActor() && ps[i].GetActor()->sector() == se ) return i;
if(getPlayer(i)->GetActor() && getPlayer(i)->GetActor()->sector() == se ) return i;
return -1;
}
@ -103,60 +108,60 @@ inline bool isIn(int value, const std::initializer_list<int>& list)
// these are mainly here to avoid directly accessing the input data so that it can be more easily refactored later.
inline bool PlayerInput(int pl, ESyncBits bit)
{
return (!!((ps[pl].input.actions) & bit));
return (!!((getPlayer(pl)->input.actions) & bit));
}
inline ESyncBits PlayerInputBits(int pl, ESyncBits bits)
{
return (ps[pl].input.actions & bits);
return (getPlayer(pl)->input.actions & bits);
}
inline void PlayerSetInput(int pl, ESyncBits bit)
{
ps[pl].input.actions |= bit;
getPlayer(pl)->input.actions |= bit;
}
inline int PlayerNewWeapon(int pl)
{
return ps[pl].input.getNewWeapon();
return getPlayer(pl)->input.getNewWeapon();
}
inline void PlayerSetItemUsed(int pl, int num)
{
ps[pl].input.setItemUsed(num - 1);
getPlayer(pl)->input.setItemUsed(num - 1);
}
inline bool PlayerUseItem(int pl, int num)
{
return ps[pl].input.isItemUsed(num - 1);
return getPlayer(pl)->input.isItemUsed(num - 1);
}
inline float PlayerInputSideVel(int pl)
{
return ps[pl].input.svel;
return getPlayer(pl)->input.svel;
}
inline float PlayerInputForwardVel(int pl)
{
return ps[pl].input.fvel;
return getPlayer(pl)->input.fvel;
}
inline float PlayerInputAngVel(int pl)
{
return ps[pl].input.avel;
return getPlayer(pl)->input.avel;
}
inline DAngle GetPlayerHorizon(int pl)
{
return DAngle::fromDeg(ps[pl].input.horz);
return DAngle::fromDeg(getPlayer(pl)->input.horz);
}
inline void clearfriction()
{
for (int i = 0; i != -1; i = connectpoint2[i])
{
ps[i].fric.X = ps[i].fric.Y = 0;
getPlayer(i)->fric.X = getPlayer(i)->fric.Y = 0;
}
}
@ -273,7 +278,7 @@ inline int monsterCheatCheck(DDukeActor* self)
inline void processinputvel(int snum)
{
const auto p = &ps[snum];
const auto p = getPlayer(snum);
const auto velvect = DVector2(p->input.fvel, p->input.svel).Rotated(p->GetActor()->spr.Angles.Yaw) + p->fric;
p->input.fvel = (float)velvect.X;
p->input.svel = (float)velvect.Y;

View file

@ -56,7 +56,7 @@ void hud_input(int plnum)
uint8_t dainv;
DukePlayer* p;
p = &ps[plnum];
p = getPlayer(plnum);
auto pact = p->GetActor();
i = p->aim_mode;
@ -496,7 +496,7 @@ void hud_input(int plnum)
unsigned GameInterface::getCrouchState()
{
const auto p = &ps[myconnectindex];
const auto p = getPlayer(myconnectindex);
const int sectorLotag = p->insector() ? p->cursector->lotag : 0;
const int crouchable = sectorLotag != ST_2_UNDERWATER && (sectorLotag != ST_1_ABOVE_WATER || p->spritebridge) && !p->jetpack_on;
const int disableToggle = (!crouchable && p->on_ground) || p->jetpack_on || (isRRRA() && (p->OnMotorcycle || p->OnBoat));
@ -511,7 +511,7 @@ unsigned GameInterface::getCrouchState()
void GameInterface::doPlayerMovement(const float scaleAdjust)
{
auto const p = &ps[myconnectindex];
auto const p = getPlayer(myconnectindex);
if (isRRRA() && (p->OnMotorcycle || p->OnBoat))
{

View file

@ -33,7 +33,7 @@ BEGIN_DUKE_NS
int madenoise(int snum)
{
DukePlayer *p;
p = &ps[snum];
p = getPlayer(snum);
p->donoise = 1;
p->noise = p->GetActor()->spr.pos.XY();
return 1;
@ -41,7 +41,7 @@ int madenoise(int snum)
int wakeup(DDukeActor* actor, int snum)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
if (!p->donoise)
return 0;
if (actor->spr.pal == 30 || actor->spr.pal == 32 || actor->spr.pal == 33 || (isRRRA() && actor->spr.pal == 8))

View file

@ -59,17 +59,17 @@ void PlayerColorChanged(void)
if (ud.recstat != 0)
return;
auto& pp = ps[myconnectindex];
auto pp = getPlayer(myconnectindex);
if (ud.multimode > 1)
{
//Net_SendClientInfo();
}
else
{
pp.palookup = ud.user_pals[myconnectindex] = playercolor2lookup(playercolor);
pp->palookup = ud.user_pals[myconnectindex] = playercolor2lookup(playercolor);
}
if (pp.GetActor()->isPlayer() && pp.GetActor()->spr.pal != 1)
pp.GetActor()->spr.pal = ud.user_pals[myconnectindex];
if (pp->GetActor()->isPlayer() && pp->GetActor()->spr.pal != 1)
pp->GetActor()->spr.pal = ud.user_pals[myconnectindex];
}
//---------------------------------------------------------------------------
@ -203,7 +203,7 @@ DDukeActor* aim(DDukeActor* actor, int abase, bool force, bool* b)
// Autoaim from DukeGDX.
if (actor->isPlayer())
{
auto* plr = &ps[actor->PlayerIndex()];
auto* plr = getPlayer(actor->PlayerIndex());
int autoaim = force? 1 : Autoaim(actor->PlayerIndex());
bool ww2gipistol = (plr->curr_weapon == PISTOL_WEAPON && isWW2GI());
@ -267,13 +267,13 @@ DDukeActor* aim(DDukeActor* actor, int abase, bool force, bool* b)
}
else if (isWW2GI())
{
gotshrinker = actor->isPlayer() && aplWeaponWorksLike(ps[actor->PlayerIndex()].curr_weapon, actor->PlayerIndex()) == SHRINKER_WEAPON;
gotfreezer = actor->isPlayer() && aplWeaponWorksLike(ps[actor->PlayerIndex()].curr_weapon, actor->PlayerIndex()) == FREEZE_WEAPON;
gotshrinker = actor->isPlayer() && aplWeaponWorksLike(getPlayer(actor->PlayerIndex())->curr_weapon, actor->PlayerIndex()) == SHRINKER_WEAPON;
gotfreezer = actor->isPlayer() && aplWeaponWorksLike(getPlayer(actor->PlayerIndex())->curr_weapon, actor->PlayerIndex()) == FREEZE_WEAPON;
}
else
{
gotshrinker = actor->isPlayer() && ps[actor->PlayerIndex()].curr_weapon == SHRINKER_WEAPON;
gotfreezer = actor->isPlayer() && ps[actor->PlayerIndex()].curr_weapon == FREEZE_WEAPON;
gotshrinker = actor->isPlayer() && getPlayer(actor->PlayerIndex())->curr_weapon == SHRINKER_WEAPON;
gotfreezer = actor->isPlayer() && getPlayer(actor->PlayerIndex())->curr_weapon == FREEZE_WEAPON;
}
double smax = 0x7fffffff;
@ -318,7 +318,7 @@ DDukeActor* aim(DDukeActor* actor, int abase, bool force, bool* b)
if (actor->isPlayer())
{
double checkval = (act->spr.pos.Z - actor->spr.pos.Z) * 1.25 / sdist;
double horiz = ps[actor->PlayerIndex()].Angles.getPitchWithView().Tan();
double horiz = getPlayer(actor->PlayerIndex())->Angles.getPitchWithView().Tan();
check = abs(checkval - horiz) < 0.78125;
}
else check = 1;
@ -354,7 +354,7 @@ DDukeActor* aim_(DDukeActor* actor, DDukeActor* weapon, double aimangle, bool* b
void dokneeattack(int snum)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
auto pact = p->GetActor();
if (p->knee_incs > 0)
@ -382,8 +382,8 @@ void dokneeattack(int snum)
if (p->actorsqu->isPlayer())
{
quickkill(&ps[p->actorsqu->PlayerIndex()]);
ps[p->actorsqu->PlayerIndex()].frag_ps = snum;
quickkill(getPlayer(p->actorsqu->PlayerIndex()));
getPlayer(p->actorsqu->PlayerIndex())->frag_ps = snum;
}
else
{
@ -405,7 +405,7 @@ void dokneeattack(int snum)
int makepainsounds(int snum, int type)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
auto actor = p->GetActor();
int k = 0;
@ -478,7 +478,7 @@ int makepainsounds(int snum, int type)
void footprints(int snum)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
auto actor = p->GetActor();
if (p->footprintcount > 0 && p->on_ground)
@ -521,7 +521,7 @@ void footprints(int snum)
void playerisdead(int snum, int psectlotag, double floorz, double ceilingz)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
auto actor = p->GetActor();
// lock input when dead.
@ -555,8 +555,8 @@ void playerisdead(int snum, int psectlotag, double floorz, double ceilingz)
{
if (p->frag_ps != snum)
{
ps[p->frag_ps].frag++;
ps[p->frag_ps].frags[snum]++;
getPlayer(p->frag_ps)->frag++;
getPlayer(p->frag_ps)->frags[snum]++;
auto pname = PlayerName(p->frag_ps);
if (snum == screenpeek)
@ -615,7 +615,7 @@ void playerisdead(int snum, int psectlotag, double floorz, double ceilingz)
int endoflevel(int snum)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
// the fist puching the end-of-level thing...
p->ofist_incs = p->fist_incs;
@ -644,7 +644,7 @@ int endoflevel(int snum)
int timedexit(int snum)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
p->timebeforeexit--;
if (p->timebeforeexit == 26 * 5)
{
@ -671,7 +671,7 @@ int timedexit(int snum)
void playerCrouch(int snum)
{
const auto p = &ps[snum];
const auto p = getPlayer(snum);
const auto pact = p->GetActor();
const auto nVelMoveDown = abs(p->input.uvel * (p->input.uvel < 0));
constexpr double vel = 8 + 3;
@ -686,7 +686,7 @@ void playerCrouch(int snum)
void playerJump(int snum, double floorz, double ceilingz)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
if (p->jumping_toggle == 0 && p->jumping_counter == 0)
{
if ((floorz - ceilingz) > 56)
@ -820,7 +820,7 @@ void DukePlayer::playerweaponsway(double xvel)
void checklook(int snum, ESyncBits actions)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
if ((actions & SB_LOOK_LEFT) && !p->OnMotorcycle)
{
@ -851,7 +851,7 @@ void checklook(int snum, ESyncBits actions)
void playerCenterView(int snum)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
OnEvent(EVENT_RETURNTOCENTER, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() == 0)
@ -868,7 +868,7 @@ void playerCenterView(int snum)
void playerLookUp(int snum, ESyncBits actions)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
OnEvent(EVENT_LOOKUP, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() == 0)
@ -883,7 +883,7 @@ void playerLookUp(int snum, ESyncBits actions)
void playerLookDown(int snum, ESyncBits actions)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
OnEvent(EVENT_LOOKDOWN, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() == 0)
@ -898,7 +898,7 @@ void playerLookDown(int snum, ESyncBits actions)
void playerAimUp(int snum, ESyncBits actions)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
OnEvent(EVENT_AIMUP, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() != 0)
@ -909,7 +909,7 @@ void playerAimUp(int snum, ESyncBits actions)
void playerAimDown(int snum, ESyncBits actions)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
OnEvent(EVENT_AIMDOWN, snum, p->GetActor(), -1); // due to a typo in WW2GI's CON files this is the same as EVENT_AIMUP.
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() != 0)
@ -936,9 +936,9 @@ void shoot(DDukeActor* actor, PClass* cls)
if (actor->isPlayer())
{
p = actor->PlayerIndex();
spos = actor->getPosWithOffsetZ().plusZ(ps[p].pyoff + 4);
spos = actor->getPosWithOffsetZ().plusZ(getPlayer(p)->pyoff + 4);
ps[p].crack_time = CRACK_TIME;
getPlayer(p)->crack_time = CRACK_TIME;
}
else
{
@ -1000,7 +1000,7 @@ bool movementBlocked(DukePlayer *p)
int haslock(sectortype* sectp, int snum)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
if (!sectp)
return 0;
if (!sectp->lockinfo)
@ -1229,21 +1229,21 @@ int playeraddammo(DukePlayer* p, int weaponindex, int amount)
}
addammo(weaponindex, p, amount);
if (p->curr_weapon == KNEE_WEAPON)
if (p->gotweapon[weaponindex] && (WeaponSwitch(p - ps) & 1))
if (p->gotweapon[weaponindex] && (WeaponSwitch(p - PlayerArray) & 1))
fi.addweapon(p, weaponindex, true);
return true;
}
int playeraddweapon(DukePlayer* p, int weaponindex, int amount)
{
if (p->gotweapon[weaponindex] == 0) fi.addweapon(p, weaponindex, !!(WeaponSwitch(p- ps) & 1));
if (p->gotweapon[weaponindex] == 0) fi.addweapon(p, weaponindex, !!(WeaponSwitch(p- PlayerArray) & 1));
else if (p->ammo_amount[weaponindex] >= gs.max_ammo_amount[weaponindex])
{
return false;
}
addammo(weaponindex, p, amount);
if (p->curr_weapon == KNEE_WEAPON)
if (p->gotweapon[weaponindex] && (WeaponSwitch(p - ps) & 1))
if (p->gotweapon[weaponindex] && (WeaponSwitch(p - PlayerArray) & 1))
fi.addweapon(p, weaponindex, true);
return true;
@ -1327,7 +1327,7 @@ int checkp(DDukeActor* self, DukePlayer* p, int flags)
bool j = 0;
double vel = self->vel.X;
unsigned plindex = unsigned(p - ps);
unsigned plindex = unsigned(p - PlayerArray);
// sigh.. this was yet another place where number literals were used as bit masks for every single value, making the code totally unreadable.
if ((flags & pducking) && p->on_ground && PlayerInput(plindex, SB_CROUCH))
@ -1366,7 +1366,7 @@ int checkp(DDukeActor* self, DukePlayer* p, int flags)
{
DAngle ang;
if (self->isPlayer() && ud.multimode > 1)
ang = absangle(ps[otherp].GetActor()->spr.Angles.Yaw, (p->GetActor()->spr.pos.XY() - ps[otherp].GetActor()->spr.pos.XY()).Angle());
ang = absangle(getPlayer(otherp)->GetActor()->spr.Angles.Yaw, (p->GetActor()->spr.pos.XY() - getPlayer(otherp)->GetActor()->spr.pos.XY()).Angle());
else
ang = absangle(p->GetActor()->spr.Angles.Yaw, (self->spr.pos.XY() - p->GetActor()->spr.pos.XY()).Angle());
@ -1484,7 +1484,7 @@ void playerreset(DukePlayer* p, DDukeActor* g_ac)
else
{
// I am not convinced this is even remotely smart to be executed from here..
pickrandomspot(int(p - ps));
pickrandomspot(int(p - PlayerArray));
g_ac->spr.pos = p->GetActor()->getPosWithOffsetZ();
p->GetActor()->backuppos();
p->setbobpos();
@ -1504,7 +1504,7 @@ void playerreset(DukePlayer* p, DDukeActor* g_ac)
p->wantweaponfire = -1;
p->GetActor()->PrevAngles.Pitch = p->GetActor()->spr.Angles.Pitch = nullAngle;
p->on_crane = nullptr;
p->frag_ps = int(p - ps);
p->frag_ps = int(p - PlayerArray);
p->Angles.PrevViewAngles.Pitch = p->Angles.ViewAngles.Pitch = nullAngle;
p->opyoff = 0;
p->wackedbyactor = nullptr;
@ -1563,8 +1563,8 @@ void playerkick(DukePlayer* p, DDukeActor* g_ac)
{
if (ud.multimode > 1 && g_ac->isPlayer())
{
if (ps[otherp].quick_kick == 0)
ps[otherp].quick_kick = 14;
if (getPlayer(otherp)->quick_kick == 0)
getPlayer(otherp)->quick_kick = 14;
}
else if (!g_ac->isPlayer() && p->quick_kick == 0)
p->quick_kick = 14;
@ -1578,7 +1578,7 @@ void playerkick(DukePlayer* p, DDukeActor* g_ac)
void underwater(int snum, ESyncBits actions, double floorz, double ceilingz)
{
const auto p = &ps[snum];
const auto p = getPlayer(snum);
const auto pact = p->GetActor();
constexpr double dist = (348. / 256.);
const auto kbdDir = ((actions & SB_JUMP) && !p->OnMotorcycle) - ((actions & SB_CROUCH) || p->OnMotorcycle);

View file

@ -89,7 +89,7 @@ void incur_damage_d(DukePlayer* p)
void selectweapon_d(int snum, int weap) // playernum, weaponnum
{
int i, j, k;
auto p = &ps[snum];
auto p = getPlayer(snum);
if (p->last_pissed_time <= (26 * 218) && p->show_empty_weapon == 0 && p->kickback_pic == 0 && p->quick_kick == 0 && p->GetActor()->spr.scale.X > 0.5 && p->access_incs == 0 && p->knee_incs == 0)
{
if ((p->weapon_pos == 0 || (p->holster_weapon && p->weapon_pos == -9)))
@ -577,7 +577,7 @@ void checkweapons_d(DukePlayer* p)
static void operateJetpack(int snum, ESyncBits actions, int psectlotag, double floorz, double ceilingz, int shrunk)
{
const auto p = &ps[snum];
const auto p = getPlayer(snum);
const auto pact = p->GetActor();
const auto kbdDir = !!(actions & SB_JUMP) - !!(actions & SB_CROUCH);
const double dist = shrunk ? 2 : 8;
@ -646,7 +646,7 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, double f
static void movement(int snum, ESyncBits actions, sectortype* psect, double floorz, double ceilingz, int shrunk, double truefdist, int psectlotag)
{
int j;
auto p = &ps[snum];
auto p = getPlayer(snum);
auto pact = p->GetActor();
if (p->airleft != 15 * 26)
@ -830,7 +830,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo
int operateTripbomb(int snum)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
HitInfo hit{};
double vel = 1024, zvel = 0;
setFreeAimVelocity(vel, zvel, p->Angles.getPitchWithView(), 16.);
@ -882,7 +882,7 @@ int operateTripbomb(int snum)
static void fireweapon(int snum)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
auto pact = p->GetActor();
p->crack_time = CRACK_TIME;
@ -1000,7 +1000,7 @@ static void fireweapon(int snum)
static void operateweapon(int snum, ESyncBits actions)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
auto pact = p->GetActor();
// already firing...
@ -1453,7 +1453,7 @@ static void operateweapon(int snum, ESyncBits actions)
static void processweapon(int snum, ESyncBits actions)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
auto pact = p->GetActor();
int shrunk = (pact->spr.scale.Y < 0.5);
@ -1538,7 +1538,7 @@ void processinput_d(int snum)
int psectlotag;
DukePlayer* p;
p = &ps[snum];
p = getPlayer(snum);
auto pact = p->GetActor();
ESyncBits& actions = p->input.actions;
@ -1952,7 +1952,7 @@ HORIZONLY:
if (p->show_empty_weapon > 0)
{
p->show_empty_weapon--;
if (p->show_empty_weapon == 0 && (WeaponSwitch(p - ps) & 2))
if (p->show_empty_weapon == 0 && (WeaponSwitch(p - PlayerArray) & 2))
{
if (p->last_full_weapon == GROW_WEAPON)
p->subweapon |= (1 << GROW_WEAPON);

View file

@ -88,7 +88,7 @@ void incur_damage_r(DukePlayer* p)
void selectweapon_r(int snum, int weap)
{
int i, j, k;
auto p = &ps[snum];
auto p = getPlayer(snum);
if (p->last_pissed_time <= (26 * 218) && p->show_empty_weapon == 0 && p->kickback_pic == 0 && p->quick_kick == 0 && p->GetActor()->spr.scale.X > 0.125 && p->access_incs == 0 && p->knee_incs == 0)
{
if ((p->weapon_pos == 0 || (p->holster_weapon && p->weapon_pos == -9)))
@ -273,7 +273,7 @@ void selectweapon_r(int snum, int weap)
case SLINGBLADE_WEAPON:
if (isRRRA())
{
S_PlayActorSound(496, ps[screenpeek].GetActor());
S_PlayActorSound(496, getPlayer(screenpeek)->GetActor());
fi.addweapon(p, j, true);
}
break;
@ -966,7 +966,7 @@ static void doVehicleThrottling(DukePlayer* p, DDukeActor* pact, unsigned& flags
static void onMotorcycle(int snum, ESyncBits &actions)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
auto pact = p->GetActor();
unsigned flags = outVehicleFlags(p, actions);
@ -1045,7 +1045,7 @@ static void onMotorcycle(int snum, ESyncBits &actions)
static void onBoat(int snum, ESyncBits &actions)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
auto pact = p->GetActor();
if (p->NotOnWater)
@ -1115,7 +1115,7 @@ static void onBoat(int snum, ESyncBits &actions)
static void movement(int snum, ESyncBits actions, sectortype* psect, double floorz, double ceilingz, int shrunk, double truefdist, int psectlotag)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
auto pact = p->GetActor();
if (p->airleft != 15 * 26)
@ -1342,7 +1342,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo
void onMotorcycleMove(int snum, walltype* wal)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
auto pact = p->GetActor();
double angleDelta = absangle(p->GetActor()->spr.Angles.Yaw, wal->delta().Angle()).Degrees();
double damageAmount = p->MotoSpeed * p->MotoSpeed;
@ -1398,7 +1398,7 @@ void onMotorcycleMove(int snum, walltype* wal)
void onBoatMove(int snum, int psectlotag, walltype* wal)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
auto pact = p->GetActor();
double angleDelta = absangle(p->GetActor()->spr.Angles.Yaw, wal->delta().Angle()).Degrees();
@ -1440,7 +1440,7 @@ void onBoatMove(int snum, int psectlotag, walltype* wal)
void onMotorcycleHit(int snum, DDukeActor* victim)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
if (badguy(victim) || victim->isPlayer())
{
if (!victim->isPlayer())
@ -1473,7 +1473,7 @@ void onMotorcycleHit(int snum, DDukeActor* victim)
void onBoatHit(int snum, DDukeActor* victim)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
if (badguy(victim) || victim->isPlayer())
{
@ -1503,7 +1503,7 @@ void onBoatHit(int snum, DDukeActor* victim)
static void fireweapon(int snum)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
p->crack_time = CRACK_TIME;
@ -1635,7 +1635,7 @@ static void fireweapon(int snum)
static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
auto pact = p->GetActor();
int psectlotag = psectp ? psectp->lotag : 857;
@ -2207,7 +2207,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
static void processweapon(int snum, ESyncBits actions, sectortype* psectp)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
auto pact = p->GetActor();
int shrunk = (pact->spr.scale.Y < 0.125);
@ -2268,7 +2268,7 @@ void processinput_r(int snum)
int psectlotag;
double floorz = 0, ceilingz = 0;
auto p = &ps[snum];
auto p = getPlayer(snum);
auto pact = p->GetActor();
ESyncBits& actions = p->input.actions;
@ -2910,7 +2910,7 @@ HORIZONLY:
{
p->show_empty_weapon--;
if (p->show_empty_weapon == 0 && (WeaponSwitch(p - ps) & 2))
if (p->show_empty_weapon == 0 && (WeaponSwitch(p - PlayerArray) & 2))
{
fi.addweapon(p, p->last_full_weapon, true);
return;

View file

@ -140,7 +140,7 @@ void DoSpawn(DukePlayer *p, int snum)
void fireweapon_ww(int snum)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
auto pact = p->GetActor();
p->crack_time = CRACK_TIME;
@ -307,7 +307,7 @@ void fireweapon_ww(int snum)
void operateweapon_ww(int snum, ESyncBits actions)
{
auto p = &ps[snum];
auto p = getPlayer(snum);
auto pact = p->GetActor();
// already firing...

View file

@ -51,16 +51,16 @@ short myangbak[MOVEFIFOSIZ];
void resetmys()
{
mypos = omypos = ps[myconnectindex].GetActor()->getPosWithOffsetZ();
mypos = omypos = getPlayer(myconnectindex)->GetActor()->getPosWithOffsetZ();
myxvel = myyvel = myzvel = 0;
myang = ps[myconnectindex].GetActor()->spr.Angles.Yaw;
myhoriz = omyhoriz = ps[myconnectindex].GetActor()->spr.Angles.Pitch;
myhorizoff = omyhorizoff = ps[myconnectindex].Angles.ViewAngles.Pitch;
mycursectnum = sectindex(ps[myconnectindex].cursector);
myjumpingcounter = ps[myconnectindex].jumping_counter;
myjumpingtoggle = ps[myconnectindex].jumping_toggle;
myonground = ps[myconnectindex].on_ground;
myhardlanding = ps[myconnectindex].hard_landing;
myang = getPlayer(myconnectindex)->GetActor()->spr.Angles.Yaw;
myhoriz = omyhoriz = getPlayer(myconnectindex)->GetActor()->spr.Angles.Pitch;
myhorizoff = omyhorizoff = getPlayer(myconnectindex)->Angles.ViewAngles.Pitch;
mycursectnum = sectindex(getPlayer(myconnectindex)->cursector);
myjumpingcounter = getPlayer(myconnectindex)->jumping_counter;
myjumpingtoggle = getPlayer(myconnectindex)->jumping_toggle;
myonground = getPlayer(myconnectindex)->on_ground;
myhardlanding = getPlayer(myconnectindex)->hard_landing;
}
#if 0 // todo: fix this when networking works again

View file

@ -63,7 +63,7 @@ void pickrandomspot(int snum)
DukePlayer* p;
int i;
p = &ps[snum];
p = getPlayer(snum);
if( ud.multimode > 1 && ud.coop != 1)
i = krand()%numplayersprites;
@ -87,7 +87,7 @@ void resetplayerstats(int snum)
{
DukePlayer* p;
p = &ps[snum];
p = getPlayer(snum);
gFullMap = 0;
p->dead_flag = 0;
@ -293,7 +293,7 @@ void resetweapons(DukePlayer* p)
p->gotweapon[SLINGBLADE_WEAPON] = true;
p->ammo_amount[SLINGBLADE_WEAPON] = 1;
}
OnEvent(EVENT_RESETWEAPONS, int(p - ps), nullptr, -1);
OnEvent(EVENT_RESETWEAPONS, int(p - PlayerArray), nullptr, -1);
}
//---------------------------------------------------------------------------
@ -362,7 +362,7 @@ void resetinventory(DukePlayer* p)
ufocnt = 0;
hulkspawn = 2;
}
OnEvent(EVENT_RESETINVENTORY, int(p - ps), p->GetActor());
OnEvent(EVENT_RESETINVENTORY, int(p - PlayerArray), p->GetActor());
}
@ -376,7 +376,7 @@ void resetprestat(int snum,int g)
{
DukePlayer* p;
p = &ps[snum];
p = getPlayer(snum);
spriteqloc = 0;
for(auto& p : spriteq) p = nullptr;
@ -489,7 +489,7 @@ void resetpspritevars(int g, const DVector3& startpos, const DAngle startang)
int aimmode[MAXPLAYERS];
STATUSBARTYPE tsbar[MAXPLAYERS];
auto newActor = CreateActor(ps[0].cursector, startpos,
auto newActor = CreateActor(getPlayer(0)->cursector, startpos,
DukePlayerPawnClass /*fixme for RR later!*/, 0, DVector2(0, 0), startang, 0., 0., nullptr, 10);
newActor->spr.Angles.Pitch = DAngle::fromDeg(-17.354);
@ -497,55 +497,55 @@ void resetpspritevars(int g, const DVector3& startpos, const DAngle startang)
if (ud.recstat != 2) for (i = 0; i < MAXPLAYERS; i++)
{
aimmode[i] = ps[i].aim_mode;
aimmode[i] = getPlayer(i)->aim_mode;
if (ud.multimode > 1 && ud.coop == 1 && ud.last_level >= 0)
{
for (j = 0; j < MAX_WEAPONS; j++)
{
tsbar[i].ammo_amount[j] = ps[i].ammo_amount[j];
tsbar[i].gotweapon[j] = ps[i].gotweapon[j];
tsbar[i].ammo_amount[j] = getPlayer(i)->ammo_amount[j];
tsbar[i].gotweapon[j] = getPlayer(i)->gotweapon[j];
}
tsbar[i].shield_amount = ps[i].shield_amount;
tsbar[i].curr_weapon = ps[i].curr_weapon;
tsbar[i].inven_icon = ps[i].inven_icon;
tsbar[i].shield_amount = getPlayer(i)->shield_amount;
tsbar[i].curr_weapon = getPlayer(i)->curr_weapon;
tsbar[i].inven_icon = getPlayer(i)->inven_icon;
tsbar[i].firstaid_amount = ps[i].firstaid_amount;
tsbar[i].steroids_amount = ps[i].steroids_amount;
tsbar[i].holoduke_amount = ps[i].holoduke_amount;
tsbar[i].jetpack_amount = ps[i].jetpack_amount;
tsbar[i].heat_amount = ps[i].heat_amount;
tsbar[i].scuba_amount = ps[i].scuba_amount;
tsbar[i].boot_amount = ps[i].boot_amount;
tsbar[i].firstaid_amount = getPlayer(i)->firstaid_amount;
tsbar[i].steroids_amount = getPlayer(i)->steroids_amount;
tsbar[i].holoduke_amount = getPlayer(i)->holoduke_amount;
tsbar[i].jetpack_amount = getPlayer(i)->jetpack_amount;
tsbar[i].heat_amount = getPlayer(i)->heat_amount;
tsbar[i].scuba_amount = getPlayer(i)->scuba_amount;
tsbar[i].boot_amount = getPlayer(i)->boot_amount;
}
}
resetplayerstats(0);
for (i = 1; i < MAXPLAYERS; i++)
ps[i] = ps[0];
*getPlayer(i) = *getPlayer(0);
if (ud.recstat != 2) for (i = 0; i < MAXPLAYERS; i++)
{
ps[i].aim_mode = aimmode[i];
getPlayer(i)->aim_mode = aimmode[i];
if (ud.multimode > 1 && ud.coop == 1 && ud.last_level >= 0)
{
for (j = 0; j < MAX_WEAPONS; j++)
{
ps[i].ammo_amount[j] = tsbar[i].ammo_amount[j];
ps[i].gotweapon[j] = tsbar[i].gotweapon[j];
getPlayer(i)->ammo_amount[j] = tsbar[i].ammo_amount[j];
getPlayer(i)->gotweapon[j] = tsbar[i].gotweapon[j];
}
ps[i].shield_amount = tsbar[i].shield_amount;
ps[i].curr_weapon = tsbar[i].curr_weapon;
ps[i].inven_icon = tsbar[i].inven_icon;
getPlayer(i)->shield_amount = tsbar[i].shield_amount;
getPlayer(i)->curr_weapon = tsbar[i].curr_weapon;
getPlayer(i)->inven_icon = tsbar[i].inven_icon;
ps[i].firstaid_amount = tsbar[i].firstaid_amount;
ps[i].steroids_amount = tsbar[i].steroids_amount;
ps[i].holoduke_amount = tsbar[i].holoduke_amount;
ps[i].jetpack_amount = tsbar[i].jetpack_amount;
ps[i].heat_amount = tsbar[i].heat_amount;
ps[i].scuba_amount = tsbar[i].scuba_amount;
ps[i].boot_amount = tsbar[i].boot_amount;
getPlayer(i)->firstaid_amount = tsbar[i].firstaid_amount;
getPlayer(i)->steroids_amount = tsbar[i].steroids_amount;
getPlayer(i)->holoduke_amount = tsbar[i].holoduke_amount;
getPlayer(i)->jetpack_amount = tsbar[i].jetpack_amount;
getPlayer(i)->heat_amount = tsbar[i].heat_amount;
getPlayer(i)->scuba_amount = tsbar[i].scuba_amount;
getPlayer(i)->boot_amount = tsbar[i].boot_amount;
}
}
@ -575,12 +575,12 @@ void resetpspritevars(int g, const DVector3& startpos, const DAngle startang)
act->spr.xoffset = 0;
act->clipdist = 16;
if (ps[j].last_extra == 0)
if (getPlayer(j)->last_extra == 0)
{
ps[j].last_extra = gs.max_player_health;
getPlayer(j)->last_extra = gs.max_player_health;
act->spr.extra = gs.max_player_health;
}
else act->spr.extra = ps[j].last_extra;
else act->spr.extra = getPlayer(j)->last_extra;
act->spr.yint = j;
@ -588,24 +588,24 @@ void resetpspritevars(int g, const DVector3& startpos, const DAngle startang)
{
if (act->spr.pal == 0)
{
act->spr.pal = ps[j].palookup = which_palookup;
act->spr.pal = getPlayer(j)->palookup = which_palookup;
ud.user_pals[j] = which_palookup;
which_palookup++;
if (which_palookup == 17) which_palookup = 9;
}
else ud.user_pals[j] = ps[j].palookup = act->spr.pal;
else ud.user_pals[j] = getPlayer(j)->palookup = act->spr.pal;
}
else
act->spr.pal = ps[j].palookup = ud.user_pals[j];
act->spr.pal = getPlayer(j)->palookup = ud.user_pals[j];
ps[j].actor = act;
ps[j].Angles.initialize(ps[j].GetActor(), (currentLevel->levelNumber & 1)? DAngle90 : -DAngle90);
ps[j].frag_ps = j;
getPlayer(j)->actor = act;
getPlayer(j)->Angles.initialize(getPlayer(j)->GetActor(), (currentLevel->levelNumber & 1)? DAngle90 : -DAngle90);
getPlayer(j)->frag_ps = j;
act->SetOwner(act);
ps[j].setbobpos();
getPlayer(j)->setbobpos();
updatesector(act->spr.pos, &ps[j].cursector);
updatesector(act->spr.pos, &getPlayer(j)->cursector);
j = connectpoint2[j];
@ -626,7 +626,7 @@ void prelevel_common(int g)
Level.clearStats();
if (isRRRA()) ud.mapflags = MFLAG_ALLSECTORTYPES;
else if (isRR()) ud.mapflags = MFLAG_SECTORTYPE800;
auto p = &ps[screenpeek];
auto p = getPlayer(screenpeek);
p->sea_sick_stat = 0;
ud.ufospawnsminion = 0;
ud.pistonsound = 0;
@ -675,8 +675,8 @@ void prelevel_common(int g)
if (tilesurface(sectp->ceilingtexture) == TSURF_SCROLLSKY && numclouds < 127)
clouds[numclouds++] = sectp;
if (ps[0].one_parallax_sectnum == nullptr)
ps[0].one_parallax_sectnum = sectp;
if (getPlayer(0)->one_parallax_sectnum == nullptr)
getPlayer(0)->one_parallax_sectnum = sectp;
}
if (sectp->lotag == 32767) //Found a secret room
@ -687,7 +687,7 @@ void prelevel_common(int g)
if (sectp->lotag == -1)
{
ps[0].Exit = sectp->walls[0].pos;
getPlayer(0)->Exit = sectp->walls[0].pos;
continue;
}
}
@ -778,7 +778,7 @@ void resettimevars(void)
void donewgame(MapRecord* map, int sk)
{
auto p = &ps[0];
auto p = getPlayer(0);
show_shareware = 26 * 34;
ud.player_skill = sk;
@ -1116,8 +1116,8 @@ static void clearfrags(void)
{
for (int i = 0; i < ud.multimode; i++)
{
ps[i].frag = ps[i].fraggedself = 0;
memset(ps[i].frags, 0, sizeof(ps[i].frags));
getPlayer(i)->frag = getPlayer(i)->fraggedself = 0;
memset(getPlayer(i)->frags, 0, sizeof(getPlayer(i)->frags));
}
}
@ -1146,7 +1146,7 @@ void enterlevel(MapRecord *mi, int gamemode)
FX_StopAllSounds();
S_SetReverb(0);
auto p = &ps[0];
auto p = getPlayer(0);
LoadTheMap(mi, p, gamemode);
@ -1162,29 +1162,29 @@ void enterlevel(MapRecord *mi, int gamemode)
for (int i = connecthead; i >= 0; i = connectpoint2[i])
{
bool clearweapon = !!(currentLevel->flags & LEVEL_CLEARWEAPONS);
auto pn = ps[i].GetActor()->sector()->floortexture;
auto pn = getPlayer(i)->GetActor()->sector()->floortexture;
if (tileflags(pn) & TFLAG_CLEARINVENTORY)
{
resetinventory(&ps[i]);
resetinventory(getPlayer(i));
clearweapon = true;
}
if (clearweapon)
{
resetweapons(&ps[i]);
ps[i].gotweapon[PISTOL_WEAPON] = false;
ps[i].ammo_amount[PISTOL_WEAPON] = 0;
ps[i].curr_weapon = KNEE_WEAPON;
ps[i].kickback_pic = 0;
ps[i].okickback_pic = ps[i].kickback_pic = 0;
resetweapons(getPlayer(i));
getPlayer(i)->gotweapon[PISTOL_WEAPON] = false;
getPlayer(i)->ammo_amount[PISTOL_WEAPON] = 0;
getPlayer(i)->curr_weapon = KNEE_WEAPON;
getPlayer(i)->kickback_pic = 0;
getPlayer(i)->okickback_pic = getPlayer(i)->kickback_pic = 0;
}
if (currentLevel->flags & LEVEL_CLEARINVENTORY) resetinventory(&ps[i]);
if (currentLevel->flags & LEVEL_CLEARINVENTORY) resetinventory(getPlayer(i));
}
resetmys();
global_random = 0;
ud.last_level = 1;
ps[myconnectindex].over_shoulder_on = 0;
getPlayer(myconnectindex)->over_shoulder_on = 0;
clearfrags();
resettimevars(); // Here we go
setLevelStarted(mi);
@ -1205,11 +1205,11 @@ void GameInterface::NewGame(MapRecord* map, int skill, bool)
{
for (int i = 0; i != -1; i = connectpoint2[i])
{
resetweapons(&ps[i]);
resetinventory(&ps[i]);
resetweapons(getPlayer(i));
resetinventory(getPlayer(i));
}
ps[0].last_extra = gs.max_player_health;
getPlayer(0)->last_extra = gs.max_player_health;
if (skill == -1) skill = ud.player_skill;
@ -1223,7 +1223,7 @@ void GameInterface::NewGame(MapRecord* map, int skill, bool)
donewgame(map, skill);
enterlevel(map, 0);
if (isShareware() && ud.recstat != 2) FTA(QUOTE_F1HELP, &ps[myconnectindex]);
if (isShareware() && ud.recstat != 2) FTA(QUOTE_F1HELP, getPlayer(myconnectindex));
PlayerColorChanged();
}

View file

@ -60,7 +60,7 @@ void prelevel_d(int g, TArray<DDukeActor*>& actors)
if (ac->spr.lotag == -1 && (ac->spr.cstat & CSTAT_SPRITE_ALIGNMENT_WALL))
{
ps[0].Exit = ac->spr.pos.XY();
getPlayer(0)->Exit = ac->spr.pos.XY();
}
else
premapcontroller(ac);

View file

@ -52,10 +52,10 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
sound = 0;
prelevel_common(g);
p = &ps[screenpeek];
p = getPlayer(screenpeek);
if (currentLevel->gameflags & LEVEL_RR_CLEARMOONSHINE)
ps[myconnectindex].steroids_amount = 0;
getPlayer(myconnectindex)->steroids_amount = 0;
if (isRRRA())
{
@ -166,7 +166,7 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
if (ac->spr.lotag == -1 && (ac->spr.cstat & CSTAT_SPRITE_ALIGNMENT_WALL))
{
ps[0].Exit = ac->spr.pos.XY();
getPlayer(0)->Exit = ac->spr.pos.XY();
}
else
{

View file

@ -72,7 +72,7 @@ void GameInterface::UpdateCameras(double smoothratio)
if (camsprite == nullptr)
return;
auto p = &ps[screenpeek];
auto p = getPlayer(screenpeek);
if (p->newOwner != nullptr) camsprite->SetOwner(p->newOwner);
if (camsprite->GetOwner() && (p->GetActor()->spr.pos - camsprite->spr.pos).Length() < VIEWSCREEN_ACTIVE_DISTANCE)
@ -218,7 +218,7 @@ void displayrooms(int snum, double interpfrac, bool sceneonly)
DVector3 cpos;
DRotator cangles;
DukePlayer* p = &ps[snum];
DukePlayer* p = getPlayer(snum);
// update render angles.
p->Angles.updateCameraAngles(interpfrac);

View file

@ -415,7 +415,7 @@ void GameInterface::SerializeGameState(FSerializer& arc)
("rtsplaying", rtsplaying)
//("tempwallptr", tempwallptr)
("joe9000", ud.joe9000)
.Array("players", ps, ud.multimode)
.Array("players", PlayerArray, ud.multimode)
("spriteqamount", spriteqamount)
("lastvisinc", lastvisinc)
("numanimwalls", numanimwalls)
@ -487,11 +487,11 @@ void GameInterface::SerializeGameState(FSerializer& arc)
ud.m_monsters_off = ud.monsters_off;
ud.m_coop = ud.coop;
ud.m_ffire = ud.ffire;
if (ps[myconnectindex].over_shoulder_on != 0)
if (getPlayer(myconnectindex)->over_shoulder_on != 0)
{
cameradist = 0;
cameraclock = 0;
ps[myconnectindex].over_shoulder_on = 1;
getPlayer(myconnectindex)->over_shoulder_on = 1;
}
cacheit();

View file

@ -250,7 +250,7 @@ int findplayer(const DDukeActor* actor, double* d)
if (ud.multimode < 2)
{
if (d) *d = (ps[myconnectindex].GetActor()->getPrevPosWithOffsetZ() - s).plusZ(28).Sum();
if (d) *d = (getPlayer(myconnectindex)->GetActor()->getPrevPosWithOffsetZ() - s).plusZ(28).Sum();
return myconnectindex;
}
@ -259,8 +259,8 @@ int findplayer(const DDukeActor* actor, double* d)
for (j = connecthead; j >= 0; j = connectpoint2[j])
{
double x = (ps[j].GetActor()->getPrevPosWithOffsetZ() - s).plusZ(28).Sum();
if (x < closest && ps[j].GetActor()->spr.extra > 0)
double x = (getPlayer(j)->GetActor()->getPrevPosWithOffsetZ() - s).plusZ(28).Sum();
if (x < closest && getPlayer(j)->GetActor()->spr.extra > 0)
{
closest_player = j;
closest = x;
@ -285,9 +285,9 @@ int findotherplayer(int p, double* d)
closest_player = p;
for (j = connecthead; j >= 0; j = connectpoint2[j])
if (p != j && ps[j].GetActor()->spr.extra > 0)
if (p != j && getPlayer(j)->GetActor()->spr.extra > 0)
{
double x = (ps[j].GetActor()->getPrevPosWithOffsetZ() - ps[p].GetActor()->getPosWithOffsetZ()).Sum();
double x = (getPlayer(j)->GetActor()->getPrevPosWithOffsetZ() - getPlayer(p)->GetActor()->getPosWithOffsetZ()).Sum();
if (x < closest)
{
@ -403,12 +403,12 @@ void doanimations(void)
if (type == anim_floorz)
{
for (auto p = connecthead; p >= 0; p = connectpoint2[p])
if (ps[p].cursector == dasectp)
if ((dasectp->floorz - ps[p].GetActor()->getOffsetZ()) < 64)
if (ps[p].GetActor()->GetOwner() != nullptr)
if (getPlayer(p)->cursector == dasectp)
if ((dasectp->floorz - getPlayer(p)->GetActor()->getOffsetZ()) < 64)
if (getPlayer(p)->GetActor()->GetOwner() != nullptr)
{
ps[p].GetActor()->spr.pos.Z += v;
ps[p].vel.Z = 0;
getPlayer(p)->GetActor()->spr.pos.Z += v;
getPlayer(p)->vel.Z = 0;
}
DukeSectIterator it(dasectp);
@ -1329,7 +1329,7 @@ bool checkhitceiling(sectortype* sectp)
if (!data->handler)
{
sectp->setceilingtexture(data->brokentex);
S_PlayActorSound(data->breaksound, ps[screenpeek].GetActor()); // this is nonsense but what the original code did.
S_PlayActorSound(data->breaksound, getPlayer(screenpeek)->GetActor()); // this is nonsense but what the original code did.
}
else
{
@ -1369,7 +1369,7 @@ bool checkhitceiling(sectortype* sectp)
}
if (data->flags & 2)
{
ceilingglass(ps[myconnectindex].GetActor(), sectp, 10);
ceilingglass(getPlayer(myconnectindex)->GetActor(), sectp, 10);
}
return true;
}
@ -1413,7 +1413,7 @@ void checkhitdefault(DDukeActor* targ, DDukeActor* proj)
auto Owner = proj->GetOwner();
if (Owner && Owner->isPlayer() && !(targ->flags3 & SFLAG3_NOSHOTGUNBLOOD))
if (ps[Owner->PlayerIndex()].curr_weapon == SHOTGUN_WEAPON)
if (getPlayer(Owner->PlayerIndex())->curr_weapon == SHOTGUN_WEAPON)
{
shoot(targ, DukeBloodSplat3Class);
shoot(targ, DukeBloodSplat1Class);
@ -1468,12 +1468,12 @@ void checkhitdefault(DDukeActor* targ, DDukeActor* proj)
if (targ->spr.statnum == STAT_PLAYER)
{
auto p = targ->PlayerIndex();
if (ps[p].newOwner != nullptr)
if (getPlayer(p)->newOwner != nullptr)
{
ps[p].newOwner = nullptr;
ps[p].GetActor()->restoreloc();
getPlayer(p)->newOwner = nullptr;
getPlayer(p)->GetActor()->restoreloc();
updatesector(ps[p].GetActor()->getPosWithOffsetZ(), &ps[p].cursector);
updatesector(getPlayer(p)->GetActor()->getPosWithOffsetZ(), &getPlayer(p)->cursector);
DukeStatIterator it(STAT_ACTOR);
while (auto itActor = it.Next())
@ -1536,8 +1536,8 @@ void moveclouds(double interpfrac)
cloudclock = myclock + 6;
// cloudx/y were an array, but all entries were always having the same value so a single pair is enough.
cloudx += (float)ps[screenpeek].GetActor()->spr.Angles.Yaw.Cos() * 0.5f;
cloudy += (float)ps[screenpeek].GetActor()->spr.Angles.Yaw.Sin() * 0.5f;
cloudx += (float)getPlayer(screenpeek)->GetActor()->spr.Angles.Yaw.Cos() * 0.5f;
cloudy += (float)getPlayer(screenpeek)->GetActor()->spr.Angles.Yaw.Sin() * 0.5f;
for (int i = 0; i < numclouds; i++)
{
// no clamping here!
@ -1745,7 +1745,7 @@ bool checkhitswitch(int snum, walltype* wwal, DDukeActor* act)
switchpal = act->spr.pal;
// custom switches that maintain themselves can immediately abort.
swresult = CallTriggerSwitch(act, &ps[snum]);
swresult = CallTriggerSwitch(act, getPlayer(snum));
if (swresult == 1) return true;
}
else
@ -1796,15 +1796,15 @@ bool checkhitswitch(int snum, walltype* wwal, DDukeActor* act)
if (hitag == 10001 && swdef.flags & SwitchDef::oneway && isRRRA())
{
act->spr.setspritetexture(swdef.states[1]);
if (ps[snum].SeaSick == 0)
ps[snum].SeaSick = 350;
operateactivators(668, &ps[snum]);
if (getPlayer(snum)->SeaSick == 0)
getPlayer(snum)->SeaSick = 350;
operateactivators(668, getPlayer(snum));
operatemasterswitches(668);
S_PlayActorSound(328, ps[snum].GetActor());
S_PlayActorSound(328, getPlayer(snum)->GetActor());
return 1;
}
}
DVector3 v(spos, ps[snum].GetActor()->getOffsetZ());
DVector3 v(spos, getPlayer(snum)->GetActor()->getOffsetZ());
if (swdef.type != SwitchDef::None || isadoorwall(texid))
{
@ -1814,9 +1814,9 @@ bool checkhitswitch(int snum, walltype* wwal, DDukeActor* act)
{
FSoundID sound = swdef.soundid != NO_SOUND ? swdef.soundid : S_FindSoundByResID(SWITCH_ON);
if (act) S_PlaySound3D(sound, act, v);
else S_PlaySound3D(sound, ps[snum].GetActor(), v);
else S_PlaySound3D(sound, getPlayer(snum)->GetActor(), v);
if (numdips != correctdips) return 0;
S_PlaySound3D(END_OF_LEVEL_WARN, ps[snum].GetActor(), v);
S_PlaySound3D(END_OF_LEVEL_WARN, getPlayer(snum)->GetActor(), v);
}
if (swdef.type == SwitchDef::Multi)
{
@ -1854,18 +1854,18 @@ bool checkhitswitch(int snum, walltype* wwal, DDukeActor* act)
case SE_25_PISTON:
other->temp_data[4] = !other->temp_data[4];
if (other->temp_data[4])
FTA(15, &ps[snum]);
else FTA(2, &ps[snum]);
FTA(15, getPlayer(snum));
else FTA(2, getPlayer(snum));
break;
case SE_21_DROP_FLOOR:
FTA(2, &ps[screenpeek]);
FTA(2, getPlayer(screenpeek));
break;
}
}
}
operateactivators(lotag, &ps[snum]);
operateforcefields(ps[snum].GetActor(), lotag);
operateactivators(lotag, getPlayer(snum));
operateforcefields(getPlayer(snum)->GetActor(), lotag);
operatemasterswitches(lotag);
if (swdef.type == SwitchDef::Combo) return 1;
@ -1874,7 +1874,7 @@ bool checkhitswitch(int snum, walltype* wwal, DDukeActor* act)
{
FSoundID sound = swdef.soundid != NO_SOUND ? swdef.soundid : S_FindSoundByResID(SWITCH_ON);
if (act) S_PlaySound3D(sound, act, v);
else S_PlaySound3D(sound, ps[snum].GetActor(), v);
else S_PlaySound3D(sound, getPlayer(snum)->GetActor(), v);
}
else if (hitag != 0)
{
@ -1883,7 +1883,7 @@ bool checkhitswitch(int snum, walltype* wwal, DDukeActor* act)
if (act && (flags & SF_TALK) == 0)
S_PlaySound3D(hitag, act, v);
else
S_PlayActorSound(hitag, ps[snum].GetActor());
S_PlayActorSound(hitag, getPlayer(snum)->GetActor());
}
return 1;
@ -1907,7 +1907,7 @@ void animatewalls(void)
if (!ff1.isValid()) ff1 = TexMan.CheckForTexture("W_FORCEFIELD", ETextureType::Any);
if (!ff2.isValid()) ff2 = TexMan.CheckForTexture("W_FORCEFIELD2", ETextureType::Any);
if (ps[screenpeek].sea_sick_stat == 1)
if (getPlayer(screenpeek)->sea_sick_stat == 1)
{
for (auto& wal : wall)
{

View file

@ -50,35 +50,35 @@ BEGIN_DUKE_NS
bool checkaccessswitch_d(int snum, int switchpal, DDukeActor* act, walltype* wwal)
{
if (ps[snum].access_incs == 0)
if (getPlayer(snum)->access_incs == 0)
{
if (switchpal == 0)
{
if ((ps[snum].got_access & 1))
ps[snum].access_incs = 1;
else FTA(70, &ps[snum]);
if ((getPlayer(snum)->got_access & 1))
getPlayer(snum)->access_incs = 1;
else FTA(70, getPlayer(snum));
}
else if (switchpal == 21)
{
if (ps[snum].got_access & 2)
ps[snum].access_incs = 1;
else FTA(71, &ps[snum]);
if (getPlayer(snum)->got_access & 2)
getPlayer(snum)->access_incs = 1;
else FTA(71, getPlayer(snum));
}
else if (switchpal == 23)
{
if (ps[snum].got_access & 4)
ps[snum].access_incs = 1;
else FTA(72, &ps[snum]);
if (getPlayer(snum)->got_access & 4)
getPlayer(snum)->access_incs = 1;
else FTA(72, getPlayer(snum));
}
if (ps[snum].access_incs == 1)
if (getPlayer(snum)->access_incs == 1)
{
if (!act)
ps[snum].access_wall = wwal;
getPlayer(snum)->access_wall = wwal;
else
ps[snum].access_spritenum = act;
getPlayer(snum)->access_spritenum = act;
}
return 1;
@ -185,7 +185,7 @@ void checksectors_d(int snum)
walltype* hitscanwall;
HitInfo near;
p = &ps[snum];
p = getPlayer(snum);
auto pact = p->GetActor();
if (!p->insector()) return;

View file

@ -51,47 +51,47 @@ BEGIN_DUKE_NS
bool checkaccessswitch_r(int snum, int switchpal, DDukeActor* act, walltype* wwal)
{
if (ps[snum].access_incs == 0)
if (getPlayer(snum)->access_incs == 0)
{
if (switchpal == 0)
{
if (ps[snum].keys[1])
ps[snum].access_incs = 1;
if (getPlayer(snum)->keys[1])
getPlayer(snum)->access_incs = 1;
else
{
FTA(70, &ps[snum]);
if (isRRRA()) S_PlayActorSound(99, act ? act : ps[snum].GetActor());
FTA(70, getPlayer(snum));
if (isRRRA()) S_PlayActorSound(99, act ? act : getPlayer(snum)->GetActor());
}
}
else if (switchpal == 21)
{
if (ps[snum].keys[2])
ps[snum].access_incs = 1;
if (getPlayer(snum)->keys[2])
getPlayer(snum)->access_incs = 1;
else
{
FTA(71, &ps[snum]);
if (isRRRA()) S_PlayActorSound(99, act ? act : ps[snum].GetActor());
FTA(71, getPlayer(snum));
if (isRRRA()) S_PlayActorSound(99, act ? act : getPlayer(snum)->GetActor());
}
}
else if (switchpal == 23)
{
if (ps[snum].keys[3])
ps[snum].access_incs = 1;
if (getPlayer(snum)->keys[3])
getPlayer(snum)->access_incs = 1;
else
{
FTA(72, &ps[snum]);
if (isRRRA()) S_PlayActorSound(99, act ? act : ps[snum].GetActor());
FTA(72, getPlayer(snum));
if (isRRRA()) S_PlayActorSound(99, act ? act : getPlayer(snum)->GetActor());
}
}
if (ps[snum].access_incs == 1)
if (getPlayer(snum)->access_incs == 1)
{
if (!act)
ps[snum].access_wall = wwal;
getPlayer(snum)->access_wall = wwal;
else
ps[snum].access_spritenum = act;
getPlayer(snum)->access_spritenum = act;
}
return 1;
}
@ -164,7 +164,7 @@ void checksectors_r(int snum)
walltype* hitscanwall;
HitInfo near;
p = &ps[snum];
p = getPlayer(snum);
auto pact = p->GetActor();
if (!p->insector()) return;
@ -464,8 +464,8 @@ void dofurniture(walltype* wlwal, sectortype* sectp, int snum)
if (pos_ok)
{
if (S_CheckActorSoundPlaying(ps[snum].GetActor(), 389) == 0)
S_PlayActorSound(389, ps[snum].GetActor());
if (S_CheckActorSoundPlaying(getPlayer(snum)->GetActor(), 389) == 0)
S_PlayActorSound(389, getPlayer(snum)->GetActor());
for(auto& wal : nextsect->walls)
{
auto vec = wal.pos;

View file

@ -311,7 +311,7 @@ void S_GetCamera(DVector3* c, DAngle* ca, sectortype** cs)
{
if (ud.cameraactor == nullptr)
{
auto p = &ps[screenpeek];
auto p = getPlayer(screenpeek);
auto pact = p->GetActor();
if (c)
{
@ -422,11 +422,11 @@ void GameInterface::UpdateSounds(void)
int S_PlaySound3D(FSoundID soundid, DDukeActor* actor, const DVector3& pos, int channel, EChanFlags flags)
{
auto const pl = &ps[myconnectindex];
auto const pl = getPlayer(myconnectindex);
if (!soundEngine->isValidSoundId(soundid) || !SoundEnabled() || actor == nullptr || !playrunning() ||
(pl->timebeforeexit > 0 && pl->timebeforeexit <= REALGAMETICSPERSEC * 3)) return -1;
if (flags & CHANF_LOCAL && actor != ps[screenpeek].GetActor() && !ud.coop) return -1; // makes no sense...
if (flags & CHANF_LOCAL && actor != getPlayer(screenpeek)->GetActor() && !ud.coop) return -1; // makes no sense...
soundid = GetReplacementSound(soundid);
int userflags = S_GetUserFlags(soundid);
@ -470,7 +470,7 @@ int S_PlaySound3D(FSoundID soundid, DDukeActor* actor, const DVector3& pos, int
bool explosion = ((userflags & (SF_GLOBAL | SF_DTAG)) == (SF_GLOBAL | SF_DTAG)) ||
((sfx->ResourceId == PIPEBOMB_EXPLODE || sfx->ResourceId == LASERTRIP_EXPLODE || sfx->ResourceId == RPG_EXPLODE));
bool underwater = ps[screenpeek].insector() && ps[screenpeek].cursector->lotag == ST_2_UNDERWATER;
bool underwater = getPlayer(screenpeek)->insector() && getPlayer(screenpeek)->cursector->lotag == ST_2_UNDERWATER;
float pitch = 0;
if (!explosion)
{

View file

@ -15,7 +15,7 @@ void resetswitch(int tag);
DukePlayer* duke_getviewplayer()
{
return &ps[screenpeek];
return getPlayer(screenpeek);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Duke, getviewplayer, duke_getviewplayer)
@ -26,7 +26,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Duke, getviewplayer, duke_getviewplayer)
DukePlayer* duke_getlocalplayer()
{
return &ps[myconnectindex];
return getPlayer(myconnectindex);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Duke, getlocalplayer, duke_getlocalplayer)
@ -101,7 +101,7 @@ DukePlayer* duke_checkcursectnums(sectortype* sector)
{
if (!sector) return nullptr;
int pp = checkcursectnums(sector);
return pp >= 0 ? &ps[pp] : nullptr;
return pp >= 0 ? getPlayer(pp) : nullptr;
}
DEFINE_ACTION_FUNCTION_NATIVE(_Duke, checkcursectnums, duke_checkcursectnums)
@ -179,7 +179,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Duke, StopCommentary, StopCommentary)
int getPlayerIndex(DukePlayer* p)
{
if (!p) return -1;
return int(p - ps);
return int(p - PlayerArray);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Duke, getPlayerIndex, getPlayerIndex)
@ -338,7 +338,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, getglobalz, getglobalz)
DukePlayer* DukeActor_findplayer(DDukeActor* self, double* dist)
{
double a;
return &ps[findplayer(self, dist? dist : &a)];
return getPlayer(findplayer(self, dist? dist : &a));
}
DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, findplayer, DukeActor_findplayer)
@ -353,7 +353,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, findplayer, DukeActor_findplayer)
DukePlayer* DukeActor_getplayer(DDukeActor* self)
{
return self->isPlayer() ? &ps[self->PlayerIndex()] : nullptr;
return self->isPlayer() ? getPlayer(self->PlayerIndex()) : nullptr;
}
DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, getplayer, DukeActor_getplayer)