Adds style cop (#109)
This commit is contained in:
parent
3e715bcb60
commit
556a17aba8
1725 changed files with 33831 additions and 38046 deletions
|
|
@ -1,22 +1,23 @@
|
|||
/***************************************************************************
|
||||
* Serialization.cs
|
||||
* -------------------
|
||||
* begin : May 1, 2002
|
||||
* copyright : (C) The RunUO Software Team
|
||||
* email : info@runuo.com
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
***************************************************************************/
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: AsyncWriter.cs *
|
||||
* Created: 2020/12/30 - Updated: 2020/04/25 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -29,7 +30,7 @@ namespace Server
|
|||
{
|
||||
public sealed class AsyncWriter : IGenericWriter
|
||||
{
|
||||
private readonly int BufferSize;
|
||||
private readonly int m_BufferSize;
|
||||
private BinaryWriter m_Bin;
|
||||
private bool m_Closed;
|
||||
private readonly FileStream m_File;
|
||||
|
|
@ -40,26 +41,26 @@ namespace Server
|
|||
private Thread m_WorkerThread;
|
||||
|
||||
private readonly Queue<MemoryStream> m_WriteQueue;
|
||||
private readonly bool PrefixStrings;
|
||||
private readonly bool m_PrefixStrings;
|
||||
|
||||
public AsyncWriter(string filename, bool prefix)
|
||||
: this(filename, 1048576, prefix) //1 mb buffer
|
||||
: this(filename, 1048576, prefix) // 1 mb buffer
|
||||
{
|
||||
}
|
||||
|
||||
public AsyncWriter(string filename, int buffSize, bool prefix)
|
||||
{
|
||||
PrefixStrings = prefix;
|
||||
m_PrefixStrings = prefix;
|
||||
m_Closed = false;
|
||||
m_WriteQueue = new Queue<MemoryStream>();
|
||||
BufferSize = buffSize;
|
||||
m_BufferSize = buffSize;
|
||||
|
||||
m_File = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
m_Mem = new MemoryStream(BufferSize + 1024);
|
||||
m_Mem = new MemoryStream(m_BufferSize + 1024);
|
||||
m_Bin = new BinaryWriter(m_Mem, Utility.UTF8WithEncoding);
|
||||
}
|
||||
|
||||
public static int ThreadCount{ get; private set; }
|
||||
public static int ThreadCount { get; private set; }
|
||||
|
||||
public MemoryStream MemStream
|
||||
{
|
||||
|
|
@ -95,13 +96,13 @@ namespace Server
|
|||
|
||||
private void OnWrite()
|
||||
{
|
||||
long curlen = m_Mem.Length;
|
||||
var curlen = m_Mem.Length;
|
||||
m_CurPos += curlen - m_LastPos;
|
||||
m_LastPos = curlen;
|
||||
if (curlen >= BufferSize)
|
||||
if (curlen >= m_BufferSize)
|
||||
{
|
||||
Enqueue(m_Mem);
|
||||
m_Mem = new MemoryStream(BufferSize + 1024);
|
||||
m_Mem = new MemoryStream(m_BufferSize + 1024);
|
||||
m_Bin = new BinaryWriter(m_Mem, Utility.UTF8WithEncoding);
|
||||
m_LastPos = 0;
|
||||
}
|
||||
|
|
@ -121,7 +122,7 @@ namespace Server
|
|||
|
||||
public void Write(string value)
|
||||
{
|
||||
if (PrefixStrings)
|
||||
if (m_PrefixStrings)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
|
|
@ -143,8 +144,8 @@ namespace Server
|
|||
|
||||
public void WriteDeltaTime(DateTime value)
|
||||
{
|
||||
long ticks = value.Ticks;
|
||||
long now = DateTime.UtcNow.Ticks;
|
||||
var ticks = value.Ticks;
|
||||
var now = DateTime.UtcNow.Ticks;
|
||||
|
||||
TimeSpan d;
|
||||
|
||||
|
|
@ -199,7 +200,7 @@ namespace Server
|
|||
|
||||
public void WriteEncodedInt(int value)
|
||||
{
|
||||
uint v = (uint)value;
|
||||
var v = (uint)value;
|
||||
|
||||
while (v >= 0x80)
|
||||
{
|
||||
|
|
@ -269,6 +270,7 @@ namespace Server
|
|||
m_Bin.Write(value, 0, length);
|
||||
OnWrite();
|
||||
}
|
||||
|
||||
public void Write(sbyte value)
|
||||
{
|
||||
m_Bin.Write(value);
|
||||
|
|
@ -351,7 +353,7 @@ namespace Server
|
|||
if (value == null)
|
||||
Write(0);
|
||||
else
|
||||
Write(value.Id);
|
||||
Write(value.Serial);
|
||||
}
|
||||
|
||||
public void WriteItem<T>(T value) where T : Item
|
||||
|
|
@ -387,7 +389,7 @@ namespace Server
|
|||
public void WriteItemList<T>(List<T> list, bool tidy) where T : Item
|
||||
{
|
||||
if (tidy)
|
||||
for (int i = 0; i < list.Count;)
|
||||
for (var i = 0; i < list.Count;)
|
||||
if (list[i].Deleted)
|
||||
list.RemoveAt(i);
|
||||
else
|
||||
|
|
@ -395,7 +397,7 @@ namespace Server
|
|||
|
||||
Write(list.Count);
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
Write(list[i]);
|
||||
}
|
||||
|
||||
|
|
@ -410,7 +412,7 @@ namespace Server
|
|||
|
||||
Write(set.Count);
|
||||
|
||||
foreach (Item item in set) Write(item);
|
||||
foreach (var item in set) Write(item);
|
||||
}
|
||||
|
||||
public void WriteItemSet<T>(HashSet<T> set) where T : Item
|
||||
|
|
@ -424,7 +426,7 @@ namespace Server
|
|||
|
||||
Write(set.Count);
|
||||
|
||||
foreach (T item in set) Write(item);
|
||||
foreach (var item in set) Write(item);
|
||||
}
|
||||
|
||||
public void Write(List<Mobile> list)
|
||||
|
|
@ -435,7 +437,7 @@ namespace Server
|
|||
public void Write(List<Mobile> list, bool tidy)
|
||||
{
|
||||
if (tidy)
|
||||
for (int i = 0; i < list.Count;)
|
||||
for (var i = 0; i < list.Count;)
|
||||
if (list[i].Deleted)
|
||||
list.RemoveAt(i);
|
||||
else
|
||||
|
|
@ -443,7 +445,7 @@ namespace Server
|
|||
|
||||
Write(list.Count);
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
Write(list[i]);
|
||||
}
|
||||
|
||||
|
|
@ -455,7 +457,7 @@ namespace Server
|
|||
public void WriteMobileList<T>(List<T> list, bool tidy) where T : Mobile
|
||||
{
|
||||
if (tidy)
|
||||
for (int i = 0; i < list.Count;)
|
||||
for (var i = 0; i < list.Count;)
|
||||
if (list[i].Deleted)
|
||||
list.RemoveAt(i);
|
||||
else
|
||||
|
|
@ -463,7 +465,7 @@ namespace Server
|
|||
|
||||
Write(list.Count);
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
Write(list[i]);
|
||||
}
|
||||
|
||||
|
|
@ -478,7 +480,7 @@ namespace Server
|
|||
|
||||
Write(set.Count);
|
||||
|
||||
foreach (Mobile mob in set) Write(mob);
|
||||
foreach (var mob in set) Write(mob);
|
||||
}
|
||||
|
||||
public void WriteMobileSet<T>(HashSet<T> set) where T : Mobile
|
||||
|
|
@ -492,7 +494,7 @@ namespace Server
|
|||
|
||||
Write(set.Count);
|
||||
|
||||
foreach (T mob in set) Write(mob);
|
||||
foreach (var mob in set) Write(mob);
|
||||
}
|
||||
|
||||
public void Write(List<BaseGuild> list)
|
||||
|
|
@ -503,7 +505,7 @@ namespace Server
|
|||
public void Write(List<BaseGuild> list, bool tidy)
|
||||
{
|
||||
if (tidy)
|
||||
for (int i = 0; i < list.Count;)
|
||||
for (var i = 0; i < list.Count;)
|
||||
if (list[i].Disbanded)
|
||||
list.RemoveAt(i);
|
||||
else
|
||||
|
|
@ -511,7 +513,7 @@ namespace Server
|
|||
|
||||
Write(list.Count);
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
Write(list[i]);
|
||||
}
|
||||
|
||||
|
|
@ -523,7 +525,7 @@ namespace Server
|
|||
public void WriteGuildList<T>(List<T> list, bool tidy) where T : BaseGuild
|
||||
{
|
||||
if (tidy)
|
||||
for (int i = 0; i < list.Count;)
|
||||
for (var i = 0; i < list.Count;)
|
||||
if (list[i].Disbanded)
|
||||
list.RemoveAt(i);
|
||||
else
|
||||
|
|
@ -531,7 +533,7 @@ namespace Server
|
|||
|
||||
Write(list.Count);
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
Write(list[i]);
|
||||
}
|
||||
|
||||
|
|
@ -546,7 +548,7 @@ namespace Server
|
|||
|
||||
Write(set.Count);
|
||||
|
||||
foreach (BaseGuild guild in set) Write(guild);
|
||||
foreach (var guild in set) Write(guild);
|
||||
}
|
||||
|
||||
public void WriteGuildSet<T>(HashSet<T> set) where T : BaseGuild
|
||||
|
|
@ -560,7 +562,7 @@ namespace Server
|
|||
|
||||
Write(set.Count);
|
||||
|
||||
foreach (T guild in set) Write(guild);
|
||||
foreach (var guild in set) Write(guild);
|
||||
}
|
||||
|
||||
private class WorkerThread
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019 - ModernUO Development Team *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: BinaryFileReader.cs *
|
||||
* Created: 2019/12/30 - Updated: 2020/01/18 *
|
||||
|
|
@ -46,8 +46,8 @@ namespace Server
|
|||
|
||||
public DateTime ReadDeltaTime()
|
||||
{
|
||||
long ticks = m_File.ReadInt64();
|
||||
long now = DateTime.UtcNow.Ticks;
|
||||
var ticks = m_File.ReadInt64();
|
||||
var now = DateTime.UtcNow.Ticks;
|
||||
|
||||
if (ticks > 0 && ticks + now < 0)
|
||||
return DateTime.MaxValue;
|
||||
|
|
@ -85,8 +85,8 @@ namespace Server
|
|||
|
||||
public DateTimeOffset ReadDateTimeOffset()
|
||||
{
|
||||
long ticks = m_File.ReadInt64();
|
||||
TimeSpan offset = new TimeSpan(m_File.ReadInt64());
|
||||
var ticks = m_File.ReadInt64();
|
||||
var offset = new TimeSpan(m_File.ReadInt64());
|
||||
|
||||
return new DateTimeOffset(ticks, offset);
|
||||
}
|
||||
|
|
@ -151,13 +151,13 @@ namespace Server
|
|||
|
||||
public List<T> ReadStrongItemList<T>() where T : Item
|
||||
{
|
||||
int count = ReadInt();
|
||||
var count = ReadInt();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
List<T> list = new List<T>(count);
|
||||
var list = new List<T>(count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
for (var i = 0; i < count; ++i)
|
||||
if (ReadItem() is T item)
|
||||
list.Add(item);
|
||||
|
||||
|
|
@ -171,13 +171,13 @@ namespace Server
|
|||
|
||||
public HashSet<T> ReadItemSet<T>() where T : Item
|
||||
{
|
||||
int count = ReadInt();
|
||||
var count = ReadInt();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
HashSet<T> set = new HashSet<T>();
|
||||
var set = new HashSet<T>();
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
for (var i = 0; i < count; ++i)
|
||||
if (ReadItem() is T item)
|
||||
set.Add(item);
|
||||
|
||||
|
|
@ -191,13 +191,13 @@ namespace Server
|
|||
|
||||
public List<T> ReadStrongMobileList<T>() where T : Mobile
|
||||
{
|
||||
int count = ReadInt();
|
||||
var count = ReadInt();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
List<T> list = new List<T>(count);
|
||||
var list = new List<T>(count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
for (var i = 0; i < count; ++i)
|
||||
if (ReadMobile() is T m)
|
||||
list.Add(m);
|
||||
|
||||
|
|
@ -211,13 +211,13 @@ namespace Server
|
|||
|
||||
public HashSet<T> ReadMobileSet<T>() where T : Mobile
|
||||
{
|
||||
int count = ReadInt();
|
||||
var count = ReadInt();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
HashSet<T> set = new HashSet<T>();
|
||||
var set = new HashSet<T>();
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
for (var i = 0; i < count; ++i)
|
||||
if (ReadMobile() is T item)
|
||||
set.Add(item);
|
||||
|
||||
|
|
@ -231,13 +231,13 @@ namespace Server
|
|||
|
||||
public List<T> ReadStrongGuildList<T>() where T : BaseGuild
|
||||
{
|
||||
int count = ReadInt();
|
||||
var count = ReadInt();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
List<T> list = new List<T>(count);
|
||||
var list = new List<T>(count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
for (var i = 0; i < count; ++i)
|
||||
if (ReadGuild() is T g)
|
||||
list.Add(g);
|
||||
|
||||
|
|
@ -251,13 +251,13 @@ namespace Server
|
|||
|
||||
public HashSet<T> ReadGuildSet<T>() where T : BaseGuild
|
||||
{
|
||||
int count = ReadInt();
|
||||
var count = ReadInt();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
HashSet<T> set = new HashSet<T>();
|
||||
var set = new HashSet<T>();
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
for (var i = 0; i < count; ++i)
|
||||
if (ReadGuild() is T item)
|
||||
set.Add(item);
|
||||
|
||||
|
|
@ -271,5 +271,4 @@ namespace Server
|
|||
|
||||
public bool End() => m_File.PeekChar() == -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019 - ModernUO Development Team *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: BinaryFileWriter.cs *
|
||||
* Created: 2019/12/30 - Updated: 2020/01/18 *
|
||||
|
|
@ -22,8 +22,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Server.Guilds;
|
||||
|
||||
namespace Server
|
||||
|
|
@ -45,11 +45,11 @@ namespace Server
|
|||
private long m_Position;
|
||||
|
||||
private readonly char[] m_SingleCharBuffer = new char[1];
|
||||
private readonly bool PrefixStrings;
|
||||
private readonly bool m_PrefixStrings;
|
||||
|
||||
public BinaryFileWriter(Stream strm, bool prefixStr)
|
||||
{
|
||||
PrefixStrings = prefixStr;
|
||||
m_PrefixStrings = prefixStr;
|
||||
m_Encoding = Utility.UTF8;
|
||||
m_Buffer = new byte[BufferSize];
|
||||
m_File = strm;
|
||||
|
|
@ -57,7 +57,7 @@ namespace Server
|
|||
|
||||
public BinaryFileWriter(string filename, bool prefixStr)
|
||||
{
|
||||
PrefixStrings = prefixStr;
|
||||
m_PrefixStrings = prefixStr;
|
||||
m_Buffer = new byte[BufferSize];
|
||||
m_File = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
m_Encoding = Utility.UTF8WithEncoding;
|
||||
|
|
@ -99,7 +99,7 @@ namespace Server
|
|||
|
||||
public void WriteEncodedInt(int value)
|
||||
{
|
||||
uint v = (uint)value;
|
||||
var v = (uint)value;
|
||||
|
||||
while (v >= 0x80)
|
||||
{
|
||||
|
|
@ -118,7 +118,7 @@ namespace Server
|
|||
|
||||
internal void InternalWriteString(string value)
|
||||
{
|
||||
int length = m_Encoding.GetByteCount(value);
|
||||
var length = m_Encoding.GetByteCount(value);
|
||||
|
||||
WriteEncodedInt(length);
|
||||
|
||||
|
|
@ -130,13 +130,13 @@ namespace Server
|
|||
|
||||
if (length > LargeByteBufferSize)
|
||||
{
|
||||
int current = 0;
|
||||
int charsLeft = value.Length;
|
||||
var current = 0;
|
||||
var charsLeft = value.Length;
|
||||
|
||||
while (charsLeft > 0)
|
||||
{
|
||||
int charCount = charsLeft > m_MaxBufferChars ? m_MaxBufferChars : charsLeft;
|
||||
int byteLength = m_Encoding.GetBytes(value, current, charCount, m_CharacterBuffer, 0);
|
||||
var charCount = charsLeft > m_MaxBufferChars ? m_MaxBufferChars : charsLeft;
|
||||
var byteLength = m_Encoding.GetBytes(value, current, charCount, m_CharacterBuffer, 0);
|
||||
|
||||
if (m_Index + byteLength > m_Buffer.Length)
|
||||
Flush();
|
||||
|
|
@ -150,7 +150,7 @@ namespace Server
|
|||
}
|
||||
else
|
||||
{
|
||||
int byteLength = m_Encoding.GetBytes(value, 0, value.Length, m_CharacterBuffer, 0);
|
||||
var byteLength = m_Encoding.GetBytes(value, 0, value.Length, m_CharacterBuffer, 0);
|
||||
|
||||
if (m_Index + byteLength > m_Buffer.Length)
|
||||
Flush();
|
||||
|
|
@ -162,7 +162,7 @@ namespace Server
|
|||
|
||||
public void Write(string value)
|
||||
{
|
||||
if (PrefixStrings)
|
||||
if (m_PrefixStrings)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
|
|
@ -200,8 +200,8 @@ namespace Server
|
|||
|
||||
public void WriteDeltaTime(DateTime value)
|
||||
{
|
||||
long ticks = value.Ticks;
|
||||
long now = DateTime.UtcNow.Ticks;
|
||||
var ticks = value.Ticks;
|
||||
var now = DateTime.UtcNow.Ticks;
|
||||
|
||||
TimeSpan d;
|
||||
|
||||
|
|
@ -229,9 +229,9 @@ namespace Server
|
|||
|
||||
public void Write(decimal value)
|
||||
{
|
||||
int[] bits = decimal.GetBits(value);
|
||||
var bits = decimal.GetBits(value);
|
||||
|
||||
for (int i = 0; i < bits.Length; ++i)
|
||||
for (var i = 0; i < bits.Length; ++i)
|
||||
Write(bits[i]);
|
||||
}
|
||||
|
||||
|
|
@ -344,7 +344,7 @@ namespace Server
|
|||
|
||||
m_SingleCharBuffer[0] = value;
|
||||
|
||||
int byteCount = m_Encoding.GetBytes(m_SingleCharBuffer, 0, 1, m_Buffer, m_Index);
|
||||
var byteCount = m_Encoding.GetBytes(m_SingleCharBuffer, 0, 1, m_Buffer, m_Index);
|
||||
m_Index += byteCount;
|
||||
}
|
||||
|
||||
|
|
@ -369,6 +369,7 @@ namespace Server
|
|||
Buffer.BlockCopy(value, 0, m_Buffer, m_Index, length);
|
||||
m_Index += length;
|
||||
}
|
||||
|
||||
public void Write(sbyte value)
|
||||
{
|
||||
if (m_Index + 1 > m_Buffer.Length)
|
||||
|
|
@ -455,7 +456,7 @@ namespace Server
|
|||
if (value == null)
|
||||
Write(0);
|
||||
else
|
||||
Write(value.Id);
|
||||
Write(value.Serial);
|
||||
}
|
||||
|
||||
public void WriteItem<T>(T value) where T : Item
|
||||
|
|
@ -491,7 +492,7 @@ namespace Server
|
|||
public void WriteItemList<T>(List<T> list, bool tidy) where T : Item
|
||||
{
|
||||
if (tidy)
|
||||
for (int i = 0; i < list.Count;)
|
||||
for (var i = 0; i < list.Count;)
|
||||
if (list[i]?.Deleted != false)
|
||||
list.RemoveAt(i);
|
||||
else
|
||||
|
|
@ -499,7 +500,7 @@ namespace Server
|
|||
|
||||
Write(list.Count);
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
Write(list[i]);
|
||||
}
|
||||
|
||||
|
|
@ -514,7 +515,7 @@ namespace Server
|
|||
|
||||
Write(set.Count);
|
||||
|
||||
foreach (Item item in set) Write(item);
|
||||
foreach (var item in set) Write(item);
|
||||
}
|
||||
|
||||
public void WriteItemSet<T>(HashSet<T> set) where T : Item
|
||||
|
|
@ -528,7 +529,7 @@ namespace Server
|
|||
|
||||
Write(set.Count);
|
||||
|
||||
foreach (T item in set) Write(item);
|
||||
foreach (var item in set) Write(item);
|
||||
}
|
||||
|
||||
public void Write(List<Mobile> list)
|
||||
|
|
@ -539,7 +540,7 @@ namespace Server
|
|||
public void Write(List<Mobile> list, bool tidy)
|
||||
{
|
||||
if (tidy)
|
||||
for (int i = 0; i < list.Count;)
|
||||
for (var i = 0; i < list.Count;)
|
||||
if (list[i].Deleted)
|
||||
list.RemoveAt(i);
|
||||
else
|
||||
|
|
@ -547,7 +548,7 @@ namespace Server
|
|||
|
||||
Write(list.Count);
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
Write(list[i]);
|
||||
}
|
||||
|
||||
|
|
@ -559,7 +560,7 @@ namespace Server
|
|||
public void WriteMobileList<T>(List<T> list, bool tidy) where T : Mobile
|
||||
{
|
||||
if (tidy)
|
||||
for (int i = 0; i < list.Count;)
|
||||
for (var i = 0; i < list.Count;)
|
||||
if (list[i].Deleted)
|
||||
list.RemoveAt(i);
|
||||
else
|
||||
|
|
@ -567,7 +568,7 @@ namespace Server
|
|||
|
||||
Write(list.Count);
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
Write(list[i]);
|
||||
}
|
||||
|
||||
|
|
@ -582,7 +583,7 @@ namespace Server
|
|||
|
||||
Write(set.Count);
|
||||
|
||||
foreach (Mobile mob in set) Write(mob);
|
||||
foreach (var mob in set) Write(mob);
|
||||
}
|
||||
|
||||
public void WriteMobileSet<T>(HashSet<T> set) where T : Mobile
|
||||
|
|
@ -596,7 +597,7 @@ namespace Server
|
|||
|
||||
Write(set.Count);
|
||||
|
||||
foreach (T mob in set) Write(mob);
|
||||
foreach (var mob in set) Write(mob);
|
||||
}
|
||||
|
||||
public void Write(List<BaseGuild> list)
|
||||
|
|
@ -607,7 +608,7 @@ namespace Server
|
|||
public void Write(List<BaseGuild> list, bool tidy)
|
||||
{
|
||||
if (tidy)
|
||||
for (int i = 0; i < list.Count;)
|
||||
for (var i = 0; i < list.Count;)
|
||||
if (list[i].Disbanded)
|
||||
list.RemoveAt(i);
|
||||
else
|
||||
|
|
@ -615,7 +616,7 @@ namespace Server
|
|||
|
||||
Write(list.Count);
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
Write(list[i]);
|
||||
}
|
||||
|
||||
|
|
@ -627,7 +628,7 @@ namespace Server
|
|||
public void WriteGuildList<T>(List<T> list, bool tidy) where T : BaseGuild
|
||||
{
|
||||
if (tidy)
|
||||
for (int i = 0; i < list.Count;)
|
||||
for (var i = 0; i < list.Count;)
|
||||
if (list[i].Disbanded)
|
||||
list.RemoveAt(i);
|
||||
else
|
||||
|
|
@ -635,7 +636,7 @@ namespace Server
|
|||
|
||||
Write(list.Count);
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
Write(list[i]);
|
||||
}
|
||||
|
||||
|
|
@ -650,7 +651,7 @@ namespace Server
|
|||
|
||||
Write(set.Count);
|
||||
|
||||
foreach (BaseGuild guild in set) Write(guild);
|
||||
foreach (var guild in set) Write(guild);
|
||||
}
|
||||
|
||||
public void WriteGuildSet<T>(HashSet<T> set) where T : BaseGuild
|
||||
|
|
@ -664,8 +665,7 @@ namespace Server
|
|||
|
||||
Write(set.Count);
|
||||
|
||||
foreach (T guild in set) Write(guild);
|
||||
foreach (var guild in set) Write(guild);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019 - ModernUO Development Team *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: BufferWriter.cs *
|
||||
* Created: 2019/12/30 - Updated: 2020/01/18 *
|
||||
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Server.Guilds;
|
||||
|
||||
namespace Server
|
||||
|
|
@ -41,11 +41,11 @@ namespace Server
|
|||
private int m_MaxBufferChars;
|
||||
|
||||
private readonly char[] m_SingleCharBuffer = new char[1];
|
||||
private readonly bool PrefixStrings;
|
||||
private readonly bool m_PrefixStrings;
|
||||
|
||||
public BufferWriter(bool prefixStr)
|
||||
{
|
||||
PrefixStrings = prefixStr;
|
||||
m_PrefixStrings = prefixStr;
|
||||
m_Encoding = Utility.UTF8;
|
||||
m_Buffer = new byte[BufferSize];
|
||||
}
|
||||
|
|
@ -59,6 +59,7 @@ namespace Server
|
|||
public void Close()
|
||||
{
|
||||
}
|
||||
|
||||
public void Flush()
|
||||
{
|
||||
m_Index = 0;
|
||||
|
|
@ -66,14 +67,14 @@ namespace Server
|
|||
|
||||
private void Expand()
|
||||
{
|
||||
byte[] newBuffer = new byte[BufferSize * 2];
|
||||
var newBuffer = new byte[BufferSize * 2];
|
||||
Buffer.BlockCopy(m_Buffer, 0, newBuffer, 0, m_Buffer.Length);
|
||||
m_Buffer = newBuffer;
|
||||
}
|
||||
|
||||
public void WriteEncodedInt(int value)
|
||||
{
|
||||
uint v = (uint)value;
|
||||
var v = (uint)value;
|
||||
|
||||
while (v >= 0x80)
|
||||
{
|
||||
|
|
@ -92,7 +93,7 @@ namespace Server
|
|||
|
||||
internal void InternalWriteString(string value)
|
||||
{
|
||||
int length = m_Encoding.GetByteCount(value);
|
||||
var length = m_Encoding.GetByteCount(value);
|
||||
|
||||
WriteEncodedInt(length);
|
||||
|
||||
|
|
@ -104,13 +105,13 @@ namespace Server
|
|||
|
||||
if (length > LargeByteBufferSize)
|
||||
{
|
||||
int current = 0;
|
||||
int charsLeft = value.Length;
|
||||
var current = 0;
|
||||
var charsLeft = value.Length;
|
||||
|
||||
while (charsLeft > 0)
|
||||
{
|
||||
int charCount = charsLeft > m_MaxBufferChars ? m_MaxBufferChars : charsLeft;
|
||||
int byteLength = m_Encoding.GetBytes(value, current, charCount, m_CharacterBuffer, 0);
|
||||
var charCount = charsLeft > m_MaxBufferChars ? m_MaxBufferChars : charsLeft;
|
||||
var byteLength = m_Encoding.GetBytes(value, current, charCount, m_CharacterBuffer, 0);
|
||||
|
||||
if (m_Index + byteLength > m_Buffer.Length)
|
||||
Expand();
|
||||
|
|
@ -124,7 +125,7 @@ namespace Server
|
|||
}
|
||||
else
|
||||
{
|
||||
int byteLength = m_Encoding.GetBytes(value, 0, value.Length, m_CharacterBuffer, 0);
|
||||
var byteLength = m_Encoding.GetBytes(value, 0, value.Length, m_CharacterBuffer, 0);
|
||||
|
||||
if (m_Index + byteLength > m_Buffer.Length)
|
||||
Expand();
|
||||
|
|
@ -136,7 +137,7 @@ namespace Server
|
|||
|
||||
public void Write(string value)
|
||||
{
|
||||
if (PrefixStrings)
|
||||
if (m_PrefixStrings)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
|
|
@ -174,8 +175,8 @@ namespace Server
|
|||
|
||||
public void WriteDeltaTime(DateTime value)
|
||||
{
|
||||
long ticks = value.Ticks;
|
||||
long now = DateTime.UtcNow.Ticks;
|
||||
var ticks = value.Ticks;
|
||||
var now = DateTime.UtcNow.Ticks;
|
||||
|
||||
TimeSpan d;
|
||||
|
||||
|
|
@ -203,9 +204,9 @@ namespace Server
|
|||
|
||||
public void Write(decimal value)
|
||||
{
|
||||
int[] bits = decimal.GetBits(value);
|
||||
var bits = decimal.GetBits(value);
|
||||
|
||||
for (int i = 0; i < bits.Length; ++i)
|
||||
for (var i = 0; i < bits.Length; ++i)
|
||||
Write(bits[i]);
|
||||
}
|
||||
|
||||
|
|
@ -318,7 +319,7 @@ namespace Server
|
|||
|
||||
m_SingleCharBuffer[0] = value;
|
||||
|
||||
int byteCount = m_Encoding.GetBytes(m_SingleCharBuffer, 0, 1, m_Buffer, m_Index);
|
||||
var byteCount = m_Encoding.GetBytes(m_SingleCharBuffer, 0, 1, m_Buffer, m_Index);
|
||||
m_Index += byteCount;
|
||||
}
|
||||
|
||||
|
|
@ -343,6 +344,7 @@ namespace Server
|
|||
Buffer.BlockCopy(value, 0, m_Buffer, m_Index, length);
|
||||
m_Index += length;
|
||||
}
|
||||
|
||||
public void Write(sbyte value)
|
||||
{
|
||||
if (m_Index + 1 > m_Buffer.Length)
|
||||
|
|
@ -420,7 +422,7 @@ namespace Server
|
|||
if (value == null)
|
||||
Write(0);
|
||||
else
|
||||
Write(value.Id);
|
||||
Write(value.Serial);
|
||||
}
|
||||
|
||||
public void WriteItem<T>(T value) where T : Item
|
||||
|
|
@ -456,7 +458,7 @@ namespace Server
|
|||
public void WriteItemList<T>(List<T> list, bool tidy) where T : Item
|
||||
{
|
||||
if (tidy)
|
||||
for (int i = 0; i < list.Count;)
|
||||
for (var i = 0; i < list.Count;)
|
||||
if (list[i].Deleted)
|
||||
list.RemoveAt(i);
|
||||
else
|
||||
|
|
@ -464,7 +466,7 @@ namespace Server
|
|||
|
||||
Write(list.Count);
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
Write(list[i]);
|
||||
}
|
||||
|
||||
|
|
@ -479,7 +481,7 @@ namespace Server
|
|||
|
||||
Write(set.Count);
|
||||
|
||||
foreach (Item item in set) Write(item);
|
||||
foreach (var item in set) Write(item);
|
||||
}
|
||||
|
||||
public void WriteItemSet<T>(HashSet<T> set) where T : Item
|
||||
|
|
@ -493,7 +495,7 @@ namespace Server
|
|||
|
||||
Write(set.Count);
|
||||
|
||||
foreach (T item in set) Write(item);
|
||||
foreach (var item in set) Write(item);
|
||||
}
|
||||
|
||||
public void Write(List<Mobile> list)
|
||||
|
|
@ -504,7 +506,7 @@ namespace Server
|
|||
public void Write(List<Mobile> list, bool tidy)
|
||||
{
|
||||
if (tidy)
|
||||
for (int i = 0; i < list.Count;)
|
||||
for (var i = 0; i < list.Count;)
|
||||
if (list[i].Deleted)
|
||||
list.RemoveAt(i);
|
||||
else
|
||||
|
|
@ -512,7 +514,7 @@ namespace Server
|
|||
|
||||
Write(list.Count);
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
Write(list[i]);
|
||||
}
|
||||
|
||||
|
|
@ -524,7 +526,7 @@ namespace Server
|
|||
public void WriteMobileList<T>(List<T> list, bool tidy) where T : Mobile
|
||||
{
|
||||
if (tidy)
|
||||
for (int i = 0; i < list.Count;)
|
||||
for (var i = 0; i < list.Count;)
|
||||
if (list[i].Deleted)
|
||||
list.RemoveAt(i);
|
||||
else
|
||||
|
|
@ -532,7 +534,7 @@ namespace Server
|
|||
|
||||
Write(list.Count);
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
Write(list[i]);
|
||||
}
|
||||
|
||||
|
|
@ -547,7 +549,7 @@ namespace Server
|
|||
|
||||
Write(set.Count);
|
||||
|
||||
foreach (Mobile mob in set) Write(mob);
|
||||
foreach (var mob in set) Write(mob);
|
||||
}
|
||||
|
||||
public void WriteMobileSet<T>(HashSet<T> set) where T : Mobile
|
||||
|
|
@ -561,7 +563,7 @@ namespace Server
|
|||
|
||||
Write(set.Count);
|
||||
|
||||
foreach (T mob in set) Write(mob);
|
||||
foreach (var mob in set) Write(mob);
|
||||
}
|
||||
|
||||
public void Write(List<BaseGuild> list)
|
||||
|
|
@ -572,7 +574,7 @@ namespace Server
|
|||
public void Write(List<BaseGuild> list, bool tidy)
|
||||
{
|
||||
if (tidy)
|
||||
for (int i = 0; i < list.Count;)
|
||||
for (var i = 0; i < list.Count;)
|
||||
if (list[i].Disbanded)
|
||||
list.RemoveAt(i);
|
||||
else
|
||||
|
|
@ -580,7 +582,7 @@ namespace Server
|
|||
|
||||
Write(list.Count);
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
Write(list[i]);
|
||||
}
|
||||
|
||||
|
|
@ -592,7 +594,7 @@ namespace Server
|
|||
public void WriteGuildList<T>(List<T> list, bool tidy) where T : BaseGuild
|
||||
{
|
||||
if (tidy)
|
||||
for (int i = 0; i < list.Count;)
|
||||
for (var i = 0; i < list.Count;)
|
||||
if (list[i].Disbanded)
|
||||
list.RemoveAt(i);
|
||||
else
|
||||
|
|
@ -600,7 +602,7 @@ namespace Server
|
|||
|
||||
Write(list.Count);
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
Write(list[i]);
|
||||
}
|
||||
|
||||
|
|
@ -615,7 +617,7 @@ namespace Server
|
|||
|
||||
Write(set.Count);
|
||||
|
||||
foreach (BaseGuild guild in set) Write(guild);
|
||||
foreach (var guild in set) Write(guild);
|
||||
}
|
||||
|
||||
public void WriteGuildSet<T>(HashSet<T> set) where T : BaseGuild
|
||||
|
|
@ -629,7 +631,7 @@ namespace Server
|
|||
|
||||
Write(set.Count);
|
||||
|
||||
foreach (T guild in set) Write(guild);
|
||||
foreach (var guild in set) Write(guild);
|
||||
}
|
||||
|
||||
public void WriteTo(IGenericWriter writer)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019 - ModernUO Development Team *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: IGenericReader.cs *
|
||||
* Created: 2019/12/30 - Updated: 2020/01/18 *
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019 - ModernUO Development Team *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: IGenericWriter.cs *
|
||||
* Created: 2019/12/30 - Updated: 2020/01/18 *
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019 - ModernUO Development Team *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: ISerializable.cs *
|
||||
* Created: 2019/12/30 - Updated: 2020/01/18 *
|
||||
|
|
@ -24,8 +24,8 @@ namespace Server
|
|||
public interface ISerializable
|
||||
{
|
||||
BufferWriter SaveBuffer { get; }
|
||||
int TypeReference { get; }
|
||||
uint SerialIdentity { get; }
|
||||
int TypeRef { get; }
|
||||
Serial Serial { get; }
|
||||
void Serialize();
|
||||
void Serialize(IGenericWriter writer);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue