From 9296547febab942a6ef6bd3a13207894e641b1ba Mon Sep 17 00:00:00 2001 From: Fredrik Ljungdahl Date: Sat, 25 Jan 2020 00:18:15 +0100 Subject: [PATCH] Fix tower quicksave bug (only appeared in some builds) I ran the game through Valgrind to catch various issues. One thing caught my attention -- map.resumedelay. This is used by The Tower/etc to add a delay before the game is resumed (probably for camera controls delaying it) for spawning the player. This variable was uninitialized. Notably, if I explicitly set it to 592851 or similar, it reproduces the bug, even if I cannot reproduce it with my typical compilation flags. So fixing this by initializing it to 0, alongside some other Valgrind warnings, should fix the problem entirely. --- desktop_version/src/Entity.h | 2 +- desktop_version/src/Script.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/desktop_version/src/Entity.h b/desktop_version/src/Entity.h index c25098c7..b1838cf3 100644 --- a/desktop_version/src/Entity.h +++ b/desktop_version/src/Entity.h @@ -219,7 +219,7 @@ public: std::vector customcollect; int nblocks; - bool skipblocks, skipdirblocks; + bool skipblocks = false, skipdirblocks; int platformtile; bool vertplatforms, horplatforms; diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index f606752b..bd87bdfe 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -3425,6 +3425,8 @@ void scriptclass::hardreset( KeyPoll& key, Graphics& dwgfx, Game& game,mapclass& game.teleport = false; game.companion = 0; game.roomchange = false; + game.roomx = 0; + game.roomy = 0; game.teleport_to_new_area = false; game.teleport_to_x = 0; game.teleport_to_y = 0; @@ -3460,6 +3462,8 @@ void scriptclass::hardreset( KeyPoll& key, Graphics& dwgfx, Game& game,mapclass& game.savetime = "00:00"; game.savearea = "nowhere"; game.savetrinkets = 0; + game.saverx = 0; + game.savery = 0; game.intimetrial = false; game.timetrialcountdown = 0; @@ -3534,7 +3538,9 @@ void scriptclass::hardreset( KeyPoll& key, Graphics& dwgfx, Game& game,mapclass& map.resetnames(); map.custommode=false; map.custommodeforreal=false; - + map.towermode=false; + map.cameraseekframe = 0; + map.resumedelay = 0; map.customshowmm=true; for (j = 0; j < 20; j++)