diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 408e287aa..b5fbf91ff 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -2643,7 +2643,7 @@ void actRadiusDamage(DBloodActor* source, const DVector3& pos, sectortype* pSect int x = pos.X * worldtoint, y = pos.Y * worldtoint, z = pos.Z * worldtoint; auto pOwner = source->GetOwner(); const bool newSectCheckMethod = !cl_bloodvanillaexplosions && pOwner && pOwner->IsDudeActor() && !VanillaMode(); // use new sector checking logic - auto sectorMap = GetClosestSpriteSectors(pSector, x, y, nDist, nullptr, newSectCheckMethod); + auto sectorMap = GetClosestSpriteSectors(pSector, pos.XY(), nDist, nullptr, newSectCheckMethod); nDist <<= 4; if (flags & 2) { @@ -5801,7 +5801,7 @@ static void actCheckExplosion() // so only allow this new checking method for dude spawned explosions affectedXWalls.Clear(); const bool newSectCheckMethod = !cl_bloodvanillaexplosions && Owner && Owner->IsDudeActor() && !VanillaMode(); // use new sector checking logic - auto sectorMap = GetClosestSpriteSectors(pSector, x, y, radius, &affectedXWalls, newSectCheckMethod); + auto sectorMap = GetClosestSpriteSectors(pSector, apos.XY(), radius, &affectedXWalls, newSectCheckMethod); for (auto pWall : affectedXWalls) { diff --git a/source/games/blood/src/ai.cpp b/source/games/blood/src/ai.cpp index aaf39ff88..b3001c8c4 100644 --- a/source/games/blood/src/ai.cpp +++ b/source/games/blood/src/ai.cpp @@ -1582,7 +1582,7 @@ void aiLookForTarget(DBloodActor* actor) if (actor->xspr.state) { const bool newSectCheckMethod = !cl_bloodvanillaenemies && !VanillaMode(); // use new sector checking logic - GetClosestSpriteSectors(actor->sector(), actor->int_pos().X, actor->int_pos().Y, 400, nullptr, newSectCheckMethod); + GetClosestSpriteSectors(actor->sector(), actor->spr.pos.XY(), 400, nullptr, newSectCheckMethod); BloodStatIterator it(kStatDude); while (DBloodActor* actor2 = it.Next()) diff --git a/source/games/blood/src/aibeast.cpp b/source/games/blood/src/aibeast.cpp index 738368392..d72384af5 100644 --- a/source/games/blood/src/aibeast.cpp +++ b/source/games/blood/src/aibeast.cpp @@ -90,7 +90,7 @@ void StompSeqCallback(int, DBloodActor* actor) int v1c = 5 + 2 * gGameOptions.nDifficulty; int v10 = 25 + 30 * gGameOptions.nDifficulty; const bool newSectCheckMethod = !cl_bloodvanillaenemies && !VanillaMode(); // use new sector checking logic - auto sectorMap = GetClosestSpriteSectors(pSector, x, y, vc, nullptr, newSectCheckMethod); + auto sectorMap = GetClosestSpriteSectors(pSector, actor->spr.pos.XY(), vc, nullptr, newSectCheckMethod); int hit = HitScan(actor, actor->int_pos().Z, angx, angy, 0, CLIPMASK1, 0); DBloodActor* actorh = nullptr; actHitcodeToData(hit, &gHitInfo, &actorh); diff --git a/source/games/blood/src/gameutil.cpp b/source/games/blood/src/gameutil.cpp index 1df06a69f..728490579 100644 --- a/source/games/blood/src/gameutil.cpp +++ b/source/games/blood/src/gameutil.cpp @@ -762,8 +762,10 @@ void ClipMove(vec3_t& pos, sectortype** pSector, int xv, int yv, int wd, int cd, // //--------------------------------------------------------------------------- -BitArray GetClosestSpriteSectors(sectortype* pSector, int x, int y, int nDist, TArray* pWalls, bool newSectCheckMethod) +BitArray GetClosestSpriteSectors(sectortype* pSector, const DVector2& pos, int nDist, TArray* pWalls, bool newSectCheckMethod) { + int x = pos.X * worldtoint; + int y = pos.Y * worldtoint; // by default this function fails with sectors that linked with wide spans, or there was more than one link to the same sector. for example... // E6M1: throwing TNT on the stone footpath while standing on the brown road will fail due to the start/end points of the span being too far away. it'll only do damage at one end of the road // E1M2: throwing TNT at the double doors while standing on the train platform @@ -792,7 +794,7 @@ BitArray GetClosestSpriteSectors(sectortype* pSector, int x, int y, int nDist, T } else // new method using proper math and no bad shortcut. { - double dist1 = SquareDistToWall(x * inttoworld, y * inttoworld, &wal); + double dist1 = SquareDistToWall(pos.X, pos.Y, &wal); withinRange = dist1 <= nDist4sq; } if (withinRange) // if new sector is within range, add it to the processing queue diff --git a/source/games/blood/src/gameutil.h b/source/games/blood/src/gameutil.h index d615ceb89..82d41f9b5 100644 --- a/source/games/blood/src/gameutil.h +++ b/source/games/blood/src/gameutil.h @@ -54,7 +54,7 @@ inline void ClipMove(DVector3& pos, sectortype** pSector, int xv, int yv, int wd ClipMove(ipos, pSector, xv, yv, wd, cd, fd, nMask, hit, tracecount); pos = { ipos.X * inttoworld, ipos.Y * inttoworld, ipos.Z * zinttoworld }; } -BitArray GetClosestSpriteSectors(sectortype* pSector, int x, int y, int nDist, TArray* pWalls, bool newSectCheckMethod = false); +BitArray GetClosestSpriteSectors(sectortype* pSector, const DVector2& pos, int nDist, TArray* pWalls, bool newSectCheckMethod = false); int picWidth(int nPic, int repeat); int picHeight(int nPic, int repeat); diff --git a/source/games/blood/src/weapon.cpp b/source/games/blood/src/weapon.cpp index 97bf6d3c1..1bf31bd5a 100644 --- a/source/games/blood/src/weapon.cpp +++ b/source/games/blood/src/weapon.cpp @@ -2992,6 +2992,7 @@ void WeaponProcess(PLAYER* pPlayer) { void teslaHit(DBloodActor* missileactor, int a2) { + auto mpos = missileactor->spr.pos; int x = missileactor->int_pos().X; int y = missileactor->int_pos().Y; int z = missileactor->int_pos().Z; @@ -2999,7 +3000,7 @@ void teslaHit(DBloodActor* missileactor, int a2) auto pSector = missileactor->sector(); auto owneractor = missileactor->GetOwner(); const bool newSectCheckMethod = !cl_bloodvanillaexplosions && !VanillaMode(); // use new sector checking logic - auto sectorMap = GetClosestSpriteSectors(pSector, x, y, nDist, nullptr, newSectCheckMethod); + auto sectorMap = GetClosestSpriteSectors(pSector, mpos.XY(), nDist, nullptr, newSectCheckMethod); bool v4 = true; DBloodActor* actor = nullptr; actHitcodeToData(a2, &gHitInfo, &actor);