Fixes implicit ternary expressions

This commit is contained in:
Kamron Batman 2018-09-14 14:56:48 -07:00
parent c85b0a740c
commit ff26dfa375
345 changed files with 1905 additions and 2336 deletions

View file

@ -90,8 +90,7 @@ namespace Server
{
if ( m_BodyID >= 0 && m_BodyID < m_Types.Length )
return m_Types[m_BodyID];
else
return BodyType.Empty;
return BodyType.Empty;
}
}

View file

@ -213,22 +213,21 @@ namespace Server
if ( m_Major > o.m_Major )
return 1;
else if ( m_Major < o.m_Major )
if ( m_Major < o.m_Major )
return -1;
else if ( m_Minor > o.m_Minor )
if ( m_Minor > o.m_Minor )
return 1;
else if ( m_Minor < o.m_Minor )
if ( m_Minor < o.m_Minor )
return -1;
else if ( m_Revision > o.m_Revision )
if ( m_Revision > o.m_Revision )
return 1;
else if ( m_Revision < o.m_Revision )
if ( m_Revision < o.m_Revision )
return -1;
else if ( m_Patch > o.m_Patch )
if ( m_Patch > o.m_Patch )
return 1;
else if ( m_Patch < o.m_Patch )
if ( m_Patch < o.m_Patch )
return -1;
else
return 0;
return 0;
}
public static bool IsNull( object x )
@ -240,9 +239,9 @@ namespace Server
{
if ( IsNull( x ) && IsNull( y ) )
return 0;
else if ( IsNull( x ) )
if ( IsNull( x ) )
return -1;
else if ( IsNull( y ) )
if ( IsNull( y ) )
return 1;
ClientVersion a = x as ClientVersion;
@ -258,9 +257,9 @@ namespace Server
{
if ( IsNull( a ) && IsNull( b ) )
return 0;
else if ( IsNull( a ) )
if ( IsNull( a ) )
return -1;
else if ( IsNull( b ) )
if ( IsNull( b ) )
return 1;
return a.CompareTo( b );

View file

@ -314,12 +314,10 @@ namespace Server.Gumps
{
return indexOf;
}
else
{
Invalidate();
m_Strings.Add( value );
return m_Strings.Count - 1;
}
Invalidate();
m_Strings.Add( value );
return m_Strings.Count - 1;
}
public void SendTo( NetState state )

View file

@ -69,8 +69,7 @@ namespace Server.Gumps
{
if ( m_Hue == 0 )
return $"{{ gumppic {m_X} {m_Y} {m_GumpID} }}";
else
return $"{{ gumppic {m_X} {m_Y} {m_GumpID} hue={m_Hue} }}";
return $"{{ gumppic {m_X} {m_Y} {m_GumpID} hue={m_Hue} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "gumppic" );

View file

@ -147,9 +147,8 @@ namespace Server.Gumps
if ( m_LocalizedTooltip > 0 )
return
$"{{ buttontileart {m_X} {m_Y} {m_ID1} {m_ID2} {(int) m_Type} {m_Param} {m_ButtonID} {m_ItemID} {m_Hue} {m_Width} {m_Height} }}{{ tooltip {m_LocalizedTooltip} }}";
else
return
$"{{ buttontileart {m_X} {m_Y} {m_ID1} {m_ID2} {(int) m_Type} {m_Param} {m_ButtonID} {m_ItemID} {m_Hue} {m_Width} {m_Height} }}";
return
$"{{ buttontileart {m_X} {m_Y} {m_ID1} {m_ID2} {(int) m_Type} {m_Param} {m_ButtonID} {m_ItemID} {m_Hue} {m_Width} {m_Height} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "buttontileart" );

View file

@ -69,8 +69,7 @@ namespace Server.Gumps
{
if ( m_Hue == 0 )
return $"{{ tilepic {m_X} {m_Y} {m_ItemID} }}";
else
return $"{{ tilepichue {m_X} {m_Y} {m_ItemID} {m_Hue} }}";
return $"{{ tilepichue {m_X} {m_Y} {m_ItemID} {m_Hue} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "tilepic" );

View file

@ -37,7 +37,7 @@ namespace Server
{
if ( a == null && b == null )
return true;
else if ( a == null || b == null || a.Length != b.Length )
if ( a == null || b == null || a.Length != b.Length )
return false;
return ( m_Comparer.Compare( a, b ) == 0 );

View file

@ -2694,10 +2694,9 @@ namespace Server
protected virtual Packet GetWorldPacketFor( NetState state ) {
if ( state.HighSeas )
return WorldPacketHS;
else if ( state.StygianAbyss )
if ( state.StygianAbyss )
return WorldPacketSA;
else
return WorldPacket;
return WorldPacket;
}
public virtual bool IsVirtualItem => false;
@ -2871,10 +2870,8 @@ namespace Server
{
break;
}
else
{
p = item.m_Parent;
}
p = item.m_Parent;
}
return p;
@ -4079,8 +4076,7 @@ namespace Server
if ( root == null )
return m_Location;
else
return root.Location;
return root.Location;
//return root == null ? m_Location : new Point3D( (IPoint3D) root );
}

View file

@ -74,8 +74,7 @@ namespace Server.Items
if ( id < 0x4000 )
return 1020000 + id;
else
return 1078872 + id;
return 1078872 + id;
}
return base.LabelNumber;
@ -129,16 +128,14 @@ namespace Server.Items
{
if ( m.Map == Map )
return Contains( m.X, m.Y );
else
return false;
return false;
}
public bool Contains( Item item )
{
if ( item.Map == Map )
return Contains( item.X, item.Y );
else
return false;
return false;
}
public override void Serialize( GenericWriter writer )

View file

@ -151,7 +151,7 @@ namespace Server.Items
public override void OnSnoop( Mobile from )
{
m_SnoopHandler?.Invoke( this, @from );
m_SnoopHandler?.Invoke( this, from );
}
public override bool CheckLift( Mobile from, Item item, ref LRReason reject )
@ -373,7 +373,7 @@ namespace Server.Items
{
if ( types.Length != amounts.Length )
throw new ArgumentException();
else if ( grouper == null )
if ( grouper == null )
throw new ArgumentNullException();
Item[][][] items = new Item[types.Length][][];
@ -472,7 +472,7 @@ namespace Server.Items
{
if ( types.Length != amounts.Length )
throw new ArgumentException();
else if ( grouper == null )
if ( grouper == null )
throw new ArgumentNullException();
Item[][][] items = new Item[types.Length][][];
@ -1082,7 +1082,8 @@ namespace Server.Items
{
return item;
}
else if ( recurse && item is Container )
if ( recurse && item is Container )
{
Item check = RecurseFindItemByType( item, type, recurse );
@ -1119,7 +1120,8 @@ namespace Server.Items
{
return item;
}
else if ( recurse && item is Container )
if ( recurse && item is Container )
{
Item check = RecurseFindItemByType( item, types, recurse );
@ -1464,10 +1466,8 @@ namespace Server.Items
return true;
}
else
{
return false;
}
return false;
}
public virtual bool TryDropItem( Mobile from, Item dropped, bool sendFullMessage )
@ -1873,8 +1873,7 @@ namespace Server.Items
if ( data != null )
return data;
else
return m_Default;
return m_Default;
}
private int m_GumpID;

View file

@ -125,26 +125,23 @@ namespace Server.Items
public override bool IsAccessibleTo(Mobile check)
{
if ( ( check == m_Owner && m_Open ) || check.AccessLevel >= AccessLevel.GameMaster )
if ( ( check == m_Owner && m_Open ) || check.AccessLevel >= AccessLevel.GameMaster )
return base.IsAccessibleTo (check);
else
return false;
return false;
}
public override bool OnDragDrop( Mobile from, Item dropped )
{
if ( ( from == m_Owner && m_Open ) || from.AccessLevel >= AccessLevel.GameMaster )
if ( ( from == m_Owner && m_Open ) || from.AccessLevel >= AccessLevel.GameMaster )
return base.OnDragDrop( from, dropped );
else
return false;
return false;
}
public override bool OnDragDropInto(Mobile from, Item item, Point3D p)
{
if ( ( from == m_Owner && m_Open ) || from.AccessLevel >= AccessLevel.GameMaster )
if ( ( from == m_Owner && m_Open ) || from.AccessLevel >= AccessLevel.GameMaster )
return base.OnDragDropInto (from, item, p);
else
return false;
return false;
}
public override int GetTotal(TotalType type)

View file

@ -599,24 +599,21 @@ namespace Server
{
if ( m_HitsRegenRate == null )
return m_DefaultHitsRate;
else
return m_HitsRegenRate( m );
return m_HitsRegenRate( m );
}
public static TimeSpan GetStamRegenRate( Mobile m )
{
if ( m_StamRegenRate == null )
return m_DefaultStamRate;
else
return m_StamRegenRate( m );
return m_StamRegenRate( m );
}
public static TimeSpan GetManaRegenRate( Mobile m )
{
if ( m_ManaRegenRate == null )
return m_DefaultManaRate;
else
return m_ManaRegenRate( m );
return m_ManaRegenRate( m );
}
#endregion
@ -1396,7 +1393,9 @@ namespace Server
_actions.Add( toLock );
return true;
} else if ( !_actions.Contains( toLock ) ) {
}
if ( !_actions.Contains( toLock ) ) {
_actions.Add( toLock );
return true;
@ -3180,7 +3179,7 @@ namespace Server
{
if ( !shoved.Alive || !Alive || shoved.IsDeadBondedPet || IsDeadBondedPet )
return true;
else if ( shoved.m_Hidden && shoved.m_AccessLevel > AccessLevel.Player )
if ( shoved.m_Hidden && shoved.m_AccessLevel > AccessLevel.Player )
return true;
if ( !m_Pushing )
@ -3810,14 +3809,12 @@ namespace Server
{
return m_BaseSoundID + 4;
}
else if ( m_Body.IsHuman )
if ( m_Body.IsHuman )
{
return Utility.Random( m_Female ? 0x314 : 0x423, m_Female ? 4 : 5 );
}
else
{
return -1;
}
return -1;
}
#endregion
@ -6313,7 +6310,8 @@ namespace Server
return null;
}
public bool CloseGump( Type type ) {
public bool CloseGump( Type type )
{
if ( m_NetState != null ) {
Gump gump = FindGump( type );
@ -6326,9 +6324,9 @@ namespace Server
}
return true;
} else {
return false;
}
return false;
}
[Obsolete( "Use CloseGump( Type ) instead." )]
@ -6356,9 +6354,9 @@ namespace Server
}
return true;
} else {
return false;
}
return false;
}
[Obsolete( "Use CloseAllGumps() instead.", false )]
@ -6383,11 +6381,12 @@ namespace Server
if ( m_NetState != null ) {
g.SendTo( m_NetState );
return true;
} else if ( throwOnOffline ) {
throw new MobileNotConnectedException( this, "Gump could not be sent." );
} else {
return false;
}
if ( throwOnOffline ) {
throw new MobileNotConnectedException( this, "Gump could not be sent." );
}
return false;
}
public bool SendMenu( IMenu m ) {
@ -6398,11 +6397,12 @@ namespace Server
if ( m_NetState != null ) {
m.SendTo( m_NetState );
return true;
} else if ( throwOnOffline ) {
throw new MobileNotConnectedException( this, "Menu could not be sent." );
} else {
return false;
}
if ( throwOnOffline ) {
throw new MobileNotConnectedException( this, "Menu could not be sent." );
}
return false;
}
#endregion
@ -8296,8 +8296,7 @@ namespace Server
return Map.Internal.DefaultRegion;
else
return Map.DefaultRegion;
else
return m_Region;
return m_Region;
}
}
@ -9924,10 +9923,8 @@ namespace Server
return false;
}
else
{
return true;
}
return true;
}
#region Overhead messages
@ -10530,16 +10527,14 @@ namespace Server
{
if ( m_SkillCheckLocationHandler == null )
return false;
else
return m_SkillCheckLocationHandler( this, skill, minSkill, maxSkill );
return m_SkillCheckLocationHandler( this, skill, minSkill, maxSkill );
}
public bool CheckSkill( SkillName skill, double chance )
{
if ( m_SkillCheckDirectLocationHandler == null )
return false;
else
return m_SkillCheckDirectLocationHandler( this, skill, chance );
return m_SkillCheckDirectLocationHandler( this, skill, chance );
}
public bool CheckTargetSkill( SkillName skill, object target, double minSkill, double maxSkill )

View file

@ -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();
}

View file

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

View file

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

View file

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

View file

@ -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();
}

View file

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

View file

@ -67,7 +67,7 @@ namespace Server
public static int Compute( Mobile source, Mobile target )
{
return m_Handler == null ? CanBeAttacked : m_Handler( source, target );
return m_Handler?.Invoke( source, target ) ?? CanBeAttacked;
}
}
}

View file

@ -87,9 +87,12 @@ namespace Server {
public FileQueue( int concurrentWrites, FileCommitCallback callback ) {
if ( concurrentWrites < 1 ) {
throw new ArgumentOutOfRangeException( "concurrentWrites" );
} else if ( bufferSize < 1 ) {
}
if ( bufferSize < 1 ) {
throw new ArgumentOutOfRangeException( "bufferSize" );
} else if ( callback == null ) {
}
if ( callback == null ) {
throw new ArgumentNullException( "callback" );
}
@ -194,11 +197,15 @@ namespace Server {
public void Enqueue( byte[] buffer, int offset, int size ) {
if ( buffer == null ) {
throw new ArgumentNullException( "buffer" );
} else if ( offset < 0 ) {
}
if ( offset < 0 ) {
throw new ArgumentOutOfRangeException( "offset" );
} else if ( size < 0 ) {
}
if ( size < 0 ) {
throw new ArgumentOutOfRangeException( "size" );
} else if ( ( buffer.Length - offset ) < size ) {
}
if ( ( buffer.Length - offset ) < size ) {
throw new ArgumentException();
}

View file

@ -32,15 +32,11 @@ namespace Server
{
return new DualSaveStrategy(); // return new DynamicSaveStrategy(); (4.0 or return new ParallelSaveStrategy(processorCount); (2.0)
}
else
{
return new DualSaveStrategy();
}
}
else
{
return new StandardSaveStrategy();
return new DualSaveStrategy();
}
return new StandardSaveStrategy();
}
public abstract string Name { get; }

View file

@ -47,10 +47,10 @@ namespace Server
for ( int i = 0; i < m_Poisons.Count; i++ )
{
if ( reg.Level == m_Poisons[i].Level )
if ( reg.Level == m_Poisons[i].Level )
throw new Exception( "A poison with that level already exists." );
else if ( regName == m_Poisons[i].Name.ToLower() )
throw new Exception( "A poison with that name already exists." );
if ( regName == m_Poisons[i].Name.ToLower() )
throw new Exception( "A poison with that name already exists." );
}
m_Poisons.Add( reg );

View file

@ -194,7 +194,7 @@ namespace Server
}
public bool IsDefault => m_Map.DefaultRegion == this;
public virtual MusicName DefaultMusic => m_Parent != null ? m_Parent.Music : MusicName.Invalid;
public virtual MusicName DefaultMusic => m_Parent?.Music ?? MusicName.Invalid;
public Region( string name, Map map, int priority, params Rectangle2D[] area ) : this( name, map, priority, ConvertTo3D( area ) )
{
@ -526,8 +526,7 @@ namespace Server
{
if ( m_Name != null )
return m_Name;
else
return GetType().Name;
return GetType().Name;
}
@ -790,10 +789,9 @@ namespace Server
{
if ( m_Parent != null )
return m_Parent.GetLogoutDelay( m );
else if ( m.AccessLevel > AccessLevel.Player )
if ( m.AccessLevel > AccessLevel.Player )
return m_StaffLogoutDelay;
else
return m_DefaultLogoutDelay;
return m_DefaultLogoutDelay;
}
@ -833,8 +831,8 @@ namespace Server
while ( oldR != newR )
{
int oldRChild = ( oldR != null ? oldR.ChildLevel : -1 );
int newRChild = ( newR != null ? newR.ChildLevel : -1 );
int oldRChild = oldR?.ChildLevel ?? -1;
int newRChild = newR?.ChildLevel ?? -1;
if ( oldRChild >= newRChild )
{
@ -992,17 +990,15 @@ namespace Server
return null;
}
else if ( xml.HasAttribute( attribute ) )
if ( xml.HasAttribute( attribute ) )
{
return xml.GetAttribute( attribute );
}
else
{
if ( mandatory )
Console.WriteLine( "Missing attribute '{0}' in element '{1}'", attribute, xml.Name );
if ( mandatory )
Console.WriteLine( "Missing attribute '{0}' in element '{1}'", attribute, xml.Name );
return null;
}
return null;
}
public static bool ReadString( XmlElement xml, string attribute, ref string value )
@ -1142,11 +1138,9 @@ namespace Server
value = tempVal;
return true;
}
else
{
Console.WriteLine( "Could not parse {0} enum attribute '{1}' in element '{2}'", type, attribute, xml.Name );
return false;
}
Console.WriteLine( "Could not parse {0} enum attribute '{1}' in element '{2}'", type, attribute, xml.Name );
return false;
}
public static bool ReadMap( XmlElement xml, string attribute, ref Map value )

View file

@ -92,7 +92,7 @@ namespace Server
AppendCompilerOption(ref sb, "/d:NEWPARENT");
#endif
return (sb == null ? null : sb.ToString());
return sb?.ToString();
}
private static void AppendCompilerOption( ref StringBuilder sb, string define )

View file

@ -97,7 +97,7 @@ namespace Server {
private void Replace<T>( ref List<T> list, T oldValue, T newValue ) {
if ( oldValue != null && newValue != null ) {
int index = ( list != null ? list.IndexOf( oldValue ) : -1 );
int index = list?.IndexOf( oldValue ) ?? -1;
if ( index >= 0 ) {
list[index] = newValue;

View file

@ -969,8 +969,7 @@ namespace Server
{
if ( ReadByte() != 0 )
return m_File.ReadString();
else
return null;
return null;
}
public override DateTime ReadDeltaTime()
@ -980,11 +979,15 @@ namespace Server
if ( ticks > 0 && (ticks+now) < 0 )
return DateTime.MaxValue;
else if ( ticks < 0 && (ticks+now) < 0 )
if ( ticks < 0 && (ticks+now) < 0 )
return DateTime.MinValue;
try { return new DateTime( now+ticks ); }
catch { if ( ticks > 0 ) return DateTime.MaxValue; else return DateTime.MinValue; }
catch
{
if ( ticks > 0 ) return DateTime.MaxValue;
return DateTime.MinValue;
}
}
public override IPAddress ReadIPAddress()
@ -1121,8 +1124,7 @@ namespace Server
IEntity entity = World.FindEntity( serial );
if ( entity == null )
return new Entity( serial, new Point3D( 0, 0, 0 ), Map.Internal );
else
return entity;
return entity;
}
public override Item ReadItem()
@ -1171,9 +1173,9 @@ namespace Server
}
return list;
} else {
return new ArrayList();
}
return new ArrayList();
}
public override ArrayList ReadMobileList()
@ -1192,9 +1194,9 @@ namespace Server
}
return list;
} else {
return new ArrayList();
}
return new ArrayList();
}
public override ArrayList ReadGuildList()
@ -1213,9 +1215,9 @@ namespace Server
}
return list;
} else {
return new ArrayList();
}
return new ArrayList();
}
public override List<Item> ReadStrongItemList()

View file

@ -847,9 +847,9 @@ namespace Server
{
if ( !from.CheckAlive() )
return false;
else if ( !from.Region.OnSkillUse( from, skillID ) )
if ( !from.Region.OnSkillUse( from, skillID ) )
return false;
else if ( !from.AllowSkillUse( (SkillName)skillID ) )
if ( !from.AllowSkillUse( (SkillName)skillID ) )
return false;
if ( skillID >= 0 && skillID < SkillInfo.Table.Length )
@ -866,10 +866,8 @@ namespace Server
return true;
}
else
{
from.SendSkillMessage();
}
from.SendSkillMessage();
}
else
{

View file

@ -55,8 +55,7 @@ namespace Server.Targeting
{
if ( ns.HighSeas )
return new MultiTargetReqHS( this );
else
return new MultiTargetReq( this );
return new MultiTargetReq( this );
}
}
}

View file

@ -153,8 +153,7 @@ namespace Server
{
if ( (m_Flags & TileFlag.Bridge) != 0 )
return m_Height / 2;
else
return m_Height;
return m_Height;
}
}
}

View file

@ -304,10 +304,8 @@ namespace Server
return m_TilesList.ToArray();
}
else
{
return tiles[x & 0x7][y & 0x7];
}
return tiles[x & 0x7][y & 0x7];
}
[MethodImpl(MethodImplOptions.Synchronized)]
@ -399,59 +397,57 @@ namespace Server
{
return m_EmptyStaticBlock;
}
else
int count = length / 7;
m_Statics.Seek( lookup, SeekOrigin.Begin );
if ( m_TileBuffer.Length < count )
m_TileBuffer = new StaticTile[count];
StaticTile[] staTiles = m_TileBuffer;//new StaticTile[tileCount];
fixed ( StaticTile *pTiles = staTiles )
{
int count = length / 7;
m_Statics.Seek( lookup, SeekOrigin.Begin );
if ( m_TileBuffer.Length < count )
m_TileBuffer = new StaticTile[count];
StaticTile[] staTiles = m_TileBuffer;//new StaticTile[tileCount];
fixed ( StaticTile *pTiles = staTiles )
{
#if !MONO
NativeReader.Read( m_Statics.SafeFileHandle.DangerousGetHandle(), pTiles, length );
NativeReader.Read( m_Statics.SafeFileHandle.DangerousGetHandle(), pTiles, length );
#else
NativeReader.Read( m_Statics.Handle, pTiles, length );
#endif
if ( m_Lists == null )
{
m_Lists = new TileList[8][];
for ( int i = 0; i < 8; ++i )
{
m_Lists[i] = new TileList[8];
for ( int j = 0; j < 8; ++j )
m_Lists[i][j] = new TileList();
}
}
TileList[][] lists = m_Lists;
StaticTile *pCur = pTiles, pEnd = pTiles + count;
while ( pCur < pEnd )
{
lists[pCur->m_X & 0x7][pCur->m_Y & 0x7].Add( pCur->m_ID, pCur->m_Z );
pCur = pCur + 1;
}
StaticTile[][][] tiles = new StaticTile[8][][];
if ( m_Lists == null )
{
m_Lists = new TileList[8][];
for ( int i = 0; i < 8; ++i )
{
tiles[i] = new StaticTile[8][];
m_Lists[i] = new TileList[8];
for ( int j = 0; j < 8; ++j )
tiles[i][j] = lists[i][j].ToArray();
m_Lists[i][j] = new TileList();
}
return tiles;
}
TileList[][] lists = m_Lists;
StaticTile *pCur = pTiles, pEnd = pTiles + count;
while ( pCur < pEnd )
{
lists[pCur->m_X & 0x7][pCur->m_Y & 0x7].Add( pCur->m_ID, pCur->m_Z );
pCur = pCur + 1;
}
StaticTile[][][] tiles = new StaticTile[8][][];
for ( int i = 0; i < 8; ++i )
{
tiles[i] = new StaticTile[8][];
for ( int j = 0; j < 8; ++j )
tiles[i][j] = lists[i][j].ToArray();
}
return tiles;
}
}
catch ( EndOfStreamException )

View file

@ -68,7 +68,7 @@ namespace Server
{
if ( str == null )
return null;
else if ( str.Length == 0 )
if ( str.Length == 0 )
return string.Empty;
return string.Intern( str );
@ -683,30 +683,24 @@ namespace Server
{
if ( dx > 0 )
return Direction.East;
else
return Direction.West;
return Direction.West;
}
else if ( ady >= adx * 3 )
if ( ady >= adx * 3 )
{
if ( dy > 0 )
return Direction.South;
else
return Direction.North;
return Direction.North;
}
else if ( dx > 0 )
if ( dx > 0 )
{
if ( dy > 0 )
return Direction.Down;
else
return Direction.Right;
}
else
{
if ( dy > 0 )
return Direction.Left;
else
return Direction.Up;
return Direction.Right;
}
if ( dy > 0 )
return Direction.Left;
return Direction.Up;
}
/* Should probably be rewritten to use an ITile interface
@ -776,10 +770,8 @@ namespace Server
return array.GetValue( index );
}
else
{
return emptyValue;
}
return emptyValue;
}
#region Random
@ -825,11 +817,12 @@ namespace Server
{
if ( count == 0 ) {
return from;
} else if ( count > 0 ) {
return from + RandomImpl.Next(count);
} else {
return from - RandomImpl.Next(-count);
}
if ( count > 0 ) {
return from + RandomImpl.Next(count);
}
return from - RandomImpl.Next(-count);
}
public static int Random( int count )
@ -968,10 +961,9 @@ namespace Server
{
if ( hue < 2 )
return 2;
else if ( hue > 1001 )
if ( hue > 1001 )
return 1001;
else
return hue;
return hue;
}
/// <summary>
@ -998,10 +990,9 @@ namespace Server
{
if ( hue < 1002 )
return 1002;
else if ( hue > 1058 )
if ( hue > 1058 )
return 1058;
else
return hue;
return hue;
}
//[Obsolete( "Depreciated, use the methods for the Mobile's race", false )]
@ -1015,10 +1006,9 @@ namespace Server
{
if ( hue < 1102 )
return 1102;
else if ( hue > 1149 )
if ( hue > 1149 )
return 1149;
else
return hue;
return hue;
}
//[Obsolete( "Depreciated, use the methods for the Mobile's race", false )]

View file

@ -31,8 +31,7 @@ namespace Server
{
if ( m_Values == null )
return 0;
else
return m_Values[index];
return m_Values[index];
}
public void SetValue( int index, int value )

View file

@ -127,7 +127,7 @@ namespace Server {
public BaseGuild Guild => m_Guild;
public Serial Serial => m_Guild == null ? 0 : m_Guild.Id;
public Serial Serial => m_Guild?.Id ?? 0;
public int TypeID => 0;
@ -151,7 +151,7 @@ namespace Server {
public Item Item => m_Item;
public Serial Serial => m_Item == null ? Serial.MinusOne : m_Item.Serial;
public Serial Serial => m_Item?.Serial ?? Serial.MinusOne;
public int TypeID => m_TypeID;
@ -179,7 +179,7 @@ namespace Server {
public Mobile Mobile => m_Mobile;
public Serial Serial => m_Mobile == null ? Serial.MinusOne : m_Mobile.Serial;
public Serial Serial => m_Mobile?.Serial ?? Serial.MinusOne;
public int TypeID => m_TypeID;
@ -728,7 +728,7 @@ namespace Server {
public static IEntity FindEntity( Serial serial ) {
if ( serial.IsItem )
return FindItem( serial );
else if ( serial.IsMobile )
if ( serial.IsMobile )
return FindMobile( serial );
return null;