From 8878f9e71edf05a44d6dc46a4a03e116ea100b7b Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 3 Oct 2008 17:06:10 +0000 Subject: Fix crash with P_FindNextHighestFloor. Subversion-branch: /branches/raven-branch Subversion-revision: 1327 --- src/heretic/p_spec.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'src/heretic/p_spec.c') diff --git a/src/heretic/p_spec.c b/src/heretic/p_spec.c index 0d62ad7e..274d725b 100644 --- a/src/heretic/p_spec.c +++ b/src/heretic/p_spec.c @@ -408,29 +408,35 @@ fixed_t P_FindNextHighestFloor(sector_t * sec, int currentheight) { int i; int h; - int min; + fixed_t min; line_t *check; sector_t *other; fixed_t height = currentheight; - fixed_t heightlist[20]; // 20 adjoining sectors max! + + min = INT_MAX; for (i = 0, h = 0; i < sec->linecount; i++) { check = sec->lines[i]; other = getNextSector(check, sec); - if (!other) - continue; - if (other->floorheight > height) - heightlist[h++] = other->floorheight; + + if (other != NULL && other->floorheight > height) + { + if (min < other->floorheight) + { + min = other->floorheight; + } + + ++h; + } } - // - // Find lowest height in list - // - min = heightlist[0]; - for (i = 1; i < h; i++) - if (heightlist[i] < min) - min = heightlist[i]; + // Compatibility note, in case of demo desyncs. + + if (h > 20) + { + fprintf(stderr, "P_FindNextHighestFloor: exceeded Vanilla limit\n"); + } return min; } -- cgit v1.2.3