ref: 1112fd9573f8d45e167e1ba7cbe35a0f18aa5910
parent: d0de82cad1232cd7e8b1de9031c6b4fd9e26946f
author: James Haley <[email protected]>
date: Fri Aug 26 17:09:51 EDT 2016
Overflow safety for solidsegs; hopefully interim.
--- a/src/doom/r_bsp.c
+++ b/src/doom/r_bsp.c
@@ -77,9 +77,15 @@
} cliprange_t;
+// We must expand MAXSEGS to the theoretical limit of the number of solidsegs
+// that can be generated in a scene by the DOOM engine. This was determined by
+// Lee Killough during BOOM development to be a function of the screensize.
+// The simplest thing we can do, other than fix this bug, is to let the game
+// render overage and then bomb out by detecting the overflow after the
+// fact. -haleyjd
+//#define MAXSEGS 32
+#define MAXSEGS (SCREENWIDTH / 2 + 1)
-#define MAXSEGS 32
-
// newend is one past the last valid seg
cliprange_t* newend;
cliprange_t solidsegs[MAXSEGS];
@@ -532,6 +538,10 @@
R_AddLine (line);
line++;
}
+
+ // check for solidsegs overflow - extremely unsatisfactory!
+ if(newend > &solidsegs[32])
+ I_Error("R_Subsector: solidsegs overflow (vanilla may crash here)\n");
}
--- a/src/heretic/r_bsp.c
+++ b/src/heretic/r_bsp.c
@@ -58,7 +58,14 @@
int first, last;
} cliprange_t;
-#define MAXSEGS 32
+// We must expand MAXSEGS to the theoretical limit of the number of solidsegs
+// that can be generated in a scene by the DOOM engine. This was determined by
+// Lee Killough during BOOM development to be a function of the screensize.
+// The simplest thing we can do, other than fix this bug, is to let the game
+// render overage and then bomb out by detecting the overflow after the
+// fact. -haleyjd
+//#define MAXSEGS 32
+#define MAXSEGS (SCREENWIDTH / 2 + 1)
cliprange_t solidsegs[MAXSEGS], *newend; // newend is one past the last valid seg
@@ -437,6 +444,10 @@
R_AddLine(line);
line++;
}
+
+ // check for solidsegs overflow - extremely unsatisfactory!
+ if(newend > &solidsegs[32])
+ I_Error("R_Subsector: solidsegs overflow (vanilla may crash here)\n");
}
--- a/src/hexen/r_bsp.c
+++ b/src/hexen/r_bsp.c
@@ -59,7 +59,14 @@
int first, last;
} cliprange_t;
-#define MAXSEGS 32
+// We must expand MAXSEGS to the theoretical limit of the number of solidsegs
+// that can be generated in a scene by the DOOM engine. This was determined by
+// Lee Killough during BOOM development to be a function of the screensize.
+// The simplest thing we can do, other than fix this bug, is to let the game
+// render overage and then bomb out by detecting the overflow after the
+// fact. -haleyjd
+//#define MAXSEGS 32
+#define MAXSEGS (SCREENWIDTH / 2 + 1)
cliprange_t solidsegs[MAXSEGS], *newend; // newend is one past the last valid seg
@@ -458,6 +465,10 @@
R_AddLine(line);
line++;
}
+
+ // check for solidsegs overflow - extremely unsatisfactory!
+ if(newend > &solidsegs[32])
+ I_Error("R_Subsector: solidsegs overflow (vanilla may crash here)\n");
}
--- a/src/strife/r_bsp.c
+++ b/src/strife/r_bsp.c
@@ -77,9 +77,15 @@
} cliprange_t;
+// We must expand MAXSEGS to the theoretical limit of the number of solidsegs
+// that can be generated in a scene by the DOOM engine. This was determined by
+// Lee Killough during BOOM development to be a function of the screensize.
+// The simplest thing we can do, other than fix this bug, is to let the game
+// render overage and then bomb out by detecting the overflow after the
+// fact. -haleyjd
+//#define MAXSEGS 32
+#define MAXSEGS (SCREENWIDTH / 2 + 1)
-#define MAXSEGS 32
-
// newend is one past the last valid seg
cliprange_t* newend;
cliprange_t solidsegs[MAXSEGS];
@@ -532,6 +538,10 @@
R_AddLine (line);
line++;
}
+
+ // check for solidsegs overflow - extremely unsatisfactory!
+ if(newend > &solidsegs[32])
+ I_Error("R_Subsector: solidsegs overflow (vanilla may crash here)\n");
}