Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)
This commit is contained in:
parent
e748af4430
commit
513e54f70e
1094 changed files with 15913 additions and 21892 deletions
|
|
@ -42,12 +42,7 @@ namespace Server.Items
|
|||
{
|
||||
if (item == Trade.From.VirtualCheck || item == Trade.To.VirtualCheck) return true;
|
||||
|
||||
Mobile to;
|
||||
|
||||
if (Trade.From.Container != this)
|
||||
to = Trade.From.Mobile;
|
||||
else
|
||||
to = Trade.To.Mobile;
|
||||
Mobile to = Trade.From.Container != this ? Trade.From.Mobile : Trade.To.Mobile;
|
||||
|
||||
return m.CheckTrade(to, item, this, message, checkItems, plusItems, plusWeight);
|
||||
}
|
||||
|
|
@ -60,49 +55,52 @@ namespace Server.Items
|
|||
|
||||
public override bool IsAccessibleTo(Mobile check)
|
||||
{
|
||||
if (!IsChildOf(check) || Trade == null || !Trade.Valid)
|
||||
return false;
|
||||
|
||||
return base.IsAccessibleTo(check);
|
||||
return IsChildOf(check) && Trade?.Valid == true && base.IsAccessibleTo(check);
|
||||
}
|
||||
|
||||
public override void OnItemAdded(Item item)
|
||||
{
|
||||
if (!(item is VirtualCheck)) ClearChecks();
|
||||
if (!(item is VirtualCheck))
|
||||
ClearChecks();
|
||||
}
|
||||
|
||||
public override void OnItemRemoved(Item item)
|
||||
{
|
||||
if (!(item is VirtualCheck)) ClearChecks();
|
||||
if (!(item is VirtualCheck))
|
||||
ClearChecks();
|
||||
}
|
||||
|
||||
public override void OnSubItemAdded(Item item)
|
||||
{
|
||||
if (!(item is VirtualCheck)) ClearChecks();
|
||||
if (!(item is VirtualCheck))
|
||||
ClearChecks();
|
||||
}
|
||||
|
||||
public override void OnSubItemRemoved(Item item)
|
||||
{
|
||||
if (!(item is VirtualCheck)) ClearChecks();
|
||||
if (!(item is VirtualCheck))
|
||||
ClearChecks();
|
||||
}
|
||||
|
||||
public void ClearChecks()
|
||||
{
|
||||
if (Trade != null)
|
||||
{
|
||||
if (Trade.From != null && !Trade.From.IsDisposed) Trade.From.Accepted = false;
|
||||
if (Trade == null)
|
||||
return;
|
||||
|
||||
if (Trade.To != null && !Trade.To.IsDisposed) Trade.To.Accepted = false;
|
||||
if (Trade.From?.IsDisposed == false)
|
||||
Trade.From.Accepted = false;
|
||||
|
||||
Trade.Update();
|
||||
}
|
||||
if (Trade.To?.IsDisposed == false)
|
||||
Trade.To.Accepted = false;
|
||||
|
||||
Trade.Update();
|
||||
}
|
||||
|
||||
public override bool IsChildVisibleTo(Mobile m, Item child)
|
||||
{
|
||||
if (child is VirtualCheck) return AccountGold.Enabled && (m.NetState == null || !m.NetState.NewSecureTrading);
|
||||
|
||||
return base.IsChildVisibleTo(m, child);
|
||||
return child is VirtualCheck
|
||||
? AccountGold.Enabled && m.NetState?.NewSecureTrading != true
|
||||
: base.IsChildVisibleTo(m, child);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
|
|
@ -119,4 +117,4 @@ namespace Server.Items
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue