mirror of
https://github.com/Pathoschild/SMAPI.git
synced 2026-10-12 02:08:51 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user