Adds style cop (#109)

This commit is contained in:
Kamron Batman 2020-04-26 00:16:02 -07:00 • committed by GitHub
parent 3e715bcb60
commit 556a17aba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1725 changed files with 33831 additions and 38046 deletions

View file

@ -35,13 +35,13 @@ namespace Server.Items
public abstract class BaseBulletinBoard : Item
{
// Threads will be removed six hours after the last post was made
private static TimeSpan ThreadDeletionTime = TimeSpan.FromHours(6.0);
private static readonly TimeSpan ThreadDeletionTime = TimeSpan.FromHours(6.0);
// A player may only create a thread once every two minutes
private static TimeSpan ThreadCreateTime = TimeSpan.FromMinutes(2.0);
private static readonly TimeSpan ThreadCreateTime = TimeSpan.FromMinutes(2.0);
// A player may only reply once every thirty seconds
private static TimeSpan ThreadReplyTime = TimeSpan.FromSeconds(30.0);
private static readonly TimeSpan ThreadReplyTime = TimeSpan.FromSeconds(30.0);
public BaseBulletinBoard(int itemID) : base(itemID)
{
@ -54,7 +54,7 @@ namespace Server.Items
}
[CommandProperty(AccessLevel.GameMaster)]
public string BoardName{ get; set; }
public string BoardName { get; set; }
public static bool CheckTime(DateTime time, TimeSpan range) => time + range < DateTime.UtcNow;
@ -192,10 +192,10 @@ namespace Server.Items
switch (version)
{
case 0:
{
BoardName = reader.ReadString();
break;
}
{
BoardName = reader.ReadString();
break;
}
}
}
@ -344,25 +344,25 @@ namespace Server.Items
{
}
public Mobile Poster{ get; private set; }
public Mobile Poster { get; private set; }
public BulletinMessage Thread{ get; private set; }
public BulletinMessage Thread { get; private set; }
public string Subject{ get; private set; }
public string Subject { get; private set; }
public DateTime Time{ get; private set; }
public DateTime Time { get; private set; }
public DateTime LastPostTime{ get; set; }
public DateTime LastPostTime { get; set; }
public string PostedName{ get; private set; }
public string PostedName { get; private set; }
public int PostedBody{ get; private set; }
public int PostedBody { get; private set; }
public int PostedHue{ get; private set; }
public int PostedHue { get; private set; }
public BulletinEquip[] PostedEquip{ get; private set; }
public BulletinEquip[] PostedEquip { get; private set; }
public string[] Lines{ get; private set; }
public string[] Lines { get; private set; }
public string GetTimeAsString() => Time.ToString("MMM dd, yyyy");
@ -410,38 +410,38 @@ namespace Server.Items
{
case 1:
case 0:
{
Poster = reader.ReadMobile();
Subject = reader.ReadString();
Time = reader.ReadDateTime();
LastPostTime = reader.ReadDateTime();
bool hasThread = reader.ReadBool();
Thread = reader.ReadItem() as BulletinMessage;
PostedName = reader.ReadString();
PostedBody = reader.ReadInt();
PostedHue = reader.ReadInt();
PostedEquip = new BulletinEquip[reader.ReadInt()];
for (int i = 0; i < PostedEquip.Length; ++i)
{
PostedEquip[i].itemID = reader.ReadInt();
PostedEquip[i].hue = reader.ReadInt();
Poster = reader.ReadMobile();
Subject = reader.ReadString();
Time = reader.ReadDateTime();
LastPostTime = reader.ReadDateTime();
bool hasThread = reader.ReadBool();
Thread = reader.ReadItem() as BulletinMessage;
PostedName = reader.ReadString();
PostedBody = reader.ReadInt();
PostedHue = reader.ReadInt();
PostedEquip = new BulletinEquip[reader.ReadInt()];
for (int i = 0; i < PostedEquip.Length; ++i)
{
PostedEquip[i].itemID = reader.ReadInt();
PostedEquip[i].hue = reader.ReadInt();
}
Lines = new string[reader.ReadInt()];
for (int i = 0; i < Lines.Length; ++i)
Lines[i] = reader.ReadString();
if (hasThread && Thread == null)
Delete();
if (version == 0)
ValidationQueue<BulletinMessage>.Add(this);
break;
}
Lines = new string[reader.ReadInt()];
for (int i = 0; i < Lines.Length; ++i)
Lines[i] = reader.ReadString();
if (hasThread && Thread == null)
Delete();
if (version == 0)
ValidationQueue<BulletinMessage>.Add(this);
break;
}
}
}
@ -460,19 +460,19 @@ namespace Server.Items
byte[] buffer = Utility.UTF8.GetBytes(board.BoardName ?? "");
m_Stream.Write((byte)0x00); // PacketID
m_Stream.Write(board.Serial); // Bulletin board serial
Stream.Write((byte)0x00); // PacketID
Stream.Write(board.Serial); // Bulletin board serial
// Bulletin board name
if (buffer.Length >= 29)
{
m_Stream.Write(buffer, 0, 29);
m_Stream.Write((byte)0);
Stream.Write(buffer, 0, 29);
Stream.Write((byte)0);
}
else
{
m_Stream.Write(buffer, 0, buffer.Length);
m_Stream.Fill(30 - buffer.Length);
Stream.Write(buffer, 0, buffer.Length);
Stream.Fill(30 - buffer.Length);
}
}
}
@ -487,16 +487,16 @@ namespace Server.Items
EnsureCapacity(22 + poster.Length + subject.Length + time.Length);
m_Stream.Write((byte)0x01); // PacketID
m_Stream.Write(board.Serial); // Bulletin board serial
m_Stream.Write(msg.Serial); // Message serial
Stream.Write((byte)0x01); // PacketID
Stream.Write(board.Serial); // Bulletin board serial
Stream.Write(msg.Serial); // Message serial
BulletinMessage thread = msg.Thread;
if (thread == null)
m_Stream.Write(0); // Thread serial--root
Stream.Write(0); // Thread serial--root
else
m_Stream.Write(thread.Serial); // Thread serial--parent
Stream.Write(thread.Serial); // Thread serial--parent
WriteString(poster);
WriteString(subject);
@ -511,9 +511,9 @@ namespace Server.Items
if (len > 255)
len = 255;
m_Stream.Write((byte)len);
m_Stream.Write(buffer, 0, len - 1);
m_Stream.Write((byte)0);
Stream.Write((byte)len);
Stream.Write(buffer, 0, len - 1);
Stream.Write((byte)0);
}
public string SafeString(string v) => v ?? string.Empty;
@ -529,30 +529,30 @@ namespace Server.Items
EnsureCapacity(22 + poster.Length + subject.Length + time.Length);
m_Stream.Write((byte)0x02); // PacketID
m_Stream.Write(board.Serial); // Bulletin board serial
m_Stream.Write(msg.Serial); // Message serial
Stream.Write((byte)0x02); // PacketID
Stream.Write(board.Serial); // Bulletin board serial
Stream.Write(msg.Serial); // Message serial
WriteString(poster);
WriteString(subject);
WriteString(time);
m_Stream.Write((short)msg.PostedBody);
m_Stream.Write((short)msg.PostedHue);
Stream.Write((short)msg.PostedBody);
Stream.Write((short)msg.PostedHue);
int len = msg.PostedEquip.Length;
if (len > 255)
len = 255;
m_Stream.Write((byte)len);
Stream.Write((byte)len);
for (int i = 0; i < len; ++i)
{
BulletinEquip eq = msg.PostedEquip[i];
m_Stream.Write((short)eq.itemID);
m_Stream.Write((short)eq.hue);
Stream.Write((short)eq.itemID);
Stream.Write((short)eq.hue);
}
len = msg.Lines.Length;
@ -560,7 +560,7 @@ namespace Server.Items
if (len > 255)
len = 255;
m_Stream.Write((byte)len);
Stream.Write((byte)len);
for (int i = 0; i < len; ++i)
WriteString(msg.Lines[i], true);
@ -580,13 +580,13 @@ namespace Server.Items
if (len > 255)
len = 255;
m_Stream.Write((byte)len);
m_Stream.Write(buffer, 0, len - tail);
Stream.Write((byte)len);
Stream.Write(buffer, 0, len - tail);
if (padding)
m_Stream.Write((short)0); // padding compensates for a client bug
Stream.Write((short)0); // padding compensates for a client bug
else
m_Stream.Write((byte)0);
Stream.Write((byte)0);
}
public string SafeString(string v)