- Duke: Wrap calls to player_struct::PlayerNowPosition.Y.

This commit is contained in:
Mitchell Richters 2022-11-21 13:06:26 +11:00 committed by Christoph Oelckers
parent 3a07c05af7
commit 008c05710b
8 changed files with 18 additions and 14 deletions

View file

@ -375,7 +375,7 @@ void movedummyplayers(void)
}
act->spr.pos.X += (ps[p].posX() - ps[p].PlayerOldPosition.X);
act->spr.pos.Y += (ps[p].PlayerNowPosition.Y - ps[p].PlayerOldPosition.Y);
act->spr.pos.Y += (ps[p].posY() - ps[p].PlayerOldPosition.Y);
SetActor(act, act->spr.pos);
}
}
@ -1869,7 +1869,7 @@ void handle_se00(DDukeActor* actor)
ps[p].bobpos += (result - ps[p].posXY());
ps[p].posX() = result.X;
ps[p].PlayerNowPosition.Y = result.Y;
ps[p].posY() = result.Y;
auto psp = ps[p].GetActor();
if (psp->spr.extra <= 0)

View file

@ -1368,7 +1368,7 @@ void movetransports_d(void)
(ps[p].jetpack_on && PlayerInput(p, SB_CROUCH)))
{
ps[p].posX() += Owner->spr.pos.X - act->spr.pos.X;
ps[p].PlayerNowPosition.Y += Owner->spr.pos.Y - act->spr.pos.Y;
ps[p].posY() += Owner->spr.pos.Y - act->spr.pos.Y;
ps[p].backupxy();
if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11))
@ -1426,7 +1426,7 @@ void movetransports_d(void)
if (k == 1)
{
ps[p].posX() += Owner->spr.pos.X - act->spr.pos.X;
ps[p].PlayerNowPosition.Y += Owner->spr.pos.Y - act->spr.pos.Y;
ps[p].posY() += Owner->spr.pos.Y - act->spr.pos.Y;
ps[p].backupxy();
if (!Owner || Owner->GetOwner() != Owner)

View file

@ -1253,7 +1253,7 @@ void movetransports_r(void)
(ps[p].jetpack_on && PlayerInput(p, SB_CROUCH)))
{
ps[p].posX() += Owner->spr.pos.X - act->spr.pos.X;
ps[p].PlayerNowPosition.Y += Owner->spr.pos.Y - act->spr.pos.Y;
ps[p].posY() += Owner->spr.pos.Y - act->spr.pos.Y;
ps[p].backupxy();
if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11))
@ -1320,7 +1320,7 @@ void movetransports_r(void)
if (k == 1)
{
ps[p].posX() += Owner->spr.pos.X - act->spr.pos.X;
ps[p].PlayerNowPosition.Y += Owner->spr.pos.Y - act->spr.pos.Y;
ps[p].posY() += Owner->spr.pos.Y - act->spr.pos.Y;
ps[p].backupxy();
if (Owner->GetOwner() != Owner)
@ -1335,7 +1335,7 @@ void movetransports_r(void)
else if (isRRRA() && k == 2)
{
ps[p].PlayerOldPosition.X = ps[p].posX() += 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].PlayerOldPosition.Y = ps[p].posY() += Owner->spr.pos.Y - act->spr.pos.Y;
ps[p].backupxy();
if (Owner->GetOwner() != Owner)

View file

@ -330,7 +330,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
break;
case PLAYER_POSY:
if (!bSet) SetGameVarID(lVar2, int(ps[iPlayer].PlayerNowPosition.Y * (1 / maptoworld)), sActor, sPlayer);
if (!bSet) SetGameVarID(lVar2, int(ps[iPlayer].posY() * (1 / maptoworld)), sActor, sPlayer);
break;
case PLAYER_POSZ:

View file

@ -508,7 +508,7 @@ void footprints(int snum)
{
if (act->spr.picnum == TILE_FOOTPRINTS || act->spr.picnum == TILE_FOOTPRINTS2 || act->spr.picnum == TILE_FOOTPRINTS3 || act->spr.picnum == TILE_FOOTPRINTS4)
if (abs(act->spr.pos.X - p->posX()) < 24)
if (abs(act->spr.pos.Y - p->PlayerNowPosition.Y) < 24)
if (abs(act->spr.pos.Y - p->posY()) < 24)
{
j = 1;
break;
@ -766,12 +766,12 @@ void player_struct::backuppos(bool noclipping)
if (!noclipping)
{
PlayerOldPosition.X = posX();
PlayerOldPosition.Y = PlayerNowPosition.Y;
PlayerOldPosition.Y = posY();
}
else
{
posX() = PlayerOldPosition.X;
PlayerNowPosition.Y = PlayerOldPosition.Y;
posY() = PlayerOldPosition.Y;
}
PlayerOldPosition.Z = PlayerNowPosition.Z;

View file

@ -3991,7 +3991,7 @@ void OnMotorcycle(player_struct *p, DDukeActor* motosprite)
if (motosprite)
{
p->posX() = motosprite->spr.pos.X;
p->PlayerNowPosition.Y = motosprite->spr.pos.Y;
p->posY() = motosprite->spr.pos.Y;
p->angle.ang = motosprite->spr.angle;
p->ammo_amount[MOTORCYCLE_WEAPON] = motosprite->saved_ammo;
motosprite->Destroy();
@ -4066,7 +4066,7 @@ void OnBoat(player_struct *p, DDukeActor* boat)
if (boat)
{
p->posX() = boat->spr.pos.X;
p->PlayerNowPosition.Y = boat->spr.pos.Y;
p->posY() = boat->spr.pos.Y;
p->angle.ang = boat->spr.angle;
p->ammo_amount[BOAT_WEAPON] = boat->saved_ammo;
boat->Destroy();

View file

@ -77,7 +77,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w,
if (arc.BeginObject(keyname))
{
arc("posx", w.posX())
("posy", w.PlayerNowPosition.Y)
("posy", w.posY())
("posz", w.PlayerNowPosition.Z)
("angle", w.angle)
("horizon", w.horizon)

View file

@ -362,6 +362,10 @@ struct player_struct
{
return PlayerNowPosition.X;
}
double& posY()
{
return PlayerNowPosition.Y;
}
DVector2& posXY()
{
return PlayerNowPosition.XY();