diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index ef3ad548e..ccdb00302 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -11021,29 +11021,27 @@ void updatesector(int32_t const x, int32_t const y, int16_t * const sectnum) void updatesectorbreadth(int32_t const x, int32_t const y, int16_t * const sectnum) { + if ((unsigned)*sectnum >= (unsigned)numsectors) + return; + static int16_t sectlist[MAXSECTORS]; static uint8_t sectbitmap[MAXSECTORS>>3]; - int32_t nsecs, sectcnt, j; - - if ((unsigned)(*sectnum) >= (unsigned)numsectors) - return; + int32_t nsecs; bfirst_search_init(sectlist, sectbitmap, &nsecs, numsectors, *sectnum); - for (sectcnt=0; sectcntwallptr; - int32_t endwall = sec->wallptr + sec->wallnum; + auto const sec = §or[sectlist[sectcnt]]; + int const startwall = sec->wallptr; + int const endwall = sec->wallptr + sec->wallnum; - for (j=startwall; j= 0) - bfirst_search_try(sectlist, sectbitmap, &nsecs, wall[j].nextsector); - } + for (int j=startwall; j= 0) + bfirst_search_try(sectlist, sectbitmap, &nsecs, wall[j].nextsector); } *sectnum = -1;