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()