diff --git a/Scripts/Engines/BulkOrders/LargeBulkEntry.cs b/Scripts/Engines/BulkOrders/LargeBulkEntry.cs index 40d89b6d1..2a88039a5 100644 --- a/Scripts/Engines/BulkOrders/LargeBulkEntry.cs +++ b/Scripts/Engines/BulkOrders/LargeBulkEntry.cs @@ -1,6 +1,6 @@ using System; +using System.Collections.Generic; using System.IO; -using System.Collections; using Server; namespace Server.Engines.BulkOrders @@ -127,22 +127,22 @@ namespace Server.Engines.BulkOrders } - private static Hashtable m_Cache; + private static Dictionary> m_Cache; public static SmallBulkEntry[] GetEntries( string type, string name ) { - if ( m_Cache == null ) - m_Cache = new Hashtable(); + if (m_Cache == null) + m_Cache = new Dictionary>(); - Hashtable table = (Hashtable)m_Cache[type]; + Dictionary table = null; - if ( table == null ) - m_Cache[type] = table = new Hashtable(); + if (!m_Cache.TryGetValue(type, out table)) + m_Cache[type] = table = new Dictionary(); - SmallBulkEntry[] entries = (SmallBulkEntry[])table[name]; + SmallBulkEntry[] entries = null; - if ( entries == null ) - table[name] = entries = SmallBulkEntry.LoadEntries( type, name ); + if (!table.TryGetValue(name, out entries)) + table[name] = entries = SmallBulkEntry.LoadEntries(type, name); return entries; } diff --git a/Scripts/Engines/BulkOrders/SmallBulkEntry.cs b/Scripts/Engines/BulkOrders/SmallBulkEntry.cs index d7eb8b22e..732a2a761 100644 --- a/Scripts/Engines/BulkOrders/SmallBulkEntry.cs +++ b/Scripts/Engines/BulkOrders/SmallBulkEntry.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.IO; using Server; @@ -43,22 +42,22 @@ namespace Server.Engines.BulkOrders get{ return GetEntries( "Tailoring", "leather" ); } } - private static Hashtable m_Cache; + private static Dictionary> m_Cache; public static SmallBulkEntry[] GetEntries( string type, string name ) { if ( m_Cache == null ) - m_Cache = new Hashtable(); + m_Cache = new Dictionary>(); - Hashtable table = (Hashtable)m_Cache[type]; + Dictionary table = null; - if ( table == null ) - m_Cache[type] = table = new Hashtable(); + if (!m_Cache.TryGetValue(type, out table)) + m_Cache[type] = table = new Dictionary(); - SmallBulkEntry[] entries = (SmallBulkEntry[])table[name]; + SmallBulkEntry[] entries = null; - if ( entries == null ) - table[name] = entries = LoadEntries( type, name ); + if (!table.TryGetValue(name, out entries)) + table[name] = entries = LoadEntries(type, name); return entries; } diff --git a/Scripts/Engines/Plants/PlantHue.cs b/Scripts/Engines/Plants/PlantHue.cs index 3ff18f619..88ec1ca1d 100644 --- a/Scripts/Engines/Plants/PlantHue.cs +++ b/Scripts/Engines/Plants/PlantHue.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using Server; namespace Server.Engines.Plants @@ -40,11 +40,11 @@ namespace Server.Engines.Plants public class PlantHueInfo { - private static Hashtable m_Table; + private static Dictionary m_Table; static PlantHueInfo() { - m_Table = new Hashtable(); + m_Table = new Dictionary(); m_Table[PlantHue.Plain] = new PlantHueInfo( 0, 1060813, PlantHue.Plain, 0x835 ); m_Table[PlantHue.Red] = new PlantHueInfo( 0x66D, 1060814, PlantHue.Red, 0x24 ); @@ -69,12 +69,12 @@ namespace Server.Engines.Plants public static PlantHueInfo GetInfo( PlantHue plantHue ) { - PlantHueInfo info = m_Table[plantHue] as PlantHueInfo; + PlantHueInfo info = null; - if ( info != null ) + if (m_Table.TryGetValue(plantHue, out info)) return info; else - return (PlantHueInfo)m_Table[PlantHue.Plain]; + return m_Table[PlantHue.Plain]; } public static PlantHue RandomFirstGeneration() diff --git a/Scripts/Items/Misc/EffectController.cs b/Scripts/Items/Misc/EffectController.cs index 59d51cb33..65865dae0 100644 --- a/Scripts/Items/Misc/EffectController.cs +++ b/Scripts/Items/Misc/EffectController.cs @@ -264,75 +264,75 @@ namespace Server.Items } } - public void PlaySound( object trigger ) + public void PlaySound(IEntity trigger) { IEntity ent = null; - if ( m_PlaySoundAtTrigger ) + if (m_PlaySoundAtTrigger) ent = trigger as IEntity; - if ( ent == null ) + if (ent == null) ent = this; - Effects.PlaySound( (ent is Item) ? ((Item)ent).GetWorldLocation() : ent.Location, ent.Map, m_SoundID ); + Effects.PlaySound((ent is Item) ? ((Item)ent).GetWorldLocation() : ent.Location, ent.Map, m_SoundID); } - public void DoEffect( object trigger ) + public void DoEffect(IEntity trigger) { - if ( Deleted || m_TriggerType == EffectTriggerType.None ) + if (Deleted || m_TriggerType == EffectTriggerType.None) return; - if( trigger is Mobile && ((Mobile)trigger).Hidden && ((Mobile)trigger).AccessLevel > AccessLevel.Player ) + if (trigger is Mobile && ((Mobile)trigger).Hidden && ((Mobile)trigger).AccessLevel > AccessLevel.Player) return; - if ( m_SoundID > 0 ) - Timer.DelayCall( m_SoundDelay, new TimerStateCallback( PlaySound ), trigger ); + if (m_SoundID > 0) + Timer.DelayCall(m_SoundDelay, new TimerStateCallback(PlaySound), trigger); - if ( m_Trigger != null ) - Timer.DelayCall( m_TriggerDelay, new TimerStateCallback( m_Trigger.DoEffect ), trigger ); + if (m_Trigger != null) + Timer.DelayCall(m_TriggerDelay, new TimerStateCallback(m_Trigger.DoEffect), trigger); - if ( m_EffectType != ECEffectType.None ) - Timer.DelayCall( m_EffectDelay, new TimerStateCallback( InternalDoEffect ), trigger ); + if (m_EffectType != ECEffectType.None) + Timer.DelayCall(m_EffectDelay, new TimerStateCallback(InternalDoEffect), trigger); } - public void InternalDoEffect( object trigger ) + public void InternalDoEffect(IEntity trigger) { IEntity from = m_Source, to = m_Target; - - if ( from == null ) - from = (IEntity)trigger; - if ( to == null ) - to = (IEntity)trigger; + if (from == null) + from = trigger; - switch ( m_EffectType ) + if (to == null) + to = trigger; + + switch (m_EffectType) { case ECEffectType.Lightning: - { - Effects.SendBoltEffect( from, false, m_Hue ); - break; - } + { + Effects.SendBoltEffect(from, false, m_Hue); + break; + } case ECEffectType.Location: - { - Effects.SendLocationParticles( EffectItem.Create( from.Location, from.Map, EffectItem.DefaultDuration ), m_ItemID, m_Speed, m_Duration, m_Hue, m_RenderMode, m_ParticleEffect, m_Unknown ); - break; - } + { + Effects.SendLocationParticles(EffectItem.Create(from.Location, from.Map, EffectItem.DefaultDuration), m_ItemID, m_Speed, m_Duration, m_Hue, m_RenderMode, m_ParticleEffect, m_Unknown); + break; + } case ECEffectType.Moving: - { - if ( from == this ) - from = EffectItem.Create( from.Location, from.Map, EffectItem.DefaultDuration ); + { + if (from == this) + from = EffectItem.Create(from.Location, from.Map, EffectItem.DefaultDuration); - if ( to == this ) - to = EffectItem.Create( to.Location, to.Map, EffectItem.DefaultDuration ); + if (to == this) + to = EffectItem.Create(to.Location, to.Map, EffectItem.DefaultDuration); - Effects.SendMovingParticles( from, to, m_ItemID, m_Speed, m_Duration, m_FixedDirection, m_Explodes, m_Hue, m_RenderMode, m_ParticleEffect, m_ExplodeParticleEffect, m_ExplodeSound, m_EffectLayer, m_Unknown ); - break; - } + Effects.SendMovingParticles(from, to, m_ItemID, m_Speed, m_Duration, m_FixedDirection, m_Explodes, m_Hue, m_RenderMode, m_ParticleEffect, m_ExplodeParticleEffect, m_ExplodeSound, m_EffectLayer, m_Unknown); + break; + } case ECEffectType.Target: - { - Effects.SendTargetParticles( from, m_ItemID, m_Speed, m_Duration, m_Hue, m_RenderMode, m_ParticleEffect, m_EffectLayer, m_Unknown ); - break; - } + { + Effects.SendTargetParticles(from, m_ItemID, m_Speed, m_Duration, m_Hue, m_RenderMode, m_ParticleEffect, m_EffectLayer, m_Unknown); + break; + } } } } diff --git a/Scripts/Items/Wands/BaseWand.cs b/Scripts/Items/Wands/BaseWand.cs index c501aaa5e..2dcfe15b4 100644 --- a/Scripts/Items/Wands/BaseWand.cs +++ b/Scripts/Items/Wands/BaseWand.cs @@ -87,12 +87,12 @@ namespace Server.Items public virtual void ApplyDelayTo( Mobile from ) { from.BeginAction( typeof( BaseWand ) ); - Timer.DelayCall( GetUseDelay, new TimerStateCallback( ReleaseWandLock_Callback ), from ); + Timer.DelayCall(GetUseDelay, new TimerStateCallback(ReleaseWandLock_Callback), from); } - public virtual void ReleaseWandLock_Callback( object state ) + public virtual void ReleaseWandLock_Callback(Mobile state) { - ((Mobile)state).EndAction( typeof( BaseWand ) ); + state.EndAction(typeof(BaseWand)); } public override void OnDoubleClick( Mobile from ) diff --git a/Server/IEntity.cs b/Server/IEntity.cs index 8f7bfe154..1ae647683 100644 --- a/Server/IEntity.cs +++ b/Server/IEntity.cs @@ -27,6 +27,7 @@ namespace Server Serial Serial{ get; } Point3D Location{ get; } Map Map{ get; } + bool Deleted { get; } void Delete(); void ProcessDelta(); @@ -58,12 +59,14 @@ namespace Server private Serial m_Serial; private Point3D m_Location; private Map m_Map; + private bool m_Deleted; public Entity( Serial serial, Point3D loc, Map map ) { m_Serial = serial; m_Location = loc; m_Map = map; + m_Deleted = false; } public Serial Serial { @@ -102,6 +105,12 @@ namespace Server } } + public bool Deleted { + get { + return m_Deleted; + } + } + public void Delete() { } diff --git a/Server/Map.cs b/Server/Map.cs index fdf376278..473c2d2be 100644 --- a/Server/Map.cs +++ b/Server/Map.cs @@ -1382,19 +1382,19 @@ namespace Server { IEntity e = (IEntity)m_CurrentList[m_CurrentIndex]; + if (e.Deleted) + continue; + if (e is Item) { Item item = (Item)e; - if (!item.Deleted && item.Parent == null && m_Bounds.Contains(e.Location)) - return true; - } - else if (e is Mobile) - { - Mobile m = (Mobile)e; - if (!m.Deleted && m_Bounds.Contains(e.Location)) - return true; + if (item.Parent != null) + continue; } + + if (m_Bounds.Contains(e.Location)) + return true; } } }