diff --git a/source/core/coreactor.h b/source/core/coreactor.h index b3277a555..a51e4a1fd 100644 --- a/source/core/coreactor.h +++ b/source/core/coreactor.h @@ -95,6 +95,12 @@ public: spr.pos = add; } + void copy_int_xy(DCoreActor* other) + { + spr.pos.X = other->spr.pos.X; + spr.pos.Y = other->spr.pos.Y; + } + void set_int_xy(int x, int y) { spr.pos.X = x; @@ -490,6 +496,17 @@ inline int pushmove(vec3_t* const vect, sectortype** const sect, int32_t const w return res; } +inline int pushmove(DCoreActor* actor, sectortype** const sect, int32_t const walldist, int32_t const ceildist, int32_t const flordist, + uint32_t const cliptype, bool clear = true) +{ + auto vect = actor->int_pos(); + int sectno = *sect ? sector.IndexOf(*sect) : -1; + int res = pushmove_(&vect, §no, walldist, ceildist, flordist, cliptype, clear); + actor->set_int_pos(vect); + *sect = sectno == -1 ? nullptr : §or[sectno]; + return res; +} + tspritetype* renderAddTsprite(tspriteArray& tsprites, DCoreActor* actor); inline PClassActor* PClass::FindActor(FName name) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 055003b6c..c617762dc 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -4776,7 +4776,7 @@ void MoveDude(DBloodActor* actor) if (pSector->type >= kSectorPath && pSector->type <= kSectorRotate) { auto pSector2 = pSector; - if (pushmove(&actor->spr.pos, &pSector2, wd, tz, bz, CLIPMASK0) == -1) + if (pushmove(actor, &pSector2, wd, tz, bz, CLIPMASK0) == -1) actDamageSprite(actor, actor, kDamageFall, 1000 << 4); if (pSector2 != nullptr) pSector = pSector2; diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 3555920bd..798fae76a 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -1692,7 +1692,7 @@ void debrisMove(int listIndex) if (pSector->type >= kSectorPath && pSector->type <= kSectorRotate) { auto pSector2 = pSector; - if (pushmove(&actor->spr.pos, &pSector2, clipDist, ceilDist, floorDist, CLIPMASK0) != -1) + if (pushmove(actor, &pSector2, clipDist, ceilDist, floorDist, CLIPMASK0) != -1) pSector = pSector2; } diff --git a/source/games/blood/src/osdcmd.cpp b/source/games/blood/src/osdcmd.cpp index 398ff4261..594897fa1 100644 --- a/source/games/blood/src/osdcmd.cpp +++ b/source/games/blood/src/osdcmd.cpp @@ -36,8 +36,9 @@ void GameInterface::WarpToCoords(int x, int y, int z, int ang, int horz) PLAYER* pPlayer = &gPlayer[myconnectindex]; VIEW* pView = &gPrevView[myconnectindex]; - pPlayer->actor->spr.pos.X = pView->x = gView->actor->spr.pos.X = x; - pPlayer->actor->spr.pos.Y = pView->y = gView->actor->spr.pos.Y = y; + pPlayer->actor->copy_int_xy(gView->actor); + pView->x = gView->actor->int_pos().X; + pView->y = gView->actor->int_pos().Y; pPlayer->zView = pView->viewz = gView->zView = z; if (ang != INT_MIN) diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index ff44f94b1..c97a6f723 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -1850,7 +1850,7 @@ void playerProcess(PLAYER* pPlayer) if (!gNoClip) { auto pSector = actor->sector(); - if (pushmove(&actor->spr.pos, &pSector, dw, dzt, dzb, CLIPMASK0) == -1) + if (pushmove(actor, &pSector, dw, dzt, dzb, CLIPMASK0) == -1) actDamageSprite(actor, actor, kDamageFall, 500 << 4); if (actor->sector() != pSector) { diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index 70940ad54..6eab7d3bb 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -937,8 +937,7 @@ void TranslateSector(sectortype* pSector, int a2, int a3, int a4, int a5, int a6 RotatePoint((int*)&x, (int*)&y, ang, a4, a5); viewBackupSpriteLoc(actor); actor->spr.ang = (actor->spr.ang + v14) & 2047; - actor->spr.pos.X = x + vc - a4; - actor->spr.pos.Y = y + v8 - a5; + actor->set_int_xy(x + vc - a4, y + v8 - a5); } else if (actor->spr.cstat & CSTAT_SPRITE_MOVE_REVERSE) { @@ -946,8 +945,7 @@ void TranslateSector(sectortype* pSector, int a2, int a3, int a4, int a5, int a6 RotatePoint((int*)&x, (int*)&y, -ang, a4, sprDy); viewBackupSpriteLoc(actor); actor->spr.ang = (actor->spr.ang - v14) & 2047; - actor->spr.pos.X = x - (vc - a4); - actor->spr.pos.Y = y - (v8 - a5); + actor->set_int_xy(x - vc + a4, y - v8 + a5); } else if (pXSector->Drag) { @@ -958,7 +956,11 @@ void TranslateSector(sectortype* pSector, int a2, int a3, int a4, int a5, int a6 { viewBackupSpriteLoc(actor); if (v14) - RotatePoint((int*)&actor->spr.pos.X, (int*)&actor->spr.pos.Y, v14, v20, v24); + { + auto pos = actor->int_pos(); + RotatePoint(&pos.X, &pos.Y, v14, v20, v24); + actor->set_int_pos(pos); + } actor->spr.ang = (actor->spr.ang + v14) & 2047; actor->add_int_pos({ v28, v2c, 0 }); }