Fixes implicit ternary expressions
This commit is contained in:
parent
c85b0a740c
commit
ff26dfa375
345 changed files with 1905 additions and 2336 deletions
|
|
@ -88,15 +88,16 @@ namespace Server.Network {
|
|||
{
|
||||
throw new ArgumentNullException("input");
|
||||
}
|
||||
else if (offset < 0 || offset >= input.Length)
|
||||
|
||||
if (offset < 0 || offset >= input.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("offset");
|
||||
}
|
||||
else if (count < 0 || count > input.Length)
|
||||
if (count < 0 || count > input.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count");
|
||||
}
|
||||
else if ((input.Length - offset) < count)
|
||||
if ((input.Length - offset) < count)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,7 +139,9 @@ namespace Server.Network
|
|||
// 0xEF = 239 = multicast IP, so this should never appear in a normal seed. So this is backwards compatible with older clients.
|
||||
ns.Seeded = true;
|
||||
return true;
|
||||
} else if (buffer.Length >= 4) {
|
||||
}
|
||||
|
||||
if (buffer.Length >= 4) {
|
||||
byte[] m_Peek = new byte[4];
|
||||
|
||||
buffer.Dequeue(m_Peek, 0, 4);
|
||||
|
|
@ -155,9 +157,8 @@ namespace Server.Network
|
|||
ns.m_Seed = seed;
|
||||
ns.Seeded = true;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool CheckEncrypted(NetState ns, int packetID) {
|
||||
|
|
@ -216,12 +217,15 @@ namespace Server.Network
|
|||
}
|
||||
|
||||
if ( length >= packetLength ) {
|
||||
if (handler.Ingame) {
|
||||
if (handler.Ingame)
|
||||
{
|
||||
if (ns.Mobile == null ) {
|
||||
Console.WriteLine( "Client: {0}: Sent ingame packet (0x{1:X2}) before having been attached to a mobile", ns, packetID );
|
||||
ns.Dispose();
|
||||
break;
|
||||
} else if (ns.Mobile.Deleted) {
|
||||
}
|
||||
|
||||
if (ns.Mobile.Deleted) {
|
||||
ns.Dispose();
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -278,7 +278,9 @@ namespace Server.Network {
|
|||
|
||||
if ( from.Mobile == m_Mobile && to.Mobile == m ) {
|
||||
return from.Container;
|
||||
} else if ( from.Mobile == m && to.Mobile == m_Mobile ) {
|
||||
}
|
||||
|
||||
if ( from.Mobile == m && to.Mobile == m_Mobile ) {
|
||||
return to.Container;
|
||||
}
|
||||
}
|
||||
|
|
@ -507,7 +509,7 @@ namespace Server.Network {
|
|||
}
|
||||
|
||||
PacketSendProfile prof = null;
|
||||
|
||||
|
||||
if (Core.Profiling) prof = PacketSendProfile.Acquire(p.GetType());
|
||||
|
||||
prof?.Start();
|
||||
|
|
@ -611,7 +613,9 @@ namespace Server.Network {
|
|||
if ( e.SocketError != SocketError.Success || byteCount <= 0 ) {
|
||||
Dispose( false );
|
||||
return;
|
||||
} else if ( m_Disposing ) {
|
||||
}
|
||||
|
||||
if ( m_Disposing ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -641,7 +645,7 @@ namespace Server.Network {
|
|||
|
||||
if ( result )
|
||||
Send_Process( m_SendEventArgs );
|
||||
} while ( result );
|
||||
} while ( result );
|
||||
} catch ( Exception ex ) {
|
||||
TraceException( ex );
|
||||
Dispose( false );
|
||||
|
|
@ -931,8 +935,7 @@ namespace Server.Network {
|
|||
{
|
||||
if ( ContainerGridLines )
|
||||
return PacketHandlers.Get6017Handler( packetID );
|
||||
else
|
||||
return PacketHandlers.GetHandler( packetID );
|
||||
return PacketHandlers.GetHandler( packetID );
|
||||
}
|
||||
|
||||
public static void FlushAll() {
|
||||
|
|
@ -1159,4 +1162,4 @@ namespace Server.Network {
|
|||
return m_ToString.CompareTo( other.m_ToString );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,12 +206,9 @@ namespace Server.Network
|
|||
{
|
||||
if ( packetID >= 0 && packetID < 0x100 )
|
||||
return m_ExtendedHandlersLow[packetID];
|
||||
else
|
||||
{
|
||||
PacketHandler handler;
|
||||
m_ExtendedHandlersHigh.TryGetValue( packetID, out handler );
|
||||
return handler;
|
||||
}
|
||||
PacketHandler handler;
|
||||
m_ExtendedHandlersHigh.TryGetValue( packetID, out handler );
|
||||
return handler;
|
||||
}
|
||||
|
||||
public static void RemoveExtendedHandler( int packetID )
|
||||
|
|
@ -234,12 +231,9 @@ namespace Server.Network
|
|||
{
|
||||
if ( packetID >= 0 && packetID < 0x100 )
|
||||
return m_EncodedHandlersLow[packetID];
|
||||
else
|
||||
{
|
||||
EncodedPacketHandler handler;
|
||||
m_EncodedHandlersHigh.TryGetValue( packetID, out handler );
|
||||
return handler;
|
||||
}
|
||||
EncodedPacketHandler handler;
|
||||
m_EncodedHandlersHigh.TryGetValue( packetID, out handler );
|
||||
return handler;
|
||||
}
|
||||
|
||||
public static void RemoveEncodedHandler( int packetID )
|
||||
|
|
@ -410,7 +404,8 @@ namespace Server.Network
|
|||
{
|
||||
return;
|
||||
}
|
||||
else if ( vendor.Deleted || !Utility.RangeCheck( vendor.Location, state.Mobile.Location, 10 ) )
|
||||
|
||||
if ( vendor.Deleted || !Utility.RangeCheck( vendor.Location, state.Mobile.Location, 10 ) )
|
||||
{
|
||||
state.Send( new EndVendorBuy( vendor ) );
|
||||
return;
|
||||
|
|
@ -451,7 +446,8 @@ namespace Server.Network
|
|||
{
|
||||
return;
|
||||
}
|
||||
else if ( vendor.Deleted || !Utility.RangeCheck( vendor.Location, state.Mobile.Location, 10 ) )
|
||||
|
||||
if ( vendor.Deleted || !Utility.RangeCheck( vendor.Location, state.Mobile.Location, 10 ) )
|
||||
{
|
||||
state.Send( new EndVendorSell( vendor ) );
|
||||
return;
|
||||
|
|
@ -723,10 +719,8 @@ namespace Server.Network
|
|||
state.Dispose();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void TextCommand( NetState state, PacketReader pvSrc )
|
||||
|
|
@ -1601,7 +1595,7 @@ namespace Server.Network
|
|||
bool rightClick = pvSrc.ReadBoolean();
|
||||
Mobile from = state.Mobile;
|
||||
|
||||
@from?.QuestArrow?.OnClick( rightClick );
|
||||
from?.QuestArrow?.OnClick( rightClick );
|
||||
}
|
||||
|
||||
public static void ExtendedCommand( NetState state, PacketReader pvSrc )
|
||||
|
|
@ -2543,7 +2537,8 @@ namespace Server.Network
|
|||
state.Dispose();
|
||||
return;
|
||||
}
|
||||
else if ( state.m_AuthID == 0 && authID != state.m_Seed )
|
||||
|
||||
if ( state.m_AuthID == 0 && authID != state.m_Seed )
|
||||
{
|
||||
Console.WriteLine( "Login: {0}: Invalid client detected, disconnecting", state );
|
||||
state.Dispose();
|
||||
|
|
|
|||
|
|
@ -449,7 +449,7 @@ namespace Server.Network
|
|||
public DeathAnimation( Mobile killed, Item corpse ) : base( 0xAF, 13 )
|
||||
{
|
||||
m_Stream.Write( (int) killed.Serial );
|
||||
m_Stream.Write( (int) (corpse == null ? Serial.Zero : corpse.Serial) );
|
||||
m_Stream.Write( (int) (corpse?.Serial ?? Serial.Zero) );
|
||||
m_Stream.Write( (int) 0 ) ;
|
||||
}
|
||||
}
|
||||
|
|
@ -591,7 +591,7 @@ namespace Server.Network
|
|||
{
|
||||
public ChangeCombatant( Mobile combatant ) : base( 0xAA, 5 )
|
||||
{
|
||||
m_Stream.Write( combatant != null ? combatant.Serial : Serial.Zero );
|
||||
m_Stream.Write( combatant?.Serial ?? Serial.Zero );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -904,7 +904,7 @@ namespace Server.Network
|
|||
|
||||
IEntity target = menu.Target as IEntity;
|
||||
|
||||
m_Stream.Write( (int) ( target == null ? Serial.MinusOne : target.Serial ) );
|
||||
m_Stream.Write( (int) (target?.Serial ?? Serial.MinusOne) );
|
||||
|
||||
m_Stream.Write( (byte) length );
|
||||
|
||||
|
|
@ -953,7 +953,7 @@ namespace Server.Network
|
|||
|
||||
IEntity target = menu.Target as IEntity;
|
||||
|
||||
m_Stream.Write( (int) ( target == null ? Serial.MinusOne : target.Serial ) );
|
||||
m_Stream.Write( (int) (target?.Serial ?? Serial.MinusOne) );
|
||||
|
||||
m_Stream.Write( (byte) length );
|
||||
|
||||
|
|
@ -2746,7 +2746,7 @@ namespace Server.Network
|
|||
EnsureCapacity( 6 );
|
||||
|
||||
m_Stream.Write( (short) 0x08 );
|
||||
m_Stream.Write( (byte) (m.Map == null ? 0 : m.Map.MapID) );
|
||||
m_Stream.Write( (byte) (m.Map?.MapID ?? 0) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2782,10 +2782,8 @@ namespace Server.Network
|
|||
|
||||
return p;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new SeasonChange( season, playSound );
|
||||
}
|
||||
|
||||
return new SeasonChange( season, playSound );
|
||||
}
|
||||
|
||||
public SeasonChange( int season ) : this( season, true )
|
||||
|
|
@ -3338,10 +3336,9 @@ namespace Server.Network
|
|||
{
|
||||
if (ns.NewMobileIncoming)
|
||||
return new MobileIncoming(beholder, beheld);
|
||||
else if (ns.StygianAbyss)
|
||||
if (ns.StygianAbyss)
|
||||
return new MobileIncomingSA(beholder, beheld);
|
||||
else
|
||||
return new MobileIncomingOld(beholder, beheld);
|
||||
return new MobileIncomingOld(beholder, beheld);
|
||||
}
|
||||
|
||||
private static ThreadLocal<int[]> m_DupedLayersTL = new ThreadLocal<int[]>(() => {return new int[256];});
|
||||
|
|
@ -3842,8 +3839,8 @@ namespace Server.Network
|
|||
|
||||
m_Stream.Write( (short) 0 );
|
||||
m_Stream.Write( (short) 0 );
|
||||
m_Stream.Write( (short) (map==null?6144:map.Width) );
|
||||
m_Stream.Write( (short) (map==null?4096:map.Height) );
|
||||
m_Stream.Write( (short) (map?.Width ?? 6144) );
|
||||
m_Stream.Write( (short) (map?.Height ?? 4096) );
|
||||
|
||||
m_Stream.Fill();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,15 +148,19 @@ namespace Server.Network {
|
|||
public Gram Enqueue( byte[] buffer, int offset, int length ) {
|
||||
if ( buffer == null ) {
|
||||
throw new ArgumentNullException( "buffer" );
|
||||
} else if ( !(offset >= 0 && offset < buffer.Length) ) {
|
||||
}
|
||||
|
||||
if ( !(offset >= 0 && offset < buffer.Length) ) {
|
||||
throw new ArgumentOutOfRangeException( "offset", offset, "Offset must be greater than or equal to zero and less than the size of the buffer." );
|
||||
} else if ( length < 0 || length > buffer.Length ) {
|
||||
}
|
||||
if ( length < 0 || length > buffer.Length ) {
|
||||
throw new ArgumentOutOfRangeException( "length", length, "Length cannot be less than zero or greater than the size of the buffer." );
|
||||
} else if ( ( buffer.Length - offset ) < length ) {
|
||||
}
|
||||
if ( ( buffer.Length - offset ) < length ) {
|
||||
throw new ArgumentException( "Offset and length do not point to a valid segment within the buffer." );
|
||||
}
|
||||
|
||||
int existingBytes = ( _pending.Count * m_CoalesceBufferSize ) + ( _buffered == null ? 0 : _buffered.Length );
|
||||
int existingBytes = ( _pending.Count * m_CoalesceBufferSize ) + (_buffered?.Length ?? 0);
|
||||
|
||||
if ( ( existingBytes + length ) > PendingCap ) {
|
||||
throw new CapacityExceededException();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue