fix: Fixes player vendors not reattaching to their house on deserialization (#2195)

This commit is contained in:
Kamron Batman 2025-05-24 12:00:53 -07:00 committed by GitHub
parent f3bcf89015
commit 31dc9ffac4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -171,7 +171,7 @@ public partial class PlayerVendor : Mobile
reader.ReadBool(); // New vendor system?
_shopName = reader.ReadString();
_nextPayTime = reader.ReadDeltaTime();
_house = reader.ReadEntity<BaseHouse>();
House = reader.ReadEntity<BaseHouse>();
_owner = reader.ReadEntity<Mobile>();
_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()