Merge pull request #907 from atravita-mods/error-missing-imagesource

Add validation for missing tilesheet image sources
This commit is contained in:
Jesse Plamondon-Willard 2023-06-24 12:49:56 -04:00 committed by GitHub
commit 421dfbe912
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -436,6 +436,10 @@ namespace StardewModdingAPI.Framework.ContentManagers
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)..];