- use the player position utilities in actor*.cpp

This commit is contained in:
Christoph Oelckers 2022-02-05 10:51:45 +01:00
parent 3f33719c36
commit 8ba7cb0ddb
4 changed files with 60 additions and 63 deletions

View file

@ -202,7 +202,7 @@ void checkavailweapon(struct player_struct* player)
void clearcamera(player_struct* ps)
{
ps->newOwner = nullptr;
ps->__int_pos = ps->__int_opos;
ps->restorexyz();
ps->angle.restore();
updatesector(ps->player_int_pos().X, ps->player_int_pos().Y, &ps->cursector);
@ -761,7 +761,7 @@ void movecrane(DDukeActor *actor, int crane)
actor->temp_data[0] = 0;
if (cpt.poleactor)
SetActor(cpt.poleactor, vec3_t( actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z - (34 << 8) ));
SetActor(cpt.poleactor, actor->spr.pos.plusZ(-34));
auto Owner = actor->GetOwner();
if (Owner != nullptr || actor->IsActiveCrane())
@ -790,7 +790,7 @@ void movecrane(DDukeActor *actor, int crane)
else if (actor->IsActiveCrane())
{
auto ang = ps[p].angle.ang.asbuild();
ps[p].__int_opos = ps[p].__int_pos;
ps[p].backupxyz();
ps[p].__int_pos.X = actor->int_pos().X - bcos(ang, -6);
ps[p].__int_pos.Y = actor->int_pos().Y - bsin(ang, -6);
ps[p].__int_pos.Z = actor->int_pos().Z + (2 << 8);
@ -2833,11 +2833,10 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6)
updatesector(ps[p].player_int_pos().X, ps[p].player_int_pos().Y, &k);
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && ps[p].cursector != actor->sector()))
{
ps[p].__int_pos.X = actor->int_pos().X;
ps[p].__int_pos.Y = actor->int_pos().Y;
ps[p].getxyfromactor(actor);
ps[p].setCursector(actor->sector());
SetActor(ps[p].GetActor(), actor->int_pos());
SetActor(ps[p].GetActor(), actor->spr.pos);
quickkill(&ps[p]);
}
}
@ -2872,8 +2871,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6)
if (numplayers > 1)
{
ps[p].__int_opos.X = ps[p].player_int_pos().X;
ps[p].__int_opos.Y = ps[p].player_int_pos().Y;
ps[p].backupxy();
}
if (psp->spr.extra <= 0)
{
@ -2920,8 +2918,8 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6)
updatesector(ps[p].player_int_pos().X, ps[p].player_int_pos().Y, &k);
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && ps[p].cursector != actor->sector()))
{
ps[p].__int_opos.X = ps[p].__int_pos.X = actor->int_pos().X;
ps[p].__int_opos.Y = ps[p].__int_pos.Y = actor->int_pos().Y;
ps[p].getxyfromactor(actor);
ps[p].backupxy();
ps[p].setCursector(actor->sector());
SetActor(ps[p].GetActor(), actor->int_pos());
@ -3021,8 +3019,7 @@ void handle_se30(DDukeActor *actor, int JIBS6)
updatesector(ps[p].player_int_pos().X, ps[p].player_int_pos().Y, &k);
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && ps[p].cursector != actor->sector()))
{
ps[p].__int_pos.X = actor->int_pos().X;
ps[p].__int_pos.Y = actor->int_pos().Y;
ps[p].getxyfromactor(actor);
ps[p].setCursector(actor->sector());
SetActor(ps[p].GetActor(), actor->int_pos());
@ -3040,8 +3037,7 @@ void handle_se30(DDukeActor *actor, int JIBS6)
if (numplayers > 1)
{
ps[p].__int_opos.X = ps[p].player_int_pos().X;
ps[p].__int_opos.Y = ps[p].player_int_pos().Y;
ps[p].backupxy();
}
ps[p].bobpos.X += l;
@ -3082,11 +3078,8 @@ void handle_se30(DDukeActor *actor, int JIBS6)
updatesector(ps[p].player_int_pos().X, ps[p].player_int_pos().Y, &k);
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && ps[p].cursector != actor->sector()))
{
ps[p].__int_pos.X = actor->int_pos().X;
ps[p].__int_pos.Y = actor->int_pos().Y;
ps[p].__int_opos.X = ps[p].player_int_pos().X;
ps[p].__int_opos.Y = ps[p].player_int_pos().Y;
ps[p].getxyfromactor(actor);
ps[p].backupxy();
ps[p].setCursector(actor->sector());
@ -3835,11 +3828,11 @@ void handle_se17(DDukeActor* actor)
if (act1->spr.statnum == STAT_PLAYER && act1->GetOwner())
{
int p = act1->spr.yvel;
if (numplayers < 2) ps[p].__int_opos.Z = ps[p].player_int_pos().Z;
if (numplayers < 2) ps[p].backupz();
ps[p].__int_pos.Z += q * zworldtoint;
ps[p].truefz += q;
ps[p].truecz += q;
if (numplayers > 1) ps[p].__int_opos.Z = ps[p].player_int_pos().Z;
if (numplayers > 1) ps[p].backupz();
}
if (act1->spr.statnum != STAT_EFFECTOR)
{
@ -3894,9 +3887,8 @@ void handle_se17(DDukeActor* actor)
act3->floorz = act2->sector()->floorz;
act3->ceilingz = act2->sector()->ceilingz;
ps[p].bobpos.X = ps[p].__int_opos.X = ps[p].player_int_pos().X;
ps[p].bobpos.Y = ps[p].__int_opos.Y = ps[p].player_int_pos().Y;
ps[p].__int_opos.Z = ps[p].player_int_pos().Z;
ps[p].backupxyz();
ps[p].setbobpos();
ps[p].truefz = act3->floorz;
ps[p].truecz = act3->ceilingz;
@ -4184,8 +4176,7 @@ void handle_se20(DDukeActor* actor)
ps[p].__int_pos.X += x;
ps[p].__int_pos.Y +=l;
ps[p].__int_opos.X = ps[p].player_int_pos().X;
ps[p].__int_opos.Y = ps[p].player_int_pos().Y;
ps[p].backupxy();
SetActor(ps[p].GetActor(), vec3_t( ps[p].player_int_pos().X, ps[p].player_int_pos().Y, ps[p].player_int_pos().Z + gs.int_playerheight ));
}

View file

@ -1806,9 +1806,9 @@ void movetransports_d(void)
ps[p].transporter_hold = 13;
}
ps[p].bobpos.X = ps[p].__int_opos.X = ps[p].__int_pos.X = Owner->int_pos().X;
ps[p].bobpos.Y = ps[p].__int_opos.Y = ps[p].__int_pos.Y = Owner->int_pos().Y;
ps[p].__int_opos.Z = ps[p].__int_pos.Z = Owner->int_pos().Z - gs.int_playerheight;
ps[p].getposfromactor(Owner, -gs.playerheight);
ps[p].backupxyz();
ps[p].setbobpos();
ChangeActorSect(act2, Owner->sector());
ps[p].setCursector(act2->sector());
@ -1828,13 +1828,14 @@ 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].__int_opos.X = ps[p].__int_pos.X += Owner->int_pos().X - act->int_pos().X;
ps[p].__int_opos.Y = ps[p].__int_pos.Y +=Owner->int_pos().Y - act->int_pos().Y;
ps[p].__int_pos.X += Owner->int_pos().X - act->int_pos().X;
ps[p].__int_pos.Y += Owner->int_pos().Y - act->int_pos().Y;
ps[p].backupxy();
if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11))
ps[p].__int_pos.Z = Owner->int_pos().Z - 6144;
else ps[p].__int_pos.Z = Owner->int_pos().Z + 6144;
ps[p].__int_opos.Z = ps[p].player_int_pos().Z;
ps[p].backupz();
auto pa = ps[p].GetActor();
pa->opos = DVector3(ps[p].__int_pos.X * inttoworld, ps[p].__int_pos.Y * inttoworld, ps[p].__int_pos.Z * zinttoworld);
@ -1857,8 +1858,8 @@ void movetransports_d(void)
}
if (ps[p].GetActor()->spr.extra > 0)
S_PlayActorSound(DUKE_UNDERWATER, act2);
ps[p].__int_opos.Z = ps[p].__int_pos.Z =
Owner->sector()->int_ceilingz() + (7 << 8);
ps[p].__int_pos.Z = Owner->sector()->int_ceilingz() + (7 << 8);
ps[p].backupz();
ps[p].vel.X = 4096 - (krand() & 8192);
ps[p].vel.Y = 4096 - (krand() & 8192);
@ -1875,8 +1876,8 @@ void movetransports_d(void)
}
S_PlayActorSound(DUKE_GASP, act2);
ps[p].__int_opos.Z = ps[p].__int_pos.Z =
Owner->sector()->int_floorz() - (7 << 8);
ps[p].__int_pos.Z = Owner->sector()->int_floorz() - (7 << 8);
ps[p].backupz();
ps[p].jumping_toggle = 1;
ps[p].jumping_counter = 0;
@ -1884,8 +1885,9 @@ void movetransports_d(void)
if (k == 1)
{
ps[p].__int_opos.X = ps[p].__int_pos.X += Owner->int_pos().X - act->int_pos().X;
ps[p].__int_opos.Y = ps[p].__int_pos.Y +=Owner->int_pos().Y - act->int_pos().Y;
ps[p].__int_pos.X += Owner->int_pos().X - act->int_pos().X;
ps[p].__int_pos.Y +=Owner->int_pos().Y - act->int_pos().Y;
ps[p].backupxy();
if (!Owner || Owner->GetOwner() != Owner)
ps[p].transporter_hold = -2;
@ -2183,7 +2185,7 @@ static void greenslime(DDukeActor *actor)
if (ps[p].newOwner != nullptr)
{
ps[p].newOwner = nullptr;
ps[p].__int_pos = ps[p].__int_opos;
ps[p].restorexyz();
ps[p].angle.restore();
updatesector(ps[p].player_int_pos().X, ps[p].player_int_pos().Y, &ps[p].cursector);

View file

@ -1456,9 +1456,9 @@ void movetransports_r(void)
ps[p].transporter_hold = 13;
}
ps[p].bobpos.X = ps[p].__int_opos.X = ps[p].__int_pos.X = Owner->int_pos().X;
ps[p].bobpos.Y = ps[p].__int_opos.Y = ps[p].__int_pos.Y = Owner->int_pos().Y;
ps[p].__int_opos.Z = ps[p].__int_pos.Z = Owner->int_pos().Z - (gs.int_playerheight - (4 << 8));
ps[p].getposfromactor(Owner, -gs.playerheight + 4);
ps[p].backupxyz();
ps[p].setbobpos();
ChangeActorSect(act2, Owner->sector());
ps[p].setCursector(act2->sector());
@ -1475,13 +1475,14 @@ 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].__int_opos.X = ps[p].__int_pos.X += Owner->int_pos().X - act->int_pos().X;
ps[p].__int_opos.Y = ps[p].__int_pos.Y +=Owner->int_pos().Y - act->int_pos().Y;
ps[p].__int_pos.X += Owner->int_pos().X - act->int_pos().X;
ps[p].__int_pos.Y +=Owner->int_pos().Y - act->int_pos().Y;
ps[p].backupxy();
if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11))
ps[p].__int_pos.Z = Owner->int_pos().Z - 6144;
else ps[p].__int_pos.Z = Owner->int_pos().Z + 6144;
ps[p].__int_opos.Z = ps[p].player_int_pos().Z;
ps[p].backupz();
ChangeActorSect(act2, Owner->sector());
ps[p].setCursector(Owner->sector());
@ -1496,16 +1497,16 @@ void movetransports_r(void)
if (onfloorz && sectlotag == 160 && ps[p].player_int_pos().Z > (sectp->int_floorz() - (48 << 8)))
{
k = 2;
ps[p].__int_opos.Z = ps[p].__int_pos.Z =
Owner->sector()->int_ceilingz() + (7 << 8);
ps[p].__int_pos.Z = Owner->sector()->int_ceilingz() + (7 << 8);
ps[p].backupz();
}
if (onfloorz && sectlotag == 161 && ps[p].player_int_pos().Z < (sectp->int_ceilingz() + (6 << 8)))
{
k = 2;
if (ps[p].GetActor()->spr.extra <= 0) break;
ps[p].__int_opos.Z = ps[p].__int_pos.Z =
Owner->sector()->int_floorz() - (49 << 8);
ps[p].__int_pos.Z = Owner->sector()->int_floorz() - (49 << 8);
ps[p].backupz();
}
}
@ -1519,8 +1520,8 @@ void movetransports_r(void)
FX_StopAllSounds();
}
S_PlayActorSound(DUKE_UNDERWATER, ps[p].GetActor());
ps[p].__int_opos.Z = ps[p].__int_pos.Z =
Owner->sector()->int_ceilingz() + (7 << 8);
ps[p].__int_pos.Z = Owner->sector()->int_ceilingz() + (7 << 8);
ps[p].backupz();
if (ps[p].OnMotorcycle)
ps[p].moto_underwater = 1;
}
@ -1535,14 +1536,15 @@ void movetransports_r(void)
}
S_PlayActorSound(DUKE_GASP, ps[p].GetActor());
ps[p].__int_opos.Z = ps[p].__int_pos.Z =
Owner->sector()->int_floorz() - (7 << 8);
ps[p].__int_pos.Z = Owner->sector()->int_floorz() - (7 << 8);
ps[p].backupz();
}
if (k == 1)
{
ps[p].__int_opos.X = ps[p].__int_pos.X += Owner->int_pos().X - act->int_pos().X;
ps[p].__int_opos.Y = ps[p].__int_pos.Y +=Owner->int_pos().Y - act->int_pos().Y;
ps[p].__int_pos.X += Owner->int_pos().X - act->int_pos().X;
ps[p].__int_pos.Y +=Owner->int_pos().Y - act->int_pos().Y;
ps[p].backupxy();
if (Owner->GetOwner() != Owner)
ps[p].transporter_hold = -2;
@ -1555,8 +1557,9 @@ void movetransports_r(void)
}
else if (isRRRA() && k == 2)
{
ps[p].__int_opos.X = ps[p].__int_pos.X += Owner->int_pos().X - act->int_pos().X;
ps[p].__int_opos.Y = ps[p].__int_pos.Y +=Owner->int_pos().Y - act->int_pos().Y;
ps[p].__int_pos.X += Owner->int_pos().X - act->int_pos().X;
ps[p].__int_pos.Y +=Owner->int_pos().Y - act->int_pos().Y;
ps[p].backupxy();
if (Owner->GetOwner() != Owner)
ps[p].transporter_hold = -2;
@ -1912,7 +1915,8 @@ static void rrra_specialstats()
}
else if (act->spr.extra == 200)
{
SetActor(act, vec3_t( act->int_pos().X, act->int_pos().Y, act->sector()->int_floorz() - 10 ));
// This was really 10 and not (10 << 8)!
SetActor(act, DVector3(act->spr.pos.X, act->spr.pos.Y, act->sector()->floorz - 10 * zmaptoworld));
act->spr.extra = 1;
act->spr.picnum = PIG + 11;
spawn(act, TRANSPORTERSTAR);
@ -2289,9 +2293,9 @@ void rr_specialstats()
if (act2->spr.picnum == RRTILE297)
{
ps[p].angle.ang = buildang(act2->spr.ang);
ps[p].bobpos.X = ps[p].__int_opos.X = ps[p].__int_pos.X = act2->int_pos().X;
ps[p].bobpos.Y = ps[p].__int_opos.Y = ps[p].__int_pos.Y = act2->int_pos().Y;
ps[p].__int_opos.Z = ps[p].__int_pos.Z = act2->int_pos().Z - (36 << 8);
ps[p].getposfromactor(act2, -36);
ps[p].backupxyz();
ps[p].setbobpos();
auto pact = ps[p].GetActor();
ChangeActorSect(pact, act2->sector());
ps[p].setCursector(pact->sector());
@ -2835,7 +2839,7 @@ void moveactors_r(void)
getglobalz(act);
if (sectp->lotag == 1)
{
SetActor(act, vec3_t( act->int_pos().X,act->int_pos().Y,act->actor_int_floorz() + (16 << 8) ));
SetActor(act, DVector3(act->spr.pos.X, act->spr.pos.Y, act->floorz + 16));
}
break;

View file

@ -363,7 +363,7 @@ struct player_struct
__int_opos = __int_pos;
}
void restorepos()
void restorexyz()
{
__int_pos = __int_opos;
}