update old-style try..catch asset loading

Stardew Valley 1.6 added DoesAssetExist, which is much more efficient than the old try..catch pattern.
This commit is contained in:
Jesse Plamondon-Willard
2025-04-19 20:58:15 -04:00
parent 1b064f233e
commit 8e9e8a16c5
2 changed files with 12 additions and 13 deletions
+3
View File
@@ -2,6 +2,9 @@
# Release notes
## Upcoming release
* For players:
* Improved content load performance for non-English players.
* For the web UI:
* Improved JSON parser:
* You can now hover/click braces to highlight matching pairs.
@@ -161,26 +161,22 @@ internal abstract class BaseContentManager : LocalizedContentManager, IContentMa
string localeCode = this.GetLocale(language);
IAssetName localizedName = new AssetName(baseName: assetName.BaseName, localeCode: localeCode, languageCode: language);
try
if (this.DoesAssetExist<T>(localizedName))
{
T data = this.LoadExact<T>(localizedName, useCache: useCache);
localizedAssetNames[assetName.Name] = localizedName.Name;
return data;
}
catch (ContentLoadException)
localizedName = new AssetName(assetName.BaseName + "_international", null, null);
if (this.DoesAssetExist<T>(localizedName))
{
localizedName = new AssetName(assetName.BaseName + "_international", null, null);
try
{
T data = this.LoadExact<T>(localizedName, useCache: useCache);
localizedAssetNames[assetName.Name] = localizedName.Name;
return data;
}
catch (ContentLoadException)
{
localizedAssetNames[assetName.Name] = assetName.Name;
}
T data = this.LoadExact<T>(localizedName, useCache: useCache);
localizedAssetNames[assetName.Name] = localizedName.Name;
return data;
}
localizedAssetNames[assetName.Name] = assetName.Name;
}
// use cached key