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

@ -152,10 +152,8 @@ namespace Server.Gumps
{
if ( m.Kills >= 5 )
return 0x21;
else if ( m.Criminal )
return 0x3B1;
return 0x58;
return m.Criminal ? 0x3B1 : 0x58;
}
}
}
@ -318,14 +316,7 @@ namespace Server.Gumps
for ( int i = 0; i < pools.Count; ++i )
{
BufferPool pool = pools[i];
string name;
int freeCount;
int initialCapacity;
int currentCapacity;
int bufferSize;
int misses;
pool.GetInfo( out name, out freeCount, out initialCapacity, out currentCapacity, out bufferSize, out misses );
pool.GetInfo( out string name, out int freeCount, out int initialCapacity, out int currentCapacity, out int bufferSize, out int misses );
if ( sb.Length > 0 )
sb.Append( "<br><br>" );
@ -549,10 +540,8 @@ namespace Server.Gumps
if ( m == null )
{
if ( RemoteAdmin.AdminNetwork.IsAuth( ns ) )
AddLabelCropped( 12, offset, 81, 20, LabelHue, "(remote admin)" );
else
AddLabelCropped( 12, offset, 81, 20, LabelHue, "(logging in)" );
AddLabelCropped(12, offset, 81, 20, LabelHue,
RemoteAdmin.AdminNetwork.IsAuth(ns) ? "(remote admin)" : "(logging in)");
}
else
{
@ -1978,7 +1967,7 @@ namespace Server.Gumps
}
else
{
from.SendGump( new AdminGump( from, AdminGumpPage.Clients, 0, results, notice == null ? (results.Count == 0 ? "Nothing matched your search terms." : null) : notice, null ) );
from.SendGump( new AdminGump( from, AdminGumpPage.Clients, 0, results, notice ?? (results.Count == 0 ? "Nothing matched your search terms." : null), null ) );
}
break;
@ -2052,7 +2041,7 @@ namespace Server.Gumps
}
}
from.SendGump( new AdminGump( from, dispAccount != null ? AdminGumpPage.AccountDetails_Information : m_PageType, m_ListPage, m_List, notice, dispAccount != null ? dispAccount : m_State ) );
from.SendGump( new AdminGump( from, dispAccount != null ? AdminGumpPage.AccountDetails_Information : m_PageType, m_ListPage, m_List, notice, dispAccount ?? m_State ) );
break;
}
case 7:
@ -2084,7 +2073,7 @@ namespace Server.Gumps
if ( results.Count == 1 )
from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Information, 0, null, "One match found.", results[0] ) );
else
from.SendGump( new AdminGump( from, AdminGumpPage.Accounts, 0, results, notice == null ? (results.Count == 0 ? "Nothing matched your search terms." : null) : notice, new ArrayList() ) );
from.SendGump( new AdminGump( from, AdminGumpPage.Accounts, 0, results, notice ?? (results.Count == 0 ? "Nothing matched your search terms." : null), new ArrayList() ) );
break;
}
@ -2507,14 +2496,14 @@ namespace Server.Gumps
from.SendGump( new AdminGump( from, AdminGumpPage.Firewall, 0, results,
$"Search results for : {match}", m_State ) );
else
from.SendGump( new AdminGump( from, m_PageType, m_ListPage, m_List, notice == null ? "Nothing matched your search terms." : notice, m_State ) );
from.SendGump( new AdminGump( from, m_PageType, m_ListPage, m_List, notice ?? "Nothing matched your search terms.", m_State ) );
break;
}
case 1:
{
TextRelay relay = info.GetTextEntry( 0 );
string text = ( relay == null ? null : relay.Text.Trim() );
string text = relay?.Text.Trim();
if ( text == null || text.Length == 0 )
{

View file

@ -32,12 +32,13 @@ namespace Server.Gumps
from.SendMessage( "That character is no longer online." );
return;
}
else if ( focus.Deleted )
if ( focus.Deleted )
{
from.SendMessage( "That character no longer exists." );
return;
}
else if ( from != focus && focus.Hidden && from.AccessLevel < focus.AccessLevel && ( !( focus is PlayerMobile ) || !((PlayerMobile)focus).VisibilityList.Contains( from ) ) )
if ( from != focus && focus.Hidden && from.AccessLevel < focus.AccessLevel && ( !( focus is PlayerMobile ) || !((PlayerMobile)focus).VisibilityList.Contains( from ) ) )
{
from.SendMessage( "That character is no longer visible." );
return;
@ -294,4 +295,4 @@ namespace Server.Gumps
}
}
}
}
}

View file

@ -57,7 +57,8 @@ namespace Server.Gumps
m_Mobile.SendLocalizedMessage( 1080455 ); // You can not resize your house at this time. Please remove all items fom the moving crate and try again.
return;
}
else if ( !Guilds.Guild.NewGuildSystem && m_House.FindGuildstone() != null )
if ( !Guilds.Guild.NewGuildSystem && m_House.FindGuildstone() != null )
{
m_Mobile.SendLocalizedMessage( 501389 ); // You cannot redeed a house with a guildstone inside.
return;
@ -67,17 +68,17 @@ namespace Server.Gumps
m_Mobile.SendLocalizedMessage( 503236 ); // You need to collect your vendor's belongings before moving.
return;
}*/
else if ( m_House.HasRentedVendors && m_House.VendorInventories.Count > 0 )
if ( m_House.HasRentedVendors && m_House.VendorInventories.Count > 0 )
{
m_Mobile.SendLocalizedMessage( 1062679 ); // You cannot do that that while you still have contract vendors or unclaimed contract vendor inventory in your house.
return;
}
else if ( m_House.HasRentedVendors )
if ( m_House.HasRentedVendors )
{
m_Mobile.SendLocalizedMessage( 1062680 ); // You cannot do that that while you still have contract vendors in your house.
return;
}
else if ( m_House.VendorInventories.Count > 0 )
if ( m_House.VendorInventories.Count > 0 )
{
m_Mobile.SendLocalizedMessage( 1062681 ); // You cannot do that that while you still have unclaimed contract vendor inventory in your house.
return;

View file

@ -53,8 +53,8 @@ namespace Server.Gumps
PlayerState guildState = PlayerState.Find( m_Guild.Leader );
PlayerState targetState = PlayerState.Find( m );
Faction guildFaction = ( guildState == null ? null : guildState.Faction );
Faction targetFaction = ( targetState == null ? null : targetState.Faction );
Faction guildFaction = guildState?.Faction;
Faction targetFaction = targetState?.Faction;
if ( guildFaction != targetFaction )
{
@ -67,7 +67,8 @@ namespace Server.Gumps
break;
}
else if ( targetState != null && targetState.IsLeaving )
if ( targetState != null && targetState.IsLeaving )
{
// OSI does this quite strangely, so we'll just do it this way
m_Mobile.SendMessage( "That person is quitting their faction and so you may not recruit them." );

View file

@ -19,7 +19,7 @@ namespace Server.Gumps
{
if ( GuildGump.BadLeader( m_Leader, m_Guild ) )
return;
else if ( m_Target.Deleted || !m_Guild.IsMember( m_Target ) )
if ( m_Target.Deleted || !m_Guild.IsMember( m_Target ) )
return;
GuildGump.EnsureClosed( m_Leader );
@ -30,7 +30,7 @@ namespace Server.Gumps
{
if ( GuildGump.BadLeader( m_Leader, m_Guild ) )
return;
else if ( m_Target.Deleted || !m_Guild.IsMember( m_Target ) )
if ( m_Target.Deleted || !m_Guild.IsMember( m_Target ) )
return;
text = text.Trim();

View file

@ -29,9 +29,9 @@ namespace Server.Guilds
{
if ( x == null && y == null )
return 0;
else if ( x == null )
if ( x == null )
return -1;
else if ( y == null )
if ( y == null )
return 1;
return Insensitive.Compare( x.Name, y.Name );
@ -56,9 +56,9 @@ namespace Server.Guilds
{
if ( x == null && y == null )
return 0;
else if ( x == null )
if ( x == null )
return -1;
else if ( y == null )
if ( y == null )
return 1;
GuildCompareStatus aStatus = GuildCompareStatus.Peace;
@ -90,9 +90,9 @@ namespace Server.Guilds
{
if ( x == null && y == null )
return 0;
else if ( x == null )
if ( x == null )
return -1;
else if ( y == null )
if ( y == null )
return 1;
return Insensitive.Compare( x.Abbreviation, y.Abbreviation );

View file

@ -22,9 +22,9 @@ namespace Server.Guilds
{
if ( x == null && y == null )
return 0;
else if ( x == null )
if ( x == null )
return -1;
else if ( y == null )
if ( y == null )
return 1;
return Insensitive.Compare( x.Name, y.Name );
@ -43,9 +43,9 @@ namespace Server.Guilds
{
if ( x == null && y == null )
return 0;
else if ( x == null )
if ( x == null )
return -1;
else if ( y == null )
if ( y == null )
return 1;
NetState aState = x.NetState;
@ -53,12 +53,11 @@ namespace Server.Guilds
if ( aState == null && bState == null )
return x.LastOnline.CompareTo( y.LastOnline );
else if ( aState == null )
if ( aState == null )
return -1;
else if ( bState == null )
if ( bState == null )
return 1;
else
return 0;
return 0;
}
}
private class TitleComparer : IComparer<PlayerMobile>
@ -73,9 +72,9 @@ namespace Server.Guilds
{
if ( x == null && y == null )
return 0;
else if ( x == null )
if ( x == null )
return -1;
else if ( y == null )
if ( y == null )
return 1;
return Insensitive.Compare( x.GuildTitle, y.GuildTitle );
@ -94,9 +93,9 @@ namespace Server.Guilds
{
if ( x == null && y == null )
return 0;
else if ( x == null )
if ( x == null )
return -1;
else if ( y == null )
if ( y == null )
return 1;
return x.GuildRank.Rank.CompareTo( y.GuildRank.Rank );
@ -151,7 +150,7 @@ namespace Server.Guilds
defs[0] = name;
defs[1] = pm.GuildRank.Name;
defs[2] = (pm.NetState != null) ? new TextDefinition( 1063015 ): new TextDefinition( pm.LastOnline.ToString( "yyyy-MM-dd" ) );
defs[3] = (pm.GuildTitle == null) ? "" : pm.GuildTitle;
defs[3] = pm.GuildTitle ?? "";
return defs;
}
@ -203,8 +202,8 @@ namespace Server.Guilds
PlayerState guildState = PlayerState.Find( g.Leader );
PlayerState targetState = PlayerState.Find( targ );
Faction guildFaction = ( guildState == null ? null : guildState.Faction );
Faction targetFaction = ( targetState == null ? null : targetState.Faction );
Faction guildFaction = guildState?.Faction;
Faction targetFaction = targetState?.Faction;
if ( pm == null || !IsMember( pm, guild ) || !pm.GuildRank.GetFlag( RankFlags.CanInvitePlayer ) )
{

View file

@ -59,7 +59,8 @@ namespace Server.Gumps
{
return;
}
else if ( !Guilds.Guild.NewGuildSystem && m_House.FindGuildstone() != null )
if ( !Guilds.Guild.NewGuildSystem && m_House.FindGuildstone() != null )
{
m_Mobile.SendLocalizedMessage( 501389 ); // You cannot redeed a house with a guildstone inside.
return;
@ -69,17 +70,17 @@ namespace Server.Gumps
m_Mobile.SendLocalizedMessage( 503236 ); // You need to collect your vendor's belongings before moving.
return;
}*/
else if ( m_House.HasRentedVendors && m_House.VendorInventories.Count > 0 )
if ( m_House.HasRentedVendors && m_House.VendorInventories.Count > 0 )
{
m_Mobile.SendLocalizedMessage( 1062679 ); // You cannot do that that while you still have contract vendors or unclaimed contract vendor inventory in your house.
return;
}
else if ( m_House.HasRentedVendors )
if ( m_House.HasRentedVendors )
{
m_Mobile.SendLocalizedMessage( 1062680 ); // You cannot do that that while you still have contract vendors in your house.
return;
}
else if ( m_House.VendorInventories.Count > 0 )
if ( m_House.VendorInventories.Count > 0 )
{
m_Mobile.SendLocalizedMessage( 1062681 ); // You cannot do that that while you still have unclaimed contract vendor inventory in your house.
return;

View file

@ -53,7 +53,8 @@ namespace Server.Gumps
from.SendLocalizedMessage( 503256 ); // You fail to resurrect the creature.
return;
}
else if ( m_Pet.Region != null && m_Pet.Region.IsPartOf( "Khaldun" ) ) //TODO: Confirm for pets, as per Bandage's script.
if ( m_Pet.Region != null && m_Pet.Region.IsPartOf( "Khaldun" ) ) //TODO: Confirm for pets, as per Bandage's script.
{
from.SendLocalizedMessage( 1010395 ); // The veil of death in this area is too strong and resists thy efforts to restore life.
return;

View file

@ -544,8 +544,7 @@ namespace Server.Gumps
if ( attrs.Length > 0 )
return attrs[0] as CPA;
else
return null;
return null;
}
private ArrayList GetGroups( Type objectType, PropertyInfo[] props )
@ -600,7 +599,8 @@ namespace Server.Gumps
{
return s;
}
else if ( t == typeof( byte ) || t == typeof( sbyte ) || t == typeof( short ) || t == typeof( ushort ) || t == typeof( int ) || t == typeof( uint ) || t == typeof( long ) || t == typeof( ulong ) )
if ( t == typeof( byte ) || t == typeof( sbyte ) || t == typeof( short ) || t == typeof( ushort ) || t == typeof( int ) || t == typeof( uint ) || t == typeof( long ) || t == typeof( ulong ) )
{
if ( s.StartsWith( "0x" ) )
{
@ -608,21 +608,17 @@ namespace Server.Gumps
{
return Convert.ChangeType( Convert.ToUInt64( s.Substring( 2 ), 16 ), t );
}
else
{
return Convert.ChangeType( Convert.ToInt64( s.Substring( 2 ), 16 ), t );
}
}
else
{
return Convert.ChangeType( s, t );
return Convert.ChangeType( Convert.ToInt64( s.Substring( 2 ), 16 ), t );
}
return Convert.ChangeType( s, t );
}
else if ( t == typeof( double ) || t == typeof( float ) )
if ( t == typeof( double ) || t == typeof( float ) )
{
return Convert.ChangeType( s, t );
}
else if ( t.IsDefined( typeof( ParsableAttribute ), false ) )
if ( t.IsDefined( typeof( ParsableAttribute ), false ) )
{
MethodInfo parseMethod = t.GetMethod( "Parse", new[]{ typeof( string ) } );

View file

@ -19,13 +19,13 @@ namespace Server.Gumps
{
if ( map == Map.Trammel )
return 10;
else if ( map == Map.Felucca )
if ( map == Map.Felucca )
return 81;
else if ( map == Map.Ilshenar )
if ( map == Map.Ilshenar )
return 1102;
else if ( map == Map.Malas )
if ( map == Map.Malas )
return 1102;
else if ( map == Map.Tokuno )
if ( map == Map.Tokuno )
return 1154;
return 0;

View file

@ -92,10 +92,9 @@ namespace Server.Gumps
if ( x.AccessLevel > y.AccessLevel )
return -1;
else if ( x.AccessLevel < y.AccessLevel )
if ( x.AccessLevel < y.AccessLevel )
return 1;
else
return Insensitive.Compare( x.Name, y.Name );
return Insensitive.Compare( x.Name, y.Name );
}
}
@ -232,7 +231,7 @@ namespace Server.Gumps
{
if ( m.Kills >= 5 )
return 0x21;
else if ( m.Criminal )
if ( m.Criminal )
return 0x3B1;
return 0x58;