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

This commit is contained in:
Mitchell Richters 2022-11-21 13:05:32 +11:00 committed by Christoph Oelckers
parent 5d3878eb55
commit 3a07c05af7
8 changed files with 18 additions and 14 deletions

View file

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

View file

@ -1367,7 +1367,7 @@ void movetransports_d(void)
if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP))) ||
(ps[p].jetpack_on && PlayerInput(p, SB_CROUCH)))
{
ps[p].PlayerNowPosition.X += Owner->spr.pos.X - act->spr.pos.X;
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].backupxy();
@ -1425,7 +1425,7 @@ void movetransports_d(void)
if (k == 1)
{
ps[p].PlayerNowPosition.X += Owner->spr.pos.X - act->spr.pos.X;
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].backupxy();

View file

@ -1252,7 +1252,7 @@ void movetransports_r(void)
if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && PlayerInput(p, SB_JUMP)) ||
(ps[p].jetpack_on && PlayerInput(p, SB_CROUCH)))
{
ps[p].PlayerNowPosition.X += Owner->spr.pos.X - act->spr.pos.X;
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].backupxy();
@ -1319,7 +1319,7 @@ void movetransports_r(void)
if (k == 1)
{
ps[p].PlayerNowPosition.X += Owner->spr.pos.X - act->spr.pos.X;
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].backupxy();
@ -1334,7 +1334,7 @@ void movetransports_r(void)
}
else if (isRRRA() && k == 2)
{
ps[p].PlayerOldPosition.X = ps[p].PlayerNowPosition.X += Owner->spr.pos.X - act->spr.pos.X;
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].backupxy();

View file

@ -326,7 +326,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
break;
case PLAYER_POSX: // oh, my... :( Writing to these has been disabled until I know how to do it without the engine shitting all over itself.
if (!bSet) SetGameVarID(lVar2, int(ps[iPlayer].PlayerNowPosition.X * (1/maptoworld)), sActor, sPlayer);
if (!bSet) SetGameVarID(lVar2, int(ps[iPlayer].posX() * (1/maptoworld)), sActor, sPlayer);
break;
case PLAYER_POSY:

View file

@ -507,7 +507,7 @@ void footprints(int snum)
while (auto act = it.Next())
{
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->PlayerNowPosition.X) < 24)
if (abs(act->spr.pos.X - p->posX()) < 24)
if (abs(act->spr.pos.Y - p->PlayerNowPosition.Y) < 24)
{
j = 1;
@ -765,12 +765,12 @@ void player_struct::backuppos(bool noclipping)
{
if (!noclipping)
{
PlayerOldPosition.X = PlayerNowPosition.X;
PlayerOldPosition.X = posX();
PlayerOldPosition.Y = PlayerNowPosition.Y;
}
else
{
PlayerNowPosition.X = PlayerOldPosition.X;
posX() = PlayerOldPosition.X;
PlayerNowPosition.Y = PlayerOldPosition.Y;
}

View file

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

View file

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

View file

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