Upgrades code style - First batch (#22)

This commit is contained in:
Kamron Batman 2018-08-14 06:16:50 +08:00 committed by GitHub
parent 8ee42c8ea2
commit 632e8b4757
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1834 changed files with 10245 additions and 10437 deletions

View file

@ -93,7 +93,7 @@ namespace Server
}
BaseQuiver quiver = null;
if ( archer && from != null )
quiver = from.FindItemOnLayer( Layer.Cloak ) as BaseQuiver;
@ -1023,7 +1023,7 @@ namespace Server
private static int[] m_Empty = new int[0];
public bool IsEmpty { get { return (m_Names == 0); } }
public Item Owner { get { return m_Owner; } }
public Item Owner => m_Owner;
public BaseAttributes( Item owner )
{
@ -1223,4 +1223,4 @@ namespace Server
return index;
}
}
}
}

View file

@ -82,7 +82,7 @@ namespace Server.Misc
m_DisallowedFeatures &= ~feature;
}
public static Features DisallowedFeatures { get { return m_DisallowedFeatures; } }
public static Features DisallowedFeatures => m_DisallowedFeatures;
}
private static class Negotiator
@ -107,13 +107,12 @@ namespace Server.Misc
if (m != null && m.NetState != null && m.NetState.Running)
{
Timer t;
m.Send(new BeginHandshake());
if (Settings.KickOnFailure)
m.Send(new BeginHandshake());
if (m_Dictionary.TryGetValue(m, out t) && t != null)
if (m_Dictionary.TryGetValue(m, out Timer t) && t != null)
t.Stop();
m_Dictionary[m] = t = Timer.DelayCall(Settings.HandshakeTimeout, OnHandshakeTimeout_Callback, m);
@ -128,10 +127,8 @@ namespace Server.Misc
if (state == null || state.Mobile == null || !state.Running)
return;
Timer t;
Mobile m = state.Mobile;
if (m_Dictionary.TryGetValue(m, out t))
if (m_Dictionary.TryGetValue( m, out Timer t ))
{
if (t != null)
t.Stop();
@ -192,4 +189,4 @@ namespace Server.Misc
}
}
}
}
}

View file

@ -8,7 +8,7 @@ namespace Server
{
public class BuffInfo
{
public static bool Enabled { get { return Core.ML; } }
public static bool Enabled => Core.ML;
public static void Initialize()
{
@ -17,7 +17,7 @@ namespace Server
EventSink.ClientVersionReceived += new ClientVersionReceivedHandler( delegate( ClientVersionReceivedArgs args )
{
PlayerMobile pm = args.State.Mobile as PlayerMobile;
if( pm != null )
Timer.DelayCall( TimeSpan.Zero, pm.ResendBuffs );
} );
@ -26,28 +26,28 @@ namespace Server
#region Properties
private BuffIcon m_ID;
public BuffIcon ID { get { return m_ID; } }
public BuffIcon ID => m_ID;
private int m_TitleCliloc;
public int TitleCliloc { get { return m_TitleCliloc; } }
public int TitleCliloc => m_TitleCliloc;
private int m_SecondaryCliloc;
public int SecondaryCliloc { get { return m_SecondaryCliloc; } }
public int SecondaryCliloc => m_SecondaryCliloc;
private TimeSpan m_TimeLength;
public TimeSpan TimeLength { get { return m_TimeLength; } }
public TimeSpan TimeLength => m_TimeLength;
private DateTime m_TimeStart;
public DateTime TimeStart { get { return m_TimeStart; } }
public DateTime TimeStart => m_TimeStart;
private Timer m_Timer;
public Timer Timer { get { return m_Timer; } }
public Timer Timer => m_Timer;
private bool m_RetainThroughDeath;
public bool RetainThroughDeath { get { return m_RetainThroughDeath; } }
public bool RetainThroughDeath => m_RetainThroughDeath;
private TextDefinition m_Args;
public TextDefinition Args { get { return m_Args; } }
public TextDefinition Args => m_Args;
#endregion
@ -228,7 +228,7 @@ namespace Server
SpellPlague,
SpellTrigger,
NetherBolt,
Fly
Fly
}
public sealed class AddBuffPacket : Packet

View file

@ -127,9 +127,7 @@ namespace Server
public LocalBuilder AcquireTemp( Type localType )
{
Queue<LocalBuilder> list;
if ( !m_Temps.TryGetValue( localType, out list ) )
if (!m_Temps.TryGetValue( localType, out Queue<LocalBuilder> list ))
m_Temps[localType] = list = new Queue<LocalBuilder>();
if ( list.Count > 0 )
@ -140,9 +138,7 @@ namespace Server
public void ReleaseTemp( LocalBuilder local )
{
Queue<LocalBuilder> list;
if ( !m_Temps.TryGetValue( local.LocalType, out list ) )
if (!m_Temps.TryGetValue( local.LocalType, out Queue<LocalBuilder> list ))
m_Temps[local.LocalType] = list = new Queue<LocalBuilder>();
list.Enqueue( local );
@ -504,25 +500,25 @@ namespace Server
if ( compareTo == null )
{
/* This gets a little tricky...
*
*
* There's a scenario where we might be trying to use CompareTo on an interface
* which, while it doesn't explicitly implement CompareTo itself, is said to
* extend IComparable indirectly. The implementation is implicitly passed off
* to implementers...
*
*
* interface ISomeInterface : IComparable
* {
* void SomeMethod();
* }
*
*
* class SomeClass : ISomeInterface
* {
* void SomeMethod() { ... }
* int CompareTo( object other ) { ... }
* }
*
*
* In this case, calling ISomeInterface.GetMethod( "CompareTo" ) will return null.
*
*
* Bleh.
*/
@ -555,11 +551,11 @@ namespace Server
if ( !active.IsValueType )
{
/* This object is a reference type, so we have to make it behave
*
*
* null.CompareTo( null ) = 0
* real.CompareTo( null ) = -1
* null.CompareTo( real ) = +1
*
*
*/
LocalBuilder aValue = AcquireTemp( active );
@ -724,4 +720,4 @@ namespace Server
m_Generator.Emit( OpCodes.Box, argumentType );
}
}
}
}

View file

@ -119,7 +119,7 @@ namespace Server.Items
return false;
}
}
else
else
{
return false;
}
@ -170,7 +170,7 @@ namespace Server.Items
[Flippable( 0x14F0, 0x14EF )]
public class MistletoeDeed : Item
{
public override int LabelNumber{ get{ return 1070882; } } // Mistletoe Deed
public override int LabelNumber => 1070882; // Mistletoe Deed
[Constructible]
public MistletoeDeed() : this( 0 )
@ -339,4 +339,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -15,7 +15,7 @@ namespace Server.Items
LootType = LootType.Blessed;
}
public override int LabelNumber{ get{ return 1070874; } } // a Pile of Glacial Snow
public override int LabelNumber => 1070874; // a Pile of Glacial Snow
public PileOfGlacialSnow( Serial serial ) : base( serial )
{
@ -148,4 +148,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -15,7 +15,7 @@ namespace Server.Items
LootType = LootType.Blessed;
}
public override int LabelNumber{ get{ return 1005578; } } // a pile of snow
public override int LabelNumber => 1005578; // a pile of snow
public SnowPile( Serial serial ) : base( serial )
{
@ -134,4 +134,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -11,8 +11,8 @@ namespace Server.Misc
GiftGiving.Register( new WinterGiftGiver2004() );
}
public override DateTime Start{ get{ return new DateTime( 2004, 12, 24 ); } }
public override DateTime Finish{ get{ return new DateTime( 2005, 1, 1 ); } }
public override DateTime Start => new DateTime( 2004, 12, 24 );
public override DateTime Finish => new DateTime( 2005, 1, 1 );
public override void GiveGift( Mobile mob )
{
@ -42,4 +42,4 @@ namespace Server.Misc
}
}
}
}
}

View file

@ -55,7 +55,7 @@ namespace Server.Guilds
public RankDefinition( TextDefinition name, int rank, RankFlags flags )
{
m_Name = name;
m_Name = name;
m_Rank = rank;
m_Flags = flags;
}
@ -90,7 +90,7 @@ namespace Server.Guilds
private Guild m_Leader;
private List<Guild> m_Members;
private List<Guild> m_PendingMembers;
public string Name
{
get{ return m_Name; }
@ -117,7 +117,7 @@ namespace Server.Guilds
get
{
CheckLeader();
return m_Leader;
return m_Leader;
}
set
{
@ -222,7 +222,7 @@ namespace Server.Guilds
{
m_PendingMembers.Remove( g );
}
if( m_Members.Contains( g ) ) //Sanity, just incase someone with a custom script adds a character to BOTH arrays
{
m_Members.Remove( g );
@ -262,10 +262,7 @@ namespace Server.Guilds
for( int i = 0; i < m_Members.Count; i++ )
m_Members[i].Alliance = null;
AllianceInfo aInfo = null;
m_Alliances.TryGetValue( m_Name.ToLower(), out aInfo );
m_Alliances.TryGetValue( m_Name.ToLower(), out AllianceInfo aInfo );
if( aInfo == this )
m_Alliances.Remove( m_Name.ToLower() );
@ -432,7 +429,7 @@ namespace Server.Guilds
public int Kills
{
get{ return m_Kills; }
get{ return m_Kills; }
set{ m_Kills = value; }
}
public int MaxKills
@ -455,7 +452,7 @@ namespace Server.Guilds
}
public DateTime WarBeginning
{
get{ return m_WarBeginning; }
get{ return m_WarBeginning; }
set{ m_WarBeginning = value; }
}
public bool WarRequester
@ -568,7 +565,7 @@ namespace Server.Guilds
Priority = TimerPriority.FiveSeconds;
}
protected override void OnTick()
protected override void OnTick()
{
foreach( Guild g in Guild.List.Values )
g.CheckExpiredWars();
@ -680,7 +677,7 @@ namespace Server.Guilds
PlayerMobile pm = args.Mobile as PlayerMobile;
if( !NewGuildSystem || pm == null )
return;
if( pm.Guild == null )
pm.SendGump( new CreateGuildGump( pm ) );
else
@ -729,7 +726,7 @@ namespace Server.Guilds
if( value != null )
{
if( value.Leader == this )
m_AllianceInfo = value;
else
@ -799,14 +796,14 @@ namespace Server.Guilds
return false;
}
}
public static Guild GetAllianceLeader( Guild g )
{
AllianceInfo alliance = g.Alliance;
if ( alliance != null && alliance.Leader != null && alliance.IsMember( g ) )
return alliance.Leader;
return g;
}
@ -820,7 +817,7 @@ namespace Server.Guilds
}
public List<WarDeclaration> AcceptedWars
{
get{ return m_AcceptedWars; }
get{ return m_AcceptedWars; }
}
@ -863,7 +860,7 @@ namespace Server.Guilds
{
AllianceInfo myAlliance = this.Alliance;
bool inAlliance = ( myAlliance != null && myAlliance.IsMember( this ) );
AllianceInfo otherAlliance = ((g != null) ? g.Alliance : null);
bool otherInAlliance = ( otherAlliance != null && otherAlliance.IsMember( this ) );
@ -937,12 +934,12 @@ namespace Server.Guilds
Guild victimGuild = GetAllianceLeader( victim.Guild as Guild );
Guild killerGuild = GetAllianceLeader( killer.Guild as Guild );
WarDeclaration war = killerGuild.FindActiveWar( victimGuild );
if( war == null )
return;
war.Kills++;
if ( war.Opponent == victimGuild )
@ -1049,7 +1046,7 @@ namespace Server.Guilds
m_Members[i].Delta( MobileDelta.Noto );
}
}
public void InvalidateWarNotoriety()
{
Guild g = GetAllianceLeader( this );
@ -1058,14 +1055,14 @@ namespace Server.Guilds
g.Alliance.InvalidateMemberNotoriety();
else
g.InvalidateMemberNotoriety();
if ( g.AcceptedWars == null )
return;
foreach ( WarDeclaration warDec in g.AcceptedWars )
{
Guild opponent = warDec.Opponent;
if ( opponent.Alliance != null )
opponent.Alliance.InvalidateMemberNotoriety();
else
@ -1340,7 +1337,7 @@ namespace Server.Guilds
m_Members = reader.ReadStrongMobileList();
m_Candidates = reader.ReadStrongMobileList();
m_Accepted = reader.ReadStrongMobileList();
m_Accepted = reader.ReadStrongMobileList();
m_Guildstone = reader.ReadItem();
m_Teleporter = reader.ReadItem();
@ -1388,7 +1385,7 @@ namespace Server.Guilds
alliance = this.Alliance; //CheckLeader could possibly change the value of this.Alliance
if( alliance != null && !alliance.IsMember( this ) && !alliance.IsPendingMember( this ) ) //This block is there to fix a bug in the code in an older version.
if( alliance != null && !alliance.IsMember( this ) && !alliance.IsPendingMember( this ) ) //This block is there to fix a bug in the code in an older version.
this.Alliance = null; //Will call Alliance.RemoveGuild which will set it null & perform all the pertient checks as far as alliacne disbanding
}
@ -1413,7 +1410,7 @@ namespace Server.Guilds
if( m is PlayerMobile )
((PlayerMobile)m).GuildRank = RankDefinition.Lowest;
Guild guild = m.Guild as Guild;
if ( guild != null )
@ -1430,9 +1427,9 @@ namespace Server.Guilds
if ( m_Members.Contains( m ) )
{
m_Members.Remove( m );
Guild guild = m.Guild as Guild;
m.Guild = null;
if( m is PlayerMobile )
@ -1451,10 +1448,10 @@ namespace Server.Guilds
if ( m_Members.Count == 0 )
Disband();
if ( guild != null )
guild.InvalidateWarNotoriety();
m.Delta( MobileDelta.Noto );
}
}
@ -1624,20 +1621,18 @@ namespace Server.Guilds
{
if ( m_Leader != null && !m_Leader.Deleted && m_Leader.Guild == this )
m = m_Leader;
else
else
m = memb;
}
if ( m == null )
continue;
int v;
if( !votes.TryGetValue( m, out v ) )
if( !votes.TryGetValue( m, out int v ) )
votes[m] = 1;
else
votes[m] = v + 1;
votingMembers++;
}

View file

@ -98,7 +98,7 @@ namespace Server
public string Unknown{ get{ return m_Unknown; } }
[CommandProperty( AccessLevel.GameMaster )]
public DateTime TimeReceived { get { return m_TimeReceived; } }
public DateTime TimeReceived => m_TimeReceived;
public static void Initialize()
{
@ -186,4 +186,4 @@ namespace Server
acct.HardwareInfo = info;
}
}
}
}

View file

@ -371,7 +371,7 @@ namespace Server.Misc
}
int syllableCount;
if ( 30 > Utility.Random( 100 ) )
syllableCount = Utility.Random( 1, 5 );
else
@ -433,8 +433,7 @@ namespace Server.Misc
for ( int i = 0; i < split.Length; ++i )
{
string keyword;
m_KeywordHash.TryGetValue( split[i], out keyword );
m_KeywordHash.TryGetValue( split[i], out string keyword );
if ( keyword != null )
keywordsFound.Add( keyword );
@ -592,4 +591,4 @@ namespace Server.Misc
{
}
}
}
}

View file

@ -7,7 +7,7 @@ namespace Server
{
public static class MondainsLegacy
{
public static Type[] Artifacts { get { return m_Artifacts; } }
public static Type[] Artifacts => m_Artifacts;
private static Type[] m_Artifacts = new Type[]
{
@ -83,4 +83,4 @@ namespace Server
|| region.IsPartOf( "Labyrinth" );
}
}
}
}

View file

@ -43,8 +43,7 @@ namespace Server
public static NameList GetNameList( string type )
{
NameList n = null;
m_Table.TryGetValue( type, out n );
m_Table.TryGetValue( type, out NameList n );
return n;
}

View file

@ -112,8 +112,8 @@ namespace Server.Misc
return true;
}
public static string[] StartDisallowed { get { return m_StartDisallowed; } }
public static string[] Disallowed { get { return m_Disallowed; } }
public static string[] StartDisallowed => m_StartDisallowed;
public static string[] Disallowed => m_Disallowed;
private static string[] m_StartDisallowed = new string[]
{
@ -204,4 +204,4 @@ namespace Server.Misc
"origin"
};
}
}
}

View file

@ -65,8 +65,8 @@ namespace Server
m_MessageInterval = messageInterval;
}
public override string Name{ get{ return m_Name; } }
public override int Level{ get{ return m_Level; } }
public override string Name => m_Name;
public override int Level => m_Level;
public class PoisonTimer : Timer
{
@ -153,4 +153,4 @@ namespace Server
return new PoisonTimer( m, this );
}
}
}
}

View file

@ -501,9 +501,7 @@ namespace Server.Items
if ( m_TypeTable == null )
return CraftResource.None;
CraftResource res;
if (!m_TypeTable.TryGetValue(resourceType, out res))
if (!m_TypeTable.TryGetValue(resourceType, out CraftResource res))
return CraftResource.None;
return res;
@ -723,4 +721,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -12,8 +12,8 @@ namespace Server
private int m_Number;
private string m_String;
public int Number { get { return m_Number; } }
public string String { get { return m_String; } }
public int Number => m_Number;
public string String => m_String;
public bool IsEmpty { get { return ( m_Number <= 0 && m_String == null ); } }

View file

@ -17,7 +17,7 @@ namespace Server.Misc
m_Facets = new Map[]{ Map.Felucca, Map.Trammel };
/* Static weather:
*
*
* Format:
* AddWeather( temperature, chanceOfPercipitation, chanceOfExtremeTemperature, <area ...> );
*/
@ -33,7 +33,7 @@ namespace Server.Misc
/* Dynamic weather:
*
*
* Format:
* AddDynamicWeather( temperature, chanceOfPercipitation, chanceOfExtremeTemperature, moveSpeed, width, height, bounds );
*/
@ -47,8 +47,7 @@ namespace Server.Misc
if ( facet == null )
return null;
List<Weather> list = null;
m_WeatherByFacet.TryGetValue( facet, out list );
m_WeatherByFacet.TryGetValue( facet, out List<Weather> list );
if ( list == null )
m_WeatherByFacet[facet] = list = new List<Weather>();
@ -391,4 +390,4 @@ namespace Server.Misc
int version = reader.ReadInt();
}
}
}
}