From b9e3476d8b33b44f0a5ddd5248fc2ca3233d8644 Mon Sep 17 00:00:00 2001 From: mark Date: Sun, 12 Aug 2007 07:19:44 +0000 Subject: [PATCH] general cleanup, fixed a slightly improbably crash issue --- Scripts/Accounting/Account.cs | 2 +- Scripts/Accounting/Firewall.cs | 2 +- Scripts/Accounting/IPLimiter.cs | 2 +- Scripts/Commands/GenCategorization.cs | 1 - .../Compilers/ConditionalCompiler.cs | 2 +- Scripts/Commands/VisibilityList.cs | 2 +- Scripts/Engines/Reports/Reports.cs | 2 +- Scripts/Gumps/AdminGump.cs | 4 +-- Scripts/Gumps/ClientGump.cs | 1 - Scripts/Gumps/Properties/PropsGump.cs | 16 ++++++----- Scripts/Gumps/Properties/SetObjectGump.cs | 2 +- Scripts/Gumps/Properties/SetTimeSpanGump.cs | 1 - Scripts/Gumps/ResurrectGump.cs | 4 +-- Scripts/Items/Containers/Container.cs | 14 +++++----- .../Items/Skill Items/Magical/Spellbook.cs | 3 ++ Scripts/Misc/Cleanup.cs | 2 +- Scripts/Misc/DataPath.cs | 10 ------- Scripts/Misc/SkillCheck.cs | 2 +- Scripts/Mobiles/Animals/Mounts/Ethereals.cs | 2 +- Scripts/Mobiles/Vendors/BaseVendor.cs | 3 ++ Scripts/Regions/GuardedRegion.cs | 1 + Scripts/Skills/AnimalLore.cs | 6 ++-- Scripts/Skills/AnimalTaming.cs | 28 +++++++++---------- Server/Items/Container.cs | 2 +- Server/Main.cs | 4 +-- Server/SecureTrade.cs | 11 +++++--- 26 files changed, 62 insertions(+), 67 deletions(-) diff --git a/Scripts/Accounting/Account.cs b/Scripts/Accounting/Account.cs index ea34bbf11..fda7c4a37 100644 --- a/Scripts/Accounting/Account.cs +++ b/Scripts/Accounting/Account.cs @@ -127,7 +127,7 @@ namespace Server.Accounting } /// - /// Account username and password hashed with MD5. May be null. + /// Account username and password hashed with SHA1. May be null. /// public string NewCryptPassword { diff --git a/Scripts/Accounting/Firewall.cs b/Scripts/Accounting/Firewall.cs index 6f37a0f6c..89a8014cb 100644 --- a/Scripts/Accounting/Firewall.cs +++ b/Scripts/Accounting/Firewall.cs @@ -1,8 +1,8 @@ using System; using System.Collections; +using System.Collections.Generic; using System.IO; using System.Net; -using System.Collections.Generic; namespace Server { diff --git a/Scripts/Accounting/IPLimiter.cs b/Scripts/Accounting/IPLimiter.cs index 47558763d..f13b247f4 100644 --- a/Scripts/Accounting/IPLimiter.cs +++ b/Scripts/Accounting/IPLimiter.cs @@ -48,7 +48,7 @@ namespace Server.Misc { ++count; - if ( count >= MaxAddresses ) + if ( count > MaxAddresses ) return false; } } diff --git a/Scripts/Commands/GenCategorization.cs b/Scripts/Commands/GenCategorization.cs index 7e6da5084..043ace68d 100644 --- a/Scripts/Commands/GenCategorization.cs +++ b/Scripts/Commands/GenCategorization.cs @@ -5,7 +5,6 @@ using System.Collections; using System.Reflection; using Server; using Server.Items; -using Server.Commands; namespace Server.Commands { diff --git a/Scripts/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs b/Scripts/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs index 71f94d694..3e438b3ba 100644 --- a/Scripts/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs +++ b/Scripts/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs @@ -1,9 +1,9 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Globalization; using System.Reflection; using System.Reflection.Emit; -using System.Globalization; using System.Text; using Server; diff --git a/Scripts/Commands/VisibilityList.cs b/Scripts/Commands/VisibilityList.cs index 4f757a5ed..d2d90d21b 100644 --- a/Scripts/Commands/VisibilityList.cs +++ b/Scripts/Commands/VisibilityList.cs @@ -98,7 +98,7 @@ namespace Server.Commands PlayerMobile pm = (PlayerMobile)from; Mobile targ = (Mobile)targeted; - if ( targ.AccessLevel < from.AccessLevel ) + if ( targ.AccessLevel <= from.AccessLevel ) { List list = pm.VisibilityList; diff --git a/Scripts/Engines/Reports/Reports.cs b/Scripts/Engines/Reports/Reports.cs index cdc456b17..6f07ea5dd 100644 --- a/Scripts/Engines/Reports/Reports.cs +++ b/Scripts/Engines/Reports/Reports.cs @@ -1,13 +1,13 @@ using System; using System.Threading; using System.Collections; +using System.Collections.Generic; using Server; using Server.Items; using Server.Mobiles; using Server.Network; using Server.Factions; using Server.Accounting; -using System.Collections.Generic; namespace Server.Engines.Reports { diff --git a/Scripts/Gumps/AdminGump.cs b/Scripts/Gumps/AdminGump.cs index f0bef1504..8104f8378 100644 --- a/Scripts/Gumps/AdminGump.cs +++ b/Scripts/Gumps/AdminGump.cs @@ -515,7 +515,7 @@ namespace Server.Gumps { if ( m_List == null ) { - m_List = new ArrayList( (ICollection)NetState.Instances ); + m_List = new ArrayList( NetState.Instances ); m_List.Sort( NetStateComparer.Instance ); } @@ -1119,7 +1119,7 @@ namespace Server.Gumps AccountComment c = a.Comments[i]; - sb.AppendFormat( "[{0} on {1}]
{2}", c.AddedBy, c.LastModified,c.Content ); + sb.AppendFormat( "[{0} on {1}]
{2}", c.AddedBy, c.LastModified, c.Content ); } AddHtml( 20, 180, 380, 190, sb.ToString(), true, true ); diff --git a/Scripts/Gumps/ClientGump.cs b/Scripts/Gumps/ClientGump.cs index d30e7b92a..3373d783f 100644 --- a/Scripts/Gumps/ClientGump.cs +++ b/Scripts/Gumps/ClientGump.cs @@ -4,7 +4,6 @@ using Server; using Server.Accounting; using Server.Network; using Server.Targets; -using Server.Gumps; using Server.Commands; using Server.Commands.Generic; diff --git a/Scripts/Gumps/Properties/PropsGump.cs b/Scripts/Gumps/Properties/PropsGump.cs index 98ef8e725..b56d95d0b 100644 --- a/Scripts/Gumps/Properties/PropsGump.cs +++ b/Scripts/Gumps/Properties/PropsGump.cs @@ -235,7 +235,7 @@ namespace Server.Gumps { Mobile from = state.Mobile; - if ( !Server.Commands.Generic.BaseCommand.IsAccessible( from, m_Object ) ) + if ( !BaseCommand.IsAccessible( from, m_Object ) ) { from.SendMessage( "You may no longer access their properties." ); return; @@ -315,10 +315,12 @@ namespace Server.Gumps } else if( HasAttribute( type, typeofPropertyObject, true ) ) { - object o = prop.GetValue( m_Object, null ); - - if( o != null ) - from.SendGump( new PropertiesGump( from, o, m_Stack, new StackEntry( m_Object, prop ) ) ); + object obj = prop.GetValue( m_Object, null ); + + if ( obj != null ) + from.SendGump( new PropertiesGump( from, obj, m_Stack, new StackEntry( m_Object, prop ) ) ); + else + from.SendGump( new PropertiesGump( from, m_Object, m_Stack, m_List, m_Page ) ); } } @@ -489,7 +491,7 @@ namespace Server.Gumps } else if ( o is Item ) { - return String.Format( "(I) 0x{0:X}", ((Item)o).Serial.Value ); + return String.Format( "(I) 0x{0:X}", ((Item)o).Serial ); } else if ( o is Type ) { @@ -671,7 +673,7 @@ namespace Server.Gumps } else if ( o is Item ) { - return String.Format( "(I) 0x{0:X}", ((Item)o).Serial.Value ); + return String.Format( "(I) 0x{0:X}", ((Item)o).Serial ); } else if ( o is Type ) { diff --git a/Scripts/Gumps/Properties/SetObjectGump.cs b/Scripts/Gumps/Properties/SetObjectGump.cs index 10406aa08..26a1f8510 100644 --- a/Scripts/Gumps/Properties/SetObjectGump.cs +++ b/Scripts/Gumps/Properties/SetObjectGump.cs @@ -267,7 +267,7 @@ namespace Server.Gumps if ( obj == null ) m_Mobile.SendMessage( "The property is null and so you cannot view its properties." ); - else if ( !Server.Commands.Generic.BaseCommand.IsAccessible( m_Mobile, obj ) ) + else if ( !BaseCommand.IsAccessible( m_Mobile, obj ) ) m_Mobile.SendMessage( "You may not view their properties." ); else viewProps = obj; diff --git a/Scripts/Gumps/Properties/SetTimeSpanGump.cs b/Scripts/Gumps/Properties/SetTimeSpanGump.cs index a208de1ed..fb6cdc0dd 100644 --- a/Scripts/Gumps/Properties/SetTimeSpanGump.cs +++ b/Scripts/Gumps/Properties/SetTimeSpanGump.cs @@ -134,7 +134,6 @@ namespace Server.Gumps toSet = TimeSpan.Zero; } - shouldSet = shouldSend = successfulParse; break; diff --git a/Scripts/Gumps/ResurrectGump.cs b/Scripts/Gumps/ResurrectGump.cs index 3d4182340..178142182 100644 --- a/Scripts/Gumps/ResurrectGump.cs +++ b/Scripts/Gumps/ResurrectGump.cs @@ -3,7 +3,6 @@ using System.Collections; using System.Collections.Generic; using Server; using Server.Items; -using Server.Gumps; using Server.Network; using Server.Mobiles; @@ -186,7 +185,7 @@ namespace Server.Gumps } } - if( m_FromSacrifice && !from.Criminal && from is PlayerMobile ) + if( m_FromSacrifice && from is PlayerMobile ) { ((PlayerMobile)from).AvailableResurrects -= 1; @@ -237,7 +236,6 @@ namespace Server.Gumps } } - if( from.Alive && m_HitsScalar > 0 ) from.Hits = (int)(from.HitsMax * m_HitsScalar); } diff --git a/Scripts/Items/Containers/Container.cs b/Scripts/Items/Containers/Container.cs index df0341ac4..37ef8a4ca 100644 --- a/Scripts/Items/Containers/Container.cs +++ b/Scripts/Items/Containers/Container.cs @@ -625,7 +625,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (int) 0 ); // version + writer.Write( (int) 1 ); // version } public override void Deserialize( GenericReader reader ) @@ -656,7 +656,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (int) 0 ); // version + writer.Write( (int) 1 ); // version } public override void Deserialize( GenericReader reader ) @@ -687,7 +687,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (int) 0 ); // version + writer.Write( (int) 1 ); // version } public override void Deserialize( GenericReader reader ) @@ -781,7 +781,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (int) 0 ); // version + writer.Write( (int) 1 ); // version } public override void Deserialize( GenericReader reader ) @@ -812,7 +812,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (int) 0 ); // version + writer.Write( (int) 1 ); // version } public override void Deserialize( GenericReader reader ) @@ -843,7 +843,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (int) 0 ); // version + writer.Write( (int) 1 ); // version } public override void Deserialize( GenericReader reader ) @@ -874,7 +874,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (int) 0 ); // version + writer.Write( (int) 1 ); // version } public override void Deserialize( GenericReader reader ) diff --git a/Scripts/Items/Skill Items/Magical/Spellbook.cs b/Scripts/Items/Skill Items/Magical/Spellbook.cs index 891d856bf..55773fa4a 100644 --- a/Scripts/Items/Skill Items/Magical/Spellbook.cs +++ b/Scripts/Items/Skill Items/Magical/Spellbook.cs @@ -483,6 +483,9 @@ namespace Server.Items } else if ( Parent is Item ) { + if ( to.NetState == null ) + return; + // What will happen if the client doesn't know about our parent? if ( to.NetState.IsPost6017 ) to.Send( new ContainerContentUpdate6017( this ) ); diff --git a/Scripts/Misc/Cleanup.cs b/Scripts/Misc/Cleanup.cs index 62a93af1a..1b69026fe 100644 --- a/Scripts/Misc/Cleanup.cs +++ b/Scripts/Misc/Cleanup.cs @@ -127,7 +127,7 @@ namespace Server.Misc } } - public static bool IsBuggable(Item item) + public static bool IsBuggable( Item item ) { if ( item is Fists ) return false; diff --git a/Scripts/Misc/DataPath.cs b/Scripts/Misc/DataPath.cs index 3f9cf944b..a57e4d541 100644 --- a/Scripts/Misc/DataPath.cs +++ b/Scripts/Misc/DataPath.cs @@ -45,16 +45,6 @@ namespace Server.Misc if ( pathTD != null ) Core.DataDirectories.Add( pathTD ); - - if ( CustomPath != null ) - Core.DataDirectories.Add( CustomPath ); - - if ( pathReg != null ) - Core.DataDirectories.Add( pathReg ); - - if ( pathTD != null ) - Core.DataDirectories.Add( pathTD ); - if ( Core.DataDirectories.Count == 0 ) { Console.WriteLine( "Enter the Ultima Online directory:" ); diff --git a/Scripts/Misc/SkillCheck.cs b/Scripts/Misc/SkillCheck.cs index 24098e984..3b9a89e05 100644 --- a/Scripts/Misc/SkillCheck.cs +++ b/Scripts/Misc/SkillCheck.cs @@ -179,7 +179,7 @@ namespace Server.Misc private static bool AllowGain( Mobile from, Skill skill, object obj ) { - if ( from is PlayerMobile && AntiMacroCode && UseAntiMacro[skill.Info.SkillID] ) + if ( AntiMacroCode && from is PlayerMobile && UseAntiMacro[skill.Info.SkillID] ) return ((PlayerMobile)from).AntiMacroCheck( skill, obj ); else return true; diff --git a/Scripts/Mobiles/Animals/Mounts/Ethereals.cs b/Scripts/Mobiles/Animals/Mounts/Ethereals.cs index a29f08b24..938f66ed9 100644 --- a/Scripts/Mobiles/Animals/Mounts/Ethereals.cs +++ b/Scripts/Mobiles/Animals/Mounts/Ethereals.cs @@ -178,7 +178,7 @@ namespace Server.Mobiles writer.Write( (int)3 ); // version writer.Write( m_IsDonationItem ); - writer.Write( (bool)m_IsRewardItem ); + writer.Write( m_IsRewardItem ); writer.Write( (int)m_MountedID ); writer.Write( (int)m_RegularID ); diff --git a/Scripts/Mobiles/Vendors/BaseVendor.cs b/Scripts/Mobiles/Vendors/BaseVendor.cs index 373c848f3..d1e5d1b37 100644 --- a/Scripts/Mobiles/Vendors/BaseVendor.cs +++ b/Scripts/Mobiles/Vendors/BaseVendor.cs @@ -632,6 +632,9 @@ namespace Server.Mobiles list.Sort( new BuyItemStateComparer() ); SendPacksTo( from ); + + if ( from.NetState == null ) + return; if ( from.NetState.IsPost6017 ) from.Send( new VendorBuyContent6017( list ) ); diff --git a/Scripts/Regions/GuardedRegion.cs b/Scripts/Regions/GuardedRegion.cs index dd44f07f2..42a77655b 100644 --- a/Scripts/Regions/GuardedRegion.cs +++ b/Scripts/Regions/GuardedRegion.cs @@ -133,6 +133,7 @@ namespace Server.Regions { m_GuardType = DefaultGuardType; } + public GuardedRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent ) { XmlElement el = xml["guards"]; diff --git a/Scripts/Skills/AnimalLore.cs b/Scripts/Skills/AnimalLore.cs index fd2e09f2a..03a8bcd86 100644 --- a/Scripts/Skills/AnimalLore.cs +++ b/Scripts/Skills/AnimalLore.cs @@ -173,8 +173,8 @@ namespace Server.SkillHandlers { int y = 276; - if ( Core.SE ) - { + if ( Core.SE ) + { double bd = Items.BaseInstrument.GetBaseDifficulty( c ); if ( c.Uncalmable ) bd = 0; @@ -183,7 +183,7 @@ namespace Server.SkillHandlers AddHtml( 320, y, 35, 18, FormatDouble( bd ), false, false ); y += 18; - } + } AddImage( 128, y + 2, 2086 ); AddHtmlLocalized( 147, y, 160, 18, 1049594, 200, false, false ); // Loyalty Rating diff --git a/Scripts/Skills/AnimalTaming.cs b/Scripts/Skills/AnimalTaming.cs index d183a645b..fb4035161 100644 --- a/Scripts/Skills/AnimalTaming.cs +++ b/Scripts/Skills/AnimalTaming.cs @@ -57,28 +57,28 @@ namespace Server.SkillHandlers } public static void ScaleStats( BaseCreature bc, double scalar ) - { - if ( bc.RawStr > 0 ) - bc.RawStr = (int)Math.Max( 1, bc.RawStr * scalar ); + { + if ( bc.RawStr > 0 ) + bc.RawStr = (int)Math.Max( 1, bc.RawStr * scalar ); - if ( bc.RawDex > 0 ) - bc.RawDex = (int)Math.Max( 1, bc.RawDex * scalar ); + if ( bc.RawDex > 0 ) + bc.RawDex = (int)Math.Max( 1, bc.RawDex * scalar ); if ( bc.RawInt > 0 ) bc.RawInt = (int)Math.Max( 1, bc.RawInt * scalar ); - if ( bc.HitsMaxSeed > 0 ) - { - bc.HitsMaxSeed = (int)Math.Max( 1, bc.HitsMaxSeed * scalar ); - bc.Hits = bc.Hits; + if ( bc.HitsMaxSeed > 0 ) + { + bc.HitsMaxSeed = (int)Math.Max( 1, bc.HitsMaxSeed * scalar ); + bc.Hits = bc.Hits; } - if ( bc.StamMaxSeed > 0 ) - { - bc.StamMaxSeed = (int)Math.Max( 1, bc.StamMaxSeed * scalar ); - bc.Stam = bc.Stam; - } + if ( bc.StamMaxSeed > 0 ) + { + bc.StamMaxSeed = (int)Math.Max( 1, bc.StamMaxSeed * scalar ); + bc.Stam = bc.Stam; } + } public static void ScaleSkills( BaseCreature bc, double scalar ) { diff --git a/Server/Items/Container.cs b/Server/Items/Container.cs index 935c6bfc0..f04a12fea 100644 --- a/Server/Items/Container.cs +++ b/Server/Items/Container.cs @@ -1659,7 +1659,7 @@ namespace Server.Items to.Send( new ContainerDisplay( this ) ); - if ( to.NetState.IsPost6017 ) + if ( to.NetState != null && to.NetState.IsPost6017 ) to.Send( new ContainerContent6017( to, this ) ); else to.Send( new ContainerContent( to, this ) ); diff --git a/Server/Main.cs b/Server/Main.cs index a5d77ff2d..1b271d0ab 100644 --- a/Server/Main.cs +++ b/Server/Main.cs @@ -461,10 +461,8 @@ namespace Server int sample = 0; - while( true ) + while( m_Signal.WaitOne() ) { - m_Signal.WaitOne(); - Mobile.ProcessDeltaQueue(); Item.ProcessDeltaQueue(); diff --git a/Server/SecureTrade.cs b/Server/SecureTrade.cs index 357a6b14a..f7af27493 100644 --- a/Server/SecureTrade.cs +++ b/Server/SecureTrade.cs @@ -209,14 +209,17 @@ namespace Server m_From = new SecureTradeInfo( this, from, new SecureTradeContainer( this ) ); m_To = new SecureTradeInfo( this, to, new SecureTradeContainer( this ) ); + bool from6017 = ( from.NetState == null ? false : from.NetState.IsPost6017 ); + bool to6017 = ( to.NetState == null ? false : to.NetState.IsPost6017 ); + from.Send( new MobileStatus( from, to ) ); from.Send( new UpdateSecureTrade( m_From.Container, false, false ) ); - if ( from.NetState.IsPost6017 ) + if ( from6017 ) from.Send( new SecureTradeEquip6017( m_To.Container, to ) ); else from.Send( new SecureTradeEquip( m_To.Container, to ) ); from.Send( new UpdateSecureTrade( m_From.Container, false, false ) ); - if ( from.NetState.IsPost6017 ) + if ( from6017 ) from.Send( new SecureTradeEquip6017( m_From.Container, from ) ); else from.Send( new SecureTradeEquip( m_From.Container, from ) ); @@ -225,12 +228,12 @@ namespace Server to.Send( new MobileStatus( to, from ) ); to.Send( new UpdateSecureTrade( m_To.Container, false, false ) ); - if ( to.NetState.IsPost6017 ) + if ( to6017 ) to.Send( new SecureTradeEquip6017( m_From.Container, from ) ); else to.Send( new SecureTradeEquip( m_From.Container, from ) ); to.Send( new UpdateSecureTrade( m_To.Container, false, false ) ); - if ( to.NetState.IsPost6017 ) + if ( to6017 ) to.Send( new SecureTradeEquip6017( m_To.Container, to ) ); else to.Send( new SecureTradeEquip( m_To.Container, to ) );