shithub: choc

Download patch

ref: f802aa44fd82cfeb56aa0926f90b5212316ac88e
parent: f0999abcf1295f139d13ef161e434eb459d9687e
parent: 7607140288b936d29f86b67eec1cbfa3eb60f5ca
author: Simon Howard <fraggle@soulsphere.org>
date: Wed Jun 1 10:34:18 EDT 2016

Merge branch 'master' of github.com:chocolate-doom/chocolate-doom

--- a/NEWS
+++ b/NEWS
@@ -6,7 +6,7 @@
     * Added emulation for pitch-shifting as in early versions of Doom,
       Heretic, and Hexen. (thanks Jon)
     * Write out aspect-correct 1600×1200 PNGs. (thanks Jon)
-    * OPL emulation is more accurate. (thanks khokh2001)
+    * OPL emulation is more accurate. (thanks Nuke.YKT)
     * Futher emulation of DMX bugs with GUS cards. (thanks Nuke.YKT)
     * Emulation of the disk icon has returned. (thanks Fabian, Jon)
     * Checksum calculations were fixed on big endian systems, allowing
--- a/src/doom/p_mobj.c
+++ b/src/doom/p_mobj.c
@@ -44,6 +44,12 @@
 //
 int test;
 
+// Use a heuristic approach to detect infinite state cycles: Count the number
+// of times the loop in P_SetMobjState() executes and exit with an error once
+// an arbitrary very large limit is reached.
+
+#define MOBJ_CYCLE_LIMIT 1000000
+
 boolean
 P_SetMobjState
 ( mobj_t*	mobj,
@@ -50,6 +56,7 @@
   statenum_t	state )
 {
     state_t*	st;
+    int	cycle_counter = 0;
 
     do
     {
@@ -72,6 +79,11 @@
 	    st->action.acp1(mobj);	
 	
 	state = st->nextstate;
+
+	if (cycle_counter++ > MOBJ_CYCLE_LIMIT)
+	{
+	    I_Error("P_SetMobjState: Infinite state cycle detected!");
+	}
     } while (!mobj->tics);
 				
     return true;