fix crash when mods add an invalid location with no name

This commit is contained in:
Jesse Plamondon-Willard 2018-09-21 18:25:33 -04:00
parent 7f47271be4
commit 99e4a4a1cc
2 changed files with 7 additions and 4 deletions

View File

@ -5,6 +5,7 @@
* Moved most SMAPI files into a `smapi-internal` subfolder. * Moved most SMAPI files into a `smapi-internal` subfolder.
* Moved save backups into a `save-backups` subfolder (instead of `Mods/SaveBackup/backups`). Note that previous backups will be deleted when you update. * Moved save backups into a `save-backups` subfolder (instead of `Mods/SaveBackup/backups`). Note that previous backups will be deleted when you update.
* Update checks now work even when the mod has no update keys in most cases. * Update checks now work even when the mod has no update keys in most cases.
* Fixed error when mods add an invalid location with no name.
* Fixed compatibility issues for some Linux players. SMAPI will now always use xterm if it's available. * Fixed compatibility issues for some Linux players. SMAPI will now always use xterm if it's available.
* Fixed some game install paths not detected on Windows. * Fixed some game install paths not detected on Windows.
* Fixed installer duplicating bundled mods if you moved them after the last install. * Fixed installer duplicating bundled mods if you moved them after the last install.

View File

@ -1,6 +1,8 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using StardewModdingAPI.Framework.StateTracking.Comparers;
using StardewModdingAPI.Framework.StateTracking.FieldWatchers; using StardewModdingAPI.Framework.StateTracking.FieldWatchers;
using StardewValley; using StardewValley;
using StardewValley.Buildings; using StardewValley.Buildings;
@ -18,10 +20,10 @@ namespace StardewModdingAPI.Framework.StateTracking
private readonly ICollectionWatcher<GameLocation> LocationListWatcher; private readonly ICollectionWatcher<GameLocation> LocationListWatcher;
/// <summary>A lookup of the tracked locations.</summary> /// <summary>A lookup of the tracked locations.</summary>
private IDictionary<GameLocation, LocationTracker> LocationDict { get; } = new Dictionary<GameLocation, LocationTracker>(); private IDictionary<GameLocation, LocationTracker> LocationDict { get; } = new Dictionary<GameLocation, LocationTracker>(new ObjectReferenceComparer<GameLocation>());
/// <summary>A lookup of registered buildings and their indoor location.</summary> /// <summary>A lookup of registered buildings and their indoor location.</summary>
private readonly IDictionary<Building, GameLocation> BuildingIndoors = new Dictionary<Building, GameLocation>(); private readonly IDictionary<Building, GameLocation> BuildingIndoors = new Dictionary<Building, GameLocation>(new ObjectReferenceComparer<Building>());
/********* /*********
@ -37,10 +39,10 @@ namespace StardewModdingAPI.Framework.StateTracking
public IEnumerable<LocationTracker> Locations => this.LocationDict.Values; public IEnumerable<LocationTracker> Locations => this.LocationDict.Values;
/// <summary>The locations removed since the last update.</summary> /// <summary>The locations removed since the last update.</summary>
public ICollection<GameLocation> Added { get; } = new HashSet<GameLocation>(); public ICollection<GameLocation> Added { get; } = new HashSet<GameLocation>(new ObjectReferenceComparer<GameLocation>());
/// <summary>The locations added since the last update.</summary> /// <summary>The locations added since the last update.</summary>
public ICollection<GameLocation> Removed { get; } = new HashSet<GameLocation>(); public ICollection<GameLocation> Removed { get; } = new HashSet<GameLocation>(new ObjectReferenceComparer<GameLocation>());
/********* /*********