Fixes parent references. (#15)
This commit is contained in:
parent
01d0fb75b8
commit
90ffe0ea3c
20 changed files with 55 additions and 93 deletions
|
|
@ -142,7 +142,7 @@ namespace Server.Engines.BulkOrders
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InvalidateContainers( object parent )
|
public void InvalidateContainers(IEntity parent)
|
||||||
{
|
{
|
||||||
if ( parent is Container c )
|
if ( parent is Container c )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ namespace Server.Engines.ConPVP
|
||||||
|
|
||||||
public Mobile Thrower{ get; private set; }
|
public Mobile Thrower{ get; private set; }
|
||||||
|
|
||||||
private Mobile FindOwner(object parent)
|
private Mobile FindOwner(IEntity parent)
|
||||||
{
|
{
|
||||||
if (parent is Item item)
|
if (parent is Item item)
|
||||||
return item.RootParent as Mobile;
|
return item.RootParent as Mobile;
|
||||||
|
|
|
||||||
|
|
@ -455,7 +455,7 @@ namespace Server.Engines.ConPVP
|
||||||
MoveToWorld(m_TeamInfo.Origin, m_TeamInfo.Game.Facet);
|
MoveToWorld(m_TeamInfo.Origin, m_TeamInfo.Game.Facet);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Mobile FindOwner(object parent)
|
private Mobile FindOwner(IEntity parent)
|
||||||
{
|
{
|
||||||
if (parent is Item item)
|
if (parent is Item item)
|
||||||
return item.RootParent as Mobile;
|
return item.RootParent as Mobile;
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ namespace Server.Factions
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Mobile FindOwner(object parent)
|
private Mobile FindOwner(IEntity parent)
|
||||||
{
|
{
|
||||||
if (parent is Item item)
|
if (parent is Item item)
|
||||||
return item.RootParent as Mobile;
|
return item.RootParent as Mobile;
|
||||||
|
|
|
||||||
|
|
@ -234,9 +234,7 @@ namespace Server.Gumps
|
||||||
public object FindHouseName(BaseHouse house)
|
public object FindHouseName(BaseHouse house)
|
||||||
{
|
{
|
||||||
int multiID = house.ItemID;
|
int multiID = house.ItemID;
|
||||||
HousePlacementEntry[] entries;
|
HousePlacementEntry[] entries = HousePlacementEntry.ClassicHouses;
|
||||||
|
|
||||||
entries = HousePlacementEntry.ClassicHouses;
|
|
||||||
|
|
||||||
for (int i = 0; i < entries.Length; ++i)
|
for (int i = 0; i < entries.Length; ++i)
|
||||||
if (entries[i].MultiID == multiID)
|
if (entries[i].MultiID == multiID)
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ namespace Server.Items
|
||||||
if (board.IsChildOf(from.Backpack))
|
if (board.IsChildOf(from.Backpack))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
object root = board.RootParent;
|
IEntity root = board.RootParent;
|
||||||
|
|
||||||
if (root is Mobile && root != from)
|
if (root is Mobile && root != from)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -122,9 +122,7 @@ namespace Server.Items
|
||||||
if (board.Deleted || board.Map != from.Map || !from.InRange(board.GetWorldLocation(), 1))
|
if (board.Deleted || board.Map != from.Map || !from.InRange(board.GetWorldLocation(), 1))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
BaseHouse house = BaseHouse.FindHouseAt(board);
|
return BaseHouse.FindHouseAt(board)?.IsOwner(from) == true;
|
||||||
|
|
||||||
return house != null && house.IsOwner(from);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DefaultEntry : ContextMenuEntry
|
public class DefaultEntry : ContextMenuEntry
|
||||||
|
|
|
||||||
|
|
@ -174,12 +174,7 @@ namespace Server.Items
|
||||||
if (!Movable || Protected || !from.InRange(GetWorldLocation(), 2))
|
if (!Movable || Protected || !from.InRange(GetWorldLocation(), 2))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
object root = RootParent;
|
return !(RootParent is Mobile && RootParent != from);
|
||||||
|
|
||||||
if (root is Mobile && root != from)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConvertToWorld(int x, int y, out int worldX, out int worldY)
|
public void ConvertToWorld(int x, int y, out int worldX, out int worldY)
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ namespace Server.Items
|
||||||
}
|
}
|
||||||
else if (targeted is Item item)
|
else if (targeted is Item item)
|
||||||
{
|
{
|
||||||
object root = item.RootParent;
|
IEntity root = item.RootParent;
|
||||||
|
|
||||||
if (root != null && root != from || item.Parent == from)
|
if (root != null && root != from || item.Parent == from)
|
||||||
{
|
{
|
||||||
|
|
@ -61,10 +61,7 @@ namespace Server.Items
|
||||||
}
|
}
|
||||||
else if (item.Movable)
|
else if (item.Movable)
|
||||||
{
|
{
|
||||||
if (item.Amount > 1)
|
message = item.Amount > 1 ? "You place one item on the scale. " : "You place that item on the scale. ";
|
||||||
message = "You place one item on the scale. ";
|
|
||||||
else
|
|
||||||
message = "You place that item on the scale. ";
|
|
||||||
|
|
||||||
double weight = item.Weight;
|
double weight = item.Weight;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,17 +45,13 @@ namespace Server.Items
|
||||||
int version = reader.ReadInt();
|
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)
|
if (RootParent != null)
|
||||||
return m;
|
return RootParent;
|
||||||
|
|
||||||
object obj = RootParent;
|
|
||||||
|
|
||||||
if (obj != null)
|
|
||||||
return obj;
|
|
||||||
|
|
||||||
if (Map == Map.Internal)
|
if (Map == Map.Internal)
|
||||||
return from;
|
return from;
|
||||||
|
|
@ -74,7 +70,7 @@ namespace Server.Items
|
||||||
ThrowTarget targ = from.Target as ThrowTarget;
|
ThrowTarget targ = from.Target as ThrowTarget;
|
||||||
Stackable = false; // Scavenged explosion potions won't stack with those ones in backpack, and still will explode.
|
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;
|
return;
|
||||||
|
|
||||||
from.RevealingAction();
|
from.RevealingAction();
|
||||||
|
|
@ -107,7 +103,7 @@ namespace Server.Items
|
||||||
if (Deleted)
|
if (Deleted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
object parent = FindParent(from);
|
IEntity parent = FindParent(from);
|
||||||
|
|
||||||
if (timer == 0)
|
if (timer == 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -47,15 +47,12 @@ namespace Server.Items
|
||||||
|
|
||||||
public bool Validate()
|
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)
|
public override void OnSingleClick(Mobile from)
|
||||||
|
|
|
||||||
|
|
@ -66,9 +66,7 @@ namespace Server.Misc
|
||||||
}
|
}
|
||||||
else if (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair)
|
else if (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair)
|
||||||
{
|
{
|
||||||
object rootParent = item.RootParent;
|
if (item.RootParent is Mobile rootMobile)
|
||||||
|
|
||||||
if (rootParent is Mobile rootMobile)
|
|
||||||
{
|
{
|
||||||
if (item.Parent != rootMobile && rootMobile.AccessLevel == AccessLevel.Player)
|
if (item.Parent != rootMobile && rootMobile.AccessLevel == AccessLevel.Player)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ namespace Server.SkillHandlers
|
||||||
{
|
{
|
||||||
Item stolen = null;
|
Item stolen = null;
|
||||||
|
|
||||||
object root = toSteal.RootParent;
|
IEntity root = toSteal.RootParent;
|
||||||
Mobile mobRoot = root as Mobile;
|
Mobile mobRoot = root as Mobile;
|
||||||
|
|
||||||
StealableArtifactsSpawner.StealableInstance si = null;
|
StealableArtifactsSpawner.StealableInstance si = null;
|
||||||
|
|
@ -215,7 +215,7 @@ namespace Server.SkillHandlers
|
||||||
{
|
{
|
||||||
m_Thief.SendLocalizedMessage(502710); // You can't steal that!
|
m_Thief.SendLocalizedMessage(502710); // You can't steal that!
|
||||||
}
|
}
|
||||||
else if (toSteal.LootType == LootType.Newbied || toSteal.CheckBlessed(root))
|
else if (toSteal.LootType == LootType.Newbied || toSteal.CheckBlessed(mobRoot))
|
||||||
{
|
{
|
||||||
m_Thief.SendLocalizedMessage(502710); // You can't steal that!
|
m_Thief.SendLocalizedMessage(502710); // You can't steal that!
|
||||||
}
|
}
|
||||||
|
|
@ -244,7 +244,7 @@ namespace Server.SkillHandlers
|
||||||
{
|
{
|
||||||
m_Thief.SendLocalizedMessage(502710); // You can't steal that!
|
m_Thief.SendLocalizedMessage(502710); // You can't steal that!
|
||||||
}
|
}
|
||||||
else if (mobRoot != null && !m_Thief.CanBeHarmful((Mobile)root))
|
else if (mobRoot != null && !m_Thief.CanBeHarmful(mobRoot))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else if (root is Corpse)
|
else if (root is Corpse)
|
||||||
|
|
@ -332,7 +332,7 @@ namespace Server.SkillHandlers
|
||||||
from.RevealingAction();
|
from.RevealingAction();
|
||||||
|
|
||||||
Item stolen = null;
|
Item stolen = null;
|
||||||
object root = null;
|
IEntity root = null;
|
||||||
bool caught = false;
|
bool caught = false;
|
||||||
|
|
||||||
if (target is Item item)
|
if (target is Item item)
|
||||||
|
|
@ -395,7 +395,7 @@ namespace Server.SkillHandlers
|
||||||
if (mobRoot?.Player == true && m_Thief is PlayerMobile pm &&
|
if (mobRoot?.Player == true && m_Thief is PlayerMobile pm &&
|
||||||
IsInnocentTo(pm, mobRoot) && !IsInGuild(mobRoot))
|
IsInnocentTo(pm, mobRoot) && !IsInGuild(mobRoot))
|
||||||
{
|
{
|
||||||
pm.PermaFlags.Add((Mobile)root);
|
pm.PermaFlags.Add(mobRoot);
|
||||||
pm.Delta(MobileDelta.Noto);
|
pm.Delta(MobileDelta.Noto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ namespace Server.Spells
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool OnCasterUsingObject(object o)
|
public virtual bool OnCasterUsingObject(IEntity entity)
|
||||||
{
|
{
|
||||||
if (State == SpellState.Sequencing)
|
if (State == SpellState.Sequencing)
|
||||||
Disturb(DisturbType.UseRequest);
|
Disturb(DisturbType.UseRequest);
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,6 @@ namespace Server.Spells.Third
|
||||||
{
|
{
|
||||||
SpellHelper.Turn(Caster, item);
|
SpellHelper.Turn(Caster, item);
|
||||||
|
|
||||||
object root = item.RootParent;
|
|
||||||
|
|
||||||
if (!item.IsAccessibleTo(Caster))
|
if (!item.IsAccessibleTo(Caster))
|
||||||
{
|
{
|
||||||
item.OnDoubleClickNotAccessible(Caster);
|
item.OnDoubleClickNotAccessible(Caster);
|
||||||
|
|
@ -51,7 +49,7 @@ namespace Server.Spells.Third
|
||||||
else if (!item.CheckItemUse(Caster, item))
|
else if (!item.CheckItemUse(Caster, item))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else if (root is Mobile && root != Caster)
|
else if (item.RootParent is Mobile && item.RootParent != Caster)
|
||||||
{
|
{
|
||||||
item.OnSnoop(Caster);
|
item.OnSnoop(Caster);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ namespace Server
|
||||||
void OnConnectionChanged();
|
void OnConnectionChanged();
|
||||||
bool OnCasterMoving(Direction d);
|
bool OnCasterMoving(Direction d);
|
||||||
bool OnCasterEquipping(Item item);
|
bool OnCasterEquipping(Item item);
|
||||||
bool OnCasterUsingObject(object o);
|
bool OnCasterUsingObject(IEntity entity);
|
||||||
bool OnCastInTown(Region r);
|
bool OnCastInTown(Region r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3681,15 +3681,13 @@ namespace Server
|
||||||
target.Map == null)
|
target.Map == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
object root = target.RootParent;
|
|
||||||
|
|
||||||
if (from.AccessLevel < AccessLevel.GameMaster && !from.InRange(target.GetWorldLocation(), 2))
|
if (from.AccessLevel < AccessLevel.GameMaster && !from.InRange(target.GetWorldLocation(), 2))
|
||||||
return false;
|
return false;
|
||||||
if (!from.CanSee(target) || !from.InLOS(target))
|
if (!from.CanSee(target) || !from.InLOS(target))
|
||||||
return false;
|
return false;
|
||||||
if (!target.IsAccessibleTo(from))
|
if (!target.IsAccessibleTo(from))
|
||||||
return false;
|
return false;
|
||||||
if (root is Mobile mobile && !mobile.CheckNonlocalDrop(from, this, target))
|
if (target.RootParent is Mobile mobile && !mobile.CheckNonlocalDrop(from, this, target))
|
||||||
return false;
|
return false;
|
||||||
if (!from.OnDroppedItemToItem(this, target, p))
|
if (!from.OnDroppedItemToItem(this, target, p))
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -4290,11 +4288,6 @@ namespace Server
|
||||||
Delete();
|
Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool CheckBlessed(object obj)
|
|
||||||
{
|
|
||||||
return CheckBlessed(obj as Mobile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool CheckBlessed(Mobile m)
|
public virtual bool CheckBlessed(Mobile m)
|
||||||
{
|
{
|
||||||
if (m_LootType == LootType.Blessed || Mobile.InsuranceEnabled && Insured)
|
if (m_LootType == LootType.Blessed || Mobile.InsuranceEnabled && Insured)
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,7 @@ namespace Server.Items
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object parent = Parent;
|
IEntity parent = Parent;
|
||||||
|
|
||||||
while (parent != null)
|
while (parent != null)
|
||||||
{
|
{
|
||||||
|
|
@ -627,15 +627,9 @@ namespace Server.Items
|
||||||
|
|
||||||
public virtual bool CheckContentDisplay(Mobile from)
|
public virtual bool CheckContentDisplay(Mobile from)
|
||||||
{
|
{
|
||||||
if (DisplaysContent)
|
return DisplaysContent && RootParent == null ||
|
||||||
{
|
RootParent is Item || RootParent == from ||
|
||||||
object root = RootParent;
|
from.AccessLevel > AccessLevel.Player;
|
||||||
|
|
||||||
if (root == null || root is Item || root == from || from.AccessLevel > AccessLevel.Player)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnSingleClick(Mobile from)
|
public override void OnSingleClick(Mobile from)
|
||||||
|
|
|
||||||
|
|
@ -4667,7 +4667,7 @@ namespace Server
|
||||||
if (m_Spell != null && !m_Spell.OnCasterUsingObject(item))
|
if (m_Spell != null && !m_Spell.OnCasterUsingObject(item))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
object root = item.RootParent;
|
IEntity root = item.RootParent;
|
||||||
bool okay = false;
|
bool okay = false;
|
||||||
|
|
||||||
if (!Utility.InUpdateRange(this, item.GetWorldLocation()))
|
if (!Utility.InUpdateRange(this, item.GetWorldLocation()))
|
||||||
|
|
@ -4789,7 +4789,7 @@ namespace Server
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
object root = item.RootParent;
|
IEntity root = item.RootParent;
|
||||||
|
|
||||||
if (root is Mobile mobile && !mobile.CheckNonlocalLift(from, item))
|
if (root is Mobile mobile && !mobile.CheckNonlocalLift(from, item))
|
||||||
{
|
{
|
||||||
|
|
@ -4964,7 +4964,7 @@ namespace Server
|
||||||
if (DragEffects && !item.Deleted)
|
if (DragEffects && !item.Deleted)
|
||||||
{
|
{
|
||||||
Map map = m_Map;
|
Map map = m_Map;
|
||||||
object root = item.RootParent;
|
IEntity root = item.RootParent;
|
||||||
|
|
||||||
if (map != null && (root == null || root is Item))
|
if (map != null && (root == null || root is Item))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ namespace Server
|
||||||
UnsafeNativeMethods.ReadFile(ptr, buffer, (uint)length, ref lpNumberOfBytesRead, null);
|
UnsafeNativeMethods.ReadFile(ptr, buffer, (uint)length, ref lpNumberOfBytesRead, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class UnsafeNativeMethods
|
internal static class UnsafeNativeMethods
|
||||||
{
|
{
|
||||||
/*[DllImport("kernel32")]
|
/*[DllImport("kernel32")]
|
||||||
internal unsafe static extern int _lread(IntPtr hFile, void* lpBuffer, int wBytes);*/
|
internal unsafe static extern int _lread(IntPtr hFile, void* lpBuffer, int wBytes);*/
|
||||||
|
|
@ -74,7 +74,7 @@ namespace Server
|
||||||
UnsafeNativeMethods.read(ptr, buffer, length);
|
UnsafeNativeMethods.read(ptr, buffer, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class UnsafeNativeMethods
|
internal static class UnsafeNativeMethods
|
||||||
{
|
{
|
||||||
[DllImport("libc")]
|
[DllImport("libc")]
|
||||||
internal static extern unsafe int read(IntPtr ptr, void* buffer, int length);
|
internal static extern unsafe int read(IntPtr ptr, void* buffer, int length);
|
||||||
|
|
|
||||||
|
|
@ -165,9 +165,7 @@ namespace Server.Targeting
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
object root = item.RootParent;
|
if (!AllowNonlocal && item.RootParent is Mobile && item.RootParent != from && from.AccessLevel == AccessLevel.Player)
|
||||||
|
|
||||||
if (!AllowNonlocal && root is Mobile && root != from && from.AccessLevel == AccessLevel.Player)
|
|
||||||
{
|
{
|
||||||
OnNonlocalTarget(from, item);
|
OnNonlocalTarget(from, item);
|
||||||
OnTargetFinish(from);
|
OnTargetFinish(from);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue