- Duke: Wrap calls that set player_struct::PlayerNowPosition.

This commit is contained in:
Mitchell Richters 2022-11-15 18:22:52 +11:00 committed by Christoph Oelckers
parent 25e6c4ecf8
commit 58381c6eca
9 changed files with 18 additions and 11 deletions

View file

@ -458,7 +458,7 @@ void moveplayers(void)
} }
else else
{ {
p->PlayerNowPosition = act->spr.pos.plusZ(-20); p->posSet(act->spr.pos.plusZ(-20));
p->newOwner = nullptr; p->newOwner = nullptr;
if (p->wackedbyactor != nullptr && p->wackedbyactor->spr.statnum < MAXSTATUS) if (p->wackedbyactor != nullptr && p->wackedbyactor->spr.statnum < MAXSTATUS)

View file

@ -1345,7 +1345,7 @@ void movetransports_d(void)
ps[p].transporter_hold = 13; ps[p].transporter_hold = 13;
} }
ps[p].PlayerNowPosition = Owner->spr.pos.plusZ(-gs.playerheight); ps[p].posSet(Owner->spr.pos.plusZ(-gs.playerheight));
ps[p].backupxyz(); ps[p].backupxyz();
ps[p].setbobpos(); ps[p].setbobpos();

View file

@ -1233,7 +1233,7 @@ void movetransports_r(void)
ps[p].transporter_hold = 13; ps[p].transporter_hold = 13;
} }
ps[p].PlayerNowPosition = Owner->spr.pos.plusZ(-gs.playerheight + 4); ps[p].posSet(Owner->spr.pos.plusZ(-gs.playerheight + 4));
ps[p].backupxyz(); ps[p].backupxyz();
ps[p].setbobpos(); ps[p].setbobpos();
@ -2049,7 +2049,7 @@ void rr_specialstats()
if (act2->spr.picnum == RRTELEPORTDEST) if (act2->spr.picnum == RRTELEPORTDEST)
{ {
ps[p].angle.ang = act2->spr.angle; ps[p].angle.ang = act2->spr.angle;
ps[p].PlayerNowPosition = act2->spr.pos.plusZ(-36); ps[p].posSet(act2->spr.pos.plusZ(-36));
ps[p].backupxyz(); ps[p].backupxyz();
ps[p].setbobpos(); ps[p].setbobpos();
auto pact = ps[p].GetActor(); auto pact = ps[p].GetActor();

View file

@ -115,7 +115,7 @@ void GameInterface::WarpToCoords(double x, double y, double z, DAngle ang)
{ {
player_struct* p = &ps[myconnectindex]; player_struct* p = &ps[myconnectindex];
p->PlayerNowPosition = DVector3(x, y, z); p->posSet(DVector3(x, y, z));
p->backupxyz(); p->backupxyz();
if (ang != DAngle::fromDeg(INT_MIN)) if (ang != DAngle::fromDeg(INT_MIN))

View file

@ -3101,7 +3101,8 @@ HORIZONLY:
{ {
if (!retry++) if (!retry++)
{ {
p->PlayerNowPosition = p->PlayerOldPosition = oldpos; p->posSet(oldpos);
p->backupxyz();
continue; continue;
} }
quickkill(p); quickkill(p);

View file

@ -3888,7 +3888,8 @@ HORIZONLY:
{ {
if (!retry++) if (!retry++)
{ {
p->PlayerNowPosition = p->PlayerOldPosition = oldpos; p->posSet(oldpos);
p->backupxyz();
continue; continue;
} }
quickkill(p); quickkill(p);

View file

@ -69,7 +69,7 @@ void pickrandomspot(int snum)
i = krand()%numplayersprites; i = krand()%numplayersprites;
else i = snum; else i = snum;
p->PlayerNowPosition = po[i].opos; p->posSet(po[i].opos);
p->backupxyz(); p->backupxyz();
p->setbobpos(); p->setbobpos();
p->angle.oang = p->angle.ang = po[i].oa; p->angle.oang = p->angle.ang = po[i].oa;
@ -622,7 +622,7 @@ void resetpspritevars(int g)
ps[j].frag_ps = j; ps[j].frag_ps = j;
act->SetOwner(act); act->SetOwner(act);
ps[j].PlayerNowPosition = act->spr.pos; ps[j].posSet(act->spr.pos);
ps[j].backupxyz(); ps[j].backupxyz();
ps[j].setbobpos(); ps[j].setbobpos();
act->backuppos(); act->backuppos();
@ -976,7 +976,7 @@ static int LoadTheMap(MapRecord *mi, player_struct*p, int gamemode)
SpawnSpriteDef sprites; SpawnSpriteDef sprites;
DVector3 pos; DVector3 pos;
loadMap(mi->fileName, isShareware(), &pos, &lbang, &sect, sprites); loadMap(mi->fileName, isShareware(), &pos, &lbang, &sect, sprites);
p->PlayerNowPosition = pos; p->posSet(pos);
p->cursector = sect; p->cursector = sect;
SECRET_SetMapName(mi->DisplayName(), mi->name); SECRET_SetMapName(mi->DisplayName(), mi->name);

View file

@ -383,6 +383,11 @@ struct player_struct
{ {
return PlayerNowPosition.Z; return PlayerNowPosition.Z;
} }
void posSet(const DVector3& val)
{
PlayerNowPosition = val;
}
}; };
struct Cycler struct Cycler

View file

@ -703,7 +703,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, backupxyz, dukeplayer_backupxyz)
void dukeplayer_setpos(player_struct* self, double x, double y, double z) void dukeplayer_setpos(player_struct* self, double x, double y, double z)
{ {
self->PlayerNowPosition = { x, y, z }; self->posSet({ x, y, z });
} }
DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, setpos, dukeplayer_setpos) DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, setpos, dukeplayer_setpos)