shithub: choc

Download patch

ref: 436d8edbb83fd51dd75563d608b5d592f9eecece
parent: ead4a7a8bd40d4a5ff65e078956678da0d227f12
author: Simon Howard <[email protected]>
date: Tue Oct 22 20:40:09 EDT 2013

When loading Heretic savegames, NULL out certain special values which
hold pointers to other mobj_t objects that will no longer be valid.

Subversion-branch: /branches/v2-branch
Subversion-revision: 2718

--- a/src/heretic/p_saveg.c
+++ b/src/heretic/p_saveg.c
@@ -879,6 +879,32 @@
     // specialval_t special2;
     saveg_read_specialval_t(&str->special2);
 
+    // Now we have a bunch of hacks to try to NULL out special values
+    // where special[12] contained a mobj_t pointer that isn't valid
+    // any more. This isn't in Vanilla but at least it stops the game
+    // from crashing.
+
+    switch (str->type)
+    {
+        // Gas pods use special2.m to point to the pod generator
+        // that made it.
+        case MT_POD:
+            str->special2.m = NULL;
+            break;
+
+        // Several thing types use special1.m to mean 'target':
+        case MT_MACEFX4:     // A_DeathBallImpact
+        case MT_WHIRLWIND:   // A_WhirlwindSeek
+        case MT_MUMMYFX1:    // A_MummyFX1Seek
+        case MT_HORNRODFX2:  // A_SkullRodPL2Seek
+        case MT_PHOENIXFX1:  // A_PhoenixPuff
+            str->special1.m = NULL;
+            break;
+
+        default:
+            break;
+    }
+
     // int health;
     str->health = SV_ReadLong();