From 74944c9ed0b40694eaa86c7e86f42e487860f26c Mon Sep 17 00:00:00 2001 From: terminx Date: Wed, 10 Apr 2019 09:31:09 +0000 Subject: [PATCH] Fix clipupdatesector() git-svn-id: https://svn.eduke32.com/eduke32@7573 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/src/clip.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index f268740df..240f05683 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -921,8 +921,8 @@ static void clipupdatesector(int32_t const x, int32_t const y, int16_t * const s if (inside_p(x, y, *sectnum)) return; - static int16_t sectlist[MAXCLIPSECTORS]; - static uint8_t sectbitmap[MAXCLIPSECTORS >> 3]; + static int16_t sectlist[MAXSECTORS]; + static uint8_t sectbitmap[MAXSECTORS >> 3]; int32_t nsecs; bfirst_search_init(sectlist, sectbitmap, &nsecs, numsectors, *sectnum); @@ -948,6 +948,28 @@ static void clipupdatesector(int32_t const x, int32_t const y, int16_t * const s } } + bfirst_search_init(sectlist, sectbitmap, &nsecs, numsectors, *sectnum); + + for (int sectcnt = 0; sectcnt < nsecs; sectcnt++) + { + if (inside_p(x, y, sectlist[sectcnt])) + { + // add sector to clipping list so the next call to clipdatesector() + // finishes in the loop above this one + addclipsect(sectlist[sectcnt]); + SET_AND_RETURN(*sectnum, sectlist[sectcnt]); + } + + auto const sec = §or[sectlist[sectcnt]]; + int const startwall = sec->wallptr; + int const endwall = sec->wallptr + sec->wallnum; + + // check floor curbs here? + for (int j = startwall; j < endwall; j++) + if (wall[j].nextsector >= 0) + bfirst_search_try(sectlist, sectbitmap, &nsecs, wall[j].nextsector); + } + *sectnum = -1; }