fix: Fixes demolishing house for a deed (#2003)

### Summary

* Fixes players with no bank box failing to demolish their house.
* Fixes players getting a deed, and a house infinitely.
This commit is contained in:
Kamron Batman 2024-12-03 17:58:31 -08:00 committed by GitHub
parent 1d08572926
commit ba2a41236c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 34 deletions

View file

@ -56,79 +56,81 @@ public class ConfirmDemolishHouseGump : StaticGump<ConfirmDemolishHouseGump>
return;
}
if (!_house.IsOwner(state.Mobile))
{
var from = state.Mobile;
if (!_house.IsOwner(from))
{
from.SendLocalizedMessage(501320); // Only the house owner may do this.
return;
}
if (_house.MovingCrate != null || _house.InternalizedVendors.Count > 0)
{
state.Mobile.SendLocalizedMessage(501320); // Only the house owner may do this.
return;
}
if (!Guild.NewGuildSystem && _house.FindGuildstone() != null)
{
state.Mobile.SendLocalizedMessage(501389); // You cannot redeed a house with a guildstone inside.
from.SendLocalizedMessage(501389); // You cannot redeed a house with a guildstone inside.
return;
}
/*else if (m_House.PlayerVendors.Count > 0)
{
state.Mobile.SendLocalizedMessage( 503236 ); // You need to collect your vendor's belongings before moving.
return;
}*/
if (_house.HasRentedVendors && _house.VendorInventories.Count > 0)
{
// You cannot do that that while you still have contract vendors or unclaimed contract vendor inventory in your house.
state.Mobile.SendLocalizedMessage(1062679);
from.SendLocalizedMessage(1062679);
return;
}
if (_house.HasRentedVendors)
{
// You cannot do that that while you still have contract vendors in your house.
state.Mobile.SendLocalizedMessage(1062680);
from.SendLocalizedMessage(1062680);
return;
}
if (_house.VendorInventories.Count > 0)
{
// You cannot do that that while you still have unclaimed contract vendor inventory in your house.
state.Mobile.SendLocalizedMessage(1062681);
from.SendLocalizedMessage(1062681);
return;
}
if (state.Mobile.AccessLevel > AccessLevel.Player)
if (from.AccessLevel >= AccessLevel.GameMaster)
{
state.Mobile.SendMessage("You do not get a refund for your house as you are not a player");
_house.RemoveKeys(state.Mobile);
_house.Delete();
from.SendMessage("You do not get a refund for your house as you are not a player");
}
else if (_house.IsAosRules && _house.Price > 0)
{
if (Banker.Deposit(state.Mobile, _house.Price))
{
// ~1_AMOUNT~ gold has been deposited into your bank box.
from.SendLocalizedMessage(1060397, $"{_house.Price:#,0}");
}
else
{
from.SendLocalizedMessage(500390); // Your bank box is full.
return;
}
}
else
{
var toGive = !_house.IsAosRules || _house.Price <= 0 ? _house.GetDeed() : null;
if (toGive != null && !state.Mobile.BankBox.TryDropItem(state.Mobile, toGive, false))
var deed = _house.GetDeed();
if (deed == null)
{
toGive.Delete();
state.Mobile.SendLocalizedMessage(500390); // Your bank box is full.
from.SendMessage("Unable to refund house.");
return;
}
if (_house.Price <= 0 || !Banker.Deposit(state.Mobile, _house.Price))
if (!from.BankBox.TryDropItem(from, deed, false))
{
state.Mobile.SendMessage("Unable to refund house.");
deed?.Delete();
from.SendLocalizedMessage(500390); // Your bank box is full.
return;
}
// ~1_AMOUNT~ gold has been deposited into your bank box.
state.Mobile.SendLocalizedMessage(1060397, _house.Price.ToString());
}
_house.RemoveKeys(state.Mobile);
_house.RemoveKeys(from);
_house.Delete();
}
}

View file

@ -209,19 +209,19 @@ public partial class Banker : BaseVendor
public static bool Deposit(Mobile from, int amount)
{
// If for whatever reason the TOL checks fail, we should still try old methods for depositing currency.
if (AccountGold.Enabled && from.Account?.DepositGold(amount) == true)
if (amount <= 0 || AccountGold.Enabled && from.Account?.DepositGold(amount) == true)
{
return true;
}
var box = from.FindBankNoCreate();
var box = from.BankBox;
if (box == null)
{
return false;
}
var items = new List<Item>();
using var items = PooledRefQueue<Item>.Create();
while (amount > 0)
{
@ -244,14 +244,14 @@ public partial class Banker : BaseVendor
if (box.TryDropItem(from, item, false))
{
items.Add(item);
items.Enqueue(item);
}
else
{
item.Delete();
foreach (var curItem in items)
while (items.Count > 0)
{
curItem.Delete();
items.Dequeue().Delete();
}
return false;