Add new findwallbetweensectors() function and change sectoradjacent() to use it

git-svn-id: https://svn.eduke32.com/eduke32@7608 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2019-04-19 08:31:42 +00:00 committed by Christoph Oelckers
parent a2282def5b
commit 8d85e8d934
2 changed files with 10 additions and 6 deletions

View file

@ -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;

View file

@ -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(&sect1, &sect2);
for (int i = 0; i < sector[sect1].wallnum; i++)
if (wall[sector[sect1].wallptr + i].nextsector == sect2)
return 1;
auto const sec = (usectorptr_t)&sector[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