Unused properties removed to handle warnings (Warn lvl 4, Treat Errors as warnings please & thankyou)
BaseCreature & PlayerMobile set to partial classes for easier extensibility. Prevent Item from stacking with itself Updated Bounds.bin with latest values. ItemBounds will now correctly size itself to the TileData. Compiler directives for .NET 4.0 no longer needed - .NET 4.0 is now supported by default to take advantage of the new Socket Events and Parallelization improvements.
This commit is contained in:
parent
46fc5e8de3
commit
2401b86b24
15 changed files with 10 additions and 269 deletions
Binary file not shown.
|
|
@ -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 )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ namespace Server.Items
|
|||
}
|
||||
|
||||
private AosElementAttribute m_Attribute;
|
||||
private LootType m_LootType;
|
||||
|
||||
[Constructable]
|
||||
public EarringsOfProtection() : this( RandomType() )
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ namespace Server.Mobiles
|
|||
}
|
||||
}
|
||||
|
||||
public class BaseCreature : Mobile, IHonorTarget
|
||||
public partial class BaseCreature : Mobile, IHonorTarget
|
||||
{
|
||||
public const int MaxLoyalty = 100;
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ namespace Server.Mobiles
|
|||
}
|
||||
#endregion
|
||||
|
||||
public class PlayerMobile : Mobile, IHonorTarget
|
||||
public partial class PlayerMobile : Mobile, IHonorTarget
|
||||
{
|
||||
private class CountAndTimeStamp
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,11 +36,7 @@ namespace Server.Network
|
|||
private Queue<Socket> 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<SocketAsyncEventArgs>( 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 );
|
||||
|
|
|
|||
|
|
@ -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<SocketAsyncEventArgs>( 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;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
|
||||
#if Framework_4_0
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
|
@ -310,5 +308,4 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue