From 69a3f9e884d6c792fd68a26d949f7479eca3dccd Mon Sep 17 00:00:00 2001 From: terminx Date: Sun, 20 Oct 2019 17:55:20 +0000 Subject: [PATCH] Band-aid fix for Duke3d E4L4 map "corruption" The map isn't necessarily "corrupt", but it has a large water sector with half a dozen different SE7 teleporter sprites in it, of which all but one have destination SE7 sprites that are constantly moving while the matching SE7 in the large sector stays in place. When you teleport, the game code picks one. It doesn't always pick the one that matches. Yeah, OK, it never picks the one that matches. The area is a total clusterfuck. git-svn-id: https://svn.eduke32.com/eduke32@8241 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/src/clip.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index cd8e64390..8b83310e9 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -1010,7 +1010,7 @@ static int get_floorspr_clipyou(vec2_t const v1, vec2_t const v2, vec2_t const v return clipyou; } -static void clipupdatesector(vec2_t const pos, int16_t * const sectnum, int const walldist) +static void clipupdatesector(vec2_t const pos, int16_t * const sectnum, int walldist) { if (enginecompatibility_mode != ENGINECOMPATIBILITY_NONE) { @@ -1021,9 +1021,17 @@ static void clipupdatesector(vec2_t const pos, int16_t * const sectnum, int cons if (inside_p(pos.x, pos.y, *sectnum)) return; + int16_t nsecs = min(getsectordist(pos, *sectnum), INT16_MAX); + + if (nsecs > (walldist + 8)) + { + OSD_Printf(EDUKE32_PRETTY_FUNCTION ":%d shortest distance between origin point (%d, %d) and sector %d is %d. Sector may be corrupt!\n", + __LINE__, pos.x, pos.y, *sectnum, nsecs); + walldist = 0x7fff; + } + static int16_t sectlist[MAXSECTORS]; static uint8_t sectbitmap[(MAXSECTORS+7)>>3]; - int16_t nsecs; bfirst_search_init(sectlist, sectbitmap, &nsecs, MAXSECTORS, *sectnum);