From 8415079e3257590db8822f83a96bd8bc36bec76e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 26 Oct 2022 12:18:30 +0200 Subject: [PATCH] - fixed compilation. --- source/build/src/clip.cpp | 6 +++--- source/core/gamefuncs.cpp | 18 +++++++++--------- source/core/gamefuncs.h | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index 016f60a6c..911e8385a 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -175,9 +175,9 @@ CollisionBase clipmove_(DVector3& inpos, sectortype** const sect, const DVector2 if (!clip.precise) { - - *sectnum = FindSectorInSearchList(fpos, clip.search); - if (*sectnum == -1) *sectnum = FindBestSector(fpos); + DVector3 pos3(fpos, clip.pos.Z); + *sect = FindSectorInSearchList(pos3, clip.search); + if (*sect == nullptr) *sect = FindBestSector(pos3); } copypos(); diff --git a/source/core/gamefuncs.cpp b/source/core/gamefuncs.cpp index 743a7f83c..3a909b508 100644 --- a/source/core/gamefuncs.cpp +++ b/source/core/gamefuncs.cpp @@ -1606,15 +1606,15 @@ void collectClipObjects(MoveClipper& clip, int spritemask) // //========================================================================== -int FindSectorInSearchList(const DVector3& pos, BFSSectorSearch& search) +sectortype* FindSectorInSearchList(const DVector3& pos, BFSSectorSearch& search) { search.Rewind(); while (auto sect = search.GetNext()) if (inside(pos.X, pos.Y, sect) == 1) { - return ::sectnum(sect); + return sect; } - return -1; + return nullptr; } //========================================================================== @@ -1623,9 +1623,9 @@ int FindSectorInSearchList(const DVector3& pos, BFSSectorSearch& search) // //========================================================================== -int FindBestSector(const DVector3& pos) +sectortype* FindBestSector(const DVector3& pos) { - int bestnum = 1; + sectortype* bestsect = nullptr; double bestdist = FLT_MAX; for (int secnum = (int)sector.Size() - 1; secnum >= 0; secnum--) { @@ -1641,7 +1641,7 @@ int FindBestSector(const DVector3& pos) double dist = ceilz - pos.Z; if (dist < bestdist) { - bestnum = secnum; + bestsect = sect; bestdist = dist; } } @@ -1651,18 +1651,18 @@ int FindBestSector(const DVector3& pos) double dist = pos.Z - floorz; if (dist < bestdist) { - bestnum = secnum; + bestsect = sect; bestdist = dist; } } else { // inside sector - return secnum; + return sect; } } } - return bestnum; + return bestsect; } //========================================================================== diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index 6769db237..a37023108 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -314,8 +314,8 @@ struct MoveClipper }; void collectClipObjects(MoveClipper& clip, int spritemask); -int FindBestSector(const DVector3& pos); -int FindSectorInSearchList(const DVector3& pos, BFSSectorSearch& search); +sectortype* FindBestSector(const DVector3& pos); +sectortype* FindSectorInSearchList(const DVector3& pos, BFSSectorSearch& search); void PushAway(MoveClipper &clip, DVector2& pos, sectortype* sect); void keepaway(MoveClipper& clip, DVector2& pos, ClipObject& clipo);