Fixes implicit ternary expressions
This commit is contained in:
parent
c85b0a740c
commit
ff26dfa375
345 changed files with 1905 additions and 2336 deletions
|
|
@ -219,33 +219,30 @@ namespace Server.Commands
|
|||
{
|
||||
return Enum.Parse( type, value, true );
|
||||
}
|
||||
else if ( IsType( type ) )
|
||||
|
||||
if ( IsType( type ) )
|
||||
{
|
||||
return ScriptCompiler.FindTypeByName( value );
|
||||
}
|
||||
else if ( IsParsable( type ) )
|
||||
if ( IsParsable( type ) )
|
||||
{
|
||||
return ParseParsable( type, value );
|
||||
}
|
||||
else
|
||||
object obj = value;
|
||||
|
||||
if ( value != null && value.StartsWith( "0x" ) )
|
||||
{
|
||||
object obj = value;
|
||||
if ( IsSignedNumeric( type ) )
|
||||
obj = Convert.ToInt64( value.Substring( 2 ), 16 );
|
||||
else if ( IsUnsignedNumeric( type ) )
|
||||
obj = Convert.ToUInt64( value.Substring( 2 ), 16 );
|
||||
|
||||
if ( value != null && value.StartsWith( "0x" ) )
|
||||
{
|
||||
if ( IsSignedNumeric( type ) )
|
||||
obj = Convert.ToInt64( value.Substring( 2 ), 16 );
|
||||
else if ( IsUnsignedNumeric( type ) )
|
||||
obj = Convert.ToUInt64( value.Substring( 2 ), 16 );
|
||||
|
||||
obj = Convert.ToInt32( value.Substring( 2 ), 16 );
|
||||
}
|
||||
|
||||
if ( obj == null && !type.IsValueType )
|
||||
return null;
|
||||
else
|
||||
return Convert.ChangeType( obj, type );
|
||||
obj = Convert.ToInt32( value.Substring( 2 ), 16 );
|
||||
}
|
||||
|
||||
if ( obj == null && !type.IsValueType )
|
||||
return null;
|
||||
return Convert.ChangeType( obj, type );
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -68,12 +68,13 @@ namespace Server.Commands
|
|||
e.Mobile.SendMessage( "That is either an invalid command name or one that does not support this modifier: {0}.", commandString );
|
||||
return;
|
||||
}
|
||||
else if ( e.Mobile.AccessLevel < command.AccessLevel )
|
||||
|
||||
if ( e.Mobile.AccessLevel < command.AccessLevel )
|
||||
{
|
||||
e.Mobile.SendMessage( "You do not have access to that command: {0}.", commandString );
|
||||
return;
|
||||
}
|
||||
else if ( !command.ValidateArgs( m_Scope, eventArgs[i] ) )
|
||||
if ( !command.ValidateArgs( m_Scope, eventArgs[i] ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -157,12 +158,13 @@ namespace Server.Commands
|
|||
from.SendMessage( "You must select the batch command scope." );
|
||||
return false;
|
||||
}
|
||||
else if ( m_Condition.Length > 0 && !m_Scope.SupportsConditionals )
|
||||
|
||||
if ( m_Condition.Length > 0 && !m_Scope.SupportsConditionals )
|
||||
{
|
||||
from.SendMessage( "This command scope does not support conditionals." );
|
||||
return false;
|
||||
}
|
||||
else if ( m_Condition.Length > 0 && !Utility.InsensitiveStartsWith( m_Condition, "where" ) )
|
||||
if ( m_Condition.Length > 0 && !Utility.InsensitiveStartsWith( m_Condition, "where" ) )
|
||||
{
|
||||
from.SendMessage( "The condition field must start with \"where\"." );
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ namespace Server.Commands
|
|||
|
||||
if ( aStatic && !bStatic )
|
||||
return -1;
|
||||
else if ( !aStatic && bStatic )
|
||||
if ( !aStatic && bStatic )
|
||||
return 1;
|
||||
|
||||
int v = 0;
|
||||
|
|
@ -115,7 +115,7 @@ namespace Server.Commands
|
|||
{
|
||||
if ( ctor != null )
|
||||
return ctor.IsStatic;
|
||||
else if ( method != null )
|
||||
if ( method != null )
|
||||
return method.IsStatic;
|
||||
|
||||
if ( prop != null )
|
||||
|
|
@ -133,12 +133,11 @@ namespace Server.Commands
|
|||
{
|
||||
if ( ctor != null )
|
||||
return ctor.DeclaringType.Name;
|
||||
else if ( prop != null )
|
||||
if ( prop != null )
|
||||
return prop.Name;
|
||||
else if ( method != null )
|
||||
if ( method != null )
|
||||
return method.Name;
|
||||
else
|
||||
return "";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -148,9 +147,9 @@ namespace Server.Commands
|
|||
{
|
||||
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.TypeName.CompareTo( y.TypeName );
|
||||
|
|
@ -2465,7 +2464,7 @@ namespace Server.Commands
|
|||
for( int i = 0; i < ReplaceChars.Length; ++i ) { sb.Replace( ReplaceChars[i], '-' ); }
|
||||
|
||||
if ( anonymousType ) return "(Anonymous-Type)"+sb.ToString();
|
||||
else return sb.ToString();
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static string AliasForName( string name )
|
||||
|
|
|
|||
|
|
@ -308,7 +308,8 @@ namespace Server.Commands.Generic
|
|||
m_From.SendGump( new InterfaceGump( m_From, m_Columns, m_List, m_Page, m_Item ) );
|
||||
return;
|
||||
}
|
||||
else if ( !BaseCommand.IsAccessible( m_From, m_Item ) )
|
||||
|
||||
if ( !BaseCommand.IsAccessible( m_From, m_Item ) )
|
||||
{
|
||||
m_From.SendMessage( "That is no longer accessible." );
|
||||
m_From.SendGump( new InterfaceGump( m_From, m_Columns, m_List, m_Page, m_Item ) );
|
||||
|
|
@ -469,7 +470,8 @@ namespace Server.Commands.Generic
|
|||
m_From.SendGump( new InterfaceGump( m_From, m_Columns, m_List, m_Page, m_Mobile ) );
|
||||
return;
|
||||
}
|
||||
else if ( !BaseCommand.IsAccessible( m_From, m_Mobile ) )
|
||||
|
||||
if ( !BaseCommand.IsAccessible( m_From, m_Mobile ) )
|
||||
{
|
||||
m_From.SendMessage( "That is no longer accessible." );
|
||||
m_From.SendGump( new InterfaceGump( m_From, m_Columns, m_List, m_Page, m_Mobile ) );
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace Server.Commands.Generic
|
|||
{
|
||||
RangeCommandImplementor impl = RangeCommandImplementor.Instance;
|
||||
|
||||
impl?.Process( 18, @from, command, args );
|
||||
impl?.Process( 18, from, command, args );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -628,7 +628,7 @@ namespace Server.Commands
|
|||
|
||||
Mobile owner = item.RootParent as Mobile;
|
||||
|
||||
if ( owner?.Map != null && owner.Map != Map.Internal && !BaseCommand.IsAccessible( @from, owner ) /* !from.CanSee( owner )*/ )
|
||||
if ( owner?.Map != null && owner.Map != Map.Internal && !BaseCommand.IsAccessible( from, owner ) /* !from.CanSee( owner )*/ )
|
||||
{
|
||||
from.SendMessage( "You can not go to what you can not see." );
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ namespace Server.Commands
|
|||
|
||||
return;
|
||||
}
|
||||
else
|
||||
e.Mobile.SendMessage($"Command '{arg}' not found!");
|
||||
|
||||
e.Mobile.SendMessage($"Command '{arg}' not found!");
|
||||
}
|
||||
|
||||
e.Mobile.SendGump( new CommandListGump( 0, e.Mobile, null ) );
|
||||
|
|
|
|||
|
|
@ -113,26 +113,27 @@ namespace Server.Commands
|
|||
failReason = $"Property '{propertyName}' not found.";
|
||||
return null;
|
||||
}
|
||||
else if ( (access & PropertyAccess.Read) != 0 && from.AccessLevel < attr.ReadLevel )
|
||||
|
||||
if ( (access & PropertyAccess.Read) != 0 && from.AccessLevel < attr.ReadLevel )
|
||||
{
|
||||
failReason =
|
||||
$"You must be at least {Mobile.GetAccessLevelName(attr.ReadLevel)} to get the property '{propertyName}'.";
|
||||
|
||||
return null;
|
||||
}
|
||||
else if ( (access & PropertyAccess.Write) != 0 && from.AccessLevel < attr.WriteLevel )
|
||||
if ( (access & PropertyAccess.Write) != 0 && from.AccessLevel < attr.WriteLevel )
|
||||
{
|
||||
failReason =
|
||||
$"You must be at least {Mobile.GetAccessLevelName(attr.WriteLevel)} to set the property '{propertyName}'.";
|
||||
|
||||
return null;
|
||||
}
|
||||
else if ( (access & PropertyAccess.Read) != 0 && !p.CanRead )
|
||||
if ( (access & PropertyAccess.Read) != 0 && !p.CanRead )
|
||||
{
|
||||
failReason = $"Property '{propertyName}' is write only.";
|
||||
return null;
|
||||
}
|
||||
else if ( (access & PropertyAccess.Write) != 0 && (!p.CanWrite || attr.ReadOnly) && isFinal )
|
||||
if ( (access & PropertyAccess.Write) != 0 && (!p.CanWrite || attr.ReadOnly) && isFinal )
|
||||
{
|
||||
failReason = $"Property '{propertyName}' is read only.";
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue