diff --git a/Data/Binary/Bounds.bin b/Data/Binary/Bounds.bin index dbe5830d0..214ca6efa 100644 Binary files a/Data/Binary/Bounds.bin and b/Data/Binary/Bounds.bin differ diff --git a/Scripts/Gumps/ConfirmHouseResize.cs b/Scripts/Gumps/ConfirmHouseResize.cs index 3b4c4a1fb..7446dedbb 100644 --- a/Scripts/Gumps/ConfirmHouseResize.cs +++ b/Scripts/Gumps/ConfirmHouseResize.cs @@ -12,7 +12,6 @@ namespace Server.Gumps { private Mobile m_Mobile; private BaseHouse m_House; - private TempNoHousingRegion m_Temp; public ConfirmHouseResize( Mobile mobile, BaseHouse house ) : base( 110, 100 ) { diff --git a/Scripts/Items/Armor/Glasses/LyricalGlasses.cs b/Scripts/Items/Armor/Glasses/LyricalGlasses.cs index c566d704b..3648b5fd1 100644 --- a/Scripts/Items/Armor/Glasses/LyricalGlasses.cs +++ b/Scripts/Items/Armor/Glasses/LyricalGlasses.cs @@ -16,8 +16,6 @@ namespace Server.Items public override int InitMinHits{ get{ return 255; } } public override int InitMaxHits{ get{ return 255; } } - private AosWeaponAttributes m_AosWeaponAttributes; - [Constructable] public LyricalGlasses() { diff --git a/Scripts/Items/Armor/Glasses/MaceShieldGlasses.cs b/Scripts/Items/Armor/Glasses/MaceShieldGlasses.cs index 436195cc3..b298cdfb8 100644 --- a/Scripts/Items/Armor/Glasses/MaceShieldGlasses.cs +++ b/Scripts/Items/Armor/Glasses/MaceShieldGlasses.cs @@ -16,8 +16,6 @@ namespace Server.Items public override int InitMinHits{ get{ return 255; } } public override int InitMaxHits{ get{ return 255; } } - private AosWeaponAttributes m_AosWeaponAttributes; - [Constructable] public MaceShieldGlasses() { diff --git a/Scripts/Items/Special/11th Year promo/EarringsOfProtection.cs b/Scripts/Items/Special/11th Year promo/EarringsOfProtection.cs index 1572a693e..77af900da 100644 --- a/Scripts/Items/Special/11th Year promo/EarringsOfProtection.cs +++ b/Scripts/Items/Special/11th Year promo/EarringsOfProtection.cs @@ -65,7 +65,6 @@ namespace Server.Items } private AosElementAttribute m_Attribute; - private LootType m_LootType; [Constructable] public EarringsOfProtection() : this( RandomType() ) diff --git a/Scripts/Mobiles/BaseCreature.cs b/Scripts/Mobiles/BaseCreature.cs index ce52d0b87..a31badfdf 100644 --- a/Scripts/Mobiles/BaseCreature.cs +++ b/Scripts/Mobiles/BaseCreature.cs @@ -163,7 +163,7 @@ namespace Server.Mobiles } } - public class BaseCreature : Mobile, IHonorTarget + public partial class BaseCreature : Mobile, IHonorTarget { public const int MaxLoyalty = 100; diff --git a/Scripts/Mobiles/PlayerMobile.cs b/Scripts/Mobiles/PlayerMobile.cs index 400aab80b..b7a74315a 100644 --- a/Scripts/Mobiles/PlayerMobile.cs +++ b/Scripts/Mobiles/PlayerMobile.cs @@ -72,7 +72,7 @@ namespace Server.Mobiles } #endregion - public class PlayerMobile : Mobile, IHonorTarget + public partial class PlayerMobile : Mobile, IHonorTarget { private class CountAndTimeStamp { diff --git a/Server/Item.cs b/Server/Item.cs index 0cf951aa6..95f41021c 100644 --- a/Server/Item.cs +++ b/Server/Item.cs @@ -1541,7 +1541,7 @@ namespace Server public virtual bool StackWith( Mobile from, Item dropped, bool playSound ) { - if ( dropped.Stackable && Stackable && dropped.GetType() == GetType() && dropped.ItemID == ItemID && dropped.Hue == Hue && dropped.Name == Name && (dropped.Amount + Amount) <= 60000 ) + if ( dropped.Stackable && Stackable && dropped.GetType() == GetType() && dropped.ItemID == ItemID && dropped.Hue == Hue && dropped.Name == Name && (dropped.Amount + Amount) <= 60000 && dropped != this ) { if ( m_LootType != dropped.m_LootType ) m_LootType = LootType.Regular; diff --git a/Server/ItemBounds.cs b/Server/ItemBounds.cs index f361adcaa..f5e69974a 100644 --- a/Server/ItemBounds.cs +++ b/Server/ItemBounds.cs @@ -37,15 +37,17 @@ namespace Server static ItemBounds() { + m_Bounds = new Rectangle2D[TileData.ItemTable.Length]; + if ( File.Exists( "Data/Binary/Bounds.bin" ) ) { using ( FileStream fs = new FileStream( "Data/Binary/Bounds.bin", FileMode.Open, FileAccess.Read, FileShare.Read ) ) { BinaryReader bin = new BinaryReader( fs ); - m_Bounds = new Rectangle2D[0x4000]; + int count = Math.Min( m_Bounds.Length, (int)( fs.Length / 8 ) ); - for ( int i = 0; i < 0x4000; ++i ) + for ( int i = 0; i < count; ++i ) { int xMin = bin.ReadInt16(); int yMin = bin.ReadInt16(); @@ -61,8 +63,6 @@ namespace Server else { Console.WriteLine( "Warning: Data/Binary/Bounds.bin does not exist" ); - - m_Bounds = new Rectangle2D[0x4000]; } } } diff --git a/Server/Main.cs b/Server/Main.cs index 9692a9623..48e500c6c 100644 --- a/Server/Main.cs +++ b/Server/Main.cs @@ -28,9 +28,7 @@ using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Threading; -#if Framework_4_0 using System.Threading.Tasks; -#endif using Server; using Server.Accounting; @@ -112,11 +110,7 @@ namespace Server public static Thread Thread { get { return m_Thread; } } public static MultiTextWriter MultiConsoleOut { get { return m_MultiConOut; } } -#if Framework_4_0 public static readonly bool Is64Bit = Environment.Is64BitProcess; -#else - public static readonly bool Is64Bit = (IntPtr.Size == 8); //Returns the size for the current /process/ -#endif private static bool m_MultiProcessor; private static int m_ProcessorCount; @@ -668,17 +662,10 @@ namespace Server if( a == null ) return; -#if Framework_4_0 Parallel.ForEach(a.GetTypes(), t => { VerifyType(t); }); -#else - foreach (Type t in a.GetTypes()) - { - VerifyType(t); - } -#endif } } diff --git a/Server/Network/Listener.cs b/Server/Network/Listener.cs index 593c94811..88ca8a690 100644 --- a/Server/Network/Listener.cs +++ b/Server/Network/Listener.cs @@ -36,11 +36,7 @@ namespace Server.Network private Queue m_Accepted; private object m_AcceptedSyncRoot; -#if Framework_4_0 private SocketAsyncEventArgs m_EventArgs; -#else - private AsyncCallback m_OnAccept; -#endif private static Socket[] m_EmptySockets = new Socket[0]; @@ -63,19 +59,9 @@ namespace Server.Network DisplayListener(); -#if Framework_4_0 m_EventArgs = new SocketAsyncEventArgs(); m_EventArgs.Completed += new EventHandler( Accept_Completion ); Accept_Start(); -#else - m_OnAccept = new AsyncCallback( OnAccept ); - try { - IAsyncResult res = m_Listener.BeginAccept( m_OnAccept, m_Listener ); - } catch ( SocketException ex ) { - NetState.TraceException( ex ); - } catch ( ObjectDisposedException ) { - } -#endif } private Socket Bind( IPEndPoint ipep ) @@ -146,7 +132,6 @@ namespace Server.Network } } -#if Framework_4_0 private void Accept_Start() { bool result = false; @@ -184,38 +169,6 @@ namespace Server.Network e.AcceptSocket = null; } -#else - - private void OnAccept( IAsyncResult asyncResult ) { - Socket listener = (Socket) asyncResult.AsyncState; - - Socket accepted = null; - - try { - accepted = listener.EndAccept( asyncResult ); - } catch ( SocketException ex ) { - NetState.TraceException( ex ); - } catch ( ObjectDisposedException ) { - return; - } - - if ( accepted != null ) { - if ( VerifySocket( accepted ) ) { - Enqueue( accepted ); - } else { - Release( accepted ); - } - } - - try { - listener.BeginAccept( m_OnAccept, listener ); - } catch ( SocketException ex ) { - NetState.TraceException( ex ); - } catch ( ObjectDisposedException ) { - } - } -#endif - private bool VerifySocket( Socket socket ) { try { SocketConnectEventArgs args = new SocketConnectEventArgs( socket ); diff --git a/Server/Network/NetState.cs b/Server/Network/NetState.cs index 299cdf957..b795e220e 100644 --- a/Server/Network/NetState.cs +++ b/Server/Network/NetState.cs @@ -51,11 +51,7 @@ namespace Server.Network { private bool m_Seeded; private bool m_Running; -#if Framework_4_0 private SocketAsyncEventArgs m_ReceiveEventArgs, m_SendEventArgs; -#else - private AsyncCallback m_OnReceive, m_OnSend; -#endif private MessagePump m_MessagePump; private ServerInfo[] m_ServerInfo; @@ -615,17 +611,8 @@ namespace Server.Network { } if ( gram != null ) { -#if Framework_4_0 m_SendEventArgs.SetBuffer( gram.Buffer, 0, gram.Length ); Send_Start(); -#else - try { - m_Socket.BeginSend( gram.Buffer, 0, gram.Length, SocketFlags.None, m_OnSend, m_Socket ); - } catch ( Exception ex ) { - TraceException( ex ); - Dispose( false ); - } -#endif } } catch ( CapacityExceededException ) { Console.WriteLine( "Client: {0}: Too much data pending, disconnecting...", this ); @@ -648,7 +635,6 @@ namespace Server.Network { } } -#if Framework_4_0 public void Start() { m_ReceiveEventArgs = new SocketAsyncEventArgs(); m_ReceiveEventArgs.Completed += new EventHandler( Receive_Completion ); @@ -824,172 +810,6 @@ namespace Server.Network { return false; } -#else - - public void Start() { - m_OnReceive = new AsyncCallback( OnReceive ); - m_OnSend = new AsyncCallback( OnSend ); - - m_Running = true; - - if ( m_Socket == null || m_Paused ) { - return; - } - - try { - lock ( m_AsyncLock ) { - if ( ( m_AsyncState & ( AsyncState.Pending | AsyncState.Paused ) ) == 0 ) { - InternalBeginReceive(); - } - } - } catch ( Exception ex ) { - TraceException( ex ); - Dispose( false ); - } - } - - private void InternalBeginReceive() { - m_AsyncState |= AsyncState.Pending; - - m_Socket.BeginReceive( m_RecvBuffer, 0, m_RecvBuffer.Length, SocketFlags.None, m_OnReceive, m_Socket ); - } - - private void OnReceive( IAsyncResult asyncResult ) { - Socket s = (Socket)asyncResult.AsyncState; - - try { - int byteCount = s.EndReceive( asyncResult ); - - if ( byteCount > 0 ) { - m_NextCheckActivity = DateTime.Now + TimeSpan.FromMinutes( 1.2 ); - - byte[] buffer = m_RecvBuffer; - - if ( m_Encoder != null ) - m_Encoder.DecodeIncomingPacket( this, ref buffer, ref byteCount ); - - lock ( m_Buffer ) - m_Buffer.Enqueue( buffer, 0, byteCount ); - - m_MessagePump.OnReceive( this ); - - lock ( m_AsyncLock ) { - m_AsyncState &= ~AsyncState.Pending; - - if ( ( m_AsyncState & AsyncState.Paused ) == 0 ) { - try { - InternalBeginReceive(); - } catch ( Exception ex ) { - TraceException( ex ); - Dispose( false ); - } - } - } - } else { - Dispose( false ); - } - } catch { - Dispose( false ); - } - } - - private void OnSend( IAsyncResult asyncResult ) { - Socket s = (Socket)asyncResult.AsyncState; - - try { - int bytes = s.EndSend( asyncResult ); - - if ( bytes <= 0 ) { - Dispose( false ); - return; - } - - m_NextCheckActivity = DateTime.Now + TimeSpan.FromMinutes( 1.2 ); - - if ( m_CoalesceSleep >= 0 ) { - Thread.Sleep( m_CoalesceSleep ); - } - - SendQueue.Gram gram; - - lock ( m_SendQueue ) { - gram = m_SendQueue.Dequeue(); - } - - if ( gram != null ) { - try { - s.BeginSend( gram.Buffer, 0, gram.Length, SocketFlags.None, m_OnSend, s ); - } catch ( Exception ex ) { - TraceException( ex ); - Dispose( false ); - } - } - } catch ( Exception ){ - Dispose( false ); - } - } - - public static void Pause() { - m_Paused = true; - - for ( int i = 0; i < m_Instances.Count; ++i ) { - NetState ns = m_Instances[i]; - - lock ( ns.m_AsyncLock ) { - ns.m_AsyncState |= AsyncState.Paused; - } - } - } - - public static void Resume() { - m_Paused = false; - - for ( int i = 0; i < m_Instances.Count; ++i ) { - NetState ns = m_Instances[i]; - - if ( ns.m_Socket == null ) { - continue; - } - - lock ( ns.m_AsyncLock ) { - ns.m_AsyncState &= ~AsyncState.Paused; - - try { - if ( ( ns.m_AsyncState & AsyncState.Pending ) == 0 ) - ns.InternalBeginReceive(); - } catch ( Exception ex ) { - TraceException( ex ); - ns.Dispose( false ); - } - } - } - } - - public bool Flush() { - if ( m_Socket == null || !m_SendQueue.IsFlushReady ) { - return false; - } - - SendQueue.Gram gram; - - lock ( m_SendQueue ) { - gram = m_SendQueue.CheckFlushReady(); - } - - if ( gram != null ) { - try { - m_Socket.BeginSend( gram.Buffer, 0, gram.Length, SocketFlags.None, m_OnSend, m_Socket ); - return true; - } catch ( Exception ex ) { - TraceException( ex ); - Dispose( false ); - } - } - - return false; - } -#endif - public PacketHandler GetHandler( int packetID ) { if ( ContainerGridLines ) @@ -1088,13 +908,8 @@ namespace Server.Network { m_Buffer = null; m_RecvBuffer = null; -#if Framework_4_0 m_ReceiveEventArgs = null; m_SendEventArgs = null; -#else - m_OnReceive = null; - m_OnSend = null; -#endif m_Running = false; diff --git a/Server/Persistence/DynamicSaveStrategy.cs b/Server/Persistence/DynamicSaveStrategy.cs index c5a9c5386..44227194f 100644 --- a/Server/Persistence/DynamicSaveStrategy.cs +++ b/Server/Persistence/DynamicSaveStrategy.cs @@ -18,8 +18,6 @@ * ***************************************************************************/ -#if Framework_4_0 - using System; using System.Collections.Generic; using System.Text; @@ -310,5 +308,4 @@ namespace Server } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/Server/Persistence/SaveStrategy.cs b/Server/Persistence/SaveStrategy.cs index 6d91da9b7..765f3d32c 100644 --- a/Server/Persistence/SaveStrategy.cs +++ b/Server/Persistence/SaveStrategy.cs @@ -31,13 +31,10 @@ namespace Server { int processorCount = Core.ProcessorCount; + //TODO: Upon realworld verification of DynamicSaveStrategy, change this method around. if (processorCount > 16) { -#if Framework_4_0 return new DynamicSaveStrategy(); -#else - return new ParallelSaveStrategy(processorCount); -#endif } else { diff --git a/Server/ScriptCompiler.cs b/Server/ScriptCompiler.cs index 9c6d9c6c1..0d8b1ecf3 100644 --- a/Server/ScriptCompiler.cs +++ b/Server/ScriptCompiler.cs @@ -86,15 +86,13 @@ namespace Server AppendDefine( ref sb, "/d:MONO" ); #endif - //These two defines are legacy, ie, depreciated. + //These following defines are legacy, ie, depreciated. if( Core.Is64Bit ) AppendDefine( ref sb, "/d:x64" ); AppendDefine( ref sb, "/d:Framework_2_0" ); -#if Framework_4_0 AppendDefine( ref sb, "/d:Framework_4_0" ); -#endif return (sb == null ? null : sb.ToString()); }