From 508b73394e0f430b6f44743ec5c32f21b68c090f Mon Sep 17 00:00:00 2001 From: lahm86 <33758420+lahm86@users.noreply.github.com> Date: Thu, 30 May 2024 17:57:28 +0100 Subject: [PATCH] Fix TR3 no-secret levels Regression from #681. --- .../Randomizers/Shared/SecretArtefactPlacer.cs | 8 +++++++- .../Randomizers/TR3/Classic/TR3SecretRandomizer.cs | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/TRRandomizerCore/Randomizers/Shared/SecretArtefactPlacer.cs b/TRRandomizerCore/Randomizers/Shared/SecretArtefactPlacer.cs index fb914a44..a45ef869 100644 --- a/TRRandomizerCore/Randomizers/Shared/SecretArtefactPlacer.cs +++ b/TRRandomizerCore/Randomizers/Shared/SecretArtefactPlacer.cs @@ -80,7 +80,13 @@ public void InitialiseLevel(TRGameVersion version, _sectorGetter = sectorGetter; _sectorEntityTester = sectorEntityTester; - foreach (TRRoomSector sector in _rooms.SelectMany(r => r.Sectors)) + RemoveDefaultSecrets(_rooms, _floorData); + } + + public void RemoveDefaultSecrets(List rooms, FDControl floorData) + where R : TRRoom + { + foreach (TRRoomSector sector in rooms.SelectMany(r => r.Sectors)) { if (sector.FDIndex == 0) { diff --git a/TRRandomizerCore/Randomizers/TR3/Classic/TR3SecretRandomizer.cs b/TRRandomizerCore/Randomizers/TR3/Classic/TR3SecretRandomizer.cs index 231b0873..6822c352 100644 --- a/TRRandomizerCore/Randomizers/TR3/Classic/TR3SecretRandomizer.cs +++ b/TRRandomizerCore/Randomizers/TR3/Classic/TR3SecretRandomizer.cs @@ -501,6 +501,10 @@ internal void ApplyRandomization() // Convert the placeholder reward room into an actual room now that secrets are positioned. _outer.ActualiseRewardRoom(level, rewardRoom); } + else if (!level.HasSecrets) + { + _outer._placer.RemoveDefaultSecrets(level.Data.Rooms, level.Data.FloorData); + } _outer.SaveLevel(level);