From 3b6d7fddb25f3a2cbd7949bf9954690a6dd9c112 Mon Sep 17 00:00:00 2001 From: MattEqualsCoder Date: Thu, 17 Oct 2024 21:43:52 -0400 Subject: [PATCH] Fix for plandos not loading properly --- .../Services/GenerationSettingsWindowService.cs | 6 ++++-- .../Generation/RomGenerationService.cs | 2 +- .../Generation/Smz3Plandomizer.cs | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/TrackerCouncil.Smz3.Data/Services/GenerationSettingsWindowService.cs b/src/TrackerCouncil.Smz3.Data/Services/GenerationSettingsWindowService.cs index f6e618f65..b2f4f1e12 100644 --- a/src/TrackerCouncil.Smz3.Data/Services/GenerationSettingsWindowService.cs +++ b/src/TrackerCouncil.Smz3.Data/Services/GenerationSettingsWindowService.cs @@ -218,8 +218,10 @@ public bool LoadPlando(string file, out string? error) .WithNamingConvention(PascalCaseNamingConvention.Instance) .IgnoreUnmatchedProperties() .Build(); - var configString = File.ReadAllText(file); - LoadPlando(deserializer.Deserialize(configString)); + var configString = File.ReadAllText(file, Encoding.UTF8); + var config = deserializer.Deserialize(configString); + config.FileName = Path.GetFileNameWithoutExtension(file); + LoadPlando(config); return true; } catch (Exception e) diff --git a/src/TrackerCouncil.Smz3.SeedGenerator/Generation/RomGenerationService.cs b/src/TrackerCouncil.Smz3.SeedGenerator/Generation/RomGenerationService.cs index e81984e14..f79d6cb0c 100644 --- a/src/TrackerCouncil.Smz3.SeedGenerator/Generation/RomGenerationService.cs +++ b/src/TrackerCouncil.Smz3.SeedGenerator/Generation/RomGenerationService.cs @@ -300,7 +300,7 @@ public async Task GeneratePreSeededRomAsync(RandomizerOption { var bytes = GenerateRomBytes(options, seed); var config = seed.Playthrough.Config; - var safeSeed = seed.Seed.ReplaceAny(Path.GetInvalidFileNameChars(), '_'); + var safeSeed = seed.Seed.ReplaceAny(Path.GetInvalidFileNameChars(), '_').Trim(); var folderPath = Path.Combine(options.RomOutputPath, $"{DateTimeOffset.Now:yyyyMMdd-HHmmss}_{safeSeed}"); Directory.CreateDirectory(folderPath); diff --git a/src/TrackerCouncil.Smz3.SeedGenerator/Generation/Smz3Plandomizer.cs b/src/TrackerCouncil.Smz3.SeedGenerator/Generation/Smz3Plandomizer.cs index a92242e03..beb76da57 100644 --- a/src/TrackerCouncil.Smz3.SeedGenerator/Generation/Smz3Plandomizer.cs +++ b/src/TrackerCouncil.Smz3.SeedGenerator/Generation/Smz3Plandomizer.cs @@ -57,7 +57,9 @@ public SeedData GenerateSeed(Config config, CancellationToken cancellationToken playthrough = new Playthrough(config, Enumerable.Empty()); } - var plandoName = config.PlandoConfig?.FileName ?? "unknown"; + var plandoName = string.IsNullOrEmpty(config.PlandoConfig?.FileName) + ? config.Seed + : config.PlandoConfig.FileName; // If matching base plando file name, just use the date for the seed name if (Regex.IsMatch(plandoName, "^Spoiler_Plando_(.*)_[0-9]+$"))