Merges bug fixes and cleanup with master (#17)

This commit is contained in:
Kamron Batman 2019-03-03 15:50:57 -08:00 • committed by GitHub
parent 39dfe86e10
commit 55136d8842
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 157 additions and 234 deletions

View file

@ -114,7 +114,7 @@ namespace Server.Items
if (board.IsChildOf(from.Backpack))
return true;
object root = board.RootParent;
IEntity root = board.RootParent;
if (root is Mobile && root != from)
return false;
@ -122,9 +122,7 @@ namespace Server.Items
if (board.Deleted || board.Map != from.Map || !from.InRange(board.GetWorldLocation(), 1))
return false;
BaseHouse house = BaseHouse.FindHouseAt(board);
return house != null && house.IsOwner(from);
return BaseHouse.FindHouseAt(board)?.IsOwner(from) == true;
}
public class DefaultEntry : ContextMenuEntry
@ -146,4 +144,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -174,12 +174,7 @@ namespace Server.Items
if (!Movable || Protected || !from.InRange(GetWorldLocation(), 2))
return false;
object root = RootParent;
if (root is Mobile && root != from)
return false;
return true;
return !(RootParent is Mobile && RootParent != from);
}
public void ConvertToWorld(int x, int y, out int worldX, out int worldY)
@ -381,4 +376,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -83,11 +83,7 @@ namespace Server.Items
list.Add(1060738, worth); // value: ~1_val~
}
#if NEWPARENT
public override void OnAdded(IEntity parent)
#else
public override void OnAdded(object parent)
#endif
{
base.OnAdded(parent);
@ -98,7 +94,8 @@ namespace Server.Items
Container root = parent as Container;
while (root?.Parent is Container) root = (Container)root.Parent;
while (root?.Parent is Container container)
root = container;
parent = root ?? parent;
@ -247,4 +244,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -44,11 +44,7 @@ namespace Server.Items
UpdateTotal(this, TotalType.Gold, newValue - oldValue);
}
#if NEWPARENT
public override void OnAdded(IEntity parent)
#else
public override void OnAdded(object parent)
#endif
{
base.OnAdded(parent);
@ -59,7 +55,8 @@ namespace Server.Items
Container root = parent as Container;
while (root?.Parent is Container) root = (Container)root.Parent;
while (root?.Parent is Container container)
root = container;
parent = root ?? parent;
@ -127,4 +124,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}

View file

@ -53,7 +53,7 @@ namespace Server.Items
}
else if (targeted is Item item)
{
object root = item.RootParent;
IEntity root = item.RootParent;
if (root != null && root != from || item.Parent == from)
{
@ -61,10 +61,7 @@ namespace Server.Items
}
else if (item.Movable)
{
if (item.Amount > 1)
message = "You place one item on the scale. ";
else
message = "You place that item on the scale. ";
message = item.Amount > 1 ? "You place one item on the scale. " : "You place that item on the scale. ";
double weight = item.Weight;

View file

@ -96,11 +96,13 @@ namespace Server.Items
if (m_Kit.Deleted)
return;
if (!(targeted is Corpse) && !(targeted is BigFish))
Corpse corpse = targeted as Corpse;
if (!(corpse != null || targeted is BigFish))
{
from.SendLocalizedMessage(1042600); // That is not a corpse!
}
else if (targeted is Corpse corpse && corpse.VisitedByTaxidermist)
else if (corpse?.VisitedByTaxidermist == true)
{
from.SendLocalizedMessage(1042596); // That corpse seems to have been visited by a taxidermist already.
}
@ -114,48 +116,46 @@ namespace Server.Items
}
else
{
object obj = targeted;
object obj = corpse?.Owner ?? targeted;
if (obj is Corpse)
obj = ((Corpse)obj).Owner;
foreach (TrophyInfo t in m_Table)
{
if (t.CreatureType != obj.GetType())
continue;
if (obj != null)
for (int i = 0; i < m_Table.Length; i++)
if (m_Table[i].CreatureType == obj.GetType())
Container pack = from.Backpack;
if (pack?.ConsumeTotal(typeof(Board), 10) == true)
{
from.SendLocalizedMessage(
1042278); // You review the corpse and find it worthy of a trophy.
from.SendLocalizedMessage(1042602); // You use your kit up making the trophy.
Mobile hunter = null;
int weight = 0;
if (targeted is BigFish fish)
{
Container pack = from.Backpack;
hunter = fish.Fisher;
weight = (int)fish.Weight;
if (pack != null && pack.ConsumeTotal(typeof(Board), 10))
{
from.SendLocalizedMessage(
1042278); // You review the corpse and find it worthy of a trophy.
from.SendLocalizedMessage(1042602); // You use your kit up making the trophy.
Mobile hunter = null;
int weight = 0;
if (targeted is BigFish fish)
{
hunter = fish.Fisher;
weight = (int)fish.Weight;
fish.Consume();
}
from.AddToBackpack(new TrophyDeed(m_Table[i], hunter, weight));
if (targeted is Corpse corpse1)
corpse1.VisitedByTaxidermist = true;
m_Kit.Delete();
return;
}
from.SendLocalizedMessage(1042598); // You do not have enough boards.
return;
fish.Consume();
}
from.AddToBackpack(new TrophyDeed(t, hunter, weight));
if (corpse != null)
corpse.VisitedByTaxidermist = true;
m_Kit.Delete();
return;
}
from.SendLocalizedMessage(1042598); // You do not have enough boards.
return;
}
from.SendLocalizedMessage(1042599); // That does not look like something you want hanging on a wall.
}
}
@ -539,4 +539,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -45,17 +45,13 @@ namespace Server.Items
int version = reader.ReadInt();
}
public virtual object FindParent(Mobile from)
public virtual IEntity FindParent(Mobile from)
{
Mobile m = HeldBy;
if (HeldBy?.Holding == this)
return HeldBy;
if (m != null && m.Holding == this)
return m;
object obj = RootParent;
if (obj != null)
return obj;
if (RootParent != null)
return RootParent;
if (Map == Map.Internal)
return from;
@ -74,7 +70,7 @@ namespace Server.Items
ThrowTarget targ = from.Target as ThrowTarget;
Stackable = false; // Scavenged explosion potions won't stack with those ones in backpack, and still will explode.
if (targ != null && targ.Potion == this)
if (targ?.Potion == this)
return;
from.RevealingAction();
@ -107,7 +103,7 @@ namespace Server.Items
if (Deleted)
return;
object parent = FindParent(from);
IEntity parent = FindParent(from);
if (timer == 0)
{
@ -272,4 +268,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -47,15 +47,12 @@ namespace Server.Items
public bool Validate()
{
object root = RootParent;
if (!(RootParent is Mobile mobile) || mobile.AccessLevel >= AccessLevel)
return true;
if (root is Mobile mobile && mobile.AccessLevel < AccessLevel)
{
Delete();
return false;
}
Delete();
return false;
return true;
}
public override void OnSingleClick(Mobile from)
@ -83,4 +80,4 @@ namespace Server.Items
return from.AccessLevel >= AccessLevel;
}
}
}
}