diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 233821b7c0f..db7cfbe42fd 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -855,62 +855,18 @@ int32_t nextsectorneighborz(int16_t sectnum, int32_t refz, int16_t topbottom, in // // cansee // -int32_t cansee_old(int32_t xs, int32_t ys, int32_t zs, int16_t sectnums, int32_t xe, int32_t ye, int32_t ze, int16_t sectnume) -{ - sectortype *sec, *nsec; - walltype *wal, *wal2; - int32_t intx, inty, intz, i, cnt, nextsector, dasectnum, dacnt, danum; - - if ((xs == xe) && (ys == ye) && (sectnums == sectnume)) return 1; - - clipsectorlist[0] = sectnums; danum = 1; - for(dacnt=0;dacntwallnum,wal=&wall[sec->wallptr];cnt>0;cnt--,wal++) - { - wal2 = &wall[wal->point2]; - if (lintersect(xs,ys,zs,xe,ye,ze,wal->x,wal->y,wal2->x,wal2->y,&intx,&inty,&intz) != 0) - { - nextsector = wal->nextsector; if (nextsector < 0) return 0; - - if (intz <= sec->ceilingz) return 0; - if (intz >= sec->floorz) return 0; - nsec = §or[nextsector]; - if (intz <= nsec->ceilingz) return 0; - if (intz >= nsec->floorz) return 0; - - for(i=danum-1;i>=0;i--) - if (clipsectorlist[i] == nextsector) break; - if (i < 0) clipsectorlist[danum++] = nextsector; - } - } - - if (clipsectorlist[dacnt] == sectnume) - return 1; - } - return 0; -} int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, int32_t y2, int32_t z2, int16_t sect2) { - if (enginecompatibility_mode == ENGINECOMPATIBILITY_19950829) - return cansee_old(x1, y1, z1, sect1, x2, y2, z2, sect2); - int32_t dacnt, danum; const int32_t x21 = x2-x1, y21 = y2-y1, z21 = z2-z1; - static uint8_t sectbitmap[(MAXSECTORS+7)>>3]; - memset(sectbitmap, 0, sizeof(sectbitmap)); if (x1 == x2 && y1 == y2) return (sect1 == sect2); - sectbitmap[sect1>>3] |= (1 << (sect1&7)); - clipsectorlist[0] = sect1; danum = 1; + BFSSearch search(numsectors, sect1); - for (dacnt=0; dacnt= cfz[1]) return 0; - if (!(sectbitmap[nexts>>3] & (1 << (nexts&7)))) - { - sectbitmap[nexts>>3] |= (1 << (nexts&7)); - clipsectorlist[danum++] = nexts; - } + search.Add(nexts); } } - - if (sectbitmap[sect2>>3] & (1<<(sect2&7))) - return 1; - - return 0; + return search.Check(sect2); } //