diff --git a/Scripts/Engines/Craft/Core/CraftItem.cs b/Scripts/Engines/Craft/Core/CraftItem.cs index e4df3aff0..c8905b76a 100644 --- a/Scripts/Engines/Craft/Core/CraftItem.cs +++ b/Scripts/Engines/Craft/Core/CraftItem.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Collections.Generic; using Server; using Server.Items; using Server.Factions; @@ -75,56 +76,48 @@ namespace Server.Engines.Craft m_Recipe = new Recipe( id, system, this ); } - - private static Hashtable m_ItemIDs = new Hashtable(); + + private static Dictionary _itemIds = new Dictionary(); - public static int ItemIDOf( Type type ) - { - object obj = m_ItemIDs[type]; + public static int ItemIDOf( Type type ) { + int itemId; - if ( obj != null ) - return (int)obj; - - int itemID = 0; - - if ( type == typeof( FactionExplosionTrap ) ) - itemID = 14034; - else if ( type == typeof( FactionGasTrap ) ) - itemID = 4523; - else if ( type == typeof( FactionSawTrap ) ) - itemID = 4359; - else if ( type == typeof( FactionSpikeTrap ) ) - itemID = 4517; - - if ( itemID == 0 ) - { - object[] attrs = type.GetCustomAttributes( typeof( CraftItemIDAttribute ), false ); - - if ( attrs.Length > 0 ) - { - CraftItemIDAttribute craftItemID = (CraftItemIDAttribute) attrs[0]; - itemID = craftItemID.ItemID; + if ( !_itemIds.TryGetValue( type, out itemId ) ) { + if ( type == typeof( FactionExplosionTrap ) ) { + itemId = 14034; + } else if ( type == typeof( FactionGasTrap ) ) { + itemId = 4523; + } else if ( type == typeof( FactionSawTrap ) ) { + itemId = 4359; + } else if ( type == typeof( FactionSpikeTrap ) ) { + itemId = 4517; } + + if ( itemId == 0 ) { + object[] attrs = type.GetCustomAttributes( typeof( CraftItemIDAttribute ), false ); + + if ( attrs.Length > 0 ) { + CraftItemIDAttribute craftItemID = ( CraftItemIDAttribute ) attrs[0]; + itemId = craftItemID.ItemID; + } + } + + if ( itemId == 0 ) { + Item item = null; + + try { item = Activator.CreateInstance( type ) as Item; } catch { } + + if ( item != null ) { + itemId = item.ItemID; + item.Delete(); + } + } + + _itemIds[type] = itemId; } - if ( itemID == 0 ) - { - Item item = null; - - try{ item = Activator.CreateInstance( type ) as Item; } - catch{} - - if ( item != null ) - { - itemID = item.ItemID; - item.Delete(); - } - } - - m_ItemIDs[type] = itemID; - - return itemID; + return itemId; } public CraftItem( Type type, TextDefinition groupName, TextDefinition name ) diff --git a/Scripts/Mobiles/Vendors/BaseVendor.cs b/Scripts/Mobiles/Vendors/BaseVendor.cs index 1c4866dd2..c6a4f9b9d 100644 --- a/Scripts/Mobiles/Vendors/BaseVendor.cs +++ b/Scripts/Mobiles/Vendors/BaseVendor.cs @@ -549,7 +549,7 @@ namespace Server.Mobiles list = new ArrayList( buyInfo.Length ); Container cont = this.BuyPack; - ArrayList opls = new ArrayList(); + List opls = null; for (int idx=0;idx(); + } + + if ( disp is Item ) { + opls.Add( ( ( Item ) disp ).PropertyList ); + } else if ( disp is Mobile ) { + opls.Add( ( ( Mobile ) disp ).PropertyList ); + } + } } List playerItems = cont.Items; @@ -606,7 +613,13 @@ namespace Server.Mobiles list.Add( new BuyItemState( name, cont.Serial, item.Serial, price, item.Amount, item.ItemID, item.Hue ) ); count++; - opls.Add( item.PropertyList ); + if ( ObjectPropertyList.Enabled ) { + if ( opls == null ) { + opls = new List(); + } + + opls.Add( item.PropertyList ); + } } } @@ -625,8 +638,11 @@ namespace Server.Mobiles from.Send( new DisplayBuyList( this ) ); from.Send( new MobileStatusExtended( from ) );//make sure their gold amount is sent - for ( int i = 0; i < opls.Count; ++i ) - from.Send( opls[i] as Packet ); + if ( ObjectPropertyList.Enabled && opls != null ) { + for ( int i = 0; i < opls.Count; ++i ) { + from.Send( opls[i] ); + } + } SayTo( from, 500186 ); // Greetings. Have a look around. } diff --git a/Server/Item.cs b/Server/Item.cs index 3880a8643..17f39a6ff 100644 --- a/Server/Item.cs +++ b/Server/Item.cs @@ -1648,7 +1648,7 @@ namespace Server public void InvalidateProperties() { - if ( !Core.AOS ) + if ( !ObjectPropertyList.Enabled ) return; if ( m_Map != null && m_Map != Map.Internal && !World.Loading ) diff --git a/Server/Mobile.cs b/Server/Mobile.cs index 1e848aaed..c4ec2593c 100644 --- a/Server/Mobile.cs +++ b/Server/Mobile.cs @@ -754,7 +754,7 @@ namespace Server private int m_MeleeDamageAbsorb; private int m_MagicDamageAbsorb; private int m_Followers, m_FollowersMax; - private ArrayList m_Actions; + private List _actions; // prefer List over ArrayList for more specific profiling information private Queue m_MoveRecords; private int m_WarmodeChanges = 0; private DateTime m_NextWarmodeChange; @@ -1464,17 +1464,14 @@ namespace Server public bool BeginAction( object toLock ) { - if( m_Actions == null ) - { - m_Actions = new ArrayList( 2 ); + if ( _actions == null ) { + _actions = new ArrayList( 2 ); - m_Actions.Add( toLock ); + _actions.Add( toLock ); return true; - } - else if( !m_Actions.Contains( toLock ) ) - { - m_Actions.Add( toLock ); + } else if ( !_actions.Contains( toLock ) ) { + _actions.Add( toLock ); return true; } @@ -1484,17 +1481,17 @@ namespace Server public bool CanBeginAction( object toLock ) { - return (m_Actions == null || !m_Actions.Contains( toLock )); + return ( _actions == null || !_actions.Contains( toLock ) ); } public void EndAction( object toLock ) { - if( m_Actions != null ) - { - m_Actions.Remove( toLock ); + if ( _actions != null ) { + _actions.Remove( toLock ); - if( m_Actions.Count == 0 ) - m_Actions = null; + if ( _actions.Count == 0 ) { + _actions = null; + } } } @@ -8643,7 +8640,7 @@ namespace Server public void InvalidateProperties() { - if( !Core.AOS ) + if( !ObjectPropertyList.Enabled ) return; if( m_Map != null && m_Map != Map.Internal && !World.Loading ) @@ -9636,7 +9633,7 @@ namespace Server bool sendUpdate = false, sendRemove = false; bool sendPublicStats = false, sendPrivateStats = false; bool sendMoving = false, sendNonlocalMoving = false; - bool sendOPLUpdate = Core.AOS && (delta & MobileDelta.Properties) != 0; + bool sendOPLUpdate = ObjectPropertyList.Enabled && (delta & MobileDelta.Properties) != 0; bool sendHair = false, sendFacialHair = false, removeHair = false, removeFacialHair = false;