From 807695783f5075453fc7f64653823ec791e290ed Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 11 Jun 2018 11:55:49 +0300 Subject: [PATCH] - fixed portal restoration on revisiting level in hub Added function to FLevelLocals to test if map is being reentered https://forum.zdoom.org/viewtopic.php?t=60455 (cherry picked from commit 29d2e77840f160b0e8999d4256ae8a8969c8dbab) --- src/g_levellocals.h | 6 ++++++ src/p_setup.cpp | 2 +- src/s_sound.cpp | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 257678243..f2f01e059 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -166,6 +166,12 @@ struct FLevelLocals return headgamenode; } + // Returns true if level is loaded from saved game or is being revisited as a part of a hub + bool IsReentering() const + { + return savegamerestore + || (info != nullptr && info->Snapshot.mBuffer != nullptr && info->isValid()); + } }; extern FLevelLocals level; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 712af43a2..6b7b11b07 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -4102,7 +4102,7 @@ void P_SetupLevel (const char *lumpname, int position) times[16].Clock(); if (reloop) P_LoopSidedefs (false); PO_Init (); // Initialize the polyobjs - if (!savegamerestore) + if (!level.IsReentering()) P_FinalizePortals(); // finalize line portals after polyobjects have been initialized. This info is needed for properly flagging them. times[16].Unclock(); diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 9575283f0..66047217e 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -477,7 +477,7 @@ void S_Start () // Don't start the music if loading a savegame, because the music is stored there. // Don't start the music if revisiting a level in a hub for the same reason. - if (!savegamerestore && (level.info == nullptr || level.info->Snapshot.mBuffer == nullptr || !level.info->isValid())) + if (!level.IsReentering()) { if (level.cdtrack == 0 || !S_ChangeCDMusic (level.cdtrack, level.cdid)) S_ChangeMusic (level.Music, level.musicorder);