diff --git a/source/build/include/build.h b/source/build/include/build.h index 052d0cd36..9883ccb78 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -1174,7 +1174,8 @@ int32_t try_facespr_intersect(uspriteptr_t const spr, const vec3_t *refpos, int32_t vx, int32_t vy, int32_t vz, vec3_t *intp, int32_t strictly_smaller_than_p); -bool sectoradjacent(int sect1, int sect2); +int findwallbetweensectors(int sect1, int sect2); +static FORCE_INLINE bool sectoradjacent(int sect1, int sect2) { return findwallbetweensectors(sect1, sect2) != -1; } int32_t getwalldist(vec2_t const &p, int const wallnum, vec2_t * const output = nullptr); int32_t getsectordist(vec2_t const &p, int const sectnum); extern const int16_t *chsecptr_onextwall; diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index a7ad9c3cb..cb857c869 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -10993,16 +10993,19 @@ int32_t getsectordist(vec2_t const &pos, int const sectnum) return distance; } -bool sectoradjacent(int sect1, int sect2) +int findwallbetweensectors(int sect1, int sect2) { if (sector[sect1].wallnum > sector[sect2].wallnum) swaplong(§1, §2); - for (int i = 0; i < sector[sect1].wallnum; i++) - if (wall[sector[sect1].wallptr + i].nextsector == sect2) - return 1; + auto const sec = (usectorptr_t)§or[sect1]; + int const last = sec->wallptr + sec->wallnum; - return 0; + for (int i = sec->wallptr; i < last; i++) + if (wall[i].nextsector == sect2) + return i; + + return -1; } #define MAXUPDATESECTORDIST 1536