diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 1f3d19e67..485880972 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -789,8 +789,7 @@ void movecrane(DDukeActor *actor, int crane) { auto ang = ps[p].angle.ang.asbuild(); 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].player_set_int_xy({ actor->int_pos().X - bcos(ang, -6), actor->int_pos().Y - bsin(ang, -6) }); ps[p].player_set_int_z(actor->int_pos().Z + (2 << 8)); SetActor(ps[p].GetActor(), ps[p].player_int_pos()); ps[p].setCursector(ps[p].GetActor()->sector()); @@ -2688,7 +2687,7 @@ void handle_se00(DDukeActor* actor) ps[p].bobpos.X += res.X - ps[p].player_int_pos().X; ps[p].bobpos.Y += res.Y - ps[p].player_int_pos().Y; - ps[p].__int_pos.vec2 = res; + ps[p].player_set_int_xy(res); auto psp = ps[p].GetActor(); if (psp->spr.extra <= 0) @@ -2857,10 +2856,10 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6) if (actor->sector() == psp->sector()) { - rotatepoint(actor->int_pos().vec2, ps[p].player_int_pos().vec2, q, &ps[p].__int_pos.vec2); + vec2_t result; + rotatepoint(actor->int_pos().vec2, ps[p].player_int_pos().vec2, q, &result); - ps[p].__int_pos.X += m; - ps[p].__int_pos.Y +=x; + ps[p].player_set_int_xy({ result.X + m, result.Y + x }); ps[p].bobpos.X += m; ps[p].bobpos.Y += x; @@ -3030,8 +3029,7 @@ void handle_se30(DDukeActor *actor, int JIBS6) auto psp = ps[p].GetActor(); if (psp->sector() == actor->sector()) { - ps[p].__int_pos.X += l; - ps[p].__int_pos.Y +=x; + ps[p].player_add_int_xy({ l, x }); if (numplayers > 1) { @@ -3162,8 +3160,7 @@ void handle_se02(DDukeActor* actor) for (int p = connecthead; p >= 0; p = connectpoint2[p]) if (ps[p].cursector == actor->sector() && ps[p].on_ground) { - ps[p].__int_pos.X += m; - ps[p].__int_pos.Y +=x; + ps[p].player_add_int_xy({ m, x }); ps[p].bobpos.X += m; ps[p].bobpos.Y += x; @@ -3878,8 +3875,7 @@ void handle_se17(DDukeActor* actor) { int p = act3->spr.yvel; - ps[p].__int_pos.X += act2->int_pos().X - actor->int_pos().X; - ps[p].__int_pos.Y +=act2->int_pos().Y - actor->int_pos().Y; + ps[p].player_add_int_xy({ act2->int_pos().X - actor->int_pos().X, act2->int_pos().Y - actor->int_pos().Y }); ps[p].player_set_int_z(act2->sector()->int_floorz() - (sc->int_floorz() - ps[p].player_int_pos().Z)); act3->floorz = act2->sector()->floorz; @@ -4171,9 +4167,7 @@ void handle_se20(DDukeActor* actor) for (int p = connecthead; p >= 0; p = connectpoint2[p]) if (ps[p].cursector == actor->sector() && ps[p].on_ground) { - ps[p].__int_pos.X += x; - ps[p].__int_pos.Y +=l; - + ps[p].player_add_int_xy({ x, l }); 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 )); diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 22fb02cdf..1d245bed7 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1828,8 +1828,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].__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].player_add_int_xy(Owner->int_pos().vec2 - act->int_pos().vec2); ps[p].backupxy(); if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11)) @@ -1885,8 +1884,7 @@ void movetransports_d(void) if (k == 1) { - 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].player_add_int_xy(Owner->int_pos().vec2 - act->int_pos().vec2); ps[p].backupxy(); if (!Owner || Owner->GetOwner() != Owner) diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 8c9ddae2b..5d14924af 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1475,8 +1475,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].__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].player_add_int_xy(Owner->int_pos().vec2 - act->int_pos().vec2); ps[p].backupxy(); if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11)) @@ -1542,8 +1541,7 @@ void movetransports_r(void) if (k == 1) { - 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].player_add_int_xy(Owner->int_pos().vec2 - act->int_pos().vec2); ps[p].backupxy(); if (Owner->GetOwner() != Owner) @@ -1557,8 +1555,7 @@ void movetransports_r(void) } else if (isRRRA() && k == 2) { - 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].player_add_int_xy(Owner->int_pos().vec2 - act->int_pos().vec2); ps[p].backupxy(); if (Owner->GetOwner() != Owner) diff --git a/source/games/duke/src/ccmds.cpp b/source/games/duke/src/ccmds.cpp index 3ad09309a..3853433fa 100644 --- a/source/games/duke/src/ccmds.cpp +++ b/source/games/duke/src/ccmds.cpp @@ -115,7 +115,8 @@ void GameInterface::WarpToCoords(int x, int y, int z, int ang, int horz) { player_struct* p = &ps[myconnectindex]; - p->__int_pos = { x, y, z }; + p->player_set_int_xy({ x, y}); + p->player_set_int_z(z); p->backupxyz(); if (ang != INT_MIN) diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index db4587dc3..32d2bd363 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -208,7 +208,7 @@ inline bool playrunning() inline void doslopetilting(player_struct* p, double const scaleAdjust = 1) { bool const canslopetilt = p->on_ground && p->insector() && p->cursector->lotag != ST_2_UNDERWATER && (p->cursector->floorstat & CSTAT_SECTOR_SLOPE); - p->horizon.calcviewpitch(p->__int_pos.vec2, p->angle.ang, p->aim_mode == 0, canslopetilt, p->cursector, scaleAdjust); + p->horizon.calcviewpitch(p->player_int_pos().vec2, p->angle.ang, p->aim_mode == 0, canslopetilt, p->cursector, scaleAdjust); } //--------------------------------------------------------------------------- diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index dc763be8f..580002682 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -3026,8 +3026,7 @@ HORIZONLY: Collision clip{}; if (ud.clipping) { - p->__int_pos.X += p->vel.X >> 14; - p->__int_pos.Y +=p->vel.Y >> 14; + p->player_add_int_xy({ p->vel.X >> 14, p->vel.Y >> 14 }); updatesector(p->player_int_pos().X, p->player_int_pos().Y, &p->cursector); ChangeActorSect(pact, p->cursector); } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index c7b33aba2..bbf4ddfce 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3795,8 +3795,7 @@ HORIZONLY: Collision clip{}; if (ud.clipping) { - p->__int_pos.X += p->vel.X >> 14; - p->__int_pos.Y +=p->vel.Y >> 14; + p->player_add_int_xy({ p->vel.X >> 14, p->vel.Y >> 14 }); updatesector(p->player_int_pos().X, p->player_int_pos().Y, &p->cursector); ChangeActorSect(pact, p->cursector); } diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 7083a76b5..b8cb23cbd 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -415,7 +415,7 @@ struct player_struct vec3_t player_int_opos() const { - return { int(opos.X * worldtoint), int(opos.Y * worldtoint),int(opos.Z * zworldtoint) }; + return { int(opos.X * worldtoint), int(opos.Y * worldtoint), int(opos.Z * zworldtoint) }; } void player_add_int_z(int z) @@ -427,6 +427,15 @@ struct player_struct { __int_pos.Z = z; } + void player_add_int_xy(const vec2_t& v) + { + __int_pos.vec2 += v; + } + void player_set_int_xy(const vec2_t& v) + { + __int_pos.vec2 = v; + } + };