diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index f82b577b1..d14b7f90d 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -204,14 +204,14 @@ double hitasprite(DDukeActor* actor, DDukeActor** hitsp) // //--------------------------------------------------------------------------- -int hitawall(player_struct* p, walltype** hitw) +double hitawall(player_struct* p, walltype** hitw) { HitInfo hit{}; - hitscan(p->player_int_pos(), p->cursector, { int(p->angle.ang.Cos() * (1 << 14)), int(p->angle.ang.Sin() * (1 << 14)), 0 }, hit, CLIPMASK0); + hitscan(p->pos, p->cursector, DVector3(p->angle.ang.ToVector() * 1024, 0), hit, CLIPMASK0); if (hitw) *hitw = hit.hitWall; - return (FindDistance2D(hit.int_hitpos().vec2 - p->player_int_pos().vec2)); + return (hit.hitpos.XY() - p->pos.XY()).Length(); } diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index a83ed3a15..881614f87 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -1563,10 +1563,11 @@ void checksectors_d(int snum) p->toggle_key_flag = 1; hitscanwall = nullptr; - i = hitawall(p, &hitscanwall); + double dist = hitawall(p, &hitscanwall); + if (hitscanwall != nullptr) { - if (i < 1280 && hitscanwall->overpicnum == MIRROR) + if (dist < 80 && hitscanwall->overpicnum == MIRROR) if (hitscanwall->lotag > 0 && S_CheckSoundPlaying(hitscanwall->lotag) == 0 && snum == screenpeek) { S_PlayActorSound(hitscanwall->lotag, pact); @@ -1701,6 +1702,7 @@ void checksectors_d(int snum) case VIEWSCREEN: case VIEWSCREEN2: { + i = 0; DukeStatIterator it(STAT_ACTOR); while (auto acti = it.Next()) {