From 31dc9ffac4f85db1811d489839f19311f80cc82a Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sat, 24 May 2025 12:00:53 -0700 Subject: [PATCH] fix: Fixes player vendors not reattaching to their house on deserialization (#2195) --- .../UOContent/Mobiles/Vendors/PlayerVendor.cs | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs b/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs index 9cf360aff..cc63701d3 100644 --- a/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs +++ b/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs @@ -171,7 +171,7 @@ public partial class PlayerVendor : Mobile reader.ReadBool(); // New vendor system? _shopName = reader.ReadString(); _nextPayTime = reader.ReadDeltaTime(); - _house = reader.ReadEntity(); + House = reader.ReadEntity(); _owner = reader.ReadEntity(); _bankAccount = reader.ReadInt(); _holdGold = reader.ReadInt(); @@ -201,6 +201,34 @@ public partial class PlayerVendor : Mobile { NameHue = -1; } + + // Do we have a vendor that may have been orphaned? Let's try to recover them and attach them to their house. + if (_house == null) + { + if (_owner == null) + { + Timer.DelayCall(Delete); // Don't try to dismiss, no owner. + } + Timer.DelayCall(() => + { + var house = BaseHouse.FindHouseAt(this); + + if (house != null) + { + House = house; + } + else if (_owner.AccessLevel == AccessLevel.Player) + { + // If we can't find a house, dismiss the vendor. + Dismiss(_owner); + } + } + ); + } + else + { + _house.PlayerVendors.Add(this); + } } public void InitBody()