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

@ -37,7 +37,7 @@ namespace Server.Items
if ( v < 16 )
return 16;
else if ( v > 24 )
if ( v > 24 )
return 24;
return v;

View file

@ -70,10 +70,9 @@ namespace Server.Items
if ( minutes != 0 && seconds != 0 )
return $"{minutes} minute{(minutes == 1 ? "" : "s")} and {seconds} second{(seconds == 1 ? "" : "s")}";
else if ( minutes != 0 )
if ( minutes != 0 )
return $"{minutes} minute{(minutes == 1 ? "" : "s")}";
else
return $"{seconds} second{(seconds == 1 ? "" : "s")}";
return $"{seconds} second{(seconds == 1 ? "" : "s")}";
}
public virtual void Cleanup()

View file

@ -33,7 +33,8 @@ namespace Server.Items
from.SendMessage( "You must have at least 60.0 skill in tinkering to construct a golem." );
return;
}
else if ( (from.Followers + 4) > from.FollowersMax )
if ( (from.Followers + 4) > from.FollowersMax )
{
from.SendLocalizedMessage( 1049607 ); // You have too many followers to control that creature.
return;
@ -126,4 +127,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}

View file

@ -358,7 +358,7 @@ namespace Server.Items
if ( !Active )
return;
string text = $"{@from.Name} says {message}";
string text = $"{from.Name} says {message}";
if ( RootParent is Mobile mobile )
{

View file

@ -601,7 +601,7 @@ namespace Server.Items
writer.WriteDeltaTime( m_TimeOfDeath );
List<KeyValuePair<Item, Point3D>> list = ( m_RestoreTable == null ? null : new List<KeyValuePair<Item, Point3D>>( m_RestoreTable ) );
int count = ( list == null ? 0 : list.Count );
int count = list?.Count ?? 0;
writer.Write( count );
@ -971,7 +971,8 @@ namespace Server.Items
return false;
}
else if ( IsCriminalAction( from ) )
if ( IsCriminalAction( from ) )
{
if ( m_Owner == null || !m_Owner.Player )
from.SendLocalizedMessage( 1005036 ); // Looting this monster corpse will be a criminal act!

View file

@ -163,7 +163,7 @@ namespace Server.Items
if ( Map.CanSpawnMobile( new Point2D( x, y ), Z ) )
return new Point3D( x, y, Z );
else if ( Map.CanSpawnMobile( new Point2D( x, y ), z ) )
if ( Map.CanSpawnMobile( new Point2D( x, y ), z ) )
return new Point3D( x, y, z );
}

View file

@ -33,10 +33,9 @@ namespace Server.Items
{
if ( Amount <= 1 )
return 0x2E4;
else if ( Amount <= 5 )
if ( Amount <= 5 )
return 0x2E5;
else
return 0x2E6;
return 0x2E6;
}
protected override void OnAmountChange( int oldValue )

View file

@ -147,7 +147,8 @@ namespace Server.Items
Stop();
return;
}
else if ( !m_TargetMap.CanFit( m_Location, 16 ) )
if ( !m_TargetMap.CanFit( m_Location, 16 ) )
{
m_Stone.Movable = true;
m_Caster.AddToBackpack( m_Stone );

View file

@ -224,17 +224,18 @@ namespace Server.Items
from.SendLocalizedMessage( 1062396 ); // This bulletin board must be locked down in a house to be usable.
return;
}
else if ( !from.InRange( board.GetWorldLocation(), 2 ) || !from.InLOS( board ) )
if ( !from.InRange( board.GetWorldLocation(), 2 ) || !from.InLOS( board ) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
return;
}
else if ( !CheckAccess( house, from ) )
if ( !CheckAccess( house, from ) )
{
from.SendLocalizedMessage( 1062398 ); // You are not allowed to post to this bulletin board.
return;
}
else if ( m_Greeting && !house.IsOwner( from ) )
if ( m_Greeting && !house.IsOwner( from ) )
{
return;
}
@ -299,12 +300,13 @@ namespace Server.Items
from.SendLocalizedMessage( 1062396 ); // This bulletin board must be locked down in a house to be usable.
return;
}
else if ( !from.InRange( board.GetWorldLocation(), 2 ) || !from.InLOS( board ) )
if ( !from.InRange( board.GetWorldLocation(), 2 ) || !from.InLOS( board ) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
return;
}
else if ( !CheckAccess( house, from ) )
if ( !CheckAccess( house, from ) )
{
from.SendLocalizedMessage( 1062398 ); // You are not allowed to post to this bulletin board.
return;
@ -405,12 +407,13 @@ namespace Server.Items
from.SendLocalizedMessage( 1062396 ); // This bulletin board must be locked down in a house to be usable.
return;
}
else if ( !from.InRange( board.GetWorldLocation(), 2 ) || !from.InLOS( board ) )
if ( !from.InRange( board.GetWorldLocation(), 2 ) || !from.InLOS( board ) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
return;
}
else if ( !BasePlayerBB.CheckAccess( house, from ) )
if ( !BasePlayerBB.CheckAccess( house, from ) )
{
from.SendLocalizedMessage( 1062398 ); // You are not allowed to post to this bulletin board.
return;
@ -604,7 +607,7 @@ namespace Server.Items
AddHtml( 255, 180, 150, 20, message.Time.ToString( "yyyy-MM-dd HH:mm:ss" ), false, false );
Mobile poster = message.Poster;
string name = ( poster == null ? null : poster.Name );
string name = poster?.Name;
if ( name == null || (name = name.Trim()).Length == 0 )
name = "Someone";

View file

@ -61,26 +61,24 @@ namespace Server.Items
m.SendLocalizedMessage( 1005561, "", 0x22 ); // Thou'rt a criminal and cannot escape so easily.
return false;
}
else if ( SpellHelper.CheckCombat( m ) )
if ( SpellHelper.CheckCombat( m ) )
{
m.SendLocalizedMessage( 1005564, "", 0x22 ); // Wouldst thou flee during the heat of battle??
return false;
}
else if ( m.Spell != null )
if ( m.Spell != null )
{
m.SendLocalizedMessage( 1049616 ); // You are too busy to do that at the moment.
return false;
}
else
{
m.CloseGump( typeof( MoongateGump ) );
m.SendGump( new MoongateGump( m, this ) );
m.CloseGump( typeof( MoongateGump ) );
m.SendGump( new MoongateGump( m, this ) );
if ( !m.Hidden || m.AccessLevel == AccessLevel.Player )
Effects.PlaySound( m.Location, m.Map, 0x20E );
if ( !m.Hidden || m.AccessLevel == AccessLevel.Player )
Effects.PlaySound( m.Location, m.Map, 0x20E );
return true;
}
return true;
}
public override void Serialize( GenericWriter writer )
@ -366,7 +364,7 @@ namespace Server.Items
{
if ( info.ButtonID == 0 ) // Cancel
return;
else if ( m_Mobile.Deleted || m_Moongate.Deleted || m_Mobile.Map == null )
if ( m_Mobile.Deleted || m_Moongate.Deleted || m_Mobile.Map == null )
return;
int[] switches = info.Switches;

View file

@ -160,12 +160,13 @@ namespace Server.Items
{
return false;
}
else if (m_CriminalCheck && m.Criminal)
if (m_CriminalCheck && m.Criminal)
{
m.SendLocalizedMessage(1005561, "", 0x22); // Thou'rt a criminal and cannot escape so easily.
return false;
}
else if (m_CombatCheck && SpellHelper.CheckCombat(m))
if (m_CombatCheck && SpellHelper.CheckCombat(m))
{
m.SendLocalizedMessage(1005564, "", 0x22); // Wouldst thou flee during the heat of battle??
return false;
@ -617,7 +618,8 @@ namespace Server.Items
int h = (int)Math.Round(ts.TotalHours);
return $"{h} hour{((h == 1) ? "" : "s")}";
}
else if (ts.TotalMinutes >= 1)
if (ts.TotalMinutes >= 1)
{
int m = (int)Math.Round(ts.TotalMinutes);
return $"{m} minute{((m == 1) ? "" : "s")}";
@ -653,10 +655,8 @@ namespace Server.Items
return;
}
else
{
info.Timer.Stop();
}
info.Timer.Stop();
}
if (m_StartMessage != null)