fix farmhouse edits shifting player down one tile

This commit is contained in:
Jesse Plamondon-Willard 2021-09-25 20:22:26 -04:00
parent 0e3e4f565a
commit 31e31538f1
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
2 changed files with 15 additions and 0 deletions

View File

@ -1,6 +1,10 @@
← [README](README.md)
# Release notes
## Upcoming release
* For players:
* Fixed mod edits to the farmhouse shifting the player down one tile in some cases.
## 3.12.7
Released 18 September 2021 for Stardew Valley 1.5.4.

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI.Framework.ContentManagers;
using StardewModdingAPI.Framework.Reflection;
@ -908,6 +909,8 @@ namespace StardewModdingAPI.Metadata
/// <param name="location">The location whose map to reload.</param>
private void ReloadMap(GameLocation location)
{
Vector2? playerPos = Game1.player?.Position;
if (this.AggressiveMemoryOptimizations)
location.map.DisposeTileSheets(Game1.mapDisplayDevice);
@ -926,6 +929,14 @@ namespace StardewModdingAPI.Metadata
// update for changes
location.updateWarps();
location.updateDoors();
// reset player position
// The game may move the player as part of the map changes, even if they're not in that
// location. That's not needed in this case, and it can have weird effects like players
// warping onto the wrong tile (or even off-screen) if a patch changes the farmhouse
// map on location change.
if (playerPos.HasValue)
Game1.player.Position = playerPos.Value;
}
/// <summary>Reload the disposition data for matching NPCs.</summary>