diff --git a/Scripts/Mobiles/PlayerMobile.cs b/Scripts/Mobiles/PlayerMobile.cs index d7d791bc5..d5108dd11 100644 --- a/Scripts/Mobiles/PlayerMobile.cs +++ b/Scripts/Mobiles/PlayerMobile.cs @@ -104,7 +104,7 @@ namespace Server.Mobiles private int m_Profession; private bool m_IsStealthing; // IsStealthing should be moved to Server.Mobiles private bool m_IgnoreMobiles; // IgnoreMobiles should be moved to Server.Mobiles - private int m_NonAutoreinsuredItems; // number of items that could not be automaitically reinsured because gold in bank was not enough + private int m_NonAutoreinsuredItems; // number of items that could not be automaitically reinsured because gold in bank was not enough /* * a value of zero means, that the mobile is not executing the spell. Otherwise, @@ -2070,7 +2070,7 @@ namespace Server.Mobiles public override bool OnBeforeDeath() { - m_NonAutoreinsuredItems = 0; + m_NonAutoreinsuredItems = 0; m_InsuranceCost = 0; m_InsuranceAward = base.FindMostRecentDamager( false ); @@ -2110,14 +2110,14 @@ namespace Server.Mobiles { m_InsuranceCost += cost; item.PayedInsurance = true; - SendLocalizedMessage(1060398, cost.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box. - } + SendLocalizedMessage(1060398, cost.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box. + } else { SendLocalizedMessage( 1061079, "", 0x23 ); // You lack the funds to purchase the insurance item.PayedInsurance = false; item.Insured = false; - m_NonAutoreinsuredItems++; + m_NonAutoreinsuredItems++; } } else @@ -2169,12 +2169,12 @@ namespace Server.Mobiles public override void OnDeath( Container c ) { - if (m_NonAutoreinsuredItems > 0) - { - SendMessage("You do not have the gold to automatically reinsure all your items."); - } + if (m_NonAutoreinsuredItems > 0) + { + SendMessage("You do not have the gold to automatically reinsure all your items."); + } - base.OnDeath(c); + base.OnDeath(c); HueMod = -1; NameMod = null; @@ -2493,7 +2493,7 @@ namespace Server.Mobiles /* Per EA's UO Herald Pub48 (ML): * ((resist spellsx10)/20 + 10=percentage of damage resisted) */ - + if ( oath == this ) { amount = (int)(amount * 1.1); @@ -3418,7 +3418,7 @@ namespace Server.Mobiles if ( context != null && context.Type == typeof( ReaperFormSpell ) ) return Mobile.WalkFoot; - bool running = ( (dir & Direction.Running) != 0 ); + bool running = ( (dir & Direction.Running) != 0 ); bool onHorse = ( this.Mount != null ); diff --git a/Scripts/Regions/BaseRegion.cs b/Scripts/Regions/BaseRegion.cs index 5684fe59e..6d4935bad 100644 --- a/Scripts/Regions/BaseRegion.cs +++ b/Scripts/Regions/BaseRegion.cs @@ -483,9 +483,9 @@ namespace Server.Regions { ReadBoolean( spawning, "excludeFromParent", ref m_ExcludeFromParentSpawns, false ); - object zLevel = SpawnZLevel.Lowest; - ReadEnum( spawning, "zLevel", typeof( SpawnZLevel ), ref zLevel, false ); - m_SpawnZLevel = (SpawnZLevel) zLevel; + SpawnZLevel zLevel = SpawnZLevel.Lowest; + ReadEnum( spawning, "zLevel", ref zLevel, false ); + m_SpawnZLevel = zLevel; List list = new List(); @@ -521,9 +521,8 @@ namespace Server.Regions if ( ReadPoint3D( homeEl, map, ref home, false ) ) ReadInt32( homeEl, "range", ref range, false ); - object oDir = SpawnEntry.InvalidDirection; - ReadEnum( el["direction"], "value" , typeof( Direction ), ref oDir, false ); - Direction dir = (Direction) oDir; + Direction dir = SpawnEntry.InvalidDirection; + ReadEnum( el["direction"], "value" , ref dir, false ); SpawnEntry entry = new SpawnEntry( id, this, home, range, dir, def, amount, minSpawnTime, maxSpawnTime ); list.Add( entry ); diff --git a/Scripts/Regions/Spawning/SpawnDefinition.cs b/Scripts/Regions/Spawning/SpawnDefinition.cs index 4ec12d688..3f6573f51 100644 --- a/Scripts/Regions/Spawning/SpawnDefinition.cs +++ b/Scripts/Regions/Spawning/SpawnDefinition.cs @@ -66,10 +66,11 @@ namespace Server.Regions int itemID = 0xE43; Region.ReadInt32( xml, "itemID", ref itemID, false ); - object oLevel = BaseTreasureChest.TreasureLevel.Level2; - Region.ReadEnum( xml, "level", typeof( BaseTreasureChest.TreasureLevel ), ref oLevel, false ); + BaseTreasureChest.TreasureLevel level = BaseTreasureChest.TreasureLevel.Level2; - return new SpawnTreasureChest( itemID, (BaseTreasureChest.TreasureLevel) oLevel ); + Region.ReadEnum( xml, "level", ref level, false ); + + return new SpawnTreasureChest( itemID, level ); } default: { diff --git a/Server/ExpansionInfo.cs b/Server/ExpansionInfo.cs index 3ce0458c5..60855498d 100644 --- a/Server/ExpansionInfo.cs +++ b/Server/ExpansionInfo.cs @@ -35,6 +35,7 @@ namespace Server SA } + [Flags] public enum ClientFlags { None = 0x00000000, @@ -49,6 +50,7 @@ namespace Server UOTD = 0x00000100 } + [Flags] public enum FeatureFlags { None = 0x00000000, @@ -82,6 +84,7 @@ namespace Server ExpansionSA = ExpansionML | SA } + [Flags] public enum CharacterListFlags { None = 0x00000000, diff --git a/Server/Insensitive.cs b/Server/Insensitive.cs index 715f8c30b..4babedf40 100644 --- a/Server/Insensitive.cs +++ b/Server/Insensitive.cs @@ -23,7 +23,7 @@ using System.Collections; namespace Server { - public class Insensitive + public static class Insensitive { private static IComparer m_Comparer = CaseInsensitiveComparer.Default; diff --git a/Server/Region.cs b/Server/Region.cs index 6985a7f7a..fc466ceb8 100644 --- a/Server/Region.cs +++ b/Server/Region.cs @@ -992,11 +992,11 @@ namespace Server } - object oMusic = this.DefaultMusic; + MusicName music = this.DefaultMusic; - ReadEnum( xml["music"], "name", typeof( MusicName ), ref oMusic, false ); + ReadEnum( xml["music"], "name", ref music, false ); - m_Music = (MusicName) oMusic; + m_Music = music; } protected static string GetAttribute( XmlElement xml, string attribute, bool mandatory ) @@ -1137,12 +1137,12 @@ namespace Server return true; } - public static bool ReadEnum( XmlElement xml, string attribute, Type type, ref object value ) + public static bool ReadEnum( XmlElement xml, string attribute, ref T value ) { - return ReadEnum( xml, attribute, type, ref value, true ); + return ReadEnum( xml, attribute, ref value, true ); } - public static bool ReadEnum( XmlElement xml, string attribute, Type type, ref object value, bool mandatory ) + public static bool ReadEnum( XmlElement xml, string attribute, ref T value, bool mandatory ) { string s = GetAttribute( xml, attribute, mandatory ); @@ -1151,7 +1151,8 @@ namespace Server try { - value = Enum.Parse( type, s, true ); + value = (T)Enum.Parse( typeof( T ), s, true ); + //TODO: On .NET 4.0, use Enum.TryParse } catch {