From 6bd97e312d4160329d3e5eecb9f694c9508b8652 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 13 Sep 2022 00:55:15 +0200 Subject: [PATCH] - cleanup of the wall hit checks in hitradius Yes, the z-check was indeed bad. --- source/games/duke/src/actors_d.cpp | 13 +++++++------ source/games/duke/src/actors_r.cpp | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index cf3274b4b..c19dcbb15 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -265,26 +265,27 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h { BFSSectorSearch search(actor->sector()); + double radius = r * inttoworld; while (auto dasectp = search.GetNext()) { - if (((dasectp->int_ceilingz() - actor->int_pos().Z) >> 8) < r) // what value range is this supposed to be? + if ((dasectp->ceilingz- actor->spr.pos.Z) < radius * 16) // what value range is this supposed to be? The check that was here did not multiply correctly { auto wal = dasectp->firstWall(); - int d = abs(wal->wall_int_pos().X - actor->int_pos().X) + abs(wal->wall_int_pos().Y - actor->int_pos().Y); - if (d < r) + double d = (wal->pos - actor->spr.pos.XY()).Sum(); + if (d < radius) fi.checkhitceiling(dasectp); else { auto thirdpoint = wal->point2Wall()->point2Wall(); - d = abs(thirdpoint->wall_int_pos().X - actor->int_pos().X) + abs(thirdpoint->wall_int_pos().Y - actor->int_pos().Y); - if (d < r) + d = (thirdpoint->pos - actor->spr.pos.XY()).Sum(); + if (d < radius) fi.checkhitceiling(dasectp); } } for (auto& wal : wallsofsector(dasectp)) { - if ((abs(wal.wall_int_pos().X - actor->int_pos().X) + abs(wal.wall_int_pos().Y - actor->int_pos().Y)) < r) + if ((wal.pos - actor->spr.pos.XY()).Sum() < radius) { if (wal.twoSided()) { diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 0acbfa896..8bec30d3f 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -223,26 +223,27 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h { BFSSectorSearch search(actor->sector()); + double radius = r * inttoworld; while (auto dasectp = search.GetNext()) { - if (((dasectp->int_ceilingz() - actor->int_pos().Z) >> 8) < r) + if ((dasectp->ceilingz- actor->spr.pos.Z) < radius * 16) // what value range is this supposed to be? The check that was here did not multiply correctly { auto wal = dasectp->firstWall(); - int d = abs(wal->wall_int_pos().X - actor->int_pos().X) + abs(wal->wall_int_pos().Y - actor->int_pos().Y); - if (d < r) + double d = (wal->pos - actor->spr.pos.XY()).Sum(); + if (d < radius) fi.checkhitceiling(dasectp); else { auto thirdpoint = wal->point2Wall()->point2Wall(); - d = abs(thirdpoint->wall_int_pos().X - actor->int_pos().X) + abs(thirdpoint->wall_int_pos().Y - actor->int_pos().Y); - if (d < r) + d = (thirdpoint->pos - actor->spr.pos.XY()).Sum(); + if (d < radius) fi.checkhitceiling(dasectp); } } for (auto& wal : wallsofsector(dasectp)) { - if ((abs(wal.wall_int_pos().X - actor->int_pos().X) + abs(wal.wall_int_pos().Y - actor->int_pos().Y)) < r) + if ((wal.pos - actor->spr.pos.XY()).Sum() < radius) { if (wal.twoSided()) {