shithub: choc

Download patch

ref: 9f955ea5b1f124554d58733238dff4da1d9f54c4
parent: 7e118463ae5ef0752ab0ae509eecfe409b82bdc3
author: Simon Howard <[email protected]>
date: Sat Mar 15 21:45:29 EDT 2014

heretic: Fix plat_t read when loading savegames.

The fix-up of the thinker function was (unnecessarily) guarded by an
if() condition that meant it was not being reset properly on load.
This caused moving platforms to be not restored properly when loading
savegames.

Fixes #343. Thanks to romeroyakovlev for the bug report.

--- a/src/heretic/p_saveg.c
+++ b/src/heretic/p_saveg.c
@@ -1889,8 +1889,13 @@
                 plat = Z_Malloc(sizeof(*plat), PU_LEVEL, NULL);
                 saveg_read_plat_t(plat);
                 plat->sector->specialdata = T_PlatRaise;
-                if (plat->thinker.function)
-                    plat->thinker.function = T_PlatRaise;
+                // In the original Heretic code this was a conditional "fix"
+                // of the thinker function, but the save code (above) decides
+                // whether to save a T_PlatRaise based on thinker function
+                // anyway, so it can't be NULL. Having the conditional causes
+                // a bug, as our saveg_read_thinker_t sets these to NULL.
+                // if (plat->thinker.function)
+                plat->thinker.function = T_PlatRaise;
                 P_AddThinker(&plat->thinker);
                 P_AddActivePlat(plat);
                 break;