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:
asayre 2012-01-02 10:24:08 +00:00
parent 46fc5e8de3
commit 2401b86b24
15 changed files with 10 additions and 269 deletions

View file

@ -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;