From 83999ee6e4149118036b0cd6356eb939f0e2c9e3 Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 6 Apr 2019 06:37:32 +0000 Subject: [PATCH] Minor cleanup of breadth-first search functions git-svn-id: https://svn.eduke32.com/eduke32@7476 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/include/build.h | 4 ++-- source/build/src/engine.cpp | 16 +++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index 1fcdd8580..a250a5345 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -1141,8 +1141,8 @@ static FORCE_INLINE void rotatesprite_win(int32_t sx, int32_t sy, int32_t z, int rotatesprite_(sx, sy, z, a, picnum, dashade, dapalnum, dastat, 0, 0, windowxy1.x,windowxy1.y,windowxy2.x,windowxy2.y); } -void bfirst_search_init(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int32_t maxnum, int16_t firstelt); -void bfirst_search_try(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int16_t elt); +void bfirst_search_init(int16_t * const list, uint8_t * const bitmap, int32_t * const eltnumptr, int const maxelts, int const firstelt); +void bfirst_search_try(int16_t * const list, uint8_t * const bitmap, int32_t * const eltnumptr, int const elt); void getzrange(const vec3_t *pos, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz, int32_t *florhit, int32_t walldist, uint32_t cliptype) ATTRIBUTE((nonnull(1,3,4,5,6))); diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index f38d0d3b4..f65e4e9d6 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -10939,25 +10939,23 @@ int32_t lastwall(int16_t point) } // breadth-first search helpers -void bfirst_search_init(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int32_t maxnum, int16_t firstelt) +void bfirst_search_init(int16_t * const list, uint8_t * const bitmap, int32_t * const eltnumptr, int const maxelts, int const firstelt) { - Bmemset(bitmap, 0, (maxnum+7)>>3); + Bmemset(bitmap, 0, (maxelts+7)>>3); list[0] = firstelt; - bitmap[firstelt>>3] |= (1<<(firstelt&7)); + bitmap_set(bitmap, firstelt); *eltnumptr = 1; } -void bfirst_search_try(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int16_t elt) +void bfirst_search_try(int16_t * const list, uint8_t * const bitmap, int32_t * const eltnumptr, int const elt) { if (elt < 0) return; - - if ((bitmap[elt>>3]&(1<<(elt&7)))==0) + else if (bitmap_test(bitmap, elt)==0) { - bitmap[elt>>3] |= (1<<(elt&7)); - list[*eltnumptr] = elt; - (*eltnumptr)++; + bitmap_set(bitmap, elt); + list[(*eltnumptr)++] = elt; } }