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

@ -24,9 +24,9 @@ namespace Server
public override bool DisplayWeight => false;
public override bool DisplayLootType => false;
public override double DefaultWeight { get { return 0; } }
public override double DefaultWeight => 0;
public override string DefaultName { get { return "Offer Of Currency"; } }
public override string DefaultName => "Offer Of Currency";
public EditGump Editor { get; private set; }

View file

@ -107,7 +107,7 @@ namespace Server
public static Thread Thread { get { return m_Thread; } }
public static MultiTextWriter MultiConsoleOut { get { return m_MultiConOut; } }
/*
/*
* DateTime.Now and DateTime.UtcNow are based on actual system clock time.
* The resolution is acceptable but large clock jumps are possible and cause issues.
* GetTickCount and GetTickCount64 have poor resolution.
@ -151,7 +151,7 @@ namespace Server
public static int ProcessorCount { get { return m_ProcessorCount; } }
private static bool m_Unix;
public static bool Unix { get { return m_Unix; } }
public static string FindDataFile( string path )
@ -333,7 +333,7 @@ namespace Server
{
if( World.Saving || ( m_Service && type == ConsoleEventType.CTRL_LOGOFF_EVENT ) )
return true;
Kill(); //Kill -> HandleClosed will handle waiting for the completion of flushing to disk
return true;
@ -489,18 +489,18 @@ namespace Server
while( !ScriptCompiler.Compile( m_Debug, m_Cache ) )
{
Console.WriteLine( "Scripts: One or more scripts failed to compile or no script files were found." );
if( m_Service )
return;
Console.WriteLine( " - Press return to exit, or R to try again." );
if( Console.ReadKey( true ).Key != ConsoleKey.R )
return;
}
ScriptCompiler.Invoke( "Configure" );
Region.Load();
World.Load();
@ -626,7 +626,7 @@ namespace Server
}
private static readonly Type[] m_SerialTypeArray = { typeof(Serial) };
private static void VerifyType(Type t)
{
var isItem = t.IsSubclassOf(typeof(Item));
@ -726,7 +726,7 @@ namespace Server
new FileStream(FileName, append ? FileMode.Append : FileMode.Create, FileAccess.Write, FileShare.Read)))
{
writer.WriteLine(">>>Logging started on {0}.", DateTime.UtcNow.ToString("f"));
//f = Tuesday, April 10, 2001 3:51 PM
//f = Tuesday, April 10, 2001 3:51 PM
}
_NewLine = true;
@ -774,7 +774,7 @@ namespace Server
}
}
public override Encoding Encoding { get { return Encoding.Default; } }
public override Encoding Encoding => Encoding.Default;
}
public class MultiTextWriter : TextWriter
@ -822,6 +822,6 @@ namespace Server
WriteLine(String.Format(line, args));
}
public override Encoding Encoding { get { return Encoding.Default; } }
public override Encoding Encoding => Encoding.Default;
}
}
}

View file

@ -30,14 +30,12 @@ using Server.Guilds;
namespace Server {
public sealed class DualSaveStrategy : StandardSaveStrategy {
public override string Name {
get { return "Dual"; }
}
public override string Name => "Dual";
public DualSaveStrategy() {
}
public override void Save( SaveMetrics metrics, bool permitBackgroundWrite )
public override void Save( SaveMetrics metrics, bool permitBackgroundWrite )
{
this.PermitBackgroundWrite = permitBackgroundWrite;
@ -57,4 +55,4 @@ namespace Server {
World.NotifyDiskWriteComplete();
}
}
}
}

View file

@ -36,7 +36,7 @@ namespace Server
{
public sealed class DynamicSaveStrategy : SaveStrategy
{
public override string Name { get { return "Dynamic"; } }
public override string Name => "Dynamic";
private SaveMetrics _metrics;
@ -122,7 +122,7 @@ namespace Server
IEnumerable<Item> items = World.Items.Values;
//Start the producer.
Parallel.ForEach(items, () => new QueuedMemoryWriter(),
Parallel.ForEach(items, () => new QueuedMemoryWriter(),
(Item item, ParallelLoopState state, QueuedMemoryWriter writer) =>
{
long startPosition = writer.Position;
@ -152,7 +152,7 @@ namespace Server
_itemThreadWriters.Add(writer);
});
_itemThreadWriters.CompleteAdding(); //We only get here after the Parallel.ForEach completes. Lets our task
_itemThreadWriters.CompleteAdding(); //We only get here after the Parallel.ForEach completes. Lets our task
return commitTask;
}
@ -228,7 +228,7 @@ namespace Server
_guildThreadWriters.Add(writer);
});
_guildThreadWriters.CompleteAdding(); //We only get here after the Parallel.ForEach completes. Lets our task
_guildThreadWriters.CompleteAdding(); //We only get here after the Parallel.ForEach completes. Lets our task
return commitTask;
}
@ -310,4 +310,4 @@ namespace Server
}
}
}
}

View file

@ -31,9 +31,7 @@ using Server.Guilds;
namespace Server {
public sealed class ParallelSaveStrategy : SaveStrategy {
public override string Name {
get { return "Parallel"; }
}
public override string Name => "Parallel";
private int processorCount;
@ -343,4 +341,4 @@ namespace Server {
}
}
}
}
}

View file

@ -110,21 +110,13 @@ namespace Server {
base.Dispose( disposing );
}
public override bool CanRead {
get { return false; }
}
public override bool CanRead => false;
public override bool CanSeek {
get { return false; }
}
public override bool CanSeek => false;
public override bool CanWrite {
get { return true; }
}
public override bool CanWrite => true;
public override long Length {
get { return this.Position; }
}
public override long Length => this.Position;
public override int Read( byte[] buffer, int offset, int count ) {
throw new InvalidOperationException();
@ -138,4 +130,4 @@ namespace Server {
fileStream.SetLength( value );
}
}
}
}

View file

@ -38,9 +38,7 @@ namespace Server {
public static SaveOption SaveType = SaveOption.Normal;
public override string Name {
get { return "Standard"; }
}
public override string Name => "Standard";
private Queue<Item> _decayQueue;
private bool _permitBackgroundWrite;
@ -213,4 +211,4 @@ namespace Server {
}
}
}
}
}

View file

@ -38,13 +38,9 @@ namespace Server {
}
}
public static bool IsHardwareRNG {
get { return _Random is IHardwareRNG; }
}
public static bool IsHardwareRNG => _Random is IHardwareRNG;
public static Type Type {
get { return _Random.GetType(); }
}
public static Type Type => _Random.GetType();
public static int Next(int c) {
return _Random.Next(c);
@ -177,7 +173,7 @@ namespace Server {
lock (_sync) {
CheckSwap(1);
return _Working[_Index++];
}
}
}
public void NextBytes(byte[] b) {
@ -510,7 +506,7 @@ namespace Server {
return;
_filled.WaitOne();
byte[] b = _Working;
_Working = _Buffer;
_Buffer = b;
@ -603,4 +599,4 @@ namespace Server {
Success = 1,
}
}
}

View file

@ -221,13 +221,9 @@ namespace Server
private static int m_MaxLandValue;
private static int m_MaxItemValue;
public static int MaxLandValue {
get { return m_MaxLandValue; }
}
public static int MaxLandValue => m_MaxLandValue;
public static int MaxItemValue {
get { return m_MaxItemValue; }
}
public static int MaxItemValue => m_MaxItemValue;
private static byte[] m_StringBuffer = new byte[20];
@ -369,4 +365,4 @@ namespace Server
}
}
}
}
}

View file

@ -73,13 +73,9 @@ namespace Server {
m_DiskWriteHandle.WaitOne();
}
public static Dictionary<Serial, Mobile> Mobiles {
get { return m_Mobiles; }
}
public static Dictionary<Serial, Mobile> Mobiles => m_Mobiles;
public static Dictionary<Serial, Item> Items {
get { return m_Items; }
}
public static Dictionary<Serial, Item> Items => m_Items;
public static bool OnDelete( IEntity entity ) {
if ( m_Saving || m_Loading ) {
@ -276,9 +272,7 @@ namespace Server {
private static string m_LoadingType;
public static string LoadingType {
get { return m_LoadingType; }
}
public static string LoadingType => m_LoadingType;
private static readonly Type[] m_SerialTypeArray = new Type[1] { typeof(Serial) };
@ -867,4 +861,4 @@ namespace Server {
m_Items.Remove( item.Serial );
}
}
}
}