From 7c6da8e5ec4e51692fd2610bb7e63367d68a7a0f Mon Sep 17 00:00:00 2001 From: atravita-mods <94934860+atravita-mods@users.noreply.github.com> Date: Tue, 20 Jun 2023 22:07:57 -0400 Subject: [PATCH 1/2] adds validation for missing image sources on tilesheets --- src/SMAPI/Framework/ContentManagers/ModContentManager.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs index 2c068784..c8a01b70 100644 --- a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs +++ b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs @@ -432,6 +432,12 @@ namespace StardewModdingAPI.Framework.ContentManagers this.Monitor.VerboseLog($"Fixing tilesheet paths for map '{relativeMapPath}' from mod '{this.ModName}'..."); foreach (TileSheet tilesheet in map.TileSheets) { + // validate image source + if (string.IsNullOrWhiteSpace(tilesheet.ImageSource)) + { + throw new SContentLoadException(ContentLoadErrorType.InvalidData, $"Could not load tilesheet '{tilesheet.Id}' for mod {this.ModName} - no image source found."); + } + // get image source tilesheet.ImageSource = this.NormalizePathSeparators(tilesheet.ImageSource); string imageSource = tilesheet.ImageSource; From ae36b9b166c25f173869a3d28d350dd5ebeda113 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 24 Jun 2023 12:43:44 -0400 Subject: [PATCH 2/2] tweak new validation error text --- .../Framework/ContentManagers/ModContentManager.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs index c8a01b70..8cdb65eb 100644 --- a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs +++ b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs @@ -432,16 +432,14 @@ namespace StardewModdingAPI.Framework.ContentManagers this.Monitor.VerboseLog($"Fixing tilesheet paths for map '{relativeMapPath}' from mod '{this.ModName}'..."); foreach (TileSheet tilesheet in map.TileSheets) { - // validate image source - if (string.IsNullOrWhiteSpace(tilesheet.ImageSource)) - { - throw new SContentLoadException(ContentLoadErrorType.InvalidData, $"Could not load tilesheet '{tilesheet.Id}' for mod {this.ModName} - no image source found."); - } - // get image source tilesheet.ImageSource = this.NormalizePathSeparators(tilesheet.ImageSource); string imageSource = tilesheet.ImageSource; + // validate image source + if (string.IsNullOrWhiteSpace(imageSource)) + throw new SContentLoadException(ContentLoadErrorType.InvalidData, $"{this.ModName} loaded map '{relativeMapPath}' with invalid tilesheet '{tilesheet.Id}'. This tilesheet has no image source."); + // reverse incorrect eager tilesheet path prefixing if (fixEagerPathPrefixes && relativeMapFolder.Length > 0 && imageSource.StartsWith(relativeMapFolder)) imageSource = imageSource[(relativeMapFolder.Length + 1)..];