Adds style cop (#109)
This commit is contained in:
parent
3e715bcb60
commit
556a17aba8
1725 changed files with 33831 additions and 38046 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue