From 39ca469d28c0c1096986ae4f245b8290c4d8dfb3 Mon Sep 17 00:00:00 2001 From: lahm86 <33758420+lahm86@users.noreply.github.com> Date: Mon, 17 Jun 2024 13:53:42 +0100 Subject: [PATCH] Fix texture corruption --- .../Randomizers/Shared/TextureAllocator.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/TRRandomizerCore/Randomizers/Shared/TextureAllocator.cs b/TRRandomizerCore/Randomizers/Shared/TextureAllocator.cs index f651a073..7f0b256c 100644 --- a/TRRandomizerCore/Randomizers/Shared/TextureAllocator.cs +++ b/TRRandomizerCore/Randomizers/Shared/TextureAllocator.cs @@ -66,13 +66,15 @@ Dictionary AllocateLevel(TRRScriptedLevel level, TRGData trgData) else if (Settings.TextureMode == TextureMode.Game) { TRRScriptedLevel nextLevel = levelSwaps[levels.IndexOf(level)]; - baseTextures.AddRange(textureCache[nextLevel]); - newTextures = textureCache[nextLevel]; - - while (newTextures.Count < trgData.Textures.Count) + List textureSet = textureCache[nextLevel].RandomSelection(Generator, + Math.Min(trgData.Textures.Count, textureCache[nextLevel].Count)); + while (textureSet.Count < trgData.Textures.Count) { - newTextures.Add(newTextures.RandomItem(Generator)); + textureSet.Add(textureCache[nextLevel].RandomItem(Generator)); } + + baseTextures.AddRange(textureCache[nextLevel]); + newTextures.AddRange(textureSet); } else {