summaryrefslogtreecommitdiff
path: root/src/heretic/p_spec.c
diff options
context:
space:
mode:
authorSimon Howard2008-10-03 17:06:10 +0000
committerSimon Howard2008-10-03 17:06:10 +0000
commit8878f9e71edf05a44d6dc46a4a03e116ea100b7b (patch)
tree97c981fa27a92525bc704f3fdb7c7a575296ea82 /src/heretic/p_spec.c
parentfdd2fe6367646927b54dabe719002709861ef450 (diff)
downloadchocolate-doom-8878f9e71edf05a44d6dc46a4a03e116ea100b7b.tar.gz
chocolate-doom-8878f9e71edf05a44d6dc46a4a03e116ea100b7b.tar.bz2
chocolate-doom-8878f9e71edf05a44d6dc46a4a03e116ea100b7b.zip
Fix crash with P_FindNextHighestFloor.
Subversion-branch: /branches/raven-branch Subversion-revision: 1327
Diffstat (limited to 'src/heretic/p_spec.c')
-rw-r--r--src/heretic/p_spec.c32
1 files changed, 19 insertions, 13 deletions
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;
}