From 12826da7c4103c18769fa4b5f96ad4eb8f133221 Mon Sep 17 00:00:00 2001 From: Mark Sturgill Date: Sat, 15 Feb 2014 13:21:28 -0700 Subject: [PATCH 1/4] remove ParentEntity and RootParentEntity Parent and RootParent are now IEntity properties refactor object arguments to IEntity for parent related methods branch and version bump to 2.6 --- Scripts/Engines/ConPVP/Trophy.cs | 2 +- Scripts/Engines/Factions/Items/Sigil.cs | 6 +- .../Dark Tides/Items/ScrollOfAbraxus.cs | 2 +- Scripts/Items/Armor/BaseArmor.cs | 4 +- Scripts/Items/Clothing/BaseClothing.cs | 4 +- Scripts/Items/Clothing/Cloaks.cs | 4 +- Scripts/Items/Clothing/Hats.cs | 2 +- Scripts/Items/Clothing/OuterTorso.cs | 8 +-- Scripts/Items/Containers/Container.cs | 2 +- Scripts/Items/Jewels/BaseJewel.cs | 4 +- Scripts/Items/Lights/BaseEquipableLight.cs | 2 +- Scripts/Items/Lights/Torch.cs | 2 +- Scripts/Items/Misc/PromotionalToken.cs | 2 +- Scripts/Items/Quivers/BaseQuiver.cs | 8 +-- .../Items/Skill Items/Magical/Spellbook.cs | 4 +- .../8th Anniversary Items/Talismans.cs | 2 +- .../Blacksmithy/AncientSmithyHammer.cs | 4 +- .../Blacksmithy/GlovesOfMining.cs | 4 +- .../Rares/Containers/BaseWaterContainer.cs | 2 +- Scripts/Items/Talismans/BaseTalisman.cs | 4 +- Scripts/Items/Weapons/BaseWeapon.cs | 4 +- Scripts/Mobiles/PlayerMobile.cs | 2 +- Server/AssemblyInfo.cs | 2 +- Server/Item.cs | 72 +++++++------------ 24 files changed, 66 insertions(+), 86 deletions(-) diff --git a/Scripts/Engines/ConPVP/Trophy.cs b/Scripts/Engines/ConPVP/Trophy.cs index 28ef450ab..f1096f1f8 100644 --- a/Scripts/Engines/ConPVP/Trophy.cs +++ b/Scripts/Engines/ConPVP/Trophy.cs @@ -75,7 +75,7 @@ namespace Server.Items LootType = LootType.Blessed; } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); diff --git a/Scripts/Engines/Factions/Items/Sigil.cs b/Scripts/Engines/Factions/Items/Sigil.cs index 2ae6ad511..9b91eec1e 100644 --- a/Scripts/Engines/Factions/Items/Sigil.cs +++ b/Scripts/Engines/Factions/Items/Sigil.cs @@ -186,7 +186,7 @@ namespace Server.Factions return null; } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); @@ -196,7 +196,7 @@ namespace Server.Factions mob.SolidHueOverride = OwnershipHue; } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { base.OnRemoved( parent ); @@ -442,7 +442,7 @@ namespace Server.Factions return ( monolith != null && !monolith.Deleted ); } - public override void OnParentDeleted( object parent ) + public override void OnParentDeleted(IEntity parent) { base.OnParentDeleted( parent ); diff --git a/Scripts/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs b/Scripts/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs index a8dab9a9b..beaba214b 100644 --- a/Scripts/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs +++ b/Scripts/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs @@ -29,7 +29,7 @@ namespace Server.Engines.Quests.Necro return false; } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); diff --git a/Scripts/Items/Armor/BaseArmor.cs b/Scripts/Items/Armor/BaseArmor.cs index 1f6e37b3c..6ffcd6890 100644 --- a/Scripts/Items/Armor/BaseArmor.cs +++ b/Scripts/Items/Armor/BaseArmor.cs @@ -667,7 +667,7 @@ namespace Server.Items return v; } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { if ( parent is Mobile ) { @@ -1265,7 +1265,7 @@ namespace Server.Items return base.OnEquip( from ); } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { if ( parent is Mobile ) { diff --git a/Scripts/Items/Clothing/BaseClothing.cs b/Scripts/Items/Clothing/BaseClothing.cs index 4bff72a3f..be903dcf7 100644 --- a/Scripts/Items/Clothing/BaseClothing.cs +++ b/Scripts/Items/Clothing/BaseClothing.cs @@ -335,7 +335,7 @@ namespace Server.Items return m_AosClothingAttributes.LowerStatReq; } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { Mobile mob = parent as Mobile; @@ -351,7 +351,7 @@ namespace Server.Items base.OnAdded( parent ); } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { Mobile mob = parent as Mobile; diff --git a/Scripts/Items/Clothing/Cloaks.cs b/Scripts/Items/Clothing/Cloaks.cs index b0af4b482..8c81208ae 100644 --- a/Scripts/Items/Clothing/Cloaks.cs +++ b/Scripts/Items/Clothing/Cloaks.cs @@ -188,7 +188,7 @@ namespace Server.Items public override int BasePhysicalResistance{ get{ return 3; } } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); @@ -196,7 +196,7 @@ namespace Server.Items ((Mobile)parent).VirtualArmorMod += 2; } - public override void OnRemoved(object parent) + public override void OnRemoved(IEntity parent) { base.OnRemoved( parent ); diff --git a/Scripts/Items/Clothing/Hats.cs b/Scripts/Items/Clothing/Hats.cs index f9ab30741..32aaf212d 100644 --- a/Scripts/Items/Clothing/Hats.cs +++ b/Scripts/Items/Clothing/Hats.cs @@ -728,7 +728,7 @@ namespace Server.Items return true; } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); diff --git a/Scripts/Items/Clothing/OuterTorso.cs b/Scripts/Items/Clothing/OuterTorso.cs index c6f02100a..1dd9bd303 100644 --- a/Scripts/Items/Clothing/OuterTorso.cs +++ b/Scripts/Items/Clothing/OuterTorso.cs @@ -265,7 +265,7 @@ namespace Server.Items public override int BasePhysicalResistance{ get{ return 3; } } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); @@ -273,7 +273,7 @@ namespace Server.Items ((Mobile)parent).VirtualArmorMod += 2; } - public override void OnRemoved(object parent) + public override void OnRemoved(IEntity parent) { base.OnRemoved( parent ); @@ -390,7 +390,7 @@ namespace Server.Items public override int BasePhysicalResistance{ get{ return 3; } } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); @@ -398,7 +398,7 @@ namespace Server.Items ((Mobile)parent).VirtualArmorMod += 2; } - public override void OnRemoved(object parent) + public override void OnRemoved(IEntity parent) { base.OnRemoved( parent ); diff --git a/Scripts/Items/Containers/Container.cs b/Scripts/Items/Containers/Container.cs index 8453f12ae..67b08cb7a 100644 --- a/Scripts/Items/Containers/Container.cs +++ b/Scripts/Items/Containers/Container.cs @@ -280,7 +280,7 @@ namespace Server.Items public override int DefaultMaxWeight { get { if ( Core.ML ) { - Mobile m = ParentEntity as Mobile; + Mobile m = Parent as Mobile; if ( m != null && m.Player && m.Backpack == this ) { return 550; } else { diff --git a/Scripts/Items/Jewels/BaseJewel.cs b/Scripts/Items/Jewels/BaseJewel.cs index 57c5b5140..0d67bdf14 100644 --- a/Scripts/Items/Jewels/BaseJewel.cs +++ b/Scripts/Items/Jewels/BaseJewel.cs @@ -141,7 +141,7 @@ namespace Server.Items m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax( InitMinHits, InitMaxHits ); } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { if ( Core.AOS && parent is Mobile ) { @@ -171,7 +171,7 @@ namespace Server.Items } } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { if ( Core.AOS && parent is Mobile ) { diff --git a/Scripts/Items/Lights/BaseEquipableLight.cs b/Scripts/Items/Lights/BaseEquipableLight.cs index 201777375..9afe1f34c 100644 --- a/Scripts/Items/Lights/BaseEquipableLight.cs +++ b/Scripts/Items/Lights/BaseEquipableLight.cs @@ -41,7 +41,7 @@ namespace Server.Items } } - public override void OnAdded ( object parent ) + public override void OnAdded(IEntity parent) { if ( Burning && parent is Container ) Douse(); diff --git a/Scripts/Items/Lights/Torch.cs b/Scripts/Items/Lights/Torch.cs index 45f43b947..68fae024d 100644 --- a/Scripts/Items/Lights/Torch.cs +++ b/Scripts/Items/Lights/Torch.cs @@ -24,7 +24,7 @@ namespace Server.Items Weight = 1.0; } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); diff --git a/Scripts/Items/Misc/PromotionalToken.cs b/Scripts/Items/Misc/PromotionalToken.cs index a044d4de6..c775a2109 100644 --- a/Scripts/Items/Misc/PromotionalToken.cs +++ b/Scripts/Items/Misc/PromotionalToken.cs @@ -44,7 +44,7 @@ namespace Server.Items } } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { Mobile m = null; diff --git a/Scripts/Items/Quivers/BaseQuiver.cs b/Scripts/Items/Quivers/BaseQuiver.cs index b90c1aaaa..e850a3073 100644 --- a/Scripts/Items/Quivers/BaseQuiver.cs +++ b/Scripts/Items/Quivers/BaseQuiver.cs @@ -191,8 +191,8 @@ namespace Server.Items InvalidateWeight(); } - - public override void OnAdded( object parent ) + + public override void OnAdded(IEntity parent) { if ( parent is Mobile ) { @@ -201,8 +201,8 @@ namespace Server.Items m_Attributes.AddStatBonuses( mob ); } } - - public override void OnRemoved( object parent ) + + public override void OnRemoved(IEntity parent) { if ( parent is Mobile ) { diff --git a/Scripts/Items/Skill Items/Magical/Spellbook.cs b/Scripts/Items/Skill Items/Magical/Spellbook.cs index cb8a25999..a4b44c252 100644 --- a/Scripts/Items/Skill Items/Magical/Spellbook.cs +++ b/Scripts/Items/Skill Items/Magical/Spellbook.cs @@ -454,7 +454,7 @@ namespace Server.Items book.m_AosSkillBonuses = new AosSkillBonuses( newItem, m_AosSkillBonuses ); } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { if ( Core.AOS && parent is Mobile ) { @@ -484,7 +484,7 @@ namespace Server.Items } } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { if ( Core.AOS && parent is Mobile ) { diff --git a/Scripts/Items/Special/8th Anniversary Items/Talismans.cs b/Scripts/Items/Special/8th Anniversary Items/Talismans.cs index cede77d9f..a53df7a5e 100644 --- a/Scripts/Items/Special/8th Anniversary Items/Talismans.cs +++ b/Scripts/Items/Special/8th Anniversary Items/Talismans.cs @@ -46,7 +46,7 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { base.OnRemoved( parent ); diff --git a/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs b/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs index ca4986af5..8da692539 100644 --- a/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs +++ b/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs @@ -41,7 +41,7 @@ namespace Server.Items } } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); @@ -55,7 +55,7 @@ namespace Server.Items } } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { base.OnRemoved( parent ); diff --git a/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/GlovesOfMining.cs b/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/GlovesOfMining.cs index 89883363d..4b63a8794 100644 --- a/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/GlovesOfMining.cs +++ b/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/GlovesOfMining.cs @@ -176,7 +176,7 @@ namespace Server.Items } } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); @@ -190,7 +190,7 @@ namespace Server.Items } } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { base.OnRemoved( parent ); diff --git a/Scripts/Items/Special/Rares/Containers/BaseWaterContainer.cs b/Scripts/Items/Special/Rares/Containers/BaseWaterContainer.cs index 492bdfd0b..2d833e85a 100644 --- a/Scripts/Items/Special/Rares/Containers/BaseWaterContainer.cs +++ b/Scripts/Items/Special/Rares/Containers/BaseWaterContainer.cs @@ -33,7 +33,7 @@ if( !IsEmpty ) { - IEntity rootParent = RootParentEntity; + IEntity rootParent = RootParent; if( rootParent != null && rootParent.Map != null && rootParent.Map != Map.Internal ) MoveToWorld( rootParent.Location, rootParent.Map ); diff --git a/Scripts/Items/Talismans/BaseTalisman.cs b/Scripts/Items/Talismans/BaseTalisman.cs index 556757f2d..f9b193fe6 100644 --- a/Scripts/Items/Talismans/BaseTalisman.cs +++ b/Scripts/Items/Talismans/BaseTalisman.cs @@ -234,7 +234,7 @@ namespace Server.Items return base.CanEquip( from ); } - public override void OnAdded(object parent) + public override void OnAdded(IEntity parent) { if (parent is Mobile) { @@ -259,7 +259,7 @@ namespace Server.Items InvalidateProperties(); } - public override void OnRemoved(object parent) + public override void OnRemoved(IEntity parent) { if (parent is Mobile) { diff --git a/Scripts/Items/Weapons/BaseWeapon.cs b/Scripts/Items/Weapons/BaseWeapon.cs index 10488e661..79178b435 100644 --- a/Scripts/Items/Weapons/BaseWeapon.cs +++ b/Scripts/Items/Weapons/BaseWeapon.cs @@ -659,7 +659,7 @@ namespace Server.Items return true; } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); @@ -675,7 +675,7 @@ namespace Server.Items } } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { if ( parent is Mobile ) { diff --git a/Scripts/Mobiles/PlayerMobile.cs b/Scripts/Mobiles/PlayerMobile.cs index 77d77c2e4..7f7e97cac 100644 --- a/Scripts/Mobiles/PlayerMobile.cs +++ b/Scripts/Mobiles/PlayerMobile.cs @@ -2659,7 +2659,7 @@ namespace Server.Mobiles { if (!item.Deleted && (item.LootType == LootType.Blessed || item.Insured)) { - if (this.Backpack != item.ParentEntity) + if (this.Backpack != item.Parent) { return true; } diff --git a/Server/AssemblyInfo.cs b/Server/AssemblyInfo.cs index 3706d10a8..d5c2d76c2 100644 --- a/Server/AssemblyInfo.cs +++ b/Server/AssemblyInfo.cs @@ -47,7 +47,7 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("2.5.0.*")] +[assembly: AssemblyVersion("2.6.0.*")] // // In order to sign your assembly you must specify a key to use. Refer to the diff --git a/Server/Item.cs b/Server/Item.cs index e41bbf26c..ff7392285 100644 --- a/Server/Item.cs +++ b/Server/Item.cs @@ -470,7 +470,7 @@ namespace Server { public Map m_Map; public Point3D m_Location, m_WorldLoc; - public object m_Parent; + public IEntity m_Parent; public BounceInfo( Item item ) { @@ -480,7 +480,7 @@ namespace Server m_Parent = item.Parent; } - private BounceInfo( Map map, Point3D loc, Point3D worldLoc, object parent ) + private BounceInfo( Map map, Point3D loc, Point3D worldLoc, IEntity parent ) { m_Map = map; m_Location = loc; @@ -496,7 +496,7 @@ namespace Server Point3D loc = reader.ReadPoint3D(); Point3D worldLoc = reader.ReadPoint3D(); - object parent; + IEntity parent; Serial serial = reader.ReadInt(); @@ -594,7 +594,7 @@ namespace Server private int m_Hue; private int m_Amount; private Layer m_Layer; - private object m_Parent; // Mobile, Item, or null=World + private IEntity m_Parent; // Mobile, Item, or null=World private Map m_Map; private LootType m_LootType; private DateTime m_LastMovedTime; @@ -1149,12 +1149,12 @@ namespace Server if ( bounce != null ) { - object parent = bounce.m_Parent; + IEntity parent = bounce.m_Parent; if ( parent is Item && !((Item)parent).Deleted ) { Item p = (Item)parent; - object root = p.RootParent; + IEntity root = p.RootParent; if ( p.IsAccessibleTo( from ) && ( !(root is Mobile) || ((Mobile)root).CheckNonlocalDrop( from, this, p ) ) ) { Location = bounce.m_Location; @@ -1898,11 +1898,11 @@ namespace Server { } - public virtual void OnRemoved( object parent ) + public virtual void OnRemoved( IEntity parent ) { } - public virtual void OnAdded( object parent ) + public virtual void OnAdded( IEntity parent ) { } @@ -2918,11 +2918,12 @@ namespace Server } } - public object RootParent + [CommandProperty(AccessLevel.GameMaster)] + public IEntity RootParent { get { - object p = m_Parent; + IEntity p = m_Parent; while ( p is Item ) { @@ -2944,7 +2945,7 @@ namespace Server public bool ParentsContain() where T : Item { - object p = m_Parent; + IEntity p = m_Parent; while( p is Item ) { @@ -3325,7 +3326,7 @@ namespace Server } } - public virtual void OnParentDeleted( object parent ) + public virtual void OnParentDeleted( IEntity parent ) { this.Delete(); } @@ -3539,28 +3540,6 @@ namespace Server } } - [CommandProperty( AccessLevel.GameMaster )] - public IEntity ParentEntity - { - get - { - IEntity p = Parent as IEntity; - - return p; - } - } - - [CommandProperty( AccessLevel.GameMaster )] - public IEntity RootParentEntity - { - get - { - IEntity p = RootParent as IEntity; - - return p; - } - } - #region Location Location Location! public virtual void OnLocationChange( Point3D oldLocation ) @@ -3728,7 +3707,8 @@ namespace Server } } - public virtual object Parent + [CommandProperty(AccessLevel.GameMaster)] + public virtual IEntity Parent { get { @@ -3739,7 +3719,7 @@ namespace Server if ( m_Parent == value ) return; - object oldParent = m_Parent; + IEntity oldParent = m_Parent; m_Parent = value; @@ -4190,12 +4170,12 @@ namespace Server public Point3D GetWorldLocation() { - object root = RootParent; + IEntity root = RootParent; if ( root == null ) return m_Location; else - return ((IEntity)root).Location; + return root.Location; //return root == null ? m_Location : new Point3D( (IPoint3D) root ); } @@ -4204,22 +4184,22 @@ namespace Server public Point3D GetSurfaceTop() { - object root = RootParent; + IEntity root = RootParent; if ( root == null ) return new Point3D( m_Location.m_X, m_Location.m_Y, m_Location.m_Z + (ItemData.Surface ? ItemData.CalcHeight : 0) ); else - return ((IEntity)root).Location; + return root.Location; } public Point3D GetWorldTop() { - object root = RootParent; + IEntity root = RootParent; if ( root == null ) return new Point3D( m_Location.m_X, m_Location.m_Y, m_Location.m_Z + ItemData.CalcHeight ); else - return ((IEntity)root).Location; + return root.Location; } public void SendLocalizedMessageTo( Mobile to, int number ) @@ -4378,14 +4358,14 @@ namespace Server return true;*/ } - public bool IsChildOf( object o ) + public bool IsChildOf(IEntity o) { return IsChildOf( o, false ); } - public bool IsChildOf( object o, bool allowNull ) + public bool IsChildOf(IEntity o, bool allowNull) { - object p = m_Parent; + IEntity p = m_Parent; if ( (p == null || o == null) && !allowNull ) return false; @@ -4536,7 +4516,7 @@ namespace Server int ourHue = Hue; Map thisMap = this.Map; - object thisParent = this.m_Parent; + IEntity thisParent = this.m_Parent; Point3D worldLoc = this.GetWorldLocation(); LootType type = this.LootType; From 2f005966f9e471372786e863da5b7acac497e037 Mon Sep 17 00:00:00 2001 From: Mark Sturgill Date: Sat, 15 Feb 2014 13:52:03 -0700 Subject: [PATCH 2/4] move stuckmenu methods from core mobile to PlayerMobile take advantage of IEntity/Parent refactor in a few trivial places --- Scripts/Engines/Help/HelpGump.cs | 2 +- Scripts/Engines/Help/StuckMenu.cs | 4 +- Scripts/Mobiles/PlayerMobile.cs | 77 ++++++++++++++++++++++++++++++- Server/Item.cs | 14 +++--- Server/Mobile.cs | 77 ++++++------------------------- 5 files changed, 101 insertions(+), 73 deletions(-) diff --git a/Scripts/Engines/Help/HelpGump.cs b/Scripts/Engines/Help/HelpGump.cs index 2fba14603..6d28ba7e6 100644 --- a/Scripts/Engines/Help/HelpGump.cs +++ b/Scripts/Engines/Help/HelpGump.cs @@ -239,7 +239,7 @@ namespace Server.Engines.Help { from.SendLocalizedMessage( 1061632 ); // You can't do that while carrying the sigil. } - else if ( from.CanUseStuckMenu() && from.Region.CanUseStuckMenu( from ) && !CheckCombat( from ) && !from.Frozen && !from.Criminal && (Core.AOS || from.Kills < 5) ) + else if ( from is PlayerMobile && ((PlayerMobile)from).CanUseStuckMenu() && from.Region.CanUseStuckMenu( from ) && !CheckCombat( from ) && !from.Frozen && !from.Criminal && (Core.AOS || from.Kills < 5) ) { StuckMenu menu = new StuckMenu( from, from, true ); diff --git a/Scripts/Engines/Help/StuckMenu.cs b/Scripts/Engines/Help/StuckMenu.cs index 32b07a2e3..7eb674ec3 100644 --- a/Scripts/Engines/Help/StuckMenu.cs +++ b/Scripts/Engines/Help/StuckMenu.cs @@ -1,4 +1,5 @@ using System; +using Server.Mobiles; using Server.Network; using Server.Gumps; @@ -203,7 +204,8 @@ namespace Server.Menus.Questions new TeleportTimer( m_Mobile, entry, TimeSpan.FromSeconds( 10.0 + (Utility.RandomDouble() * 110.0) ) ).Start(); - m_Mobile.UsedStuckMenu(); + if (m_Mobile is PlayerMobile) + ((PlayerMobile)m_Mobile).UsedStuckMenu(); } else { diff --git a/Scripts/Mobiles/PlayerMobile.cs b/Scripts/Mobiles/PlayerMobile.cs index 7f7e97cac..4ea4269cb 100644 --- a/Scripts/Mobiles/PlayerMobile.cs +++ b/Scripts/Mobiles/PlayerMobile.cs @@ -2936,6 +2936,47 @@ namespace Server.Mobiles } } + #region Stuck Menu + private DateTime[] m_StuckMenuUses; + + public bool CanUseStuckMenu() + { + if (m_StuckMenuUses == null) + { + return true; + } + else + { + for (int i = 0; i < m_StuckMenuUses.Length; ++i) + { + if ((DateTime.UtcNow - m_StuckMenuUses[i]) > TimeSpan.FromDays(1.0)) + { + return true; + } + } + + return false; + } + } + + public void UsedStuckMenu() + { + if (m_StuckMenuUses == null) + { + m_StuckMenuUses = new DateTime[2]; + } + + for (int i = 0; i < m_StuckMenuUses.Length; ++i) + { + if ((DateTime.UtcNow - m_StuckMenuUses[i]) > TimeSpan.FromDays(1.0)) + { + m_StuckMenuUses[i] = DateTime.UtcNow; + return; + } + } + } + #endregion + private List m_PermaFlags; private List m_VisList; private Hashtable m_AntiMacroTable; @@ -3310,6 +3351,24 @@ namespace Server.Mobiles switch ( version ) { + case 29: + { + if (reader.ReadBool()) + { + m_StuckMenuUses = new DateTime[reader.ReadInt()]; + + for (int i = 0; i < m_StuckMenuUses.Length; ++i) + { + m_StuckMenuUses[i] = reader.ReadDateTime(); + } + } + else + { + m_StuckMenuUses = null; + } + + goto case 28; + } case 28: { m_PeacedUntil = reader.ReadDateTime(); @@ -3601,7 +3660,23 @@ namespace Server.Mobiles base.Serialize( writer ); - writer.Write( (int) 28 ); // version + writer.Write( (int) 29 ); // version + + if (m_StuckMenuUses != null) + { + writer.Write(true); + + writer.Write(m_StuckMenuUses.Length); + + for (int i = 0; i < m_StuckMenuUses.Length; ++i) + { + writer.Write(m_StuckMenuUses[i]); + } + } + else + { + writer.Write(false); + } writer.Write( (DateTime) m_PeacedUntil ); writer.Write( (DateTime) m_AnkhNextUse ); diff --git a/Server/Item.cs b/Server/Item.cs index ff7392285..9ed54ae7c 100644 --- a/Server/Item.cs +++ b/Server/Item.cs @@ -1151,7 +1151,11 @@ namespace Server { IEntity parent = bounce.m_Parent; - if ( parent is Item && !((Item)parent).Deleted ) + if (parent.Deleted) + { + MoveToWorld(bounce.m_WorldLoc, bounce.m_Map); + } + else if ( parent is Item ) { Item p = (Item)parent; IEntity root = p.RootParent; @@ -1165,7 +1169,7 @@ namespace Server MoveToWorld( from.Location, from.Map ); } } - else if ( parent is Mobile && !((Mobile)parent).Deleted ) + else if ( parent is Mobile ) { if ( !((Mobile)parent).EquipItem( this ) ) MoveToWorld( bounce.m_WorldLoc, bounce.m_Map ); @@ -2157,10 +2161,8 @@ namespace Server if ( GetSaveFlag( flags, SaveFlag.Parent ) ) { - if ( m_Parent is Mobile && !( (Mobile) m_Parent ).Deleted ) - writer.Write( ( (Mobile) m_Parent ).Serial ); - else if ( m_Parent is Item && !( (Item) m_Parent ).Deleted ) - writer.Write( ( (Item) m_Parent ).Serial ); + if (m_Parent != null && !m_Parent.Deleted) + writer.Write(m_Parent.Serial); else writer.Write( (int) Serial.MinusOne ); } diff --git a/Server/Mobile.cs b/Server/Mobile.cs index 7b5e14d9d..ea7802f9f 100644 --- a/Server/Mobile.cs +++ b/Server/Mobile.cs @@ -749,7 +749,6 @@ namespace Server private bool m_DisplayGuildTitle; private Mobile m_GuildFealty; private long m_NextSpellTime; - private DateTime[] m_StuckMenuUses; private Timer m_ExpireCombatant; private Timer m_ExpireCriminal; private Timer m_ExpireAggrTimer; @@ -3502,26 +3501,6 @@ namespace Server this.Region.OnCriminalAction( this, message ); } - public virtual bool CanUseStuckMenu() - { - if( m_StuckMenuUses == null ) - { - return true; - } - else - { - for( int i = 0; i < m_StuckMenuUses.Length; ++i ) - { - if( (DateTime.UtcNow - m_StuckMenuUses[i]) > TimeSpan.FromDays( 1.0 ) ) - { - return true; - } - } - - return false; - } - } - public virtual bool IsSnoop( Mobile from ) { return (from != this); @@ -5415,23 +5394,6 @@ namespace Server { } - public void UsedStuckMenu() - { - if( m_StuckMenuUses == null ) - { - m_StuckMenuUses = new DateTime[2]; - } - - for( int i = 0; i < m_StuckMenuUses.Length; ++i ) - { - if( (DateTime.UtcNow - m_StuckMenuUses[i]) > TimeSpan.FromDays( 1.0 ) ) - { - m_StuckMenuUses[i] = DateTime.UtcNow; - return; - } - } - } - [CommandProperty( AccessLevel.GameMaster )] public bool Squelched { @@ -5451,6 +5413,11 @@ namespace Server switch( version ) { + case 32: + { + // Removed StuckMenu + goto case 31; + } case 31: { m_LastStrGain = reader.ReadDeltaTime(); @@ -5714,19 +5681,17 @@ namespace Server m_StatMods = new List(); m_SkillMods = new List(); - if( reader.ReadBool() ) + if (version < 32) { - m_StuckMenuUses = new DateTime[reader.ReadInt()]; - - for( int i = 0; i < m_StuckMenuUses.Length; ++i ) + if (reader.ReadBool()) { - m_StuckMenuUses[i] = reader.ReadDateTime(); + int count = reader.ReadInt(); + for (int i = 0; i < count; ++i) + { + reader.ReadDateTime(); + } } } - else - { - m_StuckMenuUses = null; - } if( m_Player && m_Map != Map.Internal ) { @@ -5883,7 +5848,7 @@ namespace Server public virtual void Serialize( GenericWriter writer ) { - writer.Write( (int)31 ); // version + writer.Write( (int)32 ); // version writer.WriteDeltaTime( m_LastStrGain ); writer.WriteDeltaTime( m_LastIntGain ); @@ -6001,22 +5966,6 @@ namespace Server writer.Write( (byte)m_StrLock ); writer.Write( (byte)m_DexLock ); writer.Write( (byte)m_IntLock ); - - if( m_StuckMenuUses != null ) - { - writer.Write( true ); - - writer.Write( m_StuckMenuUses.Length ); - - for( int i = 0; i < m_StuckMenuUses.Length; ++i ) - { - writer.Write( m_StuckMenuUses[i] ); - } - } - else - { - writer.Write( false ); - } } [CommandProperty( AccessLevel.GameMaster )] From 1b157e102d26f0a6b4aea0191d4d228533f080e7 Mon Sep 17 00:00:00 2001 From: Mark Sturgill Date: Sat, 15 Feb 2014 14:54:28 -0700 Subject: [PATCH 3/4] set Parent CommandProperty write accesslevel to Developer unmark Parent property as virtual --- Server/Item.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Server/Item.cs b/Server/Item.cs index 9ed54ae7c..4b0a88f00 100644 --- a/Server/Item.cs +++ b/Server/Item.cs @@ -3709,8 +3709,8 @@ namespace Server } } - [CommandProperty(AccessLevel.GameMaster)] - public virtual IEntity Parent + [CommandProperty(AccessLevel.GameMaster, AccessLevel.Developer)] + public IEntity Parent { get { From 7bffaa645dd58bc1d98e70a24887b31aae55da8e Mon Sep 17 00:00:00 2001 From: Mark Sturgill Date: Sat, 15 Feb 2014 15:05:54 -0700 Subject: [PATCH 4/4] change serverlist public ip address autodetection url fixed base OnSubItemAdded being hidden in playermobile --- Scripts/Misc/ServerList.cs | 2 +- Scripts/Mobiles/PlayerMobile.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Scripts/Misc/ServerList.cs b/Scripts/Misc/ServerList.cs index 714bc51ed..f8de32be8 100644 --- a/Scripts/Misc/ServerList.cs +++ b/Scripts/Misc/ServerList.cs @@ -170,7 +170,7 @@ namespace Server.Misc private static IPAddress FindPublicAddress() { try { - WebRequest req = HttpWebRequest.Create( "http://www.runuo.com/ip.php" ); + WebRequest req = HttpWebRequest.Create( "https://zenvera.com/ip.php" ); req.Timeout = 15000; WebResponse res = req.GetResponse(); diff --git a/Scripts/Mobiles/PlayerMobile.cs b/Scripts/Mobiles/PlayerMobile.cs index 4ea4269cb..767f593b3 100644 --- a/Scripts/Mobiles/PlayerMobile.cs +++ b/Scripts/Mobiles/PlayerMobile.cs @@ -1306,6 +1306,8 @@ namespace Server.Mobiles if ( curWeight > maxWeight ) this.SendLocalizedMessage( 1019035, true, String.Format( " : {0} / {1}", curWeight, maxWeight ) ); } + + base.OnSubItemAdded(item); } public override bool CanBeHarmful( Mobile target, bool message, bool ignoreOurBlessedness )