foxygit / doom Log in
commit 9f955ea5b1f124554d58733238dff4da1d9f54c4
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Sun Mar 16 01:45:29 2014 -0400
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Sun Mar 16 01:45:29 2014 -0400

    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.
---
 src/heretic/p_saveg.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/heretic/p_saveg.c b/src/heretic/p_saveg.c
index e0983f8c..a7ca3be0 100644
--- a/src/heretic/p_saveg.c
+++ b/src/heretic/p_saveg.c
@@ -1889,8 +1889,13 @@ void P_UnArchiveSpecials(void)
                 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;