diff options
Diffstat (limited to 'StardewModdingAPI')
-rw-r--r-- | StardewModdingAPI/Extensions.cs | 6 | ||||
-rw-r--r-- | StardewModdingAPI/Inheritance/SGame.cs | 7 |
2 files changed, 7 insertions, 6 deletions
diff --git a/StardewModdingAPI/Extensions.cs b/StardewModdingAPI/Extensions.cs index 7e849f12..c504f470 100644 --- a/StardewModdingAPI/Extensions.cs +++ b/StardewModdingAPI/Extensions.cs @@ -53,12 +53,12 @@ namespace StardewModdingAPI public static int GetHash(this IEnumerable enumerable) { - string s = string.Empty; + int hash = 0; foreach (var v in enumerable) { - s += v.GetHashCode().ToString(); + hash ^= v.GetHashCode(); } - return s.GetHashCode(); + return hash; } } }
\ No newline at end of file diff --git a/StardewModdingAPI/Inheritance/SGame.cs b/StardewModdingAPI/Inheritance/SGame.cs index cccdff23..735cd58a 100644 --- a/StardewModdingAPI/Inheritance/SGame.cs +++ b/StardewModdingAPI/Inheritance/SGame.cs @@ -465,12 +465,13 @@ namespace StardewModdingAPI.Inheritance {
Events.PlayerEvents.InvokeInventoryChanged(player.items, changedItems);
PreviousItems = player.items.Where(n => n != null).ToDictionary(n => n, n => n.Stack);
- }
+ }
- if(currentLocation != null && PreviousLocationObjects != currentLocation.objects.GetHash())
+ var objectHash = currentLocation?.objects?.GetHash();
+ if(objectHash != null && PreviousLocationObjects != objectHash)
{
Events.LocationEvents.InvokeOnNewLocationObject(currentLocation.objects);
- PreviousLocationObjects = currentLocation.objects.GetHash();
+ PreviousLocationObjects = objectHash ?? -1;
}
if (timeOfDay != PreviousTimeOfDay)
|