From 8d88ce8a169643e36531cc0db5cc6863db35e91f Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 22 Mar 2020 14:22:16 -0400 Subject: fix player_add error if the player has broken XNB mods --- .../Framework/ItemRepository.cs | 28 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'src/SMAPI.Mods.ConsoleCommands') diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs index 08dd8eed..6a17213c 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; using StardewModdingAPI.Mods.ConsoleCommands.Framework.ItemData; using StardewValley; using StardewValley.Menus; @@ -59,13 +60,13 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework yield return this.TryCreate(ItemType.Flooring, id, () => new Wallpaper(id, isFloor: true) { Category = SObject.furnitureCategory }); // equipment - foreach (int id in Game1.content.Load>("Data\\Boots").Keys) + foreach (int id in this.TryLoad("Data\\Boots").Keys) yield return this.TryCreate(ItemType.Boots, id, () => new Boots(id)); - foreach (int id in Game1.content.Load>("Data\\hats").Keys) + foreach (int id in this.TryLoad("Data\\hats").Keys) yield return this.TryCreate(ItemType.Hat, id, () => new Hat(id)); // weapons - foreach (int id in Game1.content.Load>("Data\\weapons").Keys) + foreach (int id in this.TryLoad("Data\\weapons").Keys) { yield return this.TryCreate(ItemType.Weapon, id, () => (id >= 32 && id <= 34) ? (Item)new Slingshot(id) @@ -74,7 +75,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework } // furniture - foreach (int id in Game1.content.Load>("Data\\Furniture").Keys) + foreach (int id in this.TryLoad("Data\\Furniture").Keys) { if (id == 1466 || id == 1468) yield return this.TryCreate(ItemType.Furniture, id, () => new TV(id, Vector2.Zero)); @@ -94,7 +95,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework // secret notes if (id == 79) { - foreach (int secretNoteId in Game1.content.Load>("Data\\SecretNotes").Keys) + foreach (int secretNoteId in this.TryLoad("Data\\SecretNotes").Keys) { yield return this.TryCreate(ItemType.Object, this.CustomIDOffset + secretNoteId, () => { @@ -233,6 +234,23 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework /********* ** Private methods *********/ + /// Try to load a data file, and return empty data if it's invalid. + /// The asset key type. + /// The asset value type. + /// The data asset name. + private Dictionary TryLoad(string assetName) + { + try + { + return Game1.content.Load>(assetName); + } + catch (ContentLoadException) + { + // generally due to a player incorrectly replacing a data file with an XNB mod + return new Dictionary(); + } + } + /// Create a searchable item if valid. /// The item type. /// The unique ID (if different from the item's parent sheet index). -- cgit From 6d1494a56c5d04e7bc1ee406810a5a53dea2229a Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 22 Mar 2020 19:36:49 -0400 Subject: prepare for release --- build/common.targets | 2 +- docs/README.md | 2 +- docs/release-notes.md | 10 +++++----- src/SMAPI.Mods.ConsoleCommands/manifest.json | 4 ++-- src/SMAPI.Mods.SaveBackup/manifest.json | 4 ++-- src/SMAPI/Constants.cs | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src/SMAPI.Mods.ConsoleCommands') diff --git a/build/common.targets b/build/common.targets index c1617375..b3211aba 100644 --- a/build/common.targets +++ b/build/common.targets @@ -4,7 +4,7 @@ - 3.3.2 + 3.4.0 SMAPI $(AssemblySearchPaths);{GAC} diff --git a/docs/README.md b/docs/README.md index f45e950c..546ee6b3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -67,7 +67,7 @@ Chinese | ✓ [fully translated](../src/SMAPI/i18n/zh.json) French | ✓ [fully translated](../src/SMAPI/i18n/fr.json) German | ✓ [fully translated](../src/SMAPI/i18n/de.json) Hungarian | ✓ [fully translated](../src/SMAPI/i18n/hu.json) -Italian | ❑ not translated +Italian | ✓ [fully translated](../src/SMAPI/i18n/it.json) Japanese | ✓ [fully translated](../src/SMAPI/i18n/ja.json) Korean | ❑ not translated Portuguese | ✓ [fully translated](../src/SMAPI/i18n/pt.json) diff --git a/docs/release-notes.md b/docs/release-notes.md index 12ba056d..5a5e24d4 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,15 +1,15 @@ ← [README](README.md) # Release notes -## Upcoming release +## 3.4 +Released 22 March 2020 for Stardew Valley 1.4.1 or later. + * For players: * Fixed semi-transparency issues on Linux/Mac in recent versions of Mono (e.g. pink shadows). - * Removed invalid location check. This is now handled by the game itself. + * Fixed `player_add` command error if you have broken XNB mods. + * Removed invalid-location check now handled by the game. * Updated translations. Thanks to Annosz (added Hungarian)! -* For the Console Commands mod: - * fixed `player_add` error if you have broken XNB mods. - * For modders: * Added support for flipped and rotated map tiles (in collaboration with Platonymous). * Added support for `.tmx` maps using zlib compression (thanks to Platonymous!). diff --git a/src/SMAPI.Mods.ConsoleCommands/manifest.json b/src/SMAPI.Mods.ConsoleCommands/manifest.json index 0e6805dc..dbed84eb 100644 --- a/src/SMAPI.Mods.ConsoleCommands/manifest.json +++ b/src/SMAPI.Mods.ConsoleCommands/manifest.json @@ -1,9 +1,9 @@ { "Name": "Console Commands", "Author": "SMAPI", - "Version": "3.3.2", + "Version": "3.4.0", "Description": "Adds SMAPI console commands that let you manipulate the game.", "UniqueID": "SMAPI.ConsoleCommands", "EntryDll": "ConsoleCommands.dll", - "MinimumApiVersion": "3.3.2" + "MinimumApiVersion": "3.4.0" } diff --git a/src/SMAPI.Mods.SaveBackup/manifest.json b/src/SMAPI.Mods.SaveBackup/manifest.json index 5165d2b2..dc8bc8d4 100644 --- a/src/SMAPI.Mods.SaveBackup/manifest.json +++ b/src/SMAPI.Mods.SaveBackup/manifest.json @@ -1,9 +1,9 @@ { "Name": "Save Backup", "Author": "SMAPI", - "Version": "3.3.2", + "Version": "3.4.0", "Description": "Automatically backs up all your saves once per day into its folder.", "UniqueID": "SMAPI.SaveBackup", "EntryDll": "SaveBackup.dll", - "MinimumApiVersion": "3.3.2" + "MinimumApiVersion": "3.4.0" } diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index 3242a12c..d66e9d6b 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -20,7 +20,7 @@ namespace StardewModdingAPI ** Public ****/ /// SMAPI's current semantic version. - public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("3.3.2"); + public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("3.4.0"); /// The minimum supported version of Stardew Valley. public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.4.1"); -- cgit