- Duke: Rename player's opos to something identifiable.

This commit is contained in:
Mitchell Richters 2022-11-14 18:52:08 +11:00 committed by Christoph Oelckers
parent 4aa63b5446
commit 4b7d2fcfcc
16 changed files with 60 additions and 60 deletions

View file

@ -374,8 +374,8 @@ void movedummyplayers(void)
}
}
act->spr.pos.X += (ps[p].PlayerNowPosition.X - ps[p].opos.X);
act->spr.pos.Y += (ps[p].PlayerNowPosition.Y - ps[p].opos.Y);
act->spr.pos.X += (ps[p].PlayerNowPosition.X - ps[p].PlayerOldPosition.X);
act->spr.pos.Y += (ps[p].PlayerNowPosition.Y - ps[p].PlayerOldPosition.Y);
SetActor(act, act->spr.pos);
}
}
@ -400,7 +400,7 @@ void moveplayers(void)
{
if (p->newOwner != nullptr) //Looking thru the camera
{
act->spr.pos = p->opos.plusZ(gs.playerheight);
act->spr.pos = p->PlayerOldPosition.plusZ(gs.playerheight);
act->backupz();
act->spr.angle = p->angle.oang;
SetActor(act, act->spr.pos);
@ -3046,10 +3046,10 @@ void handle_se17(DDukeActor* actor)
{
int p = act3->PlayerIndex();
ps[p].opos -= ps[p].PlayerNowPosition;
ps[p].PlayerOldPosition -= ps[p].PlayerNowPosition;
ps[p].PlayerNowPosition.XY() += act2->spr.pos.XY() - actor->spr.pos.XY();
ps[p].PlayerNowPosition.Z += act2->sector()->floorz - sc->floorz;
ps[p].opos += ps[p].PlayerNowPosition;
ps[p].PlayerOldPosition += ps[p].PlayerNowPosition;
if (q > 0) ps[p].backupz();
@ -4419,8 +4419,8 @@ void movefta(void)
if (badguy(act))
{
auto xyrand = []() -> double { return (64 - (krand() & 127)) * maptoworld; };
double px = ps[p].opos.X - xyrand();
double py = ps[p].opos.Y - xyrand();
double px = ps[p].PlayerOldPosition.X - xyrand();
double py = ps[p].PlayerOldPosition.Y - xyrand();
updatesector(DVector3(px, py, 0), &psect);
if (psect == nullptr)
{
@ -4437,14 +4437,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].opos.Z - r1 }, ps[p].cursector);
canseeme = cansee({ sx, sy, act->spr.pos.Z - r2 }, act->sector(), { px, py, ps[p].PlayerOldPosition.Z - r1 }, ps[p].cursector);
}
}
else
{
int r1 = krand();
int r2 = krand();
canseeme = cansee(act->spr.pos.plusZ(-(r2 & 31)), act->sector(), ps[p].opos.plusZ(-(r1 & 31)), ps[p].cursector);
canseeme = cansee(act->spr.pos.plusZ(-(r2 & 31)), act->sector(), ps[p].PlayerOldPosition.plusZ(-(r1 & 31)), ps[p].cursector);
}

View file

@ -3034,7 +3034,7 @@ void move_d(DDukeActor *actor, int playernum, int xvel)
if (a & face_player)
{
if (ps[playernum].newOwner != nullptr)
goalang = (ps[playernum].opos.XY() - actor->spr.pos.XY()).Angle();
goalang = (ps[playernum].PlayerOldPosition.XY() - actor->spr.pos.XY()).Angle();
else goalang = (ps[playernum].PlayerNowPosition.XY() - actor->spr.pos.XY()).Angle();
angdif = deltaangle(actor->spr.angle, goalang) * 0.25;
if (angdif > -DAngle22_5 / 16 && angdif < nullAngle) angdif = nullAngle;
@ -3047,7 +3047,7 @@ void move_d(DDukeActor *actor, int playernum, int xvel)
if (a & face_player_slow)
{
if (ps[playernum].newOwner != nullptr)
goalang = (ps[playernum].opos.XY() - actor->spr.pos.XY()).Angle();
goalang = (ps[playernum].PlayerOldPosition.XY() - actor->spr.pos.XY()).Angle();
else goalang = (ps[playernum].PlayerNowPosition.XY() - actor->spr.pos.XY()).Angle();
angdif = DAngle22_5 * 0.25 * Sgn(deltaangle(actor->spr.angle, goalang).Degrees()); // this looks very wrong...
actor->spr.angle += angdif;

View file

@ -1334,8 +1334,8 @@ void movetransports_r(void)
}
else if (isRRRA() && k == 2)
{
ps[p].opos.X = ps[p].PlayerNowPosition.X += Owner->spr.pos.X - act->spr.pos.X;
ps[p].opos.Y = ps[p].PlayerNowPosition.Y += Owner->spr.pos.Y - act->spr.pos.Y;
ps[p].PlayerOldPosition.X = ps[p].PlayerNowPosition.X += Owner->spr.pos.X - act->spr.pos.X;
ps[p].PlayerOldPosition.Y = ps[p].PlayerNowPosition.Y += Owner->spr.pos.Y - act->spr.pos.Y;
ps[p].backupxy();
if (Owner->GetOwner() != Owner)
@ -3212,7 +3212,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
if (a & face_player)
{
if (ps[pnum].newOwner != nullptr)
goalang = (ps[pnum].opos.XY() - actor->spr.pos.XY()).Angle();
goalang = (ps[pnum].PlayerOldPosition.XY() - actor->spr.pos.XY()).Angle();
else goalang = (ps[pnum].PlayerNowPosition.XY() - actor->spr.pos.XY()).Angle();
angdif = deltaangle(actor->spr.angle, goalang) * 0.25;
if (angdif > -DAngle22_5 / 16 && angdif < nullAngle) angdif = nullAngle;
@ -3225,7 +3225,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
if (a & face_player_slow)
{
if (ps[pnum].newOwner != nullptr)
goalang = (ps[pnum].opos.XY() - actor->spr.pos.XY()).Angle();
goalang = (ps[pnum].PlayerOldPosition.XY() - actor->spr.pos.XY()).Angle();
else goalang = (ps[pnum].PlayerNowPosition.XY() - actor->spr.pos.XY()).Angle();
angdif = DAngle22_5 * 0.25 * Sgn(deltaangle(actor->spr.angle, goalang).Degrees()); // this looks very wrong...
actor->spr.angle += angdif;
@ -3236,7 +3236,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
if (a & antifaceplayerslow)
{
if (ps[pnum].newOwner != nullptr)
goalang = ((ps[pnum].opos.XY() - actor->spr.pos.XY()).Angle() + DAngle180);
goalang = ((ps[pnum].PlayerOldPosition.XY() - actor->spr.pos.XY()).Angle() + DAngle180);
else goalang = ((ps[pnum].PlayerNowPosition.XY() - actor->spr.pos.XY()).Angle() + DAngle180);
angdif = DAngle22_5 * 0.25 * Sgn(deltaangle(actor->spr.angle, goalang).Degrees()); // this looks very wrong...
actor->spr.angle += angdif;

View file

@ -165,7 +165,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
auto pp = &ps[h->PlayerIndex()];
if (h->spr.statnum != STAT_ACTOR && h->spr.picnum == APLAYER && pp->newOwner == nullptr && h->GetOwner())
{
t->pos = interpolatedvalue(pp->opos, pp->PlayerNowPosition, interpfrac).plusZ(gs.playerheight);
t->pos = interpolatedvalue(pp->PlayerOldPosition, pp->PlayerNowPosition, interpfrac).plusZ(gs.playerheight);
}
else if (!actorflag(h, SFLAG_NOINTERPOLATE))
{

View file

@ -144,7 +144,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
auto pp = &ps[h->PlayerIndex()];
if (h->spr.statnum != STAT_ACTOR && h->spr.picnum == APLAYER && pp->newOwner == nullptr && h->GetOwner())
{
t->pos = interpolatedvalue(pp->opos, pp->PlayerNowPosition, interpfrac).plusZ(gs.playerheight);
t->pos = interpolatedvalue(pp->PlayerOldPosition, pp->PlayerNowPosition, interpfrac).plusZ(gs.playerheight);
h->spr.scale = DVector2(0.375, 0.265625);
}
else if (!actorflag(h, SFLAG_NOINTERPOLATE))

View file

@ -271,13 +271,13 @@ void drawoverlays(double interpfrac)
}
else
{
cposxy = interpolatedvalue(pp->opos, pp->PlayerNowPosition, interpfrac).XY();
cposxy = interpolatedvalue(pp->PlayerOldPosition, pp->PlayerNowPosition, interpfrac).XY();
cang = !SyncInput() ? pp->angle.ang : interpolatedvalue(pp->angle.oang, pp->angle.ang, interpfrac);
}
}
else
{
cposxy = pp->opos.XY();
cposxy = pp->PlayerOldPosition.XY();
cang = pp->angle.oang;
}
DrawOverheadMap(cposxy, cang, interpfrac);

View file

@ -378,18 +378,18 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
break;
case PLAYER_OPOSX:
if (bSet) ps[iPlayer].opos.X = lValue * maptoworld;
else SetGameVarID(lVar2, int(ps[iPlayer].opos.X * (1/maptoworld)), sActor, sPlayer);
if (bSet) ps[iPlayer].PlayerOldPosition.X = lValue * maptoworld;
else SetGameVarID(lVar2, int(ps[iPlayer].PlayerOldPosition.X * (1/maptoworld)), sActor, sPlayer);
break;
case PLAYER_OPOSY:
if (bSet) ps[iPlayer].opos.Y = lValue * maptoworld;
else SetGameVarID(lVar2, int(ps[iPlayer].opos.Y * (1 / maptoworld)), sActor, sPlayer);
if (bSet) ps[iPlayer].PlayerOldPosition.Y = lValue * maptoworld;
else SetGameVarID(lVar2, int(ps[iPlayer].PlayerOldPosition.Y * (1 / maptoworld)), sActor, sPlayer);
break;
case PLAYER_OPOSZ:
if (bSet) ps[iPlayer].opos.Z = lValue * zmaptoworld;
else SetGameVarID(lVar2, int(ps[iPlayer].opos.Z * (1 / zmaptoworld)), sActor, sPlayer);
if (bSet) ps[iPlayer].PlayerOldPosition.Z = lValue * zmaptoworld;
else SetGameVarID(lVar2, int(ps[iPlayer].PlayerOldPosition.Z * (1 / zmaptoworld)), sActor, sPlayer);
break;
case PLAYER_PYOFF:

View file

@ -765,16 +765,16 @@ void player_struct::backuppos(bool noclipping)
{
if (!noclipping)
{
opos.X = PlayerNowPosition.X;
opos.Y = PlayerNowPosition.Y;
PlayerOldPosition.X = PlayerNowPosition.X;
PlayerOldPosition.Y = PlayerNowPosition.Y;
}
else
{
PlayerNowPosition.X = opos.X;
PlayerNowPosition.Y = opos.Y;
PlayerNowPosition.X = PlayerOldPosition.X;
PlayerNowPosition.Y = PlayerOldPosition.Y;
}
opos.Z = PlayerNowPosition.Z;
PlayerOldPosition.Z = PlayerNowPosition.Z;
bobpos = PlayerNowPosition.XY();
opyoff = pyoff;
}

View file

@ -109,7 +109,7 @@ static void shootfireball(DDukeActor *actor, int p, DVector3 pos, DAngle ang)
double scratch;
int j = findplayer(actor, &scratch);
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
zvel = ((ps[j].opos.Z - pos.Z + 3) * vel) / dist;
zvel = ((ps[j].PlayerOldPosition.Z - pos.Z + 3) * vel) / dist;
}
else
{
@ -153,7 +153,7 @@ static void shootflamethrowerflame(DDukeActor* actor, int p, DVector3 spos, DAng
{
double x;
int j = findplayer(actor, &x);
sang = (ps[j].opos.XY() - spos.XY()).Angle();
sang = (ps[j].PlayerOldPosition.XY() - spos.XY()).Angle();
if (actor->spr.picnum == BOSS5)
{
@ -165,7 +165,7 @@ static void shootflamethrowerflame(DDukeActor* actor, int p, DVector3 spos, DAng
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
if (dist != 0)
zvel = (((ps[j].opos.Z - spos.Z) * vel) / dist);
zvel = (((ps[j].PlayerOldPosition.Z - spos.Z) * vel) / dist);
if (badguy(actor) && (actor->spr.hitag & face_player_smart) != 0)
sang = actor->spr.angle + mapangle((krand() & 31) - 16);
@ -605,7 +605,7 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a
ang += DAngle22_5 / 8 - randomAngle(22.5 / 4);
#if 1
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
zvel = ((ps[j].opos.Z - pos.Z + 3) * vel) / dist;
zvel = ((ps[j].PlayerOldPosition.Z - pos.Z + 3) * vel) / dist;
#else
// this is for pitch corrected velocity
auto dist = (ps[j].GetActor()->spr.pos - actor->spr.pos).Resized(vel);
@ -693,7 +693,7 @@ static void shootrpg(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int atw
{
double x;
int j = findplayer(actor, &x);
ang = (ps[j].opos.XY() - pos.XY()).Angle();
ang = (ps[j].PlayerOldPosition.XY() - pos.XY()).Angle();
if (actor->spr.picnum == BOSS3)
{
double zoffs = 32;
@ -712,7 +712,7 @@ static void shootrpg(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int atw
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
zvel = ((ps[j].opos.Z - pos.Z) * vel) / dist;
zvel = ((ps[j].PlayerOldPosition.Z - pos.Z) * vel) / dist;
if (badguy(actor) && (actor->spr.hitag & face_player_smart))
ang = actor->spr.angle + randomAngle(DAngle22_5 / 4) - DAngle22_5 / 8;
@ -2043,7 +2043,7 @@ int operateTripbomb(int snum)
auto delta = hit.hitpos.XY() - p->PlayerNowPosition.XY();
if (delta.LengthSquared() < (18.125 * 18.125))
{
p->PlayerNowPosition.Z = p->opos.Z;
p->PlayerNowPosition.Z = p->PlayerOldPosition.Z;
p->vel.Z = 0;
return 1;
}
@ -2585,7 +2585,7 @@ static void operateweapon(int snum, ESyncBits actions)
case TRIPBOMB_WEAPON: // Claymore in NAM
if (p->kickback_pic < 4)
{
p->PlayerNowPosition.Z = p->opos.Z;
p->PlayerNowPosition.Z = p->PlayerOldPosition.Z;
p->vel.Z = 0;
if (p->kickback_pic == 3)
fi.shoot(pact, HANDHOLDINGLASER);
@ -2860,7 +2860,7 @@ void processinput_d(int snum)
checklook(snum,actions);
double iif = 2.5;
auto oldpos = p->opos;
auto oldpos = p->PlayerOldPosition;
if (p->on_crane != nullptr)
goto HORIZONLY;
@ -3101,7 +3101,7 @@ HORIZONLY:
{
if (!retry++)
{
p->PlayerNowPosition = p->opos = oldpos;
p->PlayerNowPosition = p->PlayerOldPosition = oldpos;
continue;
}
quickkill(p);

View file

@ -526,7 +526,7 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a
ang += DAngle22_5 / 8. - randomAngle(22.5 / 4);
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
zvel = ((ps[j].opos.Z - pos.Z + 3) * vel) / dist;
zvel = ((ps[j].PlayerOldPosition.Z - pos.Z + 3) * vel) / dist;
}
double oldzvel = zvel;
@ -613,7 +613,7 @@ static void shootrpg(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int atw
{
double x;
int j = findplayer(actor, &x);
ang = (ps[j].opos.XY() - pos.XY()).Angle();
ang = (ps[j].PlayerOldPosition.XY() - pos.XY()).Angle();
if (actor->spr.picnum == BOSS3)
pos.Z -= 32;
else if (actor->spr.picnum == BOSS2)
@ -623,7 +623,7 @@ static void shootrpg(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int atw
}
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
zvel = ((ps[j].opos.Z - pos.Z) * vel) / dist;
zvel = ((ps[j].PlayerOldPosition.Z - pos.Z) * vel) / dist;
if (badguy(actor) && (actor->spr.hitag & face_player_smart))
ang = actor->spr.angle + randomAngle(22.5 / 4) - DAngle22_5 / 8;
@ -758,7 +758,7 @@ static void shootwhip(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int at
ang += DAngle22_5/8 - randomAngle(22.5 / 4);
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
zvel = ((ps[j].opos.Z - pos.Z + 3) * vel) / dist;
zvel = ((ps[j].PlayerOldPosition.Z - pos.Z + 3) * vel) / dist;
}
double oldzvel = zvel;
@ -3525,7 +3525,7 @@ void processinput_r(int snum)
checklook(snum, actions);
p->apply_seasick(1);
auto oldpos = p->opos;
auto oldpos = p->PlayerOldPosition;
if (p->on_crane != nullptr)
goto HORIZONLY;
@ -3888,7 +3888,7 @@ HORIZONLY:
{
if (!retry++)
{
p->PlayerNowPosition = p->opos = oldpos;
p->PlayerNowPosition = p->PlayerOldPosition = oldpos;
continue;
}
quickkill(p);

View file

@ -436,7 +436,7 @@ void operateweapon_ww(int snum, ESyncBits actions)
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_STANDSTILL
&& p->kickback_pic < (aplWeaponFireDelay(p->curr_weapon, snum) + 1))
{
p->PlayerNowPosition.Z = p->opos.Z;
p->PlayerNowPosition.Z = p->PlayerOldPosition.Z;
p->vel.Z = 0;
}
if (p->kickback_pic == aplWeaponSound2Time(p->curr_weapon, snum))

View file

@ -290,7 +290,7 @@ void displayrooms(int snum, double interpfrac, bool sceneonly)
}
else
{
cpos = interpolatedvalue(p->opos, p->PlayerNowPosition, interpfrac);
cpos = interpolatedvalue(p->PlayerOldPosition, p->PlayerNowPosition, interpfrac);
if (SyncInput())
{

View file

@ -226,7 +226,7 @@ int findplayer(const DDukeActor* actor, double* d)
if (ud.multimode < 2)
{
if (d) *d = (ps[myconnectindex].opos - s).plusZ(28).Sum();
if (d) *d = (ps[myconnectindex].PlayerOldPosition - s).plusZ(28).Sum();
return myconnectindex;
}
@ -235,7 +235,7 @@ int findplayer(const DDukeActor* actor, double* d)
for (j = connecthead; j >= 0; j = connectpoint2[j])
{
double x = (ps[j].opos - s).plusZ(28).Sum();
double x = (ps[j].PlayerOldPosition - s).plusZ(28).Sum();
if (x < closest && ps[j].GetActor()->spr.extra > 0)
{
closest_player = j;
@ -263,7 +263,7 @@ int findotherplayer(int p, double* d)
for (j = connecthead; j >= 0; j = connectpoint2[j])
if (p != j && ps[j].GetActor()->spr.extra > 0)
{
double x = (ps[j].opos - ps[p].PlayerNowPosition).Sum();
double x = (ps[j].PlayerOldPosition - ps[p].PlayerNowPosition).Sum();
if (x < closest)
{

View file

@ -1516,7 +1516,7 @@ void checksectors_d(int snum)
return;
}
if (p->newOwner != nullptr)
neartag(p->opos, p->GetActor()->sector(), p->angle.oang, near, 80., NT_Lotag);
neartag(p->PlayerOldPosition, p->GetActor()->sector(), p->angle.oang, near, 80., NT_Lotag);
else
{
neartag(p->PlayerNowPosition, p->GetActor()->sector(), p->angle.oang, near, 80., NT_Lotag);

View file

@ -2466,7 +2466,7 @@ void checksectors_r(int snum)
}
if (p->newOwner != nullptr)
neartag(p->opos, p->GetActor()->sector(), p->angle.oang, near, 80., NT_Lotag);
neartag(p->PlayerOldPosition, p->GetActor()->sector(), p->angle.oang, near, 80., NT_Lotag);
else
{
neartag(p->PlayerNowPosition, p->GetActor()->sector(), p->angle.oang, near, 80., NT_Lotag);

View file

@ -176,7 +176,7 @@ struct player_orig
struct player_struct
{
DVector3 vel;
DVector3 PlayerNowPosition, opos;
DVector3 PlayerNowPosition, PlayerOldPosition;
DVector2 bobpos;
DVector2 fric;
DVector2 Exit;
@ -333,23 +333,23 @@ struct player_struct
void backupxyz()
{
opos = PlayerNowPosition;
PlayerOldPosition = PlayerNowPosition;
}
void restorexyz()
{
PlayerNowPosition = opos;
PlayerNowPosition = PlayerOldPosition;
}
void backupxy()
{
opos.X = PlayerNowPosition.X;
opos.Y = PlayerNowPosition.Y;
PlayerOldPosition.X = PlayerNowPosition.X;
PlayerOldPosition.Y = PlayerNowPosition.Y;
}
void backupz()
{
opos.Z = PlayerNowPosition.Z;
PlayerOldPosition.Z = PlayerNowPosition.Z;
}
void setbobpos()