Changes properties to use automatic property initializers

This commit is contained in:
Kamron Batman 2018-09-14 15:23:29 -07:00
parent f0a48ad431
commit 06fa31a7bf
623 changed files with 13072 additions and 19304 deletions

View file

@ -82,13 +82,7 @@ namespace Server
Refresh();
}
private static TimeSpan m_ExpireDelay = TimeSpan.FromMinutes( 2.0 );
public static TimeSpan ExpireDelay
{
get => m_ExpireDelay;
set => m_ExpireDelay = value;
}
public static TimeSpan ExpireDelay { get; set; } = TimeSpan.FromMinutes( 2.0 );
public static void DumpAccess()
{
@ -108,7 +102,7 @@ namespace Server
if ( m_Queued )
DumpAccess();
return ( m_Attacker.Deleted || m_Defender.Deleted || DateTime.UtcNow >= (m_LastCombatTime + m_ExpireDelay) );
return ( m_Attacker.Deleted || m_Defender.Deleted || DateTime.UtcNow >= (m_LastCombatTime + ExpireDelay) );
}
}

View file

@ -59,17 +59,11 @@ namespace Server
[AttributeUsage( AttributeTargets.Method )]
public class CallPriorityAttribute : Attribute
{
private int m_Priority;
public int Priority
{
get => m_Priority;
set => m_Priority = value;
}
public int Priority { get; set; }
public CallPriorityAttribute( int priority )
{
m_Priority = priority;
Priority = priority;
}
}
@ -115,13 +109,11 @@ namespace Server
[AttributeUsage( AttributeTargets.Class )]
public class TypeAliasAttribute : Attribute
{
private string[] m_Aliases;
public string[] Aliases => m_Aliases;
public string[] Aliases { get; }
public TypeAliasAttribute( params string[] aliases )
{
m_Aliases = aliases;
Aliases = aliases;
}
}
@ -136,26 +128,18 @@ namespace Server
[AttributeUsage( AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum )]
public class CustomEnumAttribute : Attribute
{
private string[] m_Names;
public string[] Names => m_Names;
public string[] Names { get; }
public CustomEnumAttribute( string[] names )
{
m_Names = names;
Names = names;
}
}
[AttributeUsage( AttributeTargets.Constructor )]
public class ConstructibleAttribute : Attribute
{
private AccessLevel m_AccessLevel;
public AccessLevel AccessLevel
{
get => m_AccessLevel;
set => m_AccessLevel = value;
}
public AccessLevel AccessLevel { get; set; }
public ConstructibleAttribute() : this( AccessLevel.Player ) //Lowest accesslevel for current functionality (Level determined by access to [add)
{
@ -163,26 +147,23 @@ namespace Server
public ConstructibleAttribute( AccessLevel accessLevel )
{
m_AccessLevel = accessLevel;
AccessLevel = accessLevel;
}
}
[AttributeUsage( AttributeTargets.Property )]
public class CommandPropertyAttribute : Attribute
{
private AccessLevel m_ReadLevel, m_WriteLevel;
private bool m_ReadOnly;
public AccessLevel ReadLevel { get; }
public AccessLevel ReadLevel => m_ReadLevel;
public AccessLevel WriteLevel { get; }
public AccessLevel WriteLevel => m_WriteLevel;
public bool ReadOnly => m_ReadOnly;
public bool ReadOnly { get; }
public CommandPropertyAttribute( AccessLevel level, bool readOnly )
{
m_ReadLevel = level;
m_ReadOnly = readOnly;
ReadLevel = level;
ReadOnly = readOnly;
}
public CommandPropertyAttribute( AccessLevel level ) : this( level, level )
@ -191,8 +172,8 @@ namespace Server
public CommandPropertyAttribute( AccessLevel readLevel, AccessLevel writeLevel )
{
m_ReadLevel = readLevel;
m_WriteLevel = writeLevel;
ReadLevel = readLevel;
WriteLevel = writeLevel;
}
}
}

View file

@ -36,89 +36,71 @@ namespace Server.Mobiles
public class BuyItemResponse
{
private Serial m_Serial;
private int m_Amount;
public BuyItemResponse( Serial serial, int amount )
{
m_Serial = serial;
m_Amount = amount;
Serial = serial;
Amount = amount;
}
public Serial Serial => m_Serial;
public Serial Serial { get; }
public int Amount => m_Amount;
public int Amount { get; }
}
public class SellItemResponse
{
private Item m_Item;
private int m_Amount;
public SellItemResponse( Item i, int amount )
{
m_Item = i;
m_Amount = amount;
Item = i;
Amount = amount;
}
public Item Item => m_Item;
public Item Item { get; }
public int Amount => m_Amount;
public int Amount { get; }
}
public class SellItemState
{
private Item m_Item;
private int m_Price;
private string m_Name;
public SellItemState( Item item, int price, string name )
{
m_Item = item;
m_Price = price;
m_Name = name;
Item = item;
Price = price;
Name = name;
}
public Item Item => m_Item;
public Item Item { get; }
public int Price => m_Price;
public int Price { get; }
public string Name => m_Name;
public string Name { get; }
}
public class BuyItemState
{
private Serial m_ContSer;
private Serial m_MySer;
private int m_ItemID;
private int m_Amount;
private int m_Hue;
private int m_Price;
private string m_Desc;
public BuyItemState( string name, Serial cont, Serial serial, int price, int amount, int itemID, int hue )
{
m_Desc = name;
m_ContSer = cont;
m_MySer = serial;
m_Price = price;
m_Amount = amount;
m_ItemID = itemID;
m_Hue = hue;
Description = name;
ContainerSerial = cont;
MySerial = serial;
Price = price;
Amount = amount;
ItemID = itemID;
Hue = hue;
}
public int Price => m_Price;
public int Price { get; }
public Serial MySerial => m_MySer;
public Serial MySerial { get; }
public Serial ContainerSerial => m_ContSer;
public Serial ContainerSerial { get; }
public int ItemID => m_ItemID;
public int ItemID { get; }
public int Amount => m_Amount;
public int Amount { get; }
public int Hue => m_Hue;
public int Hue { get; }
public string Description => m_Desc;
public string Description { get; }
}
}

View file

@ -35,8 +35,6 @@ namespace Server
public struct Body
{
private int m_BodyID;
private static BodyType[] m_Types;
static Body()
@ -81,88 +79,88 @@ namespace Server
public Body( int bodyID )
{
m_BodyID = bodyID;
BodyID = bodyID;
}
public BodyType Type
{
get
{
if ( m_BodyID >= 0 && m_BodyID < m_Types.Length )
return m_Types[m_BodyID];
if ( BodyID >= 0 && BodyID < m_Types.Length )
return m_Types[BodyID];
return BodyType.Empty;
}
}
public bool IsHuman => m_BodyID >= 0
&& m_BodyID < m_Types.Length
&& m_Types[m_BodyID] == BodyType.Human
&& m_BodyID != 402
&& m_BodyID != 403
&& m_BodyID != 607
&& m_BodyID != 608
&& m_BodyID != 694
&& m_BodyID != 695
&& m_BodyID != 970;
public bool IsHuman => BodyID >= 0
&& BodyID < m_Types.Length
&& m_Types[BodyID] == BodyType.Human
&& BodyID != 402
&& BodyID != 403
&& BodyID != 607
&& BodyID != 608
&& BodyID != 694
&& BodyID != 695
&& BodyID != 970;
public bool IsGargoyle => m_BodyID == 666
|| m_BodyID == 667
|| m_BodyID == 694
|| m_BodyID == 695;
public bool IsGargoyle => BodyID == 666
|| BodyID == 667
|| BodyID == 694
|| BodyID == 695;
public bool IsMale => m_BodyID == 183
|| m_BodyID == 185
|| m_BodyID == 400
|| m_BodyID == 402
|| m_BodyID == 605
|| m_BodyID == 607
|| m_BodyID == 666
|| m_BodyID == 694
|| m_BodyID == 750;
public bool IsMale => BodyID == 183
|| BodyID == 185
|| BodyID == 400
|| BodyID == 402
|| BodyID == 605
|| BodyID == 607
|| BodyID == 666
|| BodyID == 694
|| BodyID == 750;
public bool IsFemale => m_BodyID == 184
|| m_BodyID == 186
|| m_BodyID == 401
|| m_BodyID == 403
|| m_BodyID == 606
|| m_BodyID == 608
|| m_BodyID == 667
|| m_BodyID == 695
|| m_BodyID == 751;
public bool IsFemale => BodyID == 184
|| BodyID == 186
|| BodyID == 401
|| BodyID == 403
|| BodyID == 606
|| BodyID == 608
|| BodyID == 667
|| BodyID == 695
|| BodyID == 751;
public bool IsGhost => m_BodyID == 402
|| m_BodyID == 403
|| m_BodyID == 607
|| m_BodyID == 608
|| m_BodyID == 694
|| m_BodyID == 695
|| m_BodyID == 970;
public bool IsGhost => BodyID == 402
|| BodyID == 403
|| BodyID == 607
|| BodyID == 608
|| BodyID == 694
|| BodyID == 695
|| BodyID == 970;
public bool IsMonster => m_BodyID >= 0
&& m_BodyID < m_Types.Length
&& m_Types[m_BodyID] == BodyType.Monster;
public bool IsMonster => BodyID >= 0
&& BodyID < m_Types.Length
&& m_Types[BodyID] == BodyType.Monster;
public bool IsAnimal => m_BodyID >= 0
&& m_BodyID < m_Types.Length
&& m_Types[m_BodyID] == BodyType.Animal;
public bool IsAnimal => BodyID >= 0
&& BodyID < m_Types.Length
&& m_Types[BodyID] == BodyType.Animal;
public bool IsEmpty => m_BodyID >= 0
&& m_BodyID < m_Types.Length
&& m_Types[m_BodyID] == BodyType.Empty;
public bool IsEmpty => BodyID >= 0
&& BodyID < m_Types.Length
&& m_Types[BodyID] == BodyType.Empty;
public bool IsSea => m_BodyID >= 0
&& m_BodyID < m_Types.Length
&& m_Types[m_BodyID] == BodyType.Sea;
public bool IsSea => BodyID >= 0
&& BodyID < m_Types.Length
&& m_Types[BodyID] == BodyType.Sea;
public bool IsEquipment => m_BodyID >= 0
&& m_BodyID < m_Types.Length
&& m_Types[m_BodyID] == BodyType.Equipment;
public bool IsEquipment => BodyID >= 0
&& BodyID < m_Types.Length
&& m_Types[BodyID] == BodyType.Equipment;
public int BodyID => m_BodyID;
public int BodyID { get; }
public static implicit operator int( Body a )
{
return a.m_BodyID;
return a.BodyID;
}
public static implicit operator Body( int a )
@ -172,49 +170,49 @@ namespace Server
public override string ToString()
{
return $"0x{m_BodyID:X}";
return $"0x{BodyID:X}";
}
public override int GetHashCode()
{
return m_BodyID;
return BodyID;
}
public override bool Equals( object o )
{
if ( !(o is Body) ) return false;
return ((Body)o).m_BodyID == m_BodyID;
return ((Body)o).BodyID == BodyID;
}
public static bool operator == ( Body l, Body r )
{
return l.m_BodyID == r.m_BodyID;
return l.BodyID == r.BodyID;
}
public static bool operator != ( Body l, Body r )
{
return l.m_BodyID != r.m_BodyID;
return l.BodyID != r.BodyID;
}
public static bool operator > ( Body l, Body r )
{
return l.m_BodyID > r.m_BodyID;
return l.BodyID > r.BodyID;
}
public static bool operator >= ( Body l, Body r )
{
return l.m_BodyID >= r.m_BodyID;
return l.BodyID >= r.BodyID;
}
public static bool operator < ( Body l, Body r )
{
return l.m_BodyID < r.m_BodyID;
return l.BodyID < r.BodyID;
}
public static bool operator <= ( Body l, Body r )
{
return l.m_BodyID <= r.m_BodyID;
return l.BodyID <= r.BodyID;
}
}
}

View file

@ -34,21 +34,17 @@ namespace Server
public class ClientVersion : IComparable, IComparer
{
private int m_Major, m_Minor, m_Revision, m_Patch;
private ClientType m_Type;
private string m_SourceString;
public int Major { get; }
public int Major => m_Major;
public int Minor { get; }
public int Minor => m_Minor;
public int Revision { get; }
public int Revision => m_Revision;
public int Patch { get; }
public int Patch => m_Patch;
public ClientType Type { get; }
public ClientType Type => m_Type;
public string SourceString => m_SourceString;
public string SourceString { get; }
public ClientVersion( int maj, int min, int rev, int pat ) : this( maj, min, rev, pat, ClientType.Regular )
{
@ -56,13 +52,13 @@ namespace Server
public ClientVersion( int maj, int min, int rev, int pat, ClientType type )
{
m_Major = maj;
m_Minor = min;
m_Revision = rev;
m_Patch = pat;
m_Type = type;
Major = maj;
Minor = min;
Revision = rev;
Patch = pat;
Type = type;
m_SourceString = _ToStringImpl();
SourceString = _ToStringImpl();
}
public static bool operator == ( ClientVersion l, ClientVersion r )
@ -97,7 +93,7 @@ namespace Server
public override int GetHashCode()
{
return m_Major ^ m_Minor ^ m_Revision ^ m_Patch ^ (int)m_Type;
return Major ^ Minor ^ Revision ^ Patch ^ (int)Type;
}
public override bool Equals( object obj )
@ -110,38 +106,38 @@ namespace Server
if ( v == null )
return false;
return m_Major == v.m_Major
&& m_Minor == v.m_Minor
&& m_Revision == v.m_Revision
&& m_Patch == v.m_Patch
&& m_Type == v.m_Type;
return Major == v.Major
&& Minor == v.Minor
&& Revision == v.Revision
&& Patch == v.Patch
&& Type == v.Type;
}
private string _ToStringImpl()
{
StringBuilder builder = new StringBuilder(16);
builder.Append(m_Major);
builder.Append(Major);
builder.Append('.');
builder.Append(m_Minor);
builder.Append(Minor);
builder.Append('.');
builder.Append(m_Revision);
builder.Append(Revision);
if (m_Major <= 5 && m_Minor <= 0 && m_Revision <= 6) //Anything before 5.0.7
if (Major <= 5 && Minor <= 0 && Revision <= 6) //Anything before 5.0.7
{
if (m_Patch > 0)
builder.Append((char)('a' + (m_Patch - 1)));
if (Patch > 0)
builder.Append((char)('a' + (Patch - 1)));
}
else
{
builder.Append('.');
builder.Append(m_Patch);
builder.Append(Patch);
}
if (m_Type != ClientType.Regular)
if (Type != ClientType.Regular)
{
builder.Append(' ');
builder.Append(m_Type.ToString());
builder.Append(Type.ToString());
}
return builder.ToString();
@ -154,7 +150,7 @@ namespace Server
public ClientVersion( string fmt )
{
m_SourceString = fmt;
SourceString = fmt;
try
{
@ -167,37 +163,37 @@ namespace Server
while ( br3 < fmt.Length && char.IsDigit( fmt, br3 ) )
br3++;
m_Major = Utility.ToInt32( fmt.Substring( 0, br1 ) );
m_Minor = Utility.ToInt32( fmt.Substring( br1 + 1, br2 - br1 - 1 ) );
m_Revision = Utility.ToInt32( fmt.Substring( br2 + 1, br3 - br2 - 1 ) );
Major = Utility.ToInt32( fmt.Substring( 0, br1 ) );
Minor = Utility.ToInt32( fmt.Substring( br1 + 1, br2 - br1 - 1 ) );
Revision = Utility.ToInt32( fmt.Substring( br2 + 1, br3 - br2 - 1 ) );
if ( br3 < fmt.Length )
{
if ( m_Major <= 5 && m_Minor <= 0 && m_Revision <= 6 ) //Anything before 5.0.7
if ( Major <= 5 && Minor <= 0 && Revision <= 6 ) //Anything before 5.0.7
{
if ( !char.IsWhiteSpace( fmt, br3 ) )
m_Patch = (fmt[br3] - 'a') + 1;
Patch = (fmt[br3] - 'a') + 1;
}
else
{
m_Patch = Utility.ToInt32( fmt.Substring( br3+1, fmt.Length - br3 - 1 ) );
Patch = Utility.ToInt32( fmt.Substring( br3+1, fmt.Length - br3 - 1 ) );
}
}
if ( fmt.IndexOf( "god" ) >= 0 || fmt.IndexOf( "gq" ) >= 0 )
m_Type = ClientType.God;
Type = ClientType.God;
else if ( fmt.IndexOf( "third dawn" ) >= 0 || fmt.IndexOf( "uo:td" ) >= 0 || fmt.IndexOf( "uotd" ) >= 0 || fmt.IndexOf( "uo3d" ) >= 0 || fmt.IndexOf( "uo:3d" ) >= 0 )
m_Type = ClientType.UOTD;
Type = ClientType.UOTD;
else
m_Type = ClientType.Regular;
Type = ClientType.Regular;
}
catch
{
m_Major = 0;
m_Minor = 0;
m_Revision = 0;
m_Patch = 0;
m_Type = ClientType.Regular;
Major = 0;
Minor = 0;
Revision = 0;
Patch = 0;
Type = ClientType.Regular;
}
}
@ -211,21 +207,21 @@ namespace Server
if ( o == null )
throw new ArgumentException();
if ( m_Major > o.m_Major )
if ( Major > o.Major )
return 1;
if ( m_Major < o.m_Major )
if ( Major < o.Major )
return -1;
if ( m_Minor > o.m_Minor )
if ( Minor > o.Minor )
return 1;
if ( m_Minor < o.m_Minor )
if ( Minor < o.Minor )
return -1;
if ( m_Revision > o.m_Revision )
if ( Revision > o.Revision )
return 1;
if ( m_Revision < o.m_Revision )
if ( Revision < o.Revision )
return -1;
if ( m_Patch > o.m_Patch )
if ( Patch > o.Patch )
return 1;
if ( m_Patch < o.m_Patch )
if ( Patch < o.Patch )
return -1;
return 0;
}

View file

@ -28,86 +28,78 @@ namespace Server.Commands
public class CommandEventArgs : EventArgs
{
private Mobile m_Mobile;
private string m_Command, m_ArgString;
private string[] m_Arguments;
public Mobile Mobile { get; }
public Mobile Mobile => m_Mobile;
public string Command { get; }
public string Command => m_Command;
public string ArgString { get; }
public string ArgString => m_ArgString;
public string[] Arguments { get; }
public string[] Arguments => m_Arguments;
public int Length => m_Arguments.Length;
public int Length => Arguments.Length;
public string GetString( int index )
{
if ( index < 0 || index >= m_Arguments.Length )
if ( index < 0 || index >= Arguments.Length )
return "";
return m_Arguments[index];
return Arguments[index];
}
public int GetInt32( int index )
{
if ( index < 0 || index >= m_Arguments.Length )
if ( index < 0 || index >= Arguments.Length )
return 0;
return Utility.ToInt32( m_Arguments[index] );
return Utility.ToInt32( Arguments[index] );
}
public bool GetBoolean( int index )
{
if ( index < 0 || index >= m_Arguments.Length )
if ( index < 0 || index >= Arguments.Length )
return false;
return Utility.ToBoolean( m_Arguments[index] );
return Utility.ToBoolean( Arguments[index] );
}
public double GetDouble( int index )
{
if ( index < 0 || index >= m_Arguments.Length )
if ( index < 0 || index >= Arguments.Length )
return 0.0;
return Utility.ToDouble( m_Arguments[index] );
return Utility.ToDouble( Arguments[index] );
}
public TimeSpan GetTimeSpan( int index )
{
if ( index < 0 || index >= m_Arguments.Length )
if ( index < 0 || index >= Arguments.Length )
return TimeSpan.Zero;
return Utility.ToTimeSpan( m_Arguments[index] );
return Utility.ToTimeSpan( Arguments[index] );
}
public CommandEventArgs( Mobile mobile, string command, string argString, string[] arguments )
{
m_Mobile = mobile;
m_Command = command;
m_ArgString = argString;
m_Arguments = arguments;
Mobile = mobile;
Command = command;
ArgString = argString;
Arguments = arguments;
}
}
public class CommandEntry : IComparable
{
private string m_Command;
private CommandEventHandler m_Handler;
private AccessLevel m_AccessLevel;
public string Command { get; }
public string Command => m_Command;
public CommandEventHandler Handler { get; }
public CommandEventHandler Handler => m_Handler;
public AccessLevel AccessLevel => m_AccessLevel;
public AccessLevel AccessLevel { get; }
public CommandEntry( string command, CommandEventHandler handler, AccessLevel accessLevel )
{
m_Command = command;
m_Handler = handler;
m_AccessLevel = accessLevel;
Command = command;
Handler = handler;
AccessLevel = accessLevel;
}
public int CompareTo( object obj )
@ -120,19 +112,13 @@ namespace Server.Commands
if ( !(obj is CommandEntry e) )
throw new ArgumentException();
return m_Command.CompareTo( e.m_Command );
return Command.CompareTo( e.Command );
}
}
public static class CommandSystem
{
private static string m_Prefix = "[";
public static string Prefix
{
get => m_Prefix;
set => m_Prefix = value;
}
public static string Prefix { get; set; } = "[";
public static string[] Split( string value )
{
@ -187,25 +173,19 @@ namespace Server.Commands
return list.ToArray();
}
private static Dictionary<string, CommandEntry> m_Entries;
public static Dictionary<string, CommandEntry> Entries => m_Entries;
public static Dictionary<string, CommandEntry> Entries { get; }
static CommandSystem()
{
m_Entries = new Dictionary<string, CommandEntry>( StringComparer.OrdinalIgnoreCase );
Entries = new Dictionary<string, CommandEntry>( StringComparer.OrdinalIgnoreCase );
}
public static void Register( string command, AccessLevel access, CommandEventHandler handler )
{
m_Entries[command] = new CommandEntry( command, handler, access );
Entries[command] = new CommandEntry( command, handler, access );
}
private static AccessLevel m_BadCommandIngoreLevel = AccessLevel.Player;
public static AccessLevel BadCommandIgnoreLevel{ get => m_BadCommandIngoreLevel;
set => m_BadCommandIngoreLevel = value;
}
public static AccessLevel BadCommandIgnoreLevel { get; set; } = AccessLevel.Player;
public static bool Handle( Mobile from, string text )
{
@ -214,10 +194,10 @@ namespace Server.Commands
public static bool Handle( Mobile from, string text, MessageType type )
{
if ( text.StartsWith( m_Prefix ) || type == MessageType.Command )
if ( text.StartsWith( Prefix ) || type == MessageType.Command )
{
if ( type != MessageType.Command )
text = text.Substring( m_Prefix.Length );
text = text.Substring( Prefix.Length );
int indexOf = text.IndexOf( ' ' );
@ -239,7 +219,7 @@ namespace Server.Commands
args = new string[0];
}
m_Entries.TryGetValue( command, out CommandEntry entry );
Entries.TryGetValue( command, out CommandEntry entry );
if ( entry != null )
{
@ -254,7 +234,7 @@ namespace Server.Commands
}
else
{
if ( from.AccessLevel <= m_BadCommandIngoreLevel )
if ( from.AccessLevel <= BadCommandIgnoreLevel )
return false;
from.SendMessage( "You do not have access to that command." );
@ -262,7 +242,7 @@ namespace Server.Commands
}
else
{
if ( from.AccessLevel <= m_BadCommandIngoreLevel )
if ( from.AccessLevel <= BadCommandIgnoreLevel )
return false;
from.SendMessage( "That is not a valid command." );

View file

@ -28,24 +28,20 @@ namespace Server.ContextMenus
/// </summary>
public class ContextMenu
{
private Mobile m_From;
private object m_Target;
private ContextMenuEntry[] m_Entries;
/// <summary>
/// Gets the <see cref="Mobile" /> who opened this ContextMenu.
/// </summary>
public Mobile From => m_From;
public Mobile From { get; }
/// <summary>
/// Gets an object of the <see cref="Mobile" /> or <see cref="Item" /> for which this ContextMenu is on.
/// </summary>
public object Target => m_Target;
public object Target { get; }
/// <summary>
/// Gets the list of <see cref="ContextMenuEntry">entries</see> contained in this ContextMenu.
/// </summary>
public ContextMenuEntry[] Entries => m_Entries;
public ContextMenuEntry[] Entries { get; }
/// <summary>
/// Instantiates a new ContextMenu instance.
@ -60,8 +56,8 @@ namespace Server.ContextMenus
/// </param>
public ContextMenu( Mobile from, object target )
{
m_From = from;
m_Target = target;
From = from;
Target = target;
List<ContextMenuEntry> list = new List<ContextMenuEntry>();
@ -76,11 +72,11 @@ namespace Server.ContextMenus
//m_Entries = (ContextMenuEntry[])list.ToArray( typeof( ContextMenuEntry ) );
m_Entries = list.ToArray();
Entries = list.ToArray();
for ( int i = 0; i < m_Entries.Length; ++i )
for ( int i = 0; i < Entries.Length; ++i )
{
m_Entries[i].Owner = this;
Entries[i].Owner = this;
}
}
@ -91,9 +87,9 @@ namespace Server.ContextMenus
{
get
{
for ( int i = 0; i < m_Entries.Length; ++i )
for ( int i = 0; i < Entries.Length; ++i )
{
if ( m_Entries[i].Number < 3000000 || m_Entries[i].Number > 3032767 )
if ( Entries[i].Number < 3000000 || Entries[i].Number > 3032767 )
return true;
}

View file

@ -28,66 +28,35 @@ namespace Server.ContextMenus
/// </summary>
public class ContextMenuEntry
{
private int m_Number;
private int m_Color;
private bool m_Enabled;
private int m_Range;
private CMEFlags m_Flags;
private ContextMenu m_Owner;
/// <summary>
/// Gets or sets additional <see cref="CMEFlags">flags</see> used in client communication.
/// </summary>
public CMEFlags Flags
{
get => m_Flags;
set => m_Flags = value;
}
public CMEFlags Flags { get; set; }
/// <summary>
/// Gets or sets the <see cref="ContextMenu" /> that owns this entry.
/// </summary>
public ContextMenu Owner
{
get => m_Owner;
set => m_Owner = value;
}
public ContextMenu Owner { get; set; }
/// <summary>
/// Gets or sets the localization number containing the name of this entry.
/// </summary>
public int Number
{
get => m_Number;
set => m_Number = value;
}
public int Number { get; set; }
/// <summary>
/// Gets or sets the maximum range at which this entry may be used, in tiles. A value of -1 signifies no maximum range.
/// </summary>
public int Range
{
get => m_Range;
set => m_Range = value;
}
public int Range { get; set; }
/// <summary>
/// Gets or sets the color for this entry. Format is A1-R5-G5-B5.
/// </summary>
public int Color
{
get => m_Color;
set => m_Color = value;
}
public int Color { get; set; }
/// <summary>
/// Gets or sets whether this entry is enabled. When false, the entry will appear in a gray hue and <see cref="OnClick" /> will never be invoked.
/// </summary>
public bool Enabled
{
get => m_Enabled;
set => m_Enabled = value;
}
public bool Enabled { get; set; }
/// <summary>
/// Gets a value indicating if non local use of this entry is permitted.
@ -119,13 +88,13 @@ namespace Server.ContextMenus
public ContextMenuEntry( int number, int range )
{
if ( number <= 0x7FFF ) // Legacy code support
m_Number = 3000000 + number;
Number = 3000000 + number;
else
m_Number = number;
Number = number;
m_Range = range;
m_Enabled = true;
m_Color = 0xFFFF;
Range = range;
Enabled = true;
Color = 0xFFFF;
}
/// <summary>

View file

@ -38,27 +38,20 @@ namespace Server.Diagnostics {
}
}
private string _name;
private long _count;
private TimeSpan _totalTime;
private TimeSpan _peakTime;
private Stopwatch _stopwatch;
public string Name => _name;
public string Name { get; }
public long Count => _count;
public long Count { get; private set; }
public TimeSpan AverageTime => TimeSpan.FromTicks( _totalTime.Ticks / Math.Max( 1, _count ) );
public TimeSpan AverageTime => TimeSpan.FromTicks( TotalTime.Ticks / Math.Max( 1, Count ) );
public TimeSpan PeakTime => _peakTime;
public TimeSpan PeakTime { get; private set; }
public TimeSpan TotalTime => _totalTime;
public TimeSpan TotalTime { get; private set; }
protected BaseProfile( string name ) {
_name = name;
Name = name;
_stopwatch = new Stopwatch();
}
@ -74,13 +67,13 @@ namespace Server.Diagnostics {
public virtual void Finish() {
TimeSpan elapsed = _stopwatch.Elapsed;
_totalTime += elapsed;
TotalTime += elapsed;
if ( elapsed > _peakTime ) {
_peakTime = elapsed;
if ( elapsed > PeakTime ) {
PeakTime = elapsed;
}
_count++;
Count++;
_stopwatch.Reset();
}

View file

@ -26,11 +26,9 @@ using System.IO;
namespace Server.Diagnostics {
public abstract class BasePacketProfile : BaseProfile {
private long _totalLength;
public long TotalLength { get; private set; }
public long TotalLength => _totalLength;
public double AverageLength => ( double ) _totalLength / Math.Max( 1, Count );
public double AverageLength => ( double ) TotalLength / Math.Max( 1, Count );
protected BasePacketProfile(string name)
: base( name ) {
@ -39,7 +37,7 @@ namespace Server.Diagnostics {
public void Finish( int length ) {
Finish();
_totalLength += length;
TotalLength += length;
}
public override void WriteTo( TextWriter op ) {

View file

@ -41,22 +41,11 @@ namespace Server.Diagnostics {
return prof;
}
private long _created, _started, _stopped;
public long Created { get; set; }
public long Created {
get => _created;
set => _created = value;
}
public long Started { get; set; }
public long Started {
get => _started;
set => _started = value;
}
public long Stopped {
get => _stopped;
set => _stopped = value;
}
public long Stopped { get; set; }
public TimerProfile( string name )
: base( name ) {
@ -65,7 +54,7 @@ namespace Server.Diagnostics {
public override void WriteTo( TextWriter op ) {
base.WriteTo( op );
op.Write( "\t{0,12:N0} {1,12:N0} {2,-12:N0}", _created, _started, _stopped );
op.Write( "\t{0,12:N0} {1,12:N0} {2,-12:N0}", Created, Started, Stopped );
}
}
}

View file

@ -42,17 +42,11 @@ namespace Server
public static class Effects
{
private static ParticleSupportType m_ParticleSupportType = ParticleSupportType.Detect;
public static ParticleSupportType ParticleSupportType
{
get => m_ParticleSupportType;
set => m_ParticleSupportType = value;
}
public static ParticleSupportType ParticleSupportType { get; set; } = ParticleSupportType.Detect;
public static bool SendParticlesTo( NetState state )
{
return ( m_ParticleSupportType == ParticleSupportType.Full || (m_ParticleSupportType == ParticleSupportType.Detect && state.IsUOTDClient) );
return ( ParticleSupportType == ParticleSupportType.Full || (ParticleSupportType == ParticleSupportType.Detect && state.IsUOTDClient) );
}
public static void PlaySound( IPoint3D p, Map map, int soundID )

View file

@ -74,126 +74,102 @@ namespace Server
public class ClientVersionReceivedArgs : EventArgs
{
private NetState m_State;
private ClientVersion m_Version;
public NetState State { get; }
public NetState State => m_State;
public ClientVersion Version => m_Version;
public ClientVersion Version { get; }
public ClientVersionReceivedArgs( NetState state, ClientVersion cv )
{
m_State = state;
m_Version = cv;
State = state;
Version = cv;
}
}
public class CreateGuildEventArgs : EventArgs
{
private int m_Id;
public int Id { get => m_Id;
set => m_Id = value;
}
public int Id { get; set; }
private BaseGuild m_Guild;
public BaseGuild Guild { get => m_Guild;
set => m_Guild = value;
}
public BaseGuild Guild { get; set; }
public CreateGuildEventArgs( int id )
{
m_Id = id;
Id = id;
}
}
public class GuildGumpRequestArgs : EventArgs
{
private Mobile m_Mobile;
public Mobile Mobile => m_Mobile;
public Mobile Mobile { get; }
public GuildGumpRequestArgs( Mobile mobile )
{
m_Mobile = mobile;
Mobile = mobile;
}
}
public class QuestGumpRequestArgs : EventArgs
{
private Mobile m_Mobile;
public Mobile Mobile => m_Mobile;
public Mobile Mobile { get; }
public QuestGumpRequestArgs( Mobile mobile )
{
m_Mobile = mobile;
Mobile = mobile;
}
}
public class SetAbilityEventArgs : EventArgs
{
private Mobile m_Mobile;
private int m_Index;
public Mobile Mobile { get; }
public Mobile Mobile => m_Mobile;
public int Index => m_Index;
public int Index { get; }
public SetAbilityEventArgs( Mobile mobile, int index )
{
m_Mobile = mobile;
m_Index = index;
Mobile = mobile;
Index = index;
}
}
public class DeleteRequestEventArgs : EventArgs
{
private NetState m_State;
private int m_Index;
public NetState State { get; }
public NetState State => m_State;
public int Index => m_Index;
public int Index { get; }
public DeleteRequestEventArgs( NetState state, int index )
{
m_State = state;
m_Index = index;
State = state;
Index = index;
}
}
public class GameLoginEventArgs : EventArgs
{
private NetState m_State;
private string m_Username;
private string m_Password;
private bool m_Accepted;
private CityInfo[] m_CityInfo;
public NetState State { get; }
public NetState State => m_State;
public string Username => m_Username;
public string Password => m_Password;
public bool Accepted{ get => m_Accepted;
set => m_Accepted = value;
}
public CityInfo[] CityInfo{ get => m_CityInfo;
set => m_CityInfo = value;
}
public string Username { get; }
public string Password { get; }
public bool Accepted { get; set; }
public CityInfo[] CityInfo { get; set; }
public GameLoginEventArgs( NetState state, string un, string pw )
{
m_State = state;
m_Username = un;
m_Password = pw;
State = state;
Username = un;
Password = pw;
}
}
public class AggressiveActionEventArgs : EventArgs
{
private Mobile m_Aggressed;
private Mobile m_Aggressor;
private bool m_Criminal;
public Mobile Aggressed { get; private set; }
public Mobile Aggressed => m_Aggressed;
public Mobile Aggressor => m_Aggressor;
public bool Criminal => m_Criminal;
public Mobile Aggressor { get; private set; }
public bool Criminal { get; private set; }
private static Queue<AggressiveActionEventArgs> m_Pool = new Queue<AggressiveActionEventArgs>();
@ -205,9 +181,9 @@ namespace Server
{
args = m_Pool.Dequeue();
args.m_Aggressed = aggressed;
args.m_Aggressor = aggressor;
args.m_Criminal = criminal;
args.Aggressed = aggressed;
args.Aggressor = aggressor;
args.Criminal = criminal;
}
else
{
@ -219,9 +195,9 @@ namespace Server
private AggressiveActionEventArgs( Mobile aggressed, Mobile aggressor, bool criminal )
{
m_Aggressed = aggressed;
m_Aggressor = aggressor;
m_Criminal = criminal;
Aggressed = aggressed;
Aggressor = aggressor;
Criminal = criminal;
}
public void Free()
@ -232,319 +208,272 @@ namespace Server
public class ProfileRequestEventArgs : EventArgs
{
private Mobile m_Beholder;
private Mobile m_Beheld;
public Mobile Beholder { get; }
public Mobile Beholder => m_Beholder;
public Mobile Beheld => m_Beheld;
public Mobile Beheld { get; }
public ProfileRequestEventArgs( Mobile beholder, Mobile beheld )
{
m_Beholder = beholder;
m_Beheld = beheld;
Beholder = beholder;
Beheld = beheld;
}
}
public class ChangeProfileRequestEventArgs : EventArgs
{
private Mobile m_Beholder;
private Mobile m_Beheld;
private string m_Text;
public Mobile Beholder { get; }
public Mobile Beholder => m_Beholder;
public Mobile Beheld => m_Beheld;
public string Text => m_Text;
public Mobile Beheld { get; }
public string Text { get; }
public ChangeProfileRequestEventArgs( Mobile beholder, Mobile beheld, string text )
{
m_Beholder = beholder;
m_Beheld = beheld;
m_Text = text;
Beholder = beholder;
Beheld = beheld;
Text = text;
}
}
public class PaperdollRequestEventArgs : EventArgs
{
private Mobile m_Beholder;
private Mobile m_Beheld;
public Mobile Beholder { get; }
public Mobile Beholder => m_Beholder;
public Mobile Beheld => m_Beheld;
public Mobile Beheld { get; }
public PaperdollRequestEventArgs( Mobile beholder, Mobile beheld )
{
m_Beholder = beholder;
m_Beheld = beheld;
Beholder = beholder;
Beheld = beheld;
}
}
public class AccountLoginEventArgs : EventArgs
{
private NetState m_State;
private string m_Username;
private string m_Password;
public NetState State { get; }
private bool m_Accepted;
private ALRReason m_RejectReason;
public string Username { get; }
public NetState State => m_State;
public string Username => m_Username;
public string Password => m_Password;
public bool Accepted{ get => m_Accepted;
set => m_Accepted = value;
}
public ALRReason RejectReason{ get => m_RejectReason;
set => m_RejectReason = value;
}
public string Password { get; }
public bool Accepted { get; set; }
public ALRReason RejectReason { get; set; }
public AccountLoginEventArgs( NetState state, string username, string password )
{
m_State = state;
m_Username = username;
m_Password = password;
State = state;
Username = username;
Password = password;
}
}
public class VirtueItemRequestEventArgs : EventArgs
{
private Mobile m_Beholder;
private Mobile m_Beheld;
private int m_GumpID;
public Mobile Beholder { get; }
public Mobile Beholder => m_Beholder;
public Mobile Beheld => m_Beheld;
public int GumpID => m_GumpID;
public Mobile Beheld { get; }
public int GumpID { get; }
public VirtueItemRequestEventArgs( Mobile beholder, Mobile beheld, int gumpID )
{
m_Beholder = beholder;
m_Beheld = beheld;
m_GumpID = gumpID;
Beholder = beholder;
Beheld = beheld;
GumpID = gumpID;
}
}
public class VirtueGumpRequestEventArgs : EventArgs
{
private Mobile m_Beholder, m_Beheld;
public Mobile Beholder { get; }
public Mobile Beholder => m_Beholder;
public Mobile Beheld => m_Beheld;
public Mobile Beheld { get; }
public VirtueGumpRequestEventArgs( Mobile beholder, Mobile beheld )
{
m_Beholder = beholder;
m_Beheld = beheld;
Beholder = beholder;
Beheld = beheld;
}
}
public class VirtueMacroRequestEventArgs : EventArgs
{
private Mobile m_Mobile;
private int m_VirtueID;
public Mobile Mobile { get; }
public Mobile Mobile => m_Mobile;
public int VirtueID => m_VirtueID;
public int VirtueID { get; }
public VirtueMacroRequestEventArgs( Mobile mobile, int virtueID )
{
m_Mobile = mobile;
m_VirtueID = virtueID;
Mobile = mobile;
VirtueID = virtueID;
}
}
public class ChatRequestEventArgs : EventArgs
{
private Mobile m_Mobile;
public Mobile Mobile => m_Mobile;
public Mobile Mobile { get; }
public ChatRequestEventArgs( Mobile mobile )
{
m_Mobile = mobile;
Mobile = mobile;
}
}
public class PlayerDeathEventArgs : EventArgs
{
private Mobile m_Mobile;
public Mobile Mobile => m_Mobile;
public Mobile Mobile { get; }
public PlayerDeathEventArgs( Mobile mobile )
{
m_Mobile = mobile;
Mobile = mobile;
}
}
public class RenameRequestEventArgs : EventArgs
{
private Mobile m_From, m_Target;
private string m_Name;
public Mobile From { get; }
public Mobile From => m_From;
public Mobile Target => m_Target;
public string Name => m_Name;
public Mobile Target { get; }
public string Name { get; }
public RenameRequestEventArgs( Mobile from, Mobile target, string name )
{
m_From = from;
m_Target = target;
m_Name = name;
From = from;
Target = target;
Name = name;
}
}
public class LogoutEventArgs : EventArgs
{
private Mobile m_Mobile;
public Mobile Mobile => m_Mobile;
public Mobile Mobile { get; }
public LogoutEventArgs( Mobile m )
{
m_Mobile = m;
Mobile = m;
}
}
public class SocketConnectEventArgs : EventArgs
{
private Socket m_Socket;
private bool m_AllowConnection;
public Socket Socket { get; }
public Socket Socket => m_Socket;
public bool AllowConnection{ get => m_AllowConnection;
set => m_AllowConnection = value;
}
public bool AllowConnection { get; set; }
public SocketConnectEventArgs( Socket s )
{
m_Socket = s;
m_AllowConnection = true;
Socket = s;
AllowConnection = true;
}
}
public class ConnectedEventArgs : EventArgs
{
private Mobile m_Mobile;
public Mobile Mobile => m_Mobile;
public Mobile Mobile { get; }
public ConnectedEventArgs( Mobile m )
{
m_Mobile = m;
Mobile = m;
}
}
public class DisconnectedEventArgs : EventArgs
{
private Mobile m_Mobile;
public Mobile Mobile => m_Mobile;
public Mobile Mobile { get; }
public DisconnectedEventArgs( Mobile m )
{
m_Mobile = m;
Mobile = m;
}
}
public class AnimateRequestEventArgs : EventArgs
{
private Mobile m_Mobile;
private string m_Action;
public Mobile Mobile { get; }
public Mobile Mobile => m_Mobile;
public string Action => m_Action;
public string Action { get; }
public AnimateRequestEventArgs( Mobile m, string action )
{
m_Mobile = m;
m_Action = action;
Mobile = m;
Action = action;
}
}
public class CastSpellRequestEventArgs : EventArgs
{
private Mobile m_Mobile;
private Item m_Spellbook;
private int m_SpellID;
public Mobile Mobile { get; }
public Mobile Mobile => m_Mobile;
public Item Spellbook => m_Spellbook;
public int SpellID => m_SpellID;
public Item Spellbook { get; }
public int SpellID { get; }
public CastSpellRequestEventArgs( Mobile m, int spellID, Item book )
{
m_Mobile = m;
m_Spellbook = book;
m_SpellID = spellID;
Mobile = m;
Spellbook = book;
SpellID = spellID;
}
}
public class BandageTargetRequestEventArgs : EventArgs
{
private Mobile m_Mobile;
private Item m_Bandage;
private Mobile m_Target;
public Mobile Mobile { get; }
public Mobile Mobile => m_Mobile;
public Item Bandage => m_Bandage;
public Mobile Target => m_Target;
public Item Bandage { get; }
public Mobile Target { get; }
public BandageTargetRequestEventArgs(Mobile m, Item bandage, Mobile target)
{
m_Mobile = m;
m_Bandage = bandage;
m_Target = target;
Mobile = m;
Bandage = bandage;
Target = target;
}
}
public class OpenSpellbookRequestEventArgs : EventArgs
{
private Mobile m_Mobile;
private int m_Type;
public Mobile Mobile { get; }
public Mobile Mobile => m_Mobile;
public int Type => m_Type;
public int Type { get; }
public OpenSpellbookRequestEventArgs( Mobile m, int type )
{
m_Mobile = m;
m_Type = type;
Mobile = m;
Type = type;
}
}
public class StunRequestEventArgs : EventArgs
{
private Mobile m_Mobile;
public Mobile Mobile => m_Mobile;
public Mobile Mobile { get; }
public StunRequestEventArgs( Mobile m )
{
m_Mobile = m;
Mobile = m;
}
}
public class DisarmRequestEventArgs : EventArgs
{
private Mobile m_Mobile;
public Mobile Mobile => m_Mobile;
public Mobile Mobile { get; }
public DisarmRequestEventArgs( Mobile m )
{
m_Mobile = m;
Mobile = m;
}
}
public class HelpRequestEventArgs : EventArgs
{
private Mobile m_Mobile;
public Mobile Mobile => m_Mobile;
public Mobile Mobile { get; }
public HelpRequestEventArgs( Mobile m )
{
m_Mobile = m;
Mobile = m;
}
}
@ -557,46 +486,36 @@ namespace Server
public class CrashedEventArgs : EventArgs
{
private Exception m_Exception;
private bool m_Close;
public Exception Exception { get; }
public Exception Exception => m_Exception;
public bool Close{ get => m_Close;
set => m_Close = value;
}
public bool Close { get; set; }
public CrashedEventArgs( Exception e )
{
m_Exception = e;
Exception = e;
}
}
public class HungerChangedEventArgs : EventArgs
{
private Mobile m_Mobile;
private int m_OldValue;
public Mobile Mobile { get; }
public Mobile Mobile => m_Mobile;
public int OldValue => m_OldValue;
public int OldValue { get; }
public HungerChangedEventArgs( Mobile mobile, int oldValue )
{
m_Mobile = mobile;
m_OldValue = oldValue;
Mobile = mobile;
OldValue = oldValue;
}
}
public class MovementEventArgs : EventArgs
{
private Mobile m_Mobile;
private Direction m_Direction;
private bool m_Blocked;
public Mobile Mobile { get; private set; }
public Mobile Mobile => m_Mobile;
public Direction Direction => m_Direction;
public bool Blocked{ get => m_Blocked;
set => m_Blocked = value;
}
public Direction Direction { get; private set; }
public bool Blocked { get; set; }
private static Queue<MovementEventArgs> m_Pool = new Queue<MovementEventArgs>();
@ -608,9 +527,9 @@ namespace Server
{
args = m_Pool.Dequeue();
args.m_Mobile = mobile;
args.m_Direction = dir;
args.m_Blocked = false;
args.Mobile = mobile;
args.Direction = dir;
args.Blocked = false;
}
else
{
@ -622,8 +541,8 @@ namespace Server
public MovementEventArgs( Mobile mobile, Direction dir )
{
m_Mobile = mobile;
m_Direction = dir;
Mobile = mobile;
Direction = dir;
}
public void Free()
@ -634,17 +553,13 @@ namespace Server
public class ServerListEventArgs : EventArgs
{
private NetState m_State;
private IAccount m_Account;
private bool m_Rejected;
private List<ServerInfo> m_Servers;
public NetState State { get; }
public NetState State => m_State;
public IAccount Account => m_Account;
public bool Rejected{ get => m_Rejected;
set => m_Rejected = value;
}
public List<ServerInfo> Servers => m_Servers;
public IAccount Account { get; }
public bool Rejected { get; set; }
public List<ServerInfo> Servers { get; }
public void AddServer( string name, IPEndPoint address )
{
@ -653,137 +568,123 @@ namespace Server
public void AddServer( string name, int fullPercent, TimeZone tz, IPEndPoint address )
{
m_Servers.Add( new ServerInfo( name, fullPercent, tz, address ) );
Servers.Add( new ServerInfo( name, fullPercent, tz, address ) );
}
public ServerListEventArgs( NetState state, IAccount account )
{
m_State = state;
m_Account = account;
m_Servers = new List<ServerInfo>();
State = state;
Account = account;
Servers = new List<ServerInfo>();
}
}
public struct SkillNameValue
{
private SkillName m_Name;
private int m_Value;
public SkillName Name { get; }
public SkillName Name => m_Name;
public int Value => m_Value;
public int Value { get; }
public SkillNameValue( SkillName name, int value )
{
m_Name = name;
m_Value = value;
Name = name;
Value = value;
}
}
public class CharacterCreatedEventArgs : EventArgs
{
private NetState m_State;
private IAccount m_Account;
private CityInfo m_City;
private SkillNameValue[] m_Skills;
private int m_ShirtHue, m_PantsHue;
private int m_HairID, m_HairHue;
private int m_BeardID, m_BeardHue;
private string m_Name;
private bool m_Female;
private int m_Hue;
private int m_Str, m_Dex, m_Int;
private int m_Profession;
private Mobile m_Mobile;
public NetState State { get; }
private Race m_Race;
public IAccount Account { get; }
public NetState State => m_State;
public IAccount Account => m_Account;
public Mobile Mobile{ get => m_Mobile;
set => m_Mobile = value;
}
public string Name => m_Name;
public bool Female => m_Female;
public int Hue => m_Hue;
public int Str => m_Str;
public int Dex => m_Dex;
public int Int => m_Int;
public CityInfo City => m_City;
public SkillNameValue[] Skills => m_Skills;
public int ShirtHue => m_ShirtHue;
public int PantsHue => m_PantsHue;
public int HairID => m_HairID;
public int HairHue => m_HairHue;
public int BeardID => m_BeardID;
public int BeardHue => m_BeardHue;
public int Profession{ get => m_Profession;
set => m_Profession = value;
}
public Race Race => m_Race;
public Mobile Mobile { get; set; }
public string Name { get; }
public bool Female { get; }
public int Hue { get; }
public int Str { get; }
public int Dex { get; }
public int Int { get; }
public CityInfo City { get; }
public SkillNameValue[] Skills { get; }
public int ShirtHue { get; }
public int PantsHue { get; }
public int HairID { get; }
public int HairHue { get; }
public int BeardID { get; }
public int BeardHue { get; }
public int Profession { get; set; }
public Race Race { get; }
public CharacterCreatedEventArgs( NetState state, IAccount a, string name, bool female, int hue, int str, int dex, int intel, CityInfo city, SkillNameValue[] skills, int shirtHue, int pantsHue, int hairID, int hairHue, int beardID, int beardHue, int profession, Race race )
{
m_State = state;
m_Account = a;
m_Name = name;
m_Female = female;
m_Hue = hue;
m_Str = str;
m_Dex = dex;
m_Int = intel;
m_City = city;
m_Skills = skills;
m_ShirtHue = shirtHue;
m_PantsHue = pantsHue;
m_HairID = hairID;
m_HairHue = hairHue;
m_BeardID = beardID;
m_BeardHue = beardHue;
m_Profession = profession;
m_Race = race;
State = state;
Account = a;
Name = name;
Female = female;
Hue = hue;
Str = str;
Dex = dex;
Int = intel;
City = city;
Skills = skills;
ShirtHue = shirtHue;
PantsHue = pantsHue;
HairID = hairID;
HairHue = hairHue;
BeardID = beardID;
BeardHue = beardHue;
Profession = profession;
Race = race;
}
}
public class OpenDoorMacroEventArgs : EventArgs
{
private Mobile m_Mobile;
public Mobile Mobile => m_Mobile;
public Mobile Mobile { get; }
public OpenDoorMacroEventArgs( Mobile mobile )
{
m_Mobile = mobile;
Mobile = mobile;
}
}
public class SpeechEventArgs : EventArgs
{
private Mobile m_Mobile;
private string m_Speech;
private MessageType m_Type;
private int m_Hue;
private int[] m_Keywords;
private bool m_Handled;
private bool m_Blocked;
public Mobile Mobile { get; }
public Mobile Mobile => m_Mobile;
public string Speech{ get => m_Speech;
set => m_Speech = value;
}
public MessageType Type => m_Type;
public int Hue => m_Hue;
public int[] Keywords => m_Keywords;
public bool Handled{ get => m_Handled;
set => m_Handled = value;
}
public bool Blocked{ get => m_Blocked;
set => m_Blocked = value;
}
public string Speech { get; set; }
public MessageType Type { get; }
public int Hue { get; }
public int[] Keywords { get; }
public bool Handled { get; set; }
public bool Blocked { get; set; }
public bool HasKeyword( int keyword )
{
for ( int i = 0; i < m_Keywords.Length; ++i )
if ( m_Keywords[i] == keyword )
for ( int i = 0; i < Keywords.Length; ++i )
if ( Keywords[i] == keyword )
return true;
return false;
@ -791,53 +692,45 @@ namespace Server
public SpeechEventArgs( Mobile mobile, string speech, MessageType type, int hue, int[] keywords )
{
m_Mobile = mobile;
m_Speech = speech;
m_Type = type;
m_Hue = hue;
m_Keywords = keywords;
Mobile = mobile;
Speech = speech;
Type = type;
Hue = hue;
Keywords = keywords;
}
}
public class LoginEventArgs : EventArgs
{
private Mobile m_Mobile;
public Mobile Mobile => m_Mobile;
public Mobile Mobile { get; }
public LoginEventArgs( Mobile mobile )
{
m_Mobile = mobile;
Mobile = mobile;
}
}
public class WorldSaveEventArgs : EventArgs
{
private bool m_Msg;
public bool Message => m_Msg;
public bool Message { get; }
public WorldSaveEventArgs( bool msg )
{
m_Msg = msg;
Message = msg;
}
}
public class FastWalkEventArgs : EventArgs
{
private NetState m_State;
private bool m_Blocked;
public FastWalkEventArgs( NetState state )
{
m_State = state;
m_Blocked = false;
NetState = state;
Blocked = false;
}
public NetState NetState => m_State;
public bool Blocked{ get => m_Blocked;
set => m_Blocked = value;
}
public NetState NetState { get; }
public bool Blocked { get; set; }
}
public static class EventSink

View file

@ -481,62 +481,51 @@ namespace Server
[PropertyObject]
public struct Rectangle3D
{
private Point3D m_Start;
private Point3D m_End;
public Rectangle3D( Point3D start, Point3D end )
{
m_Start = start;
m_End = end;
Start = start;
End = end;
}
public Rectangle3D( int x, int y, int z, int width, int height, int depth )
{
m_Start = new Point3D( x, y, z );
m_End = new Point3D( x + width, y + height, z + depth );
Start = new Point3D( x, y, z );
End = new Point3D( x + width, y + height, z + depth );
}
[CommandProperty( AccessLevel.Counselor )]
public Point3D Start
{
get => m_Start;
set => m_Start = value;
}
public Point3D Start { get; set; }
[CommandProperty( AccessLevel.Counselor )]
public Point3D End
{
get => m_End;
set => m_End = value;
}
public Point3D End { get; set; }
[CommandProperty( AccessLevel.Counselor )]
public int Width => m_End.X - m_Start.X;
public int Width => End.X - Start.X;
[CommandProperty( AccessLevel.Counselor )]
public int Height => m_End.Y - m_Start.Y;
public int Height => End.Y - Start.Y;
[CommandProperty( AccessLevel.Counselor )]
public int Depth => m_End.Z - m_Start.Z;
public int Depth => End.Z - Start.Z;
public bool Contains( Point3D p )
{
return ( p.m_X >= m_Start.m_X )
&& ( p.m_X < m_End.m_X )
&& ( p.m_Y >= m_Start.m_Y )
&& ( p.m_Y < m_End.m_Y )
&& ( p.m_Z >= m_Start.m_Z )
&& ( p.m_Z < m_End.m_Z );
return ( p.m_X >= Start.m_X )
&& ( p.m_X < End.m_X )
&& ( p.m_Y >= Start.m_Y )
&& ( p.m_Y < End.m_Y )
&& ( p.m_Z >= Start.m_Z )
&& ( p.m_Z < End.m_Z );
}
public bool Contains( IPoint3D p )
{
return ( p.X >= m_Start.m_X )
&& ( p.X < m_End.m_X )
&& ( p.Y >= m_Start.m_Y )
&& ( p.Y < m_End.m_Y )
&& ( p.Z >= m_Start.m_Z )
&& ( p.Z < m_End.m_Z );
return ( p.X >= Start.m_X )
&& ( p.X < End.m_X )
&& ( p.Y >= Start.m_Y )
&& ( p.Y < End.m_Y )
&& ( p.Z >= Start.m_Z )
&& ( p.Z < End.m_Z );
}
}
}

View file

@ -32,28 +32,26 @@ namespace Server.Guilds
public abstract class BaseGuild : ISerializable
{
private int m_Id;
protected BaseGuild( int Id )//serialization ctor
{
m_Id = Id;
m_GuildList.Add( m_Id, this );
if ( m_Id+1 > m_NextID )
m_NextID = m_Id + 1;
this.Id = Id;
List.Add( this.Id, this );
if ( this.Id+1 > m_NextID )
m_NextID = this.Id + 1;
}
protected BaseGuild()
{
m_Id = m_NextID++;
m_GuildList.Add( m_Id, this );
Id = m_NextID++;
List.Add( Id, this );
}
[CommandProperty( AccessLevel.Counselor )]
public int Id => m_Id;
public int Id { get; }
int ISerializable.TypeReference => 0;
int ISerializable.SerialIdentity => m_Id;
int ISerializable.SerialIdentity => Id;
public abstract void Deserialize( GenericReader reader );
public abstract void Serialize( GenericWriter writer );
@ -64,23 +62,22 @@ namespace Server.Guilds
public abstract bool Disbanded{ get; }
public abstract void OnDelete( Mobile mob );
private static Dictionary<int, BaseGuild> m_GuildList = new Dictionary<int, BaseGuild>();
private static int m_NextID = 1;
public static Dictionary<int, BaseGuild> List => m_GuildList;
public static Dictionary<int, BaseGuild> List { get; } = new Dictionary<int, BaseGuild>();
public static BaseGuild Find( int id )
{
BaseGuild g;
m_GuildList.TryGetValue( id, out g );
List.TryGetValue( id, out g );
return g;
}
public static BaseGuild FindByName( string name )
{
foreach ( BaseGuild g in m_GuildList.Values )
foreach ( BaseGuild g in List.Values )
{
if ( g.Name == name )
return g;
@ -91,7 +88,7 @@ namespace Server.Guilds
public static BaseGuild FindByAbbrev( string abbr )
{
foreach ( BaseGuild g in m_GuildList.Values )
foreach ( BaseGuild g in List.Values )
{
if ( g.Abbreviation == abbr )
return g;
@ -105,7 +102,7 @@ namespace Server.Guilds
string[] words = find.ToLower().Split( ' ' );
List<BaseGuild> results = new List<BaseGuild>();
foreach ( BaseGuild g in m_GuildList.Values )
foreach ( BaseGuild g in List.Values )
{
bool match = true;
string name = g.Name.ToLower();
@ -127,7 +124,7 @@ namespace Server.Guilds
public override string ToString()
{
return $"0x{m_Id:X} \"{Name} [{Abbreviation}]\"";
return $"0x{Id:X} \"{Name} [{Abbreviation}]\"";
}
}
}

View file

@ -27,7 +27,6 @@ namespace Server.Gumps
{
public class Gump
{
private List<GumpEntry> m_Entries;
private List<string> m_Strings;
internal int m_TextEntries, m_Switches;
@ -35,7 +34,6 @@ namespace Server.Gumps
private static int m_NextSerial = 1;
private int m_Serial;
private int m_TypeID;
private int m_X, m_Y;
private bool m_Dragable = true;
@ -58,9 +56,9 @@ namespace Server.Gumps
m_X = x;
m_Y = y;
m_TypeID = GetTypeID( GetType() );
TypeID = GetTypeID( GetType() );
m_Entries = new List<GumpEntry>();
Entries = new List<GumpEntry>();
m_Strings = new List<string>();
}
@ -70,9 +68,9 @@ namespace Server.Gumps
// m_Strings.Clear();
}
public int TypeID => m_TypeID;
public int TypeID { get; }
public List<GumpEntry> Entries => m_Entries;
public List<GumpEntry> Entries { get; }
public int Serial
{
@ -289,20 +287,20 @@ namespace Server.Gumps
{
g.Parent = this;
}
else if ( !m_Entries.Contains( g ) )
else if ( !Entries.Contains( g ) )
{
Invalidate();
m_Entries.Add( g );
Entries.Add( g );
}
}
public void Remove( GumpEntry g )
{
if (g == null || !m_Entries.Contains(g))
if (g == null || !Entries.Contains(g))
return;
Invalidate();
m_Entries.Remove( g );
Entries.Remove( g );
g.Parent = null;
}
@ -365,12 +363,12 @@ namespace Server.Gumps
if ( !m_Resizable )
disp.AppendLayout( m_NoResize );
int count = m_Entries.Count;
int count = Entries.Count;
GumpEntry e;
for ( int i = 0; i < count; ++i )
{
e = m_Entries[i];
e = Entries[i];
disp.AppendLayout( m_BeginLayout );
e.AppendTo( ns, disp );

View file

@ -37,8 +37,6 @@ namespace Server.Gumps
private int m_Width;
private int m_Height;
private int m_LocalizedTooltip;
public GumpImageTileButton( int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type, int param, int itemID, int hue, int width, int height ) : this(x, y, normalID, pressedID, buttonID, type, param, itemID, hue, width, height, -1 )
{
}
@ -57,7 +55,7 @@ namespace Server.Gumps
m_Width = width;
m_Height = height;
m_LocalizedTooltip = localizedTooltip;
LocalizedTooltip = localizedTooltip;
}
public int X
@ -136,17 +134,13 @@ namespace Server.Gumps
set => Delta( ref m_Height, value );
}
public int LocalizedTooltip
{
get => m_LocalizedTooltip;
set => m_LocalizedTooltip = value;
}
public int LocalizedTooltip { get; set; }
public override string Compile( NetState ns )
{
if ( m_LocalizedTooltip > 0 )
if ( LocalizedTooltip > 0 )
return
$"{{ buttontileart {m_X} {m_Y} {m_ID1} {m_ID2} {(int) m_Type} {m_Param} {m_ButtonID} {m_ItemID} {m_Hue} {m_Width} {m_Height} }}{{ tooltip {m_LocalizedTooltip} }}";
$"{{ buttontileart {m_X} {m_Y} {m_ID1} {m_ID2} {(int) m_Type} {m_Param} {m_ButtonID} {m_ItemID} {m_Hue} {m_Width} {m_Height} }}{{ tooltip {LocalizedTooltip} }}";
return
$"{{ buttontileart {m_X} {m_Y} {m_ID1} {m_ID2} {(int) m_Type} {m_Param} {m_ButtonID} {m_ItemID} {m_Hue} {m_Width} {m_Height} }}";
}
@ -170,10 +164,10 @@ namespace Server.Gumps
disp.AppendLayout( m_Width );
disp.AppendLayout( m_Height );
if ( m_LocalizedTooltip > 0 )
if ( LocalizedTooltip > 0 )
{
disp.AppendLayout( m_LayoutTooltip );
disp.AppendLayout( m_LocalizedTooltip );
disp.AppendLayout( LocalizedTooltip );
}
}
}

View file

@ -22,44 +22,37 @@ namespace Server.Gumps
{
public class TextRelay
{
private int m_EntryID;
private string m_Text;
public TextRelay( int entryID, string text )
{
m_EntryID = entryID;
m_Text = text;
EntryID = entryID;
Text = text;
}
public int EntryID => m_EntryID;
public int EntryID { get; }
public string Text => m_Text;
public string Text { get; }
}
public class RelayInfo
{
private int m_ButtonID;
private int[] m_Switches;
private TextRelay[] m_TextEntries;
public RelayInfo( int buttonID, int[] switches, TextRelay[] textEntries )
{
m_ButtonID = buttonID;
m_Switches = switches;
m_TextEntries = textEntries;
ButtonID = buttonID;
Switches = switches;
TextEntries = textEntries;
}
public int ButtonID => m_ButtonID;
public int ButtonID { get; }
public int[] Switches => m_Switches;
public int[] Switches { get; }
public TextRelay[] TextEntries => m_TextEntries;
public TextRelay[] TextEntries { get; }
public bool IsSwitched( int switchID )
{
for ( int i = 0; i < m_Switches.Length; ++i )
for ( int i = 0; i < Switches.Length; ++i )
{
if ( m_Switches[i] == switchID )
if ( Switches[i] == switchID )
{
return true;
}
@ -70,11 +63,11 @@ namespace Server.Gumps
public TextRelay GetTextEntry( int entryID )
{
for ( int i = 0; i < m_TextEntries.Length; ++i )
for ( int i = 0; i < TextEntries.Length; ++i )
{
if ( m_TextEntries[i].EntryID == entryID )
if ( TextEntries[i].EntryID == entryID )
{
return m_TextEntries[i];
return TextEntries[i];
}
}

View file

@ -26,21 +26,18 @@ namespace Server.HuePickers
{
private static int m_NextSerial = 1;
private int m_Serial;
private int m_ItemID;
public int Serial { get; }
public int Serial => m_Serial;
public int ItemID => m_ItemID;
public int ItemID { get; }
public HuePicker( int itemID )
{
do
{
m_Serial = m_NextSerial++;
} while ( m_Serial == 0 );
Serial = m_NextSerial++;
} while ( Serial == 0 );
m_ItemID = itemID;
ItemID = itemID;
}
public virtual void OnResponse( int hue )

View file

@ -41,7 +41,7 @@ namespace Server
if ( other == null )
return -1;
return m_Serial.CompareTo( other.Serial );
return Serial.CompareTo( other.Serial );
}
public int CompareTo( Entity other )
@ -57,38 +57,33 @@ namespace Server
throw new ArgumentException();
}
private Serial m_Serial;
private Point3D m_Location;
private Map m_Map;
private bool m_Deleted;
public Entity( Serial serial, Point3D loc, Map map )
{
m_Serial = serial;
m_Location = loc;
m_Map = map;
m_Deleted = false;
Serial = serial;
Location = loc;
Map = map;
Deleted = false;
}
public Serial Serial => m_Serial;
public Serial Serial { get; }
public Point3D Location => m_Location;
public Point3D Location { get; private set; }
public int X => m_Location.X;
public int X => Location.X;
public int Y => m_Location.Y;
public int Y => Location.Y;
public int Z => m_Location.Z;
public int Z => Location.Z;
public Map Map => m_Map;
public Map Map { get; private set; }
public virtual void MoveToWorld(Point3D newLocation, Map map)
{
m_Location = newLocation;
m_Map = map;
Location = newLocation;
Map = map;
}
public bool Deleted => m_Deleted;
public bool Deleted { get; }
public void Delete()
{

View file

@ -24,13 +24,11 @@ namespace Server
{
public static class Insensitive
{
private static IComparer m_Comparer = CaseInsensitiveComparer.Default;
public static IComparer Comparer => m_Comparer;
public static IComparer Comparer { get; } = CaseInsensitiveComparer.Default;
public static int Compare( string a, string b )
{
return m_Comparer.Compare( a, b );
return Comparer.Compare( a, b );
}
public static bool Equals( string a, string b )
@ -40,7 +38,7 @@ namespace Server
if ( a == null || b == null || a.Length != b.Length )
return false;
return ( m_Comparer.Compare( a, b ) == 0 );
return ( Comparer.Compare( a, b ) == 0 );
}
public static bool StartsWith( string a, string b )
@ -48,7 +46,7 @@ namespace Server
if ( a == null || b == null || a.Length < b.Length )
return false;
return ( m_Comparer.Compare( a.Substring( 0, b.Length ), b ) == 0 );
return ( Comparer.Compare( a.Substring( 0, b.Length ), b ) == 0 );
}
public static bool EndsWith( string a, string b )
@ -56,7 +54,7 @@ namespace Server
if ( a == null || b == null || a.Length < b.Length )
return false;
return ( m_Comparer.Compare( a.Substring( a.Length - b.Length ), b ) == 0 );
return ( Comparer.Compare( a.Substring( a.Length - b.Length ), b ) == 0 );
}
public static bool Contains( string a, string b )

View file

@ -567,7 +567,7 @@ namespace Server
if ( other == null )
return -1;
return m_Serial.CompareTo( other.Serial );
return Serial.CompareTo( other.Serial );
}
public int CompareTo( Item other )
@ -584,7 +584,7 @@ namespace Server
}
#region Standard fields
private Serial m_Serial;
private Point3D m_Location;
private int m_ItemID;
private int m_Hue;
@ -593,7 +593,6 @@ namespace Server
private IEntity m_Parent; // Mobile, Item, or null=World
private Map m_Map;
private LootType m_LootType;
private DateTime m_LastMovedTime;
private Direction m_Direction;
#endregion
@ -1259,17 +1258,17 @@ namespace Server
public void LabelTo( Mobile to, int number )
{
to.Send( new MessageLocalized( m_Serial, m_ItemID, MessageType.Label, 0x3B2, 3, number, "", "" ) );
to.Send( new MessageLocalized( Serial, m_ItemID, MessageType.Label, 0x3B2, 3, number, "", "" ) );
}
public void LabelTo( Mobile to, int number, string args )
{
to.Send( new MessageLocalized( m_Serial, m_ItemID, MessageType.Label, 0x3B2, 3, number, "", args ) );
to.Send( new MessageLocalized( Serial, m_ItemID, MessageType.Label, 0x3B2, 3, number, "", args ) );
}
public void LabelTo( Mobile to, string text )
{
to.Send( new UnicodeMessage( m_Serial, m_ItemID, MessageType.Label, 0x3B2, 3, "ENU", "", text ) );
to.Send( new UnicodeMessage( Serial, m_ItemID, MessageType.Label, 0x3B2, 3, "ENU", "", text ) );
}
public void LabelTo( Mobile to, string format, params object[] args )
@ -1279,12 +1278,12 @@ namespace Server
public void LabelToAffix( Mobile to, int number, AffixType type, string affix )
{
to.Send( new MessageLocalizedAffix( m_Serial, m_ItemID, MessageType.Label, 0x3B2, 3, number, "", type, affix, "" ) );
to.Send( new MessageLocalizedAffix( Serial, m_ItemID, MessageType.Label, 0x3B2, 3, number, "", type, affix, "" ) );
}
public void LabelToAffix( Mobile to, int number, AffixType type, string affix, string args )
{
to.Send( new MessageLocalizedAffix( m_Serial, m_ItemID, MessageType.Label, 0x3B2, 3, number, "", type, affix, args ) );
to.Send( new MessageLocalizedAffix( Serial, m_ItemID, MessageType.Label, 0x3B2, 3, number, "", type, affix, args ) );
}
public virtual void LabelLootTypeTo( Mobile to )
@ -1453,14 +1452,10 @@ namespace Server
}
}
private static TimeSpan m_DDT = TimeSpan.FromHours( 1.0 );
public static TimeSpan DefaultDecayTime{ get => m_DDT;
set => m_DDT = value;
}
public static TimeSpan DefaultDecayTime { get; set; } = TimeSpan.FromHours( 1.0 );
[CommandProperty( AccessLevel.GameMaster )]
public virtual TimeSpan DecayTime => m_DDT;
public virtual TimeSpan DecayTime => DefaultDecayTime;
[CommandProperty( AccessLevel.GameMaster )]
public virtual bool Decays => (Movable && Visible/* && Spawner == null*/);
@ -1472,14 +1467,10 @@ namespace Server
public void SetLastMoved()
{
m_LastMovedTime = DateTime.UtcNow;
LastMoved = DateTime.UtcNow;
}
public DateTime LastMoved
{
get => m_LastMovedTime;
set => m_LastMovedTime = value;
}
public DateTime LastMoved { get; set; }
public virtual bool CanStackWith( Item dropped )
{
@ -1962,7 +1953,7 @@ namespace Server
int ISerializable.TypeReference => m_TypeRef;
int ISerializable.SerialIdentity => m_Serial;
int ISerializable.SerialIdentity => Serial;
public virtual void Serialize( GenericWriter writer )
{
@ -2058,7 +2049,7 @@ namespace Server
writer.Write( (int) flags );
/* begin last moved time optimization */
long ticks = m_LastMovedTime.Ticks;
long ticks = LastMoved.Ticks;
long now = DateTime.UtcNow.Ticks;
TimeSpan d;
@ -2210,31 +2201,20 @@ namespace Server
return map.GetClientsInRange( GetWorldLocation(), range );
}
private static int m_LockedDownFlag;
private static int m_SecureFlag;
public static int LockedDownFlag { get; set; }
public static int LockedDownFlag
{
get => m_LockedDownFlag;
set => m_LockedDownFlag = value;
}
public static int SecureFlag
{
get => m_SecureFlag;
set => m_SecureFlag = value;
}
public static int SecureFlag { get; set; }
public bool IsLockedDown
{
get => GetTempFlag( m_LockedDownFlag );
set{ SetTempFlag( m_LockedDownFlag, value ); InvalidateProperties(); }
get => GetTempFlag( LockedDownFlag );
set{ SetTempFlag( LockedDownFlag, value ); InvalidateProperties(); }
}
public bool IsSecure
{
get => GetTempFlag( m_SecureFlag );
set{ SetTempFlag( m_SecureFlag, value ); InvalidateProperties(); }
get => GetTempFlag( SecureFlag );
set{ SetTempFlag( SecureFlag, value ); InvalidateProperties(); }
}
public bool GetTempFlag( int flag )
@ -3005,13 +2985,7 @@ namespace Server
}
}
private bool m_NoMoveHS;
public bool NoMoveHS
{
get => m_NoMoveHS;
set => m_NoMoveHS = value;
}
public bool NoMoveHS { get; set; }
public void ProcessDelta()
{
@ -3331,9 +3305,9 @@ namespace Server
if ( p == null )
{
if ( ascii )
p = new AsciiMessage( m_Serial, m_ItemID, type, hue, 3, Name, text );
p = new AsciiMessage( Serial, m_ItemID, type, hue, 3, Name, text );
else
p = new UnicodeMessage( m_Serial, m_ItemID, type, hue, 3, "ENU", Name, text );
p = new UnicodeMessage( Serial, m_ItemID, type, hue, 3, "ENU", Name, text );
p.Acquire();
}
@ -3369,7 +3343,7 @@ namespace Server
if ( m.CanSee( this ) && m.InRange( worldLoc, GetUpdateRange( m ) ) )
{
if ( p == null )
p = Packet.Acquire( new MessageLocalized( m_Serial, m_ItemID, type, hue, 3, number, Name, args ) );
p = Packet.Acquire( new MessageLocalized( Serial, m_ItemID, type, hue, 3, number, Name, args ) );
state.Send( p );
}
@ -3457,7 +3431,7 @@ namespace Server
public virtual int EnergyResistance => 0;
[CommandProperty( AccessLevel.Counselor )]
public Serial Serial => m_Serial;
public Serial Serial { get; }
#region Location Location Location!
@ -3507,7 +3481,7 @@ namespace Server
foreach (NetState state in eable) {
Mobile m = state.Mobile;
if ( m.CanSee( this ) && m.InRange( m_Location, GetUpdateRange( m ) ) && ( !state.HighSeas || !m_NoMoveHS || ( m_DeltaFlags & ItemDelta.Update ) != 0 || !m.InRange( oldLoc, GetUpdateRange( m ) ) ) )
if ( m.CanSee( this ) && m.InRange( m_Location, GetUpdateRange( m ) ) && ( !state.HighSeas || !NoMoveHS || ( m_DeltaFlags & ItemDelta.Update ) != 0 || !m.InRange( oldLoc, GetUpdateRange( m ) ) ) )
SendInfoTo( state );
}
@ -3699,7 +3673,7 @@ namespace Server
InvalidateProperties();
if ( !Stackable && m_Amount > 1 )
Console.WriteLine( "Warning: 0x{0:X}: Amount changed for non-stackable item '{2}'. ({1})", m_Serial.Value, m_Amount, GetType().Name );
Console.WriteLine( "Warning: 0x{0:X}: Amount changed for non-stackable item '{2}'. ({1})", Serial.Value, m_Amount, GetType().Name );
}
}
}
@ -4348,7 +4322,7 @@ namespace Server
ObjectPropertyList opl = PropertyList;
if ( opl.Header > 0 )
from.Send( new MessageLocalized( m_Serial, m_ItemID, MessageType.Label, 0x3B2, 3, opl.Header, Name, opl.HeaderArgs ) );
from.Send( new MessageLocalized( Serial, m_ItemID, MessageType.Label, 0x3B2, 3, opl.Header, Name, opl.HeaderArgs ) );
}
public virtual void OnSingleClick( Mobile from )
@ -4366,25 +4340,19 @@ namespace Server
if ( Name == null )
{
if ( m_Amount <= 1 )
ns.Send( new MessageLocalized( m_Serial, m_ItemID, MessageType.Label, 0x3B2, 3, LabelNumber, "", "" ) );
ns.Send( new MessageLocalized( Serial, m_ItemID, MessageType.Label, 0x3B2, 3, LabelNumber, "", "" ) );
else
ns.Send( new MessageLocalizedAffix( m_Serial, m_ItemID, MessageType.Label, 0x3B2, 3, LabelNumber, "", AffixType.Append,
ns.Send( new MessageLocalizedAffix( Serial, m_ItemID, MessageType.Label, 0x3B2, 3, LabelNumber, "", AffixType.Append,
$" : {m_Amount}", "" ) );
}
else
{
ns.Send( new UnicodeMessage( m_Serial, m_ItemID, MessageType.Label, 0x3B2, 3, "ENU", "", Name + ( m_Amount > 1 ? " : " + m_Amount : "" ) ) );
ns.Send( new UnicodeMessage( Serial, m_ItemID, MessageType.Label, 0x3B2, 3, "ENU", "", Name + ( m_Amount > 1 ? " : " + m_Amount : "" ) ) );
}
}
}
private static bool m_ScissorCopyLootType;
public static bool ScissorCopyLootType
{
get => m_ScissorCopyLootType;
set => m_ScissorCopyLootType = value;
}
public static bool ScissorCopyLootType { get; set; }
public virtual void ScissorHelper( Mobile from, Item newItem, int amountPerOldItem )
{
@ -4414,7 +4382,7 @@ namespace Server
if ( carryHue )
newItem.Hue = ourHue;
if ( m_ScissorCopyLootType )
if ( ScissorCopyLootType )
newItem.LootType = type;
if ( !(thisParent is Container) || !((Container)thisParent).TryDropItem( from, newItem, false ) )
@ -4529,14 +4497,14 @@ namespace Server
public override string ToString()
{
return $"0x{m_Serial.Value:X} \"{GetType().Name}\"";
return $"0x{Serial.Value:X} \"{GetType().Name}\"";
}
internal int m_TypeRef;
public Item()
{
m_Serial = Serial.NewItem;
Serial = Serial.NewItem;
//m_Items = new ArrayList( 1 );
Visible = true;
@ -4566,7 +4534,7 @@ namespace Server
public Item( Serial serial )
{
m_Serial = serial;
Serial = serial;
Type ourType = GetType();
m_TypeRef = World.m_ItemTypes.IndexOf( ourType );

View file

@ -25,13 +25,11 @@ namespace Server
{
public static class ItemBounds
{
private static Rectangle2D[] m_Bounds;
public static Rectangle2D[] Table => m_Bounds;
public static Rectangle2D[] Table { get; }
static ItemBounds()
{
m_Bounds = new Rectangle2D[TileData.ItemTable.Length];
Table = new Rectangle2D[TileData.ItemTable.Length];
if ( File.Exists( "Data/Binary/Bounds.bin" ) )
{
@ -39,7 +37,7 @@ namespace Server
{
BinaryReader bin = new BinaryReader( fs );
int count = Math.Min( m_Bounds.Length, (int)( fs.Length / 8 ) );
int count = Math.Min( Table.Length, (int)( fs.Length / 8 ) );
for ( int i = 0; i < count; ++i )
{
@ -48,7 +46,7 @@ namespace Server
int xMax = bin.ReadInt16();
int yMax = bin.ReadInt16();
m_Bounds[i].Set( xMin, yMin, (xMax - xMin) + 1, (yMax - yMin) + 1 );
Table[i].Set( xMin, yMin, (xMax - xMin) + 1, (yMax - yMin) + 1 );
}
bin.Close();

View file

@ -33,13 +33,7 @@ namespace Server.Items
public class Container : Item
{
private static ContainerSnoopHandler m_SnoopHandler;
public static ContainerSnoopHandler SnoopHandler
{
get => m_SnoopHandler;
set => m_SnoopHandler = value;
}
public static ContainerSnoopHandler SnoopHandler { get; set; }
private ContainerData m_ContainerData;
@ -51,8 +45,6 @@ namespace Server.Items
private int m_TotalWeight;
private int m_TotalGold;
private bool m_LiftOverride;
internal List<Item> m_Items;
public ContainerData ContainerData
@ -118,11 +110,7 @@ namespace Server.Items
}
[CommandProperty( AccessLevel.GameMaster )]
public bool LiftOverride
{
get => m_LiftOverride;
set => m_LiftOverride = value;
}
public bool LiftOverride { get; set; }
public virtual void UpdateContainerData()
{
@ -137,10 +125,10 @@ namespace Server.Items
[CommandProperty( AccessLevel.GameMaster )]
public virtual int DefaultDropSound => ContainerData.DropSound;
public virtual int DefaultMaxItems => m_GlobalMaxItems;
public virtual int DefaultMaxWeight => m_GlobalMaxWeight;
public virtual int DefaultMaxItems => GlobalMaxItems;
public virtual int DefaultMaxWeight => GlobalMaxWeight;
public virtual bool IsDecoContainer => !Movable && !IsLockedDown && !IsSecure && Parent == null && !m_LiftOverride;
public virtual bool IsDecoContainer => !Movable && !IsLockedDown && !IsSecure && Parent == null && !LiftOverride;
public virtual int GetDroppedSound( Item item )
{
@ -151,7 +139,7 @@ namespace Server.Items
public override void OnSnoop( Mobile from )
{
m_SnoopHandler?.Invoke( this, from );
SnoopHandler?.Invoke( this, from );
}
public override bool CheckLift( Mobile from, Item item, ref LRReason reject )
@ -1284,7 +1272,7 @@ namespace Server.Items
SetSaveFlag( ref flags, SaveFlag.MaxItems, m_MaxItems != -1 );
SetSaveFlag( ref flags, SaveFlag.GumpID, m_GumpID != -1 );
SetSaveFlag( ref flags, SaveFlag.DropSound, m_DropSound != -1 );
SetSaveFlag( ref flags, SaveFlag.LiftOverride, m_LiftOverride );
SetSaveFlag( ref flags, SaveFlag.LiftOverride, LiftOverride );
writer.Write( (byte) flags );
@ -1325,7 +1313,7 @@ namespace Server.Items
else
m_DropSound = -1;
m_LiftOverride = GetSaveFlag( flags, SaveFlag.LiftOverride );
LiftOverride = GetSaveFlag( flags, SaveFlag.LiftOverride );
break;
}
@ -1337,7 +1325,7 @@ namespace Server.Items
case 0:
{
if ( version < 1 )
m_MaxItems = m_GlobalMaxItems;
m_MaxItems = GlobalMaxItems;
m_GumpID = reader.ReadInt();
m_DropSound = reader.ReadInt();
@ -1362,15 +1350,9 @@ namespace Server.Items
UpdateContainerData();
}
private static int m_GlobalMaxItems = 125;
private static int m_GlobalMaxWeight = 400;
public static int GlobalMaxItems { get; set; } = 125;
public static int GlobalMaxItems{ get => m_GlobalMaxItems;
set => m_GlobalMaxItems = value;
}
public static int GlobalMaxWeight{ get => m_GlobalMaxWeight;
set => m_GlobalMaxWeight = value;
}
public static int GlobalMaxWeight { get; set; } = 400;
public Container( int itemID ) : base( itemID )
{
@ -1658,13 +1640,7 @@ namespace Server.Items
//LabelTo( from, 1050044, String.Format( "{0}\t{1}", TotalItems.ToString(), TotalWeight.ToString() ) );
}
private List<Mobile> m_Openers;
public List<Mobile> Openers
{
get => m_Openers;
set => m_Openers = value;
}
public List<Mobile> Openers { get; set; }
public virtual bool IsPublicContainer => false;
@ -1672,7 +1648,7 @@ namespace Server.Items
{
base.OnDelete();
m_Openers = null;
Openers = null;
}
public virtual void DisplayTo( Mobile to )
@ -1706,14 +1682,14 @@ namespace Server.Items
{
bool contains = false;
if ( m_Openers != null )
if ( Openers != null )
{
Point3D worldLoc = GetWorldLocation();
Map map = Map;
for ( int i = 0; i < m_Openers.Count; ++i )
for ( int i = 0; i < Openers.Count; ++i )
{
Mobile mob = m_Openers[i];
Mobile mob = Openers[i];
if ( mob == opener )
contains = true;
@ -1722,20 +1698,20 @@ namespace Server.Items
int range = GetUpdateRange( mob );
if ( mob.Map != map || !mob.InRange( worldLoc, range ) )
m_Openers.RemoveAt( i-- );
Openers.RemoveAt( i-- );
}
}
}
if ( !contains )
{
if ( m_Openers == null )
m_Openers = new List<Mobile>();
if ( Openers == null )
Openers = new List<Mobile>();
m_Openers.Add( opener );
Openers.Add( opener );
}
else if ( m_Openers != null && m_Openers.Count == 0 )
m_Openers = null;
else if ( Openers != null && Openers.Count == 0 )
Openers = null;
}
}
@ -1786,7 +1762,7 @@ namespace Server.Items
if ( !File.Exists( path ) )
{
m_Default = new ContainerData( 0x3C, new Rectangle2D( 44, 65, 142, 94 ), 0x48 );
Default = new ContainerData( 0x3C, new Rectangle2D( 44, 65, 142, 94 ), 0x48 );
return;
}
@ -1824,8 +1800,8 @@ namespace Server.Items
ContainerData data = new ContainerData( gumpID, bounds, dropSound );
if ( m_Default == null )
m_Default = data;
if ( Default == null )
Default = data;
if ( split.Length >= 4 )
{
@ -1853,18 +1829,13 @@ namespace Server.Items
}
}
if ( m_Default == null )
m_Default = new ContainerData( 0x3C, new Rectangle2D( 44, 65, 142, 94 ), 0x48 );
if ( Default == null )
Default = new ContainerData( 0x3C, new Rectangle2D( 44, 65, 142, 94 ), 0x48 );
}
private static ContainerData m_Default;
private static Dictionary<int, ContainerData> m_Table;
public static ContainerData Default
{
get => m_Default;
set => m_Default = value;
}
public static ContainerData Default { get; set; }
public static ContainerData GetData( int itemID )
{
@ -1873,22 +1844,20 @@ namespace Server.Items
if ( data != null )
return data;
return m_Default;
return Default;
}
private int m_GumpID;
private Rectangle2D m_Bounds;
private int m_DropSound;
public int GumpID { get; }
public int GumpID => m_GumpID;
public Rectangle2D Bounds => m_Bounds;
public int DropSound => m_DropSound;
public Rectangle2D Bounds { get; }
public int DropSound { get; }
public ContainerData( int gumpID, Rectangle2D bounds, int dropSound )
{
m_GumpID = gumpID;
m_Bounds = bounds;
m_DropSound = dropSound;
GumpID = gumpID;
Bounds = bounds;
DropSound = dropSound;
}
}
}

View file

@ -27,9 +27,6 @@ namespace Server.Items
{
public class BankBox : Container
{
private Mobile m_Owner;
private bool m_Open;
public override int DefaultMaxWeight => 0;
public override bool IsVirtualItem => true;
@ -38,20 +35,20 @@ namespace Server.Items
{
}
public Mobile Owner => m_Owner;
public Mobile Owner { get; private set; }
public bool Opened => m_Open;
public bool Opened { get; private set; }
public void Open()
{
m_Open = true;
Opened = true;
if ( m_Owner != null )
if ( Owner != null )
{
m_Owner.PrivateOverheadMessage( MessageType.Regular, 0x3B2, true,
$"Bank container has {TotalItems} items, {TotalWeight} stones", m_Owner.NetState );
m_Owner.Send( new EquipUpdate( this ) );
DisplayTo( m_Owner );
Owner.PrivateOverheadMessage( MessageType.Regular, 0x3B2, true,
$"Bank container has {TotalItems} items, {TotalWeight} stones", Owner.NetState );
Owner.Send( new EquipUpdate( this ) );
DisplayTo( Owner );
}
}
@ -61,8 +58,8 @@ namespace Server.Items
writer.Write( (int) 0 ); // version
writer.Write( (Mobile) m_Owner );
writer.Write( (bool) m_Open );
writer.Write( (Mobile) Owner );
writer.Write( (bool) Opened );
}
public override void Deserialize( GenericReader reader )
@ -75,10 +72,10 @@ namespace Server.Items
{
case 0:
{
m_Owner = reader.ReadMobile();
m_Open = reader.ReadBool();
Owner = reader.ReadMobile();
Opened = reader.ReadBool();
if ( m_Owner == null )
if ( Owner == null )
Delete();
break;
@ -89,18 +86,14 @@ namespace Server.Items
ItemID = 0xE7C;
}
private static bool m_SendRemovePacket;
public static bool SendDeleteOnClose{ get => m_SendRemovePacket;
set => m_SendRemovePacket = value;
}
public static bool SendDeleteOnClose { get; set; }
public void Close()
{
m_Open = false;
Opened = false;
if ( m_Owner != null && m_SendRemovePacket )
m_Owner.Send( RemovePacket );
if ( Owner != null && SendDeleteOnClose )
Owner.Send( RemovePacket );
}
public override void OnSingleClick( Mobile from )
@ -120,26 +113,26 @@ namespace Server.Items
{
Layer = Layer.Bank;
Movable = false;
m_Owner = owner;
Owner = owner;
}
public override bool IsAccessibleTo(Mobile check)
{
if ( ( check == m_Owner && m_Open ) || check.AccessLevel >= AccessLevel.GameMaster )
if ( ( check == Owner && Opened ) || check.AccessLevel >= AccessLevel.GameMaster )
return base.IsAccessibleTo (check);
return false;
}
public override bool OnDragDrop( Mobile from, Item dropped )
{
if ( ( from == m_Owner && m_Open ) || from.AccessLevel >= AccessLevel.GameMaster )
if ( ( from == Owner && Opened ) || from.AccessLevel >= AccessLevel.GameMaster )
return base.OnDragDrop( from, dropped );
return false;
}
public override bool OnDragDropInto(Mobile from, Item item, Point3D p)
{
if ( ( from == m_Owner && m_Open ) || from.AccessLevel >= AccessLevel.GameMaster )
if ( ( from == Owner && Opened ) || from.AccessLevel >= AccessLevel.GameMaster )
return base.OnDragDropInto (from, item, p);
return false;
}

View file

@ -25,13 +25,11 @@ namespace Server.Items
{
public class SecureTradeContainer : Container
{
private SecureTrade m_Trade;
public SecureTrade Trade => m_Trade;
public SecureTrade Trade { get; }
public SecureTradeContainer( SecureTrade trade ) : base( 0x1E5E )
{
m_Trade = trade;
Trade = trade;
Movable = false;
}
@ -65,7 +63,7 @@ namespace Server.Items
public override bool IsAccessibleTo( Mobile check )
{
if ( !IsChildOf( check ) || m_Trade == null || !m_Trade.Valid )
if ( !IsChildOf( check ) || Trade == null || !Trade.Valid )
return false;
return base.IsAccessibleTo( check );
@ -105,19 +103,19 @@ namespace Server.Items
public void ClearChecks( )
{
if ( m_Trade != null )
if ( Trade != null )
{
if ( m_Trade.From != null && !m_Trade.From.IsDisposed )
if ( Trade.From != null && !Trade.From.IsDisposed )
{
m_Trade.From.Accepted = false;
Trade.From.Accepted = false;
}
if ( m_Trade.To != null && !m_Trade.To.IsDisposed )
if ( Trade.To != null && !Trade.To.IsDisposed )
{
m_Trade.To.Accepted = false;
Trade.To.Accepted = false;
}
m_Trade.Update();
Trade.Update();
}
}

View file

@ -24,18 +24,11 @@ namespace Server
{
public abstract class BaseHairInfo
{
private int m_ItemID;
private int m_Hue;
[CommandProperty( AccessLevel.GameMaster )]
public int ItemID { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public int ItemID { get => m_ItemID;
set => m_ItemID = value;
}
[CommandProperty( AccessLevel.GameMaster )]
public int Hue { get => m_Hue;
set => m_Hue = value;
}
public int Hue { get; set; }
protected BaseHairInfo( int itemid )
: this( itemid, 0 )
@ -44,8 +37,8 @@ namespace Server
protected BaseHairInfo( int itemid, int hue )
{
m_ItemID = itemid;
m_Hue = hue;
ItemID = itemid;
Hue = hue;
}
protected BaseHairInfo( GenericReader reader )
@ -56,8 +49,8 @@ namespace Server
{
case 0:
{
m_ItemID = reader.ReadInt();
m_Hue = reader.ReadInt();
ItemID = reader.ReadInt();
Hue = reader.ReadInt();
break;
}
}
@ -66,8 +59,8 @@ namespace Server
public virtual void Serialize( GenericWriter writer )
{
writer.Write( (int)0 ); //version
writer.Write( (int)m_ItemID );
writer.Write( (int)m_Hue );
writer.Write( (int)ItemID );
writer.Write( (int)Hue );
}
}

View file

@ -23,21 +23,20 @@ namespace Server
public class KeywordList
{
private int[] m_Keywords;
private int m_Count;
public KeywordList()
{
m_Keywords = new int[8];
m_Count = 0;
Count = 0;
}
public int Count => m_Count;
public int Count { get; private set; }
public bool Contains( int keyword )
{
bool contains = false;
for ( int i = 0; !contains && i < m_Count; ++i )
for ( int i = 0; !contains && i < Count; ++i )
contains = ( keyword == m_Keywords[i] );
return contains;
@ -45,7 +44,7 @@ namespace Server
public void Add( int keyword )
{
if ( (m_Count + 1) > m_Keywords.Length )
if ( (Count + 1) > m_Keywords.Length )
{
int[] old = m_Keywords;
m_Keywords = new int[old.Length * 2];
@ -54,22 +53,22 @@ namespace Server
m_Keywords[i] = old[i];
}
m_Keywords[m_Count++] = keyword;
m_Keywords[Count++] = keyword;
}
private static int[] m_EmptyInts = new int[0];
public int[] ToArray()
{
if ( m_Count == 0 )
if ( Count == 0 )
return m_EmptyInts;
int[] keywords = new int[m_Count];
int[] keywords = new int[Count];
for ( int i = 0; i < m_Count; ++i )
for ( int i = 0; i < Count; ++i )
keywords[i] = m_Keywords[i];
m_Count = 0;
Count = 0;
return keywords;
}

View file

@ -42,29 +42,13 @@ namespace Server
private static string m_BaseDirectory;
private static string m_ExePath;
private static readonly List<string> m_DataDirectories = new List<string>();
private static Assembly m_Assembly;
private static Process m_Process;
private static Thread m_Thread;
private static bool m_Service;
private static bool m_Debug;
private static bool m_Cache = true;
private static bool m_HaltOnWarning;
private static bool m_VBdotNET;
private static MultiTextWriter m_MultiConOut;
private static bool m_Profiling;
private static DateTime m_ProfileStart;
private static TimeSpan m_ProfileTime;
private static MessagePump m_MessagePump;
public static MessagePump MessagePump
{
get => m_MessagePump;
set => m_MessagePump = value;
}
public static MessagePump MessagePump { get; set; }
public static Slice Slice;
@ -96,18 +80,24 @@ namespace Server
}
}
public static bool Service => m_Service;
public static bool Debug => m_Debug;
internal static bool HaltOnWarning => m_HaltOnWarning;
internal static bool VBdotNet => m_VBdotNET;
public static List<string> DataDirectories => m_DataDirectories;
public static Assembly Assembly { get => m_Assembly;
set => m_Assembly = value;
}
public static Version Version => m_Assembly.GetName().Version;
public static Process Process => m_Process;
public static Thread Thread => m_Thread;
public static MultiTextWriter MultiConsoleOut => m_MultiConOut;
public static bool Service { get; private set; }
public static bool Debug { get; private set; }
internal static bool HaltOnWarning { get; private set; }
internal static bool VBdotNet { get; private set; }
public static List<string> DataDirectories { get; } = new List<string>();
public static Assembly Assembly { get; set; }
public static Version Version => Assembly.GetName().Version;
public static Process Process { get; private set; }
public static Thread Thread { get; private set; }
public static MultiTextWriter MultiConsoleOut { get; private set; }
/*
* DateTime.Now and DateTime.UtcNow are based on actual system clock time.
@ -146,24 +136,20 @@ namespace Server
public static readonly bool Is64Bit = Environment.Is64BitProcess;
private static bool m_MultiProcessor;
private static int m_ProcessorCount;
public static bool MultiProcessor { get; private set; }
public static bool MultiProcessor => m_MultiProcessor;
public static int ProcessorCount => m_ProcessorCount;
public static int ProcessorCount { get; private set; }
private static bool m_Unix;
public static bool Unix => m_Unix;
public static bool Unix { get; private set; }
public static string FindDataFile( string path )
{
if ( m_DataDirectories.Count == 0 )
if ( DataDirectories.Count == 0 )
throw new InvalidOperationException( "Attempted to FindDataFile before DataDirectories list has been filled." );
string fullPath = null;
foreach (string p in m_DataDirectories)
foreach (string p in DataDirectories)
{
fullPath = Path.Combine( p, path );
@ -183,32 +169,27 @@ namespace Server
#region Expansions
private static Expansion m_Expansion;
public static Expansion Expansion
{
get => m_Expansion;
set => m_Expansion = value;
}
public static Expansion Expansion { get; set; }
public static bool T2A => m_Expansion >= Expansion.T2A;
public static bool T2A => Expansion >= Expansion.T2A;
public static bool UOR => m_Expansion >= Expansion.UOR;
public static bool UOR => Expansion >= Expansion.UOR;
public static bool UOTD => m_Expansion >= Expansion.UOTD;
public static bool UOTD => Expansion >= Expansion.UOTD;
public static bool LBR => m_Expansion >= Expansion.LBR;
public static bool LBR => Expansion >= Expansion.LBR;
public static bool AOS => m_Expansion >= Expansion.AOS;
public static bool AOS => Expansion >= Expansion.AOS;
public static bool SE => m_Expansion >= Expansion.SE;
public static bool SE => Expansion >= Expansion.SE;
public static bool ML => m_Expansion >= Expansion.ML;
public static bool ML => Expansion >= Expansion.ML;
public static bool SA => m_Expansion >= Expansion.SA;
public static bool SA => Expansion >= Expansion.SA;
public static bool HS => m_Expansion >= Expansion.HS;
public static bool HS => Expansion >= Expansion.HS;
public static bool TOL => m_Expansion >= Expansion.TOL;
public static bool TOL => Expansion >= Expansion.TOL;
#endregion
@ -260,11 +241,11 @@ namespace Server
{
}
if ( !close && !m_Service )
if ( !close && !Service )
{
try
{
foreach (Listener l in m_MessagePump.Listeners)
foreach (Listener l in MessagePump.Listeners)
{
l.Dispose();
}
@ -300,7 +281,7 @@ namespace Server
private static bool OnConsoleEvent( ConsoleEventType type )
{
if ( World.Saving || ( m_Service && type == ConsoleEventType.CTRL_LOGOFF_EVENT ) )
if ( World.Saving || ( Service && type == ConsoleEventType.CTRL_LOGOFF_EVENT ) )
return true;
Kill(); //Kill -> HandleClosed will handle waiting for the completion of flushing to disk
@ -313,8 +294,7 @@ namespace Server
HandleClosed();
}
private static bool m_Closing;
public static bool Closing => m_Closing;
public static bool Closing { get; private set; }
private static int m_CycleIndex = 1;
private static readonly float[] m_CyclesPerSecond = new float[100];
@ -335,15 +315,15 @@ namespace Server
if ( restart )
Process.Start( ExePath, Arguments );
m_Process.Kill();
Process.Kill();
}
private static void HandleClosed()
{
if ( m_Closing )
if ( Closing )
return;
m_Closing = true;
Closing = true;
Console.Write( "Exiting..." );
@ -369,45 +349,45 @@ namespace Server
foreach (string a in args)
{
if ( Insensitive.Equals( a, "-debug" ) )
m_Debug = true;
Debug = true;
else if ( Insensitive.Equals( a, "-service" ) )
m_Service = true;
Service = true;
else if ( Insensitive.Equals( a, "-profile" ) )
Profiling = true;
else if ( Insensitive.Equals( a, "-nocache" ) )
m_Cache = false;
else if ( Insensitive.Equals( a, "-haltonwarning" ) )
m_HaltOnWarning = true;
HaltOnWarning = true;
else if ( Insensitive.Equals( a, "-vb" ) )
m_VBdotNET = true;
VBdotNet = true;
else if ( Insensitive.Equals( a, "-usehrt" ) )
_UseHRT = true;
}
try
{
if ( m_Service )
if ( Service )
{
if ( !Directory.Exists( "Logs" ) )
Directory.CreateDirectory( "Logs" );
Console.SetOut( m_MultiConOut = new MultiTextWriter( new FileLogger( "Logs/Console.log" ) ) );
Console.SetOut( MultiConsoleOut = new MultiTextWriter( new FileLogger( "Logs/Console.log" ) ) );
}
else
{
Console.SetOut( m_MultiConOut = new MultiTextWriter( Console.Out ) );
Console.SetOut( MultiConsoleOut = new MultiTextWriter( Console.Out ) );
}
}
catch
{
}
m_Thread = Thread.CurrentThread;
m_Process = Process.GetCurrentProcess();
m_Assembly = Assembly.GetEntryAssembly();
Thread = Thread.CurrentThread;
Process = Process.GetCurrentProcess();
Assembly = Assembly.GetEntryAssembly();
if ( m_Thread != null )
m_Thread.Name = "Core Thread";
if ( Thread != null )
Thread.Name = "Core Thread";
if ( BaseDirectory.Length > 0 )
Directory.SetCurrentDirectory( BaseDirectory );
@ -418,7 +398,7 @@ namespace Server
Name = "Timer Thread"
};
Version ver = m_Assembly.GetName().Version;
Version ver = Assembly.GetName().Version;
// Added to help future code support on forums, as a 'check' people can ask for to it see if they recompiled core or not
Console.WriteLine("RunUO - [https://github.com/runuo/] Version {0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision);
@ -429,17 +409,17 @@ namespace Server
if ( s.Length > 0 )
Console.WriteLine( "Core: Running with arguments: {0}", s );
m_ProcessorCount = Environment.ProcessorCount;
ProcessorCount = Environment.ProcessorCount;
if ( m_ProcessorCount > 1 )
m_MultiProcessor = true;
if ( ProcessorCount > 1 )
MultiProcessor = true;
if ( m_MultiProcessor || Is64Bit )
Console.WriteLine( "Core: Optimizing for {0} {2}processor{1}", m_ProcessorCount, m_ProcessorCount == 1 ? "" : "s", Is64Bit ? "64-bit " : "" );
if ( MultiProcessor || Is64Bit )
Console.WriteLine( "Core: Optimizing for {0} {2}processor{1}", ProcessorCount, ProcessorCount == 1 ? "" : "s", Is64Bit ? "64-bit " : "" );
int platform = (int)Environment.OSVersion.Platform;
if ( platform == 4 || platform == 128 ) { // MS 4, MONO 128
m_Unix = true;
Unix = true;
Console.WriteLine( "Core: Unix environment detected" );
}
else {
@ -455,11 +435,11 @@ namespace Server
Console.WriteLine("RandomImpl: {0} ({1})", RandomImpl.Type.Name, RandomImpl.IsHardwareRNG ? "Hardware" : "Software");
while( !ScriptCompiler.Compile( m_Debug, m_Cache ) )
while( !ScriptCompiler.Compile( Debug, m_Cache ) )
{
Console.WriteLine( "Scripts: One or more scripts failed to compile or no script files were found." );
if ( m_Service )
if ( Service )
return;
Console.WriteLine( " - Press return to exit, or R to try again." );
@ -475,7 +455,7 @@ namespace Server
ScriptCompiler.Invoke( "Initialize" );
MessagePump messagePump = m_MessagePump = new MessagePump();
MessagePump messagePump = MessagePump = new MessagePump();
timerThread.Start();
@ -495,7 +475,7 @@ namespace Server
long sample = 0;
while( !m_Closing )
while( !Closing )
{
m_Signal.WaitOne();
@ -534,10 +514,10 @@ namespace Server
{
StringBuilder sb = new StringBuilder();
if ( m_Debug )
if ( Debug )
Utility.Separate( sb, "-debug", " " );
if ( m_Service )
if ( Service )
Utility.Separate( sb, "-service", " " );
if ( m_Profiling )
@ -546,10 +526,10 @@ namespace Server
if ( !m_Cache )
Utility.Separate( sb, "-nocache", " " );
if ( m_HaltOnWarning )
if ( HaltOnWarning )
Utility.Separate( sb, "-haltonwarning", " " );
if ( m_VBdotNET )
if ( VBdotNet )
Utility.Separate( sb, "-vb", " " );
if ( _UseHRT )
@ -559,21 +539,9 @@ namespace Server
}
}
private static int m_GlobalUpdateRange = 18;
public static int GlobalUpdateRange { get; set; } = 18;
public static int GlobalUpdateRange
{
get => m_GlobalUpdateRange;
set => m_GlobalUpdateRange = value;
}
private static int m_GlobalMaxUpdateRange = 24;
public static int GlobalMaxUpdateRange
{
get => m_GlobalMaxUpdateRange;
set => m_GlobalMaxUpdateRange = value;
}
public static int GlobalMaxUpdateRange { get; set; } = 24;
private static int m_ItemCount, m_MobileCount;

View file

@ -291,49 +291,38 @@ namespace Server
public const int SectorShift = 4;
public static int SectorActiveRange = 2;
private static Map[] m_Maps = new Map[0x100];
public static Map[] Maps { get; } = new Map[0x100];
public static Map[] Maps => m_Maps;
public static Map Felucca => Maps[0];
public static Map Trammel => Maps[1];
public static Map Ilshenar => Maps[2];
public static Map Malas => Maps[3];
public static Map Tokuno => Maps[4];
public static Map TerMur => Maps[5];
public static Map Internal => Maps[0x7F];
public static Map Felucca => m_Maps[0];
public static Map Trammel => m_Maps[1];
public static Map Ilshenar => m_Maps[2];
public static Map Malas => m_Maps[3];
public static Map Tokuno => m_Maps[4];
public static Map TerMur => m_Maps[5];
public static Map Internal => m_Maps[0x7F];
public static List<Map> AllMaps { get; } = new List<Map>();
private static List<Map> m_AllMaps = new List<Map>();
private int m_FileIndex;
public static List<Map> AllMaps => m_AllMaps;
private int m_MapID, m_MapIndex, m_FileIndex;
private int m_Width, m_Height;
private int m_SectorsWidth, m_SectorsHeight;
private int m_Season;
private Dictionary<string, Region> m_Regions;
private Region m_DefaultRegion;
public int Season { get => m_Season;
set => m_Season = value;
}
public int Season { get; set; }
private string m_Name;
private MapRules m_Rules;
private Sector[][] m_Sectors;
private Sector m_InvalidSector;
private TileMatrix m_Tiles;
public static string[] GetMapNames()
{
return m_Maps.Where(m => m != null).Select(m => m.Name).ToArray();
return Maps.Where(m => m != null).Select(m => m.Name).ToArray();
}
public static Map[] GetMapValues()
{
return m_Maps.Where(m => m != null).ToArray();
return Maps.Where(m => m != null).ToArray();
}
public static Map Parse(string value)
@ -350,7 +339,7 @@ namespace Server
if (!int.TryParse(value, out int index))
{
return m_Maps.FirstOrDefault(m => m != null && Insensitive.Equals(m.Name, value));
return Maps.FirstOrDefault(m => m != null && Insensitive.Equals(m.Name, value));
}
if (index == 127)
@ -358,7 +347,7 @@ namespace Server
return Internal;
}
return m_Maps.FirstOrDefault(m => m != null && m.MapIndex == index);
return Maps.FirstOrDefault(m => m != null && m.MapIndex == index);
}
public override string ToString()
@ -523,7 +512,7 @@ namespace Server
if ( this == Internal )
return false;
if ( x < 0 || y < 0 || x >= m_Width || y >= m_Height )
if ( x < 0 || y < 0 || x >= Width || y >= Height )
return false;
bool hasSurface = false;
@ -853,15 +842,15 @@ namespace Server
{
if ( x < 0 )
newX = 0;
else if ( x >= m_Width )
newX = m_Width - 1;
else if ( x >= Width )
newX = Width - 1;
else
newX = x;
if ( y < 0 )
newY = 0;
else if ( y >= m_Height )
newY = m_Height - 1;
else if ( y >= Height )
newY = Height - 1;
else
newY = y;
}
@ -872,29 +861,29 @@ namespace Server
if ( x < 0 )
x = 0;
else if ( x >= m_Width )
x = m_Width - 1;
else if ( x >= Width )
x = Width - 1;
if ( y < 0 )
y = 0;
else if ( y >= m_Height )
y = m_Height - 1;
else if ( y >= Height )
y = Height - 1;
return new Point2D( x, y );
}
public Map( int mapID, int mapIndex, int fileIndex, int width, int height, int season, string name, MapRules rules )
{
m_MapID = mapID;
m_MapIndex = mapIndex;
MapID = mapID;
MapIndex = mapIndex;
m_FileIndex = fileIndex;
m_Width = width;
m_Height = height;
m_Season = season;
Width = width;
Height = height;
Season = season;
m_Name = name;
m_Rules = rules;
m_Regions = new Dictionary<string, Region>( StringComparer.OrdinalIgnoreCase );
m_InvalidSector = new Sector( 0, 0, this );
Rules = rules;
Regions = new Dictionary<string, Region>( StringComparer.OrdinalIgnoreCase );
InvalidSector = new Sector( 0, 0, this );
m_SectorsWidth = width >> SectorShift;
m_SectorsHeight = height >> SectorShift;
m_Sectors = new Sector[m_SectorsWidth][];
@ -943,7 +932,7 @@ namespace Server
return sec;
}
return m_InvalidSector;
return InvalidSector;
}
#endregion
@ -954,7 +943,7 @@ namespace Server
for ( int y = cy - SectorActiveRange; y <= cy + SectorActiveRange; ++y )
{
Sector sect = GetRealSector( x, y );
if ( sect != m_InvalidSector )
if ( sect != InvalidSector )
sect.Activate();
}
}
@ -967,7 +956,7 @@ namespace Server
for ( int y = cy - SectorActiveRange; y <= cy + SectorActiveRange; ++y )
{
Sector sect = GetRealSector( x, y );
if ( sect != m_InvalidSector && !PlayersInRange( sect, SectorActiveRange ) )
if ( sect != InvalidSector && !PlayersInRange( sect, SectorActiveRange ) )
sect.Deactivate();
}
}
@ -980,7 +969,7 @@ namespace Server
for ( int y = sect.Y - range; y <= sect.Y + range; ++y )
{
Sector check = GetRealSector( x, y );
if ( check != m_InvalidSector && check.Players.Count > 0 )
if ( check != InvalidSector && check.Players.Count > 0 )
return true;
}
}
@ -1127,21 +1116,21 @@ namespace Server
{
if (m_Tiles == null)
lock (tileLock)
m_Tiles = new TileMatrix(this, m_FileIndex, m_MapID, m_Width, m_Height);
m_Tiles = new TileMatrix(this, m_FileIndex, MapID, Width, Height);
return m_Tiles;
}
}
public int MapID => m_MapID;
public int MapID { get; }
public int MapIndex => m_MapIndex;
public int MapIndex { get; }
public int Width => m_Width;
public int Width { get; }
public int Height => m_Height;
public int Height { get; }
public Dictionary<string, Region> Regions => m_Regions;
public Dictionary<string, Region> Regions { get; }
public void RegisterRegion( Region reg )
{
@ -1149,10 +1138,10 @@ namespace Server
if ( regName != null )
{
if ( m_Regions.ContainsKey( regName ) )
if ( Regions.ContainsKey( regName ) )
Console.WriteLine( "Warning: Duplicate region name '{0}' for map '{1}'", regName, Name );
else
m_Regions[regName] = reg;
Regions[regName] = reg;
}
}
@ -1161,7 +1150,7 @@ namespace Server
string regName = reg.Name;
if ( regName != null )
m_Regions.Remove( regName );
Regions.Remove( regName );
}
public Region DefaultRegion
@ -1176,13 +1165,9 @@ namespace Server
set => m_DefaultRegion = value;
}
public MapRules Rules
{
get => m_Rules;
set => m_Rules = value;
}
public MapRules Rules { get; set; }
public Sector InvalidSector => m_InvalidSector;
public Sector InvalidSector { get; }
public string Name
{
@ -1349,20 +1334,15 @@ namespace Server
}
#region Line Of Sight
private static int m_MaxLOSDistance = 25;
public static int MaxLOSDistance
{
get => m_MaxLOSDistance;
set => m_MaxLOSDistance = value;
}
public static int MaxLOSDistance { get; set; } = 25;
public bool LineOfSight( Point3D org, Point3D dest )
{
if ( this == Internal )
return false;
if ( !Utility.InRange( org, dest, m_MaxLOSDistance ) )
if ( !Utility.InRange( org, dest, MaxLOSDistance ) )
return false;
Point3D end = dest;
@ -1465,8 +1445,8 @@ namespace Server
bool contains = false;
int ltID = landTile.ID;
for ( int j = 0; !contains && j < m_InvalidLandTiles.Length; ++j )
contains =ltID == m_InvalidLandTiles[j];
for ( int j = 0; !contains && j < InvalidLandTiles.Length; ++j )
contains =ltID == InvalidLandTiles[j];
if ( contains && statics.Length == 0 )
{
@ -1610,20 +1590,14 @@ namespace Server
}
#endregion
private static int[] m_InvalidLandTiles = { 0x244 };
public static int[] InvalidLandTiles
{
get => m_InvalidLandTiles;
set => m_InvalidLandTiles = value;
}
public static int[] InvalidLandTiles { get; set; } = { 0x244 };
public int CompareTo( Map other )
{
if ( other == null )
return -1;
return m_MapID.CompareTo( other.m_MapID );
return MapID.CompareTo( other.MapID );
}
public int CompareTo( object other )

View file

@ -24,15 +24,11 @@ namespace Server.Menus.ItemLists
{
public class ItemListEntry
{
private string m_Name;
private int m_ItemID;
private int m_Hue;
public string Name { get; }
public string Name => m_Name;
public int ItemID { get; }
public int ItemID => m_ItemID;
public int Hue => m_Hue;
public int Hue { get; }
public ItemListEntry( string name, int itemID ) : this( name, itemID, 0 )
{
@ -40,36 +36,29 @@ namespace Server.Menus.ItemLists
public ItemListEntry( string name, int itemID, int hue )
{
m_Name = name;
m_ItemID = itemID;
m_Hue = hue;
Name = name;
ItemID = itemID;
Hue = hue;
}
}
public class ItemListMenu : IMenu
{
private string m_Question;
private ItemListEntry[] m_Entries;
private int m_Serial;
private static int m_NextSerial;
int IMenu.Serial => m_Serial;
int IMenu.EntryLength => m_Entries.Length;
int IMenu.EntryLength => Entries.Length;
public string Question => m_Question;
public string Question { get; }
public ItemListEntry[] Entries
{
get => m_Entries;
set => m_Entries = value;
}
public ItemListEntry[] Entries { get; set; }
public ItemListMenu( string question, ItemListEntry[] entries )
{
m_Question = question;
m_Entries = entries;
Question = question;
Entries = entries;
do
{

View file

@ -24,28 +24,21 @@ namespace Server.Menus.Questions
{
public class QuestionMenu : IMenu
{
private string m_Question;
private string[] m_Answers;
private int m_Serial;
private static int m_NextSerial;
int IMenu.Serial => m_Serial;
int IMenu.EntryLength => m_Answers.Length;
int IMenu.EntryLength => Answers.Length;
public string Question
{
get => m_Question;
set => m_Question = value;
}
public string Question { get; set; }
public string[] Answers => m_Answers;
public string[] Answers { get; }
public QuestionMenu( string question, string[] answers )
{
m_Question = question;
m_Answers = answers;
Question = question;
Answers = answers;
do
{

View file

@ -22,18 +22,12 @@ namespace Server.Movement
{
public static class Movement
{
private static IMovementImpl m_Impl;
public static IMovementImpl Impl
{
get => m_Impl;
set => m_Impl = value;
}
public static IMovementImpl Impl { get; set; }
public static bool CheckMovement( Mobile m, Direction d, out int newZ )
{
if ( m_Impl != null )
return m_Impl.CheckMovement( m, d, out newZ );
if ( Impl != null )
return Impl.CheckMovement( m, d, out newZ );
newZ = m.Z;
return false;
@ -41,8 +35,8 @@ namespace Server.Movement
public static bool CheckMovement( Mobile m, Map map, Point3D loc, Direction d, out int newZ )
{
if ( m_Impl != null )
return m_Impl.CheckMovement( m, map, loc, d, out newZ );
if ( Impl != null )
return Impl.CheckMovement( m, map, loc, d, out newZ );
newZ = m.Z;
return false;

View file

@ -145,39 +145,33 @@ namespace Server
public sealed class MultiComponentList
{
public static bool PostHSFormat {
get => _PostHSFormat;
set => _PostHSFormat = value;
}
public static bool PostHSFormat { get; set; }
private static bool _PostHSFormat;
private Point2D m_Min, m_Max, m_Center;
private int m_Width, m_Height;
private StaticTile[][][] m_Tiles;
private MultiTileEntry[] m_List;
private Point2D m_Min, m_Max;
public static readonly MultiComponentList Empty = new MultiComponentList();
public Point2D Min => m_Min;
public Point2D Max => m_Max;
public Point2D Center => m_Center;
public Point2D Center { get; }
public int Width => m_Width;
public int Height => m_Height;
public int Width { get; private set; }
public StaticTile[][][] Tiles => m_Tiles;
public MultiTileEntry[] List => m_List;
public int Height { get; private set; }
public StaticTile[][][] Tiles { get; private set; }
public MultiTileEntry[] List { get; private set; }
public void Add( int itemID, int x, int y, int z )
{
int vx = x + m_Center.m_X;
int vy = y + m_Center.m_Y;
int vx = x + Center.m_X;
int vy = y + Center.m_Y;
if ( vx >= 0 && vx < m_Width && vy >= 0 && vy < m_Height )
if ( vx >= 0 && vx < Width && vy >= 0 && vy < Height )
{
StaticTile[] oldTiles = m_Tiles[vx][vy];
StaticTile[] oldTiles = Tiles[vx][vy];
for ( int i = oldTiles.Length - 1; i >= 0; --i )
{
@ -193,7 +187,7 @@ namespace Server
}
}
oldTiles = m_Tiles[vx][vy];
oldTiles = Tiles[vx][vy];
StaticTile[] newTiles = new StaticTile[oldTiles.Length + 1];
@ -202,9 +196,9 @@ namespace Server
newTiles[oldTiles.Length] = new StaticTile( (ushort)itemID, (sbyte)z );
m_Tiles[vx][vy] = newTiles;
Tiles[vx][vy] = newTiles;
MultiTileEntry[] oldList = m_List;
MultiTileEntry[] oldList = List;
MultiTileEntry[] newList = new MultiTileEntry[oldList.Length + 1];
for ( int i = 0; i < oldList.Length; ++i )
@ -212,7 +206,7 @@ namespace Server
newList[oldList.Length] = new MultiTileEntry( (ushort)itemID, (short)x, (short)y, (short)z, 1 );
m_List = newList;
List = newList;
if ( x < m_Min.m_X )
m_Min.m_X = x;
@ -230,12 +224,12 @@ namespace Server
public void RemoveXYZH( int x, int y, int z, int minHeight )
{
int vx = x + m_Center.m_X;
int vy = y + m_Center.m_Y;
int vx = x + Center.m_X;
int vy = y + Center.m_Y;
if ( vx >= 0 && vx < m_Width && vy >= 0 && vy < m_Height )
if ( vx >= 0 && vx < Width && vy >= 0 && vy < Height )
{
StaticTile[] oldTiles = m_Tiles[vx][vy];
StaticTile[] oldTiles = Tiles[vx][vy];
for ( int i = 0; i < oldTiles.Length; ++i )
{
@ -251,13 +245,13 @@ namespace Server
for ( int j = i + 1; j < oldTiles.Length; ++j )
newTiles[j - 1] = oldTiles[j];
m_Tiles[vx][vy] = newTiles;
Tiles[vx][vy] = newTiles;
break;
}
}
MultiTileEntry[] oldList = m_List;
MultiTileEntry[] oldList = List;
for ( int i = 0; i < oldList.Length; ++i )
{
@ -273,7 +267,7 @@ namespace Server
for ( int j = i + 1; j < oldList.Length; ++j )
newList[j - 1] = oldList[j];
m_List = newList;
List = newList;
break;
}
@ -283,12 +277,12 @@ namespace Server
public void Remove( int itemID, int x, int y, int z )
{
int vx = x + m_Center.m_X;
int vy = y + m_Center.m_Y;
int vx = x + Center.m_X;
int vy = y + Center.m_Y;
if ( vx >= 0 && vx < m_Width && vy >= 0 && vy < m_Height )
if ( vx >= 0 && vx < Width && vy >= 0 && vy < Height )
{
StaticTile[] oldTiles = m_Tiles[vx][vy];
StaticTile[] oldTiles = Tiles[vx][vy];
for ( int i = 0; i < oldTiles.Length; ++i )
{
@ -304,13 +298,13 @@ namespace Server
for ( int j = i + 1; j < oldTiles.Length; ++j )
newTiles[j - 1] = oldTiles[j];
m_Tiles[vx][vy] = newTiles;
Tiles[vx][vy] = newTiles;
break;
}
}
MultiTileEntry[] oldList = m_List;
MultiTileEntry[] oldList = List;
for ( int i = 0; i < oldList.Length; ++i )
{
@ -326,7 +320,7 @@ namespace Server
for ( int j = i + 1; j < oldList.Length; ++j )
newList[j - 1] = oldList[j];
m_List = newList;
List = newList;
break;
}
@ -336,8 +330,8 @@ namespace Server
public void Resize( int newWidth, int newHeight )
{
int oldWidth = m_Width, oldHeight = m_Height;
StaticTile[][][] oldTiles = m_Tiles;
int oldWidth = Width, oldHeight = Height;
StaticTile[][][] oldTiles = Tiles;
int totalLength = 0;
@ -358,10 +352,10 @@ namespace Server
}
}
m_Tiles = newTiles;
m_List = new MultiTileEntry[totalLength];
m_Width = newWidth;
m_Height = newHeight;
Tiles = newTiles;
List = new MultiTileEntry[totalLength];
Width = newWidth;
Height = newHeight;
m_Min = Point2D.Zero;
m_Max = Point2D.Zero;
@ -378,8 +372,8 @@ namespace Server
{
StaticTile tile = tiles[i];
int vx = x - m_Center.X;
int vy = y - m_Center.Y;
int vx = x - Center.X;
int vy = y - Center.Y;
if ( vx < m_Min.m_X )
m_Min.m_X = vx;
@ -393,7 +387,7 @@ namespace Server
if ( vy > m_Max.m_Y )
m_Max.m_Y = vy;
m_List[index++] = new MultiTileEntry( (ushort)tile.ID, (short)vx, (short)vy, (short)tile.Z, 1 );
List[index++] = new MultiTileEntry( (ushort)tile.ID, (short)vx, (short)vy, (short)tile.Z, 1 );
}
}
}
@ -404,30 +398,30 @@ namespace Server
m_Min = toCopy.m_Min;
m_Max = toCopy.m_Max;
m_Center = toCopy.m_Center;
Center = toCopy.Center;
m_Width = toCopy.m_Width;
m_Height = toCopy.m_Height;
Width = toCopy.Width;
Height = toCopy.Height;
m_Tiles = new StaticTile[m_Width][][];
Tiles = new StaticTile[Width][][];
for ( int x = 0; x < m_Width; ++x )
for ( int x = 0; x < Width; ++x )
{
m_Tiles[x] = new StaticTile[m_Height][];
Tiles[x] = new StaticTile[Height][];
for ( int y = 0; y < m_Height; ++y )
for ( int y = 0; y < Height; ++y )
{
m_Tiles[x][y] = new StaticTile[toCopy.m_Tiles[x][y].Length];
Tiles[x][y] = new StaticTile[toCopy.Tiles[x][y].Length];
for ( int i = 0; i < m_Tiles[x][y].Length; ++i )
m_Tiles[x][y][i] = toCopy.m_Tiles[x][y][i];
for ( int i = 0; i < Tiles[x][y].Length; ++i )
Tiles[x][y][i] = toCopy.Tiles[x][y][i];
}
}
m_List = new MultiTileEntry[toCopy.m_List.Length];
List = new MultiTileEntry[toCopy.List.Length];
for ( int i = 0; i < m_List.Length; ++i )
m_List[i] = toCopy.m_List[i];
for ( int i = 0; i < List.Length; ++i )
List[i] = toCopy.List[i];
}
public void Serialize( GenericWriter writer )
@ -436,16 +430,16 @@ namespace Server
writer.Write( m_Min );
writer.Write( m_Max );
writer.Write( m_Center );
writer.Write( Center );
writer.Write( (int) m_Width );
writer.Write( (int) m_Height );
writer.Write( (int) Width );
writer.Write( (int) Height );
writer.Write( (int) m_List.Length );
writer.Write( (int) List.Length );
for ( int i = 0; i < m_List.Length; ++i )
for ( int i = 0; i < List.Length; ++i )
{
MultiTileEntry ent = m_List[i];
MultiTileEntry ent = List[i];
writer.Write( (ushort) ent.m_ItemID );
writer.Write( (short) ent.m_OffsetX );
@ -461,13 +455,13 @@ namespace Server
m_Min = reader.ReadPoint2D();
m_Max = reader.ReadPoint2D();
m_Center = reader.ReadPoint2D();
m_Width = reader.ReadInt();
m_Height = reader.ReadInt();
Center = reader.ReadPoint2D();
Width = reader.ReadInt();
Height = reader.ReadInt();
int length = reader.ReadInt();
MultiTileEntry[] allTiles = m_List = new MultiTileEntry[length];
MultiTileEntry[] allTiles = List = new MultiTileEntry[length];
if ( version == 0 ) {
for ( int i = 0; i < length; ++i )
@ -493,15 +487,15 @@ namespace Server
}
}
TileList[][] tiles = new TileList[m_Width][];
m_Tiles = new StaticTile[m_Width][][];
TileList[][] tiles = new TileList[Width][];
Tiles = new StaticTile[Width][][];
for ( int x = 0; x < m_Width; ++x )
for ( int x = 0; x < Width; ++x )
{
tiles[x] = new TileList[m_Height];
m_Tiles[x] = new StaticTile[m_Height][];
tiles[x] = new TileList[Height];
Tiles[x] = new StaticTile[Height][];
for ( int y = 0; y < m_Height; ++y )
for ( int y = 0; y < Height; ++y )
tiles[x][y] = new TileList();
}
@ -509,21 +503,21 @@ namespace Server
{
if ( i == 0 || allTiles[i].m_Flags != 0 )
{
int xOffset = allTiles[i].m_OffsetX + m_Center.m_X;
int yOffset = allTiles[i].m_OffsetY + m_Center.m_Y;
int xOffset = allTiles[i].m_OffsetX + Center.m_X;
int yOffset = allTiles[i].m_OffsetY + Center.m_Y;
tiles[xOffset][yOffset].Add( (ushort)allTiles[i].m_ItemID, (sbyte)allTiles[i].m_OffsetZ );
}
}
for ( int x = 0; x < m_Width; ++x )
for ( int y = 0; y < m_Height; ++y )
m_Tiles[x][y] = tiles[x][y].ToArray();
for ( int x = 0; x < Width; ++x )
for ( int y = 0; y < Height; ++y )
Tiles[x][y] = tiles[x][y].ToArray();
}
public MultiComponentList( BinaryReader reader, int count )
{
MultiTileEntry[] allTiles = m_List = new MultiTileEntry[count];
MultiTileEntry[] allTiles = List = new MultiTileEntry[count];
for ( int i = 0; i < count; ++i )
{
@ -533,7 +527,7 @@ namespace Server
allTiles[i].m_OffsetZ = reader.ReadInt16();
allTiles[i].m_Flags = reader.ReadInt32();
if ( _PostHSFormat )
if ( PostHSFormat )
reader.ReadInt32(); // ??
MultiTileEntry e = allTiles[i];
@ -554,19 +548,19 @@ namespace Server
}
}
m_Center = new Point2D( -m_Min.m_X, -m_Min.m_Y );
m_Width = (m_Max.m_X - m_Min.m_X) + 1;
m_Height = (m_Max.m_Y - m_Min.m_Y) + 1;
Center = new Point2D( -m_Min.m_X, -m_Min.m_Y );
Width = (m_Max.m_X - m_Min.m_X) + 1;
Height = (m_Max.m_Y - m_Min.m_Y) + 1;
TileList[][] tiles = new TileList[m_Width][];
m_Tiles = new StaticTile[m_Width][][];
TileList[][] tiles = new TileList[Width][];
Tiles = new StaticTile[Width][][];
for ( int x = 0; x < m_Width; ++x )
for ( int x = 0; x < Width; ++x )
{
tiles[x] = new TileList[m_Height];
m_Tiles[x] = new StaticTile[m_Height][];
tiles[x] = new TileList[Height];
Tiles[x] = new StaticTile[Height][];
for ( int y = 0; y < m_Height; ++y )
for ( int y = 0; y < Height; ++y )
tiles[x][y] = new TileList();
}
@ -574,22 +568,22 @@ namespace Server
{
if ( i == 0 || allTiles[i].m_Flags != 0 )
{
int xOffset = allTiles[i].m_OffsetX + m_Center.m_X;
int yOffset = allTiles[i].m_OffsetY + m_Center.m_Y;
int xOffset = allTiles[i].m_OffsetX + Center.m_X;
int yOffset = allTiles[i].m_OffsetY + Center.m_Y;
tiles[xOffset][yOffset].Add( (ushort)allTiles[i].m_ItemID, (sbyte)allTiles[i].m_OffsetZ );
}
}
for ( int x = 0; x < m_Width; ++x )
for ( int y = 0; y < m_Height; ++y )
m_Tiles[x][y] = tiles[x][y].ToArray();
for ( int x = 0; x < Width; ++x )
for ( int y = 0; y < Height; ++y )
Tiles[x][y] = tiles[x][y].ToArray();
}
private MultiComponentList()
{
m_Tiles = new StaticTile[0][][];
m_List = new MultiTileEntry[0];
Tiles = new StaticTile[0][][];
List = new MultiTileEntry[0];
}
}
}

View file

@ -24,11 +24,7 @@ namespace Server.Network
{
public class BufferPool
{
private static List<BufferPool> m_Pools = new List<BufferPool>();
public static List<BufferPool> Pools{ get => m_Pools;
set => m_Pools = value;
}
public static List<BufferPool> Pools { get; set; } = new List<BufferPool>();
private string m_Name;
@ -64,8 +60,8 @@ namespace Server.Network
for ( int i = 0; i < initialCapacity; ++i )
m_FreeBuffers.Enqueue( new byte[bufferSize] );
lock ( m_Pools )
m_Pools.Add( this );
lock ( Pools )
Pools.Add( this );
}
public byte[] AcquireBuffer()
@ -95,8 +91,8 @@ namespace Server.Network
public void Free()
{
lock ( m_Pools )
m_Pools.Remove( this );
lock ( Pools )
Pools.Remove( this );
}
}
}

View file

@ -26,11 +26,10 @@ namespace Server.Network
{
private int m_Head;
private int m_Tail;
private int m_Size;
private byte[] m_Buffer;
public int Length => m_Size;
public int Length { get; private set; }
public ByteQueue()
{
@ -41,18 +40,18 @@ namespace Server.Network
{
m_Head = 0;
m_Tail = 0;
m_Size = 0;
Length = 0;
}
private void SetCapacity( int capacity )
{
byte[] newBuffer = new byte[capacity];
if ( m_Size > 0 )
if ( Length > 0 )
{
if ( m_Head < m_Tail )
{
Buffer.BlockCopy( m_Buffer, m_Head, newBuffer, 0, m_Size );
Buffer.BlockCopy( m_Buffer, m_Head, newBuffer, 0, Length );
}
else
{
@ -62,13 +61,13 @@ namespace Server.Network
}
m_Head = 0;
m_Tail = m_Size;
m_Tail = Length;
m_Buffer = newBuffer;
}
public byte GetPacketID()
{
if ( m_Size >= 1 )
if ( Length >= 1 )
return m_Buffer[m_Head];
return 0xFF;
@ -76,7 +75,7 @@ namespace Server.Network
public int GetPacketLength()
{
if ( m_Size >= 3 )
if ( Length >= 3 )
return (m_Buffer[(m_Head + 1) % m_Buffer.Length] << 8) | m_Buffer[(m_Head + 2) % m_Buffer.Length];
return 0;
@ -84,8 +83,8 @@ namespace Server.Network
public int Dequeue( byte[] buffer, int offset, int size )
{
if ( size > m_Size )
size = m_Size;
if ( size > Length )
size = Length;
if ( size == 0 )
return 0;
@ -110,9 +109,9 @@ namespace Server.Network
}
m_Head = ( m_Head + size ) % m_Buffer.Length;
m_Size -= size;
Length -= size;
if ( m_Size == 0 )
if ( Length == 0 )
{
m_Head = 0;
m_Tail = 0;
@ -123,8 +122,8 @@ namespace Server.Network
public void Enqueue( byte[] buffer, int offset, int size )
{
if ( (m_Size + size) > m_Buffer.Length )
SetCapacity( (m_Size + size + 2047) & ~2047 );
if ( (Length + size) > m_Buffer.Length )
SetCapacity( (Length + size + 2047) & ~2047 );
if ( m_Head < m_Tail )
{
@ -146,7 +145,7 @@ namespace Server.Network
}
m_Tail = ( m_Tail + size ) % m_Buffer.Length;
m_Size += size;
Length += size;
}
}
}

View file

@ -24,21 +24,17 @@ namespace Server.Network
public class EncodedPacketHandler
{
private int m_PacketID;
private bool m_Ingame;
private OnEncodedPacketReceive m_OnReceive;
public EncodedPacketHandler( int packetID, bool ingame, OnEncodedPacketReceive onReceive )
{
m_PacketID = packetID;
m_Ingame = ingame;
m_OnReceive = onReceive;
PacketID = packetID;
Ingame = ingame;
OnReceive = onReceive;
}
public int PacketID => m_PacketID;
public int PacketID { get; }
public OnEncodedPacketReceive OnReceive => m_OnReceive;
public OnEncodedPacketReceive OnReceive { get; }
public bool Ingame => m_Ingame;
public bool Ingame { get; }
}
}

View file

@ -43,12 +43,7 @@ namespace Server.Network
private static Socket[] m_EmptySockets = new Socket[0];
private static IPEndPoint[] m_EndPoints;
public static IPEndPoint[] EndPoints {
get => m_EndPoints;
set => m_EndPoints = value;
}
public static IPEndPoint[] EndPoints { get; set; }
public Listener( IPEndPoint ipep )
{

View file

@ -29,7 +29,6 @@ namespace Server.Network
{
public class MessagePump
{
private Listener[] m_Listeners;
private Queue<NetState> m_Queue;
private Queue<NetState> m_WorkingQueue;
private Queue<NetState> m_Throttled;
@ -38,7 +37,7 @@ namespace Server.Network
{
IPEndPoint[] ipep = Listener.EndPoints;
m_Listeners = new Listener[ipep.Length];
Listeners = new Listener[ipep.Length];
bool success = false;
@ -47,7 +46,7 @@ namespace Server.Network
Listener l = new Listener( ipep[i] );
if ( !success && l != null )
success = true;
m_Listeners[i] = l;
Listeners[i] = l;
}
if ( !success ) {
@ -61,29 +60,25 @@ namespace Server.Network
m_Throttled = new Queue<NetState>();
}
public Listener[] Listeners
{
get => m_Listeners;
set => m_Listeners = value;
}
public Listener[] Listeners { get; set; }
public void AddListener( Listener l )
{
Listener[] old = m_Listeners;
Listener[] old = Listeners;
m_Listeners = new Listener[old.Length + 1];
Listeners = new Listener[old.Length + 1];
for ( int i = 0; i < old.Length; ++i )
m_Listeners[i] = old[i];
Listeners[i] = old[i];
m_Listeners[old.Length] = l;
Listeners[old.Length] = l;
}
private void CheckListener()
{
for ( int j = 0; j < m_Listeners.Length; ++j )
for ( int j = 0; j < Listeners.Length; ++j )
{
Socket[] accepted = m_Listeners[j].Slice();
Socket[] accepted = Listeners[j].Slice();
for ( int i = 0; i < accepted.Length; ++i )
{

View file

@ -41,13 +41,8 @@ namespace Server.Network {
public delegate void NetStateCreatedCallback( NetState ns );
public class NetState : IComparable<NetState> {
private Socket m_Socket;
private IPAddress m_Address;
private ByteQueue m_Buffer;
private byte[] m_RecvBuffer;
private SendQueue m_SendQueue;
private bool m_Seeded;
private bool m_Running;
#if NewAsyncSockets
private SocketAsyncEventArgs m_ReceiveEventArgs, m_SendEventArgs;
@ -56,33 +51,17 @@ namespace Server.Network {
#endif
private MessagePump m_MessagePump;
private ServerInfo[] m_ServerInfo;
private IAccount m_Account;
private Mobile m_Mobile;
private CityInfo[] m_CityInfo;
private List<Gump> m_Gumps;
private List<HuePicker> m_HuePickers;
private List<IMenu> m_Menus;
private List<SecureTrade> m_Trades;
private int m_Sequence;
private bool m_CompressionEnabled;
private string m_ToString;
private ClientVersion m_Version;
private bool m_SentFirstPacket;
private bool m_BlockAllPackets;
private DateTime m_ConnectedOn;
public DateTime ConnectedOn { get; }
public DateTime ConnectedOn => m_ConnectedOn;
public TimeSpan ConnectedFor => ( DateTime.UtcNow - m_ConnectedOn );
public TimeSpan ConnectedFor => ( DateTime.UtcNow - ConnectedOn );
internal int m_Seed;
internal int m_AuthID;
public IPAddress Address => m_Address;
private ClientFlags m_Flags;
public IPAddress Address { get; }
private static bool m_Paused;
@ -95,34 +74,15 @@ namespace Server.Network {
private AsyncState m_AsyncState;
private object m_AsyncLock = new object();
private IPacketEncoder m_Encoder;
public IPacketEncoder PacketEncoder { get; set; }
public IPacketEncoder PacketEncoder {
get => m_Encoder;
set => m_Encoder = value;
}
public static NetStateCreatedCallback CreatedCallback { get; set; }
private static NetStateCreatedCallback m_CreatedCallback;
public bool SentFirstPacket { get; set; }
public static NetStateCreatedCallback CreatedCallback {
get => m_CreatedCallback;
set => m_CreatedCallback = value;
}
public bool BlockAllPackets { get; set; }
public bool SentFirstPacket {
get => m_SentFirstPacket;
set => m_SentFirstPacket = value;
}
public bool BlockAllPackets {
get => m_BlockAllPackets;
set => m_BlockAllPackets = value;
}
public ClientFlags Flags {
get => m_Flags;
set => m_Flags = value;
}
public ClientFlags Flags { get; set; }
public ClientVersion Version {
get => m_Version;
@ -225,19 +185,19 @@ namespace Server.Network {
public bool NewMobileIncoming => ((_ProtocolChanges & ProtocolChanges.NewMobileIncoming) != 0);
public bool NewSecureTrading => ((_ProtocolChanges & ProtocolChanges.NewSecureTrading) != 0);
public bool IsUOTDClient => ( (m_Flags & ClientFlags.UOTD) != 0 || ( m_Version != null && m_Version.Type == ClientType.UOTD ) );
public bool IsUOTDClient => ( (Flags & ClientFlags.UOTD) != 0 || ( m_Version != null && m_Version.Type == ClientType.UOTD ) );
public bool IsSAClient => ( m_Version != null && m_Version.Type == ClientType.SA );
public List<SecureTrade> Trades => m_Trades;
public List<SecureTrade> Trades { get; }
public void ValidateAllTrades() {
for ( int i = m_Trades.Count - 1; i >= 0; --i ) {
if ( i >= m_Trades.Count ) {
for ( int i = Trades.Count - 1; i >= 0; --i ) {
if ( i >= Trades.Count ) {
continue;
}
SecureTrade trade = m_Trades[i];
SecureTrade trade = Trades[i];
if ( trade.From.Mobile.Deleted || trade.To.Mobile.Deleted || !trade.From.Mobile.Alive || !trade.To.Mobile.Alive || !trade.From.Mobile.InRange( trade.To.Mobile, 2 ) || trade.From.Mobile.Map != trade.To.Mobile.Map ) {
trade.Cancel();
@ -246,20 +206,20 @@ namespace Server.Network {
}
public void CancelAllTrades() {
for ( int i = m_Trades.Count - 1; i >= 0; --i ) {
if ( i < m_Trades.Count ) {
m_Trades[i].Cancel();
for ( int i = Trades.Count - 1; i >= 0; --i ) {
if ( i < Trades.Count ) {
Trades[i].Cancel();
}
}
}
public void RemoveTrade( SecureTrade trade ) {
m_Trades.Remove( trade );
Trades.Remove( trade );
}
public SecureTrade FindTrade( Mobile m ) {
for ( int i = 0; i < m_Trades.Count; ++i ) {
SecureTrade trade = m_Trades[i];
for ( int i = 0; i < Trades.Count; ++i ) {
SecureTrade trade = Trades[i];
if ( trade.From.Mobile == m || trade.To.Mobile == m ) {
return trade;
@ -270,17 +230,17 @@ namespace Server.Network {
}
public SecureTradeContainer FindTradeContainer( Mobile m ) {
for ( int i = 0; i < m_Trades.Count; ++i ) {
SecureTrade trade = m_Trades[i];
for ( int i = 0; i < Trades.Count; ++i ) {
SecureTrade trade = Trades[i];
SecureTradeInfo from = trade.From;
SecureTradeInfo to = trade.To;
if ( from.Mobile == m_Mobile && to.Mobile == m ) {
if ( from.Mobile == Mobile && to.Mobile == m ) {
return from.Container;
}
if ( from.Mobile == m && to.Mobile == m_Mobile ) {
if ( from.Mobile == m && to.Mobile == Mobile ) {
return to.Container;
}
}
@ -289,46 +249,29 @@ namespace Server.Network {
}
public SecureTradeContainer AddTrade( NetState state ) {
SecureTrade newTrade = new SecureTrade( m_Mobile, state.m_Mobile );
SecureTrade newTrade = new SecureTrade( Mobile, state.Mobile );
m_Trades.Add( newTrade );
state.m_Trades.Add( newTrade );
Trades.Add( newTrade );
state.Trades.Add( newTrade );
return newTrade.From.Container;
}
public bool CompressionEnabled {
get => m_CompressionEnabled;
set => m_CompressionEnabled = value;
}
public bool CompressionEnabled { get; set; }
public int Sequence {
get => m_Sequence;
set => m_Sequence = value;
}
public int Sequence { get; set; }
public List<Gump> Gumps => m_Gumps;
public List<Gump> Gumps { get; private set; }
public List<HuePicker> HuePickers => m_HuePickers;
public List<HuePicker> HuePickers { get; private set; }
public List<IMenu> Menus => m_Menus;
public List<IMenu> Menus { get; private set; }
private static int m_GumpCap = 512, m_HuePickerCap = 512, m_MenuCap = 512;
public static int GumpCap { get; set; } = 512;
public static int GumpCap {
get => m_GumpCap;
set => m_GumpCap = value;
}
public static int HuePickerCap { get; set; } = 512;
public static int HuePickerCap {
get => m_HuePickerCap;
set => m_HuePickerCap = value;
}
public static int MenuCap {
get => m_MenuCap;
set => m_MenuCap = value;
}
public static int MenuCap { get; set; } = 512;
public void WriteConsole( string text ) {
Console.WriteLine( "Client: {0}: {1}", this, text );
@ -339,12 +282,12 @@ namespace Server.Network {
}
public void AddMenu( IMenu menu ) {
if ( m_Menus == null ) {
m_Menus = new List<IMenu>();
if ( Menus == null ) {
Menus = new List<IMenu>();
}
if ( m_Menus.Count < m_MenuCap ) {
m_Menus.Add( menu );
if ( Menus.Count < MenuCap ) {
Menus.Add( menu );
} else {
WriteConsole( "Exceeded menu cap, disconnecting..." );
Dispose();
@ -353,26 +296,26 @@ namespace Server.Network {
public void RemoveMenu( IMenu menu )
{
m_Menus?.Remove( menu );
Menus?.Remove( menu );
}
public void RemoveMenu( int index )
{
m_Menus?.RemoveAt( index );
Menus?.RemoveAt( index );
}
public void ClearMenus()
{
m_Menus?.Clear();
Menus?.Clear();
}
public void AddHuePicker( HuePicker huePicker ) {
if ( m_HuePickers == null ) {
m_HuePickers = new List<HuePicker>();
if ( HuePickers == null ) {
HuePickers = new List<HuePicker>();
}
if ( m_HuePickers.Count < m_HuePickerCap ) {
m_HuePickers.Add( huePicker );
if ( HuePickers.Count < HuePickerCap ) {
HuePickers.Add( huePicker );
} else {
WriteConsole( "Exceeded hue picker cap, disconnecting..." );
Dispose();
@ -381,26 +324,26 @@ namespace Server.Network {
public void RemoveHuePicker( HuePicker huePicker )
{
m_HuePickers?.Remove( huePicker );
HuePickers?.Remove( huePicker );
}
public void RemoveHuePicker( int index )
{
m_HuePickers?.RemoveAt( index );
HuePickers?.RemoveAt( index );
}
public void ClearHuePickers()
{
m_HuePickers?.Clear();
HuePickers?.Clear();
}
public void AddGump( Gump gump ) {
if ( m_Gumps == null ) {
m_Gumps = new List<Gump>();
if ( Gumps == null ) {
Gumps = new List<Gump>();
}
if ( m_Gumps.Count < m_GumpCap ) {
m_Gumps.Add( gump );
if ( Gumps.Count < GumpCap ) {
Gumps.Add( gump );
} else {
WriteConsole( "Exceeded gump cap, disconnecting..." );
Dispose();
@ -409,17 +352,17 @@ namespace Server.Network {
public void RemoveGump( Gump gump )
{
m_Gumps?.Remove( gump );
Gumps?.Remove( gump );
}
public void RemoveGump( int index )
{
m_Gumps?.RemoveAt( index );
Gumps?.RemoveAt( index );
}
public void ClearGumps()
{
m_Gumps?.Clear();
Gumps?.Clear();
}
public void LaunchBrowser( string url ) {
@ -427,80 +370,66 @@ namespace Server.Network {
Send( new LaunchBrowser( url ) );
}
public CityInfo[] CityInfo {
get => m_CityInfo;
set => m_CityInfo = value;
}
public CityInfo[] CityInfo { get; set; }
public Mobile Mobile {
get => m_Mobile;
set => m_Mobile = value;
}
public Mobile Mobile { get; set; }
public ServerInfo[] ServerInfo {
get => m_ServerInfo;
set => m_ServerInfo = value;
}
public ServerInfo[] ServerInfo { get; set; }
public IAccount Account {
get => m_Account;
set => m_Account = value;
}
public IAccount Account { get; set; }
public override string ToString() {
return m_ToString;
}
private static List<NetState> m_Instances = new List<NetState>();
public static List<NetState> Instances => m_Instances;
public static List<NetState> Instances { get; } = new List<NetState>();
private static BufferPool m_ReceiveBufferPool = new BufferPool( "Receive", 2048, 2048 );
public NetState( Socket socket, MessagePump messagePump )
{
m_Socket = socket;
m_Buffer = new ByteQueue();
m_Seeded = false;
m_Running = false;
Socket = socket;
Buffer = new ByteQueue();
Seeded = false;
Running = false;
m_RecvBuffer = m_ReceiveBufferPool.AcquireBuffer();
m_MessagePump = messagePump;
m_Gumps = new List<Gump>();
m_HuePickers = new List<HuePicker>();
m_Menus = new List<IMenu>();
m_Trades = new List<SecureTrade>();
Gumps = new List<Gump>();
HuePickers = new List<HuePicker>();
Menus = new List<IMenu>();
Trades = new List<SecureTrade>();
m_SendQueue = new SendQueue();
m_NextCheckActivity = Core.TickCount + 30000;
m_Instances.Add( this );
Instances.Add( this );
try {
m_Address = Utility.Intern( ( ( IPEndPoint ) m_Socket.RemoteEndPoint ).Address );
m_ToString = m_Address.ToString();
Address = Utility.Intern( ( ( IPEndPoint ) Socket.RemoteEndPoint ).Address );
m_ToString = Address.ToString();
} catch ( Exception ex ) {
TraceException( ex );
m_Address = IPAddress.None;
Address = IPAddress.None;
m_ToString = "(error)";
}
m_ConnectedOn = DateTime.UtcNow;
ConnectedOn = DateTime.UtcNow;
m_CreatedCallback?.Invoke( this );
CreatedCallback?.Invoke( this );
}
private bool _sending;
private object _sendL = new object();
public virtual void Send( Packet p ) {
if ( m_Socket == null || m_BlockAllPackets ) {
if ( Socket == null || BlockAllPackets ) {
p.OnSend();
return;
}
int length;
byte[] buffer = p.Compile( m_CompressionEnabled, out length );
byte[] buffer = p.Compile( CompressionEnabled, out length );
if ( buffer != null ) {
if ( buffer.Length <= 0 || length <= 0 ) {
@ -514,7 +443,7 @@ namespace Server.Network {
prof?.Start();
m_Encoder?.EncodeOutgoingPacket( this, ref buffer, ref length );
PacketEncoder?.EncodeOutgoingPacket( this, ref buffer, ref length );
try {
SendQueue.Gram gram;
@ -567,9 +496,9 @@ namespace Server.Network {
m_SendEventArgs = new SocketAsyncEventArgs();
m_SendEventArgs.Completed += Send_Completion;
m_Running = true;
Running = true;
if ( m_Socket == null || m_Paused ) {
if ( Socket == null || m_Paused ) {
return;
}
@ -585,7 +514,7 @@ namespace Server.Network {
lock ( m_AsyncLock ) {
if ( ( m_AsyncState & ( AsyncState.Pending | AsyncState.Paused ) ) == 0 ) {
m_AsyncState |= AsyncState.Pending;
result = !m_Socket.ReceiveAsync( m_ReceiveEventArgs );
result = !Socket.ReceiveAsync( m_ReceiveEventArgs );
if ( result )
Receive_Process( m_ReceiveEventArgs );
@ -602,7 +531,7 @@ namespace Server.Network {
{
Receive_Process( e );
if ( !m_Disposing )
if ( !IsDisposing )
Receive_Start();
}
@ -615,7 +544,7 @@ namespace Server.Network {
return;
}
if ( m_Disposing ) {
if ( IsDisposing ) {
return;
}
@ -623,10 +552,10 @@ namespace Server.Network {
byte[] buffer = m_RecvBuffer;
m_Encoder?.DecodeIncomingPacket( this, ref buffer, ref byteCount );
PacketEncoder?.DecodeIncomingPacket( this, ref buffer, ref byteCount );
lock ( m_Buffer )
m_Buffer.Enqueue( buffer, 0, byteCount );
lock ( Buffer )
Buffer.Enqueue( buffer, 0, byteCount );
m_MessagePump.OnReceive( this );
@ -641,7 +570,7 @@ namespace Server.Network {
bool result = false;
do {
result = !m_Socket.SendAsync( m_SendEventArgs );
result = !Socket.SendAsync( m_SendEventArgs );
if ( result )
Send_Process( m_SendEventArgs );
@ -656,11 +585,11 @@ namespace Server.Network {
{
Send_Process( e );
if ( m_Disposing )
if ( IsDisposing )
return;
if ( m_CoalesceSleep >= 0 ) {
Thread.Sleep( m_CoalesceSleep );
if ( CoalesceSleep >= 0 ) {
Thread.Sleep( CoalesceSleep );
}
SendQueue.Gram gram;
@ -696,8 +625,8 @@ namespace Server.Network {
public static void Pause() {
m_Paused = true;
for ( int i = 0; i < m_Instances.Count; ++i ) {
NetState ns = m_Instances[i];
for ( int i = 0; i < Instances.Count; ++i ) {
NetState ns = Instances[i];
lock ( ns.m_AsyncLock ) {
ns.m_AsyncState |= AsyncState.Paused;
@ -708,10 +637,10 @@ namespace Server.Network {
public static void Resume() {
m_Paused = false;
for ( int i = 0; i < m_Instances.Count; ++i ) {
NetState ns = m_Instances[i];
for ( int i = 0; i < Instances.Count; ++i ) {
NetState ns = Instances[i];
if ( ns.m_Socket == null ) {
if ( ns.Socket == null ) {
continue;
}
@ -725,7 +654,7 @@ namespace Server.Network {
}
public bool Flush() {
if ( m_Socket == null )
if ( Socket == null )
return false;
lock (_sendL) {
@ -939,25 +868,20 @@ namespace Server.Network {
}
public static void FlushAll() {
if (m_Instances.Count >= 1024)
Parallel.ForEach(m_Instances, ns => ns.Flush());
if (Instances.Count >= 1024)
Parallel.ForEach(Instances, ns => ns.Flush());
else
for ( int i = 0; i < m_Instances.Count; ++i ) {
m_Instances[i].Flush();
for ( int i = 0; i < Instances.Count; ++i ) {
Instances[i].Flush();
}
}
private static int m_CoalesceSleep = -1;
public static int CoalesceSleep {
get => m_CoalesceSleep;
set => m_CoalesceSleep = value;
}
public static int CoalesceSleep { get; set; } = -1;
private long m_NextCheckActivity;
public void CheckAlive(long curTicks) {
if ( m_Socket == null )
if ( Socket == null )
return;
if (m_NextCheckActivity - curTicks >= 0) {
@ -992,32 +916,30 @@ namespace Server.Network {
}
}
private bool m_Disposing;
public bool IsDisposing => m_Disposing;
public bool IsDisposing { get; private set; }
public void Dispose() {
Dispose( true );
}
public virtual void Dispose( bool flush ) {
if ( m_Socket == null || m_Disposing ) {
if ( Socket == null || IsDisposing ) {
return;
}
m_Disposing = true;
IsDisposing = true;
if ( flush )
flush = Flush();
try {
m_Socket.Shutdown( SocketShutdown.Both );
Socket.Shutdown( SocketShutdown.Both );
} catch ( SocketException ex ) {
TraceException( ex );
}
try {
m_Socket.Close();
Socket.Close();
} catch ( SocketException ex ) {
TraceException( ex );
}
@ -1027,9 +949,9 @@ namespace Server.Network {
m_ReceiveBufferPool.ReleaseBuffer( m_RecvBuffer );
}
m_Socket = null;
Socket = null;
m_Buffer = null;
Buffer = null;
m_RecvBuffer = null;
#if NewAsyncSockets
@ -1040,7 +962,7 @@ namespace Server.Network {
m_OnSend = null;
#endif
m_Running = false;
Running = false;
lock (m_Disposed)
m_Disposed.Enqueue( this );
@ -1059,11 +981,11 @@ namespace Server.Network {
try {
long curTicks = Core.TickCount;
if (m_Instances.Count >= 1024)
Parallel.ForEach(m_Instances, ns => ns.CheckAlive(curTicks));
if (Instances.Count >= 1024)
Parallel.ForEach(Instances, ns => ns.CheckAlive(curTicks));
else
for ( int i = 0; i < m_Instances.Count; ++i ) {
m_Instances[i].CheckAlive(curTicks);
for ( int i = 0; i < Instances.Count; ++i ) {
Instances[i].CheckAlive(curTicks);
}
} catch ( Exception ex ) {
TraceException( ex );
@ -1080,42 +1002,39 @@ namespace Server.Network {
++breakout;
NetState ns = m_Disposed.Dequeue();
Mobile m = ns.m_Mobile;
IAccount a = ns.m_Account;
Mobile m = ns.Mobile;
IAccount a = ns.Account;
if ( m != null ) {
m.NetState = null;
ns.m_Mobile = null;
ns.Mobile = null;
}
ns.m_Gumps.Clear();
ns.m_Menus.Clear();
ns.m_HuePickers.Clear();
ns.m_Account = null;
ns.m_ServerInfo = null;
ns.m_CityInfo = null;
ns.Gumps.Clear();
ns.Menus.Clear();
ns.HuePickers.Clear();
ns.Account = null;
ns.ServerInfo = null;
ns.CityInfo = null;
m_Instances.Remove( ns );
Instances.Remove( ns );
if ( a != null ) {
ns.WriteConsole( "Disconnected. [{0} Online] [{1}]", m_Instances.Count, a );
ns.WriteConsole( "Disconnected. [{0} Online] [{1}]", Instances.Count, a );
} else {
ns.WriteConsole( "Disconnected. [{0} Online]", m_Instances.Count );
ns.WriteConsole( "Disconnected. [{0} Online]", Instances.Count );
}
}
}
}
public bool Running => m_Running;
public bool Running { get; private set; }
public bool Seeded {
get => m_Seeded;
set => m_Seeded = value;
}
public bool Seeded { get; set; }
public Socket Socket => m_Socket;
public Socket Socket { get; private set; }
public ByteQueue Buffer => m_Buffer;
public ByteQueue Buffer { get; private set; }
public ExpansionInfo ExpansionInfo {
get {

View file

@ -25,32 +25,22 @@ namespace Server.Network
public class PacketHandler
{
private int m_PacketID;
private int m_Length;
private bool m_Ingame;
private OnPacketReceive m_OnReceive;
private ThrottlePacketCallback m_ThrottleCallback;
public PacketHandler( int packetID, int length, bool ingame, OnPacketReceive onReceive )
{
m_PacketID = packetID;
m_Length = length;
m_Ingame = ingame;
m_OnReceive = onReceive;
PacketID = packetID;
Length = length;
Ingame = ingame;
OnReceive = onReceive;
}
public int PacketID => m_PacketID;
public int PacketID { get; }
public int Length => m_Length;
public int Length { get; }
public OnPacketReceive OnReceive => m_OnReceive;
public OnPacketReceive OnReceive { get; }
public ThrottlePacketCallback ThrottleCallback
{
get => m_ThrottleCallback;
set => m_ThrottleCallback = value;
}
public ThrottlePacketCallback ThrottleCallback { get; set; }
public bool Ingame => m_Ingame;
public bool Ingame { get; }
}
}

View file

@ -55,7 +55,6 @@ namespace Server.Network
public static class PacketHandlers
{
private static PacketHandler[] m_Handlers;
private static PacketHandler[] m_6017Handlers;
private static PacketHandler[] m_ExtendedHandlersLow;
@ -64,11 +63,11 @@ namespace Server.Network
private static EncodedPacketHandler[] m_EncodedHandlersLow;
private static Dictionary<int, EncodedPacketHandler> m_EncodedHandlersHigh;
public static PacketHandler[] Handlers => m_Handlers;
public static PacketHandler[] Handlers { get; }
static PacketHandlers()
{
m_Handlers = new PacketHandler[0x100];
Handlers = new PacketHandler[0x100];
m_6017Handlers = new PacketHandler[0x100];
m_ExtendedHandlersLow = new PacketHandler[0x100];
@ -173,7 +172,7 @@ namespace Server.Network
public static void Register( int packetID, int length, bool ingame, OnPacketReceive onReceive )
{
m_Handlers[packetID] = new PacketHandler( packetID, length, ingame, onReceive );
Handlers[packetID] = new PacketHandler( packetID, length, ingame, onReceive );
if ( m_6017Handlers[packetID] == null )
m_6017Handlers[packetID] = new PacketHandler( packetID, length, ingame, onReceive );
@ -181,7 +180,7 @@ namespace Server.Network
public static PacketHandler GetHandler( int packetID )
{
return m_Handlers[packetID];
return Handlers[packetID];
}
public static void Register6017( int packetID, int length, bool ingame, OnPacketReceive onReceive )
@ -1467,13 +1466,7 @@ namespace Server.Network
}
}
private static bool m_SingleClickProps;
public static bool SingleClickProps
{
get => m_SingleClickProps;
set => m_SingleClickProps = value;
}
public static bool SingleClickProps { get; set; }
public static void LookReq( NetState state, PacketReader pvSrc )
{
@ -1487,7 +1480,7 @@ namespace Server.Network
if ( m != null && from.CanSee( m ) && Utility.InUpdateRange( from, m ) )
{
if ( m_SingleClickProps )
if ( SingleClickProps )
{
m.OnAosSingleClick( from );
}
@ -1504,7 +1497,7 @@ namespace Server.Network
if ( item != null && !item.Deleted && from.CanSee( item ) && Utility.InUpdateRange( from.Location, item.GetWorldLocation() ) )
{
if ( m_SingleClickProps )
if ( SingleClickProps )
{
item.OnAosSingleClick( from );
}
@ -2457,13 +2450,7 @@ namespace Server.Network
}
}
private static bool m_ClientVerification = true;
public static bool ClientVerification
{
get => m_ClientVerification;
set => m_ClientVerification = value;
}
public static bool ClientVerification { get; set; } = true;
internal struct AuthIDPersistence {
public DateTime Age;
@ -2525,7 +2512,7 @@ namespace Server.Network
m_AuthIDWindow.Remove( authID );
state.Version = ap.Version;
} else if ( m_ClientVerification ) {
} else if ( ClientVerification ) {
Console.WriteLine( "Login: {0}: Invalid client detected, disconnecting", state );
state.Dispose();
return;

View file

@ -26,20 +26,18 @@ namespace Server.Network
{
public class PacketReader
{
private byte[] m_Data;
private int m_Size;
private int m_Index;
public PacketReader( byte[] data, int size, bool fixedSize )
{
m_Data = data;
m_Size = size;
Buffer = data;
Size = size;
m_Index = fixedSize ? 1 : 3;
}
public byte[] Buffer => m_Data;
public byte[] Buffer { get; }
public int Size => m_Size;
public int Size { get; }
public void Trace( NetState state )
{
@ -47,7 +45,7 @@ namespace Server.Network
{
using ( StreamWriter sw = new StreamWriter( "Packets.log", true ) )
{
byte[] buffer = m_Data;
byte[] buffer = Buffer;
if ( buffer.Length > 0 )
sw.WriteLine( "Client: {0}: Unhandled packet 0x{1:X2}", state, buffer[0] );
@ -70,7 +68,7 @@ namespace Server.Network
{
case SeekOrigin.Begin: m_Index = offset; break;
case SeekOrigin.Current: m_Index += offset; break;
case SeekOrigin.End: m_Index = m_Size - offset; break;
case SeekOrigin.End: m_Index = Size - offset; break;
}
return m_Index;
@ -78,61 +76,61 @@ namespace Server.Network
public int ReadInt32()
{
if ( (m_Index + 4) > m_Size )
if ( (m_Index + 4) > Size )
return 0;
return (m_Data[m_Index++] << 24)
| (m_Data[m_Index++] << 16)
| (m_Data[m_Index++] << 8)
| m_Data[m_Index++];
return (Buffer[m_Index++] << 24)
| (Buffer[m_Index++] << 16)
| (Buffer[m_Index++] << 8)
| Buffer[m_Index++];
}
public short ReadInt16()
{
if ( (m_Index + 2) > m_Size )
if ( (m_Index + 2) > Size )
return 0;
return (short)((m_Data[m_Index++] << 8) | m_Data[m_Index++]);
return (short)((Buffer[m_Index++] << 8) | Buffer[m_Index++]);
}
public byte ReadByte()
{
if ( (m_Index + 1) > m_Size )
if ( (m_Index + 1) > Size )
return 0;
return m_Data[m_Index++];
return Buffer[m_Index++];
}
public uint ReadUInt32()
{
if ( (m_Index + 4) > m_Size )
if ( (m_Index + 4) > Size )
return 0;
return (uint)((m_Data[m_Index++] << 24) | (m_Data[m_Index++] << 16) | (m_Data[m_Index++] << 8) | m_Data[m_Index++]);
return (uint)((Buffer[m_Index++] << 24) | (Buffer[m_Index++] << 16) | (Buffer[m_Index++] << 8) | Buffer[m_Index++]);
}
public ushort ReadUInt16()
{
if ( (m_Index + 2) > m_Size )
if ( (m_Index + 2) > Size )
return 0;
return (ushort)((m_Data[m_Index++] << 8) | m_Data[m_Index++]);
return (ushort)((Buffer[m_Index++] << 8) | Buffer[m_Index++]);
}
public sbyte ReadSByte()
{
if ( (m_Index + 1) > m_Size )
if ( (m_Index + 1) > Size )
return 0;
return (sbyte)m_Data[m_Index++];
return (sbyte)Buffer[m_Index++];
}
public bool ReadBoolean()
{
if ( (m_Index + 1) > m_Size )
if ( (m_Index + 1) > Size )
return false;
return ( m_Data[m_Index++] != 0 );
return ( Buffer[m_Index++] != 0 );
}
public string ReadUnicodeStringLE()
@ -141,7 +139,7 @@ namespace Server.Network
int c;
while ( (m_Index + 1) < m_Size && (c = (m_Data[m_Index++] | (m_Data[m_Index++] << 8))) != 0 )
while ( (m_Index + 1) < Size && (c = (Buffer[m_Index++] | (Buffer[m_Index++] << 8))) != 0 )
sb.Append( (char)c );
return sb.ToString();
@ -152,14 +150,14 @@ namespace Server.Network
int bound = m_Index + (fixedLength << 1);
int end = bound;
if ( bound > m_Size )
bound = m_Size;
if ( bound > Size )
bound = Size;
StringBuilder sb = new StringBuilder();
int c;
while ( (m_Index + 1) < bound && (c = (m_Data[m_Index++] | (m_Data[m_Index++] << 8))) != 0 )
while ( (m_Index + 1) < bound && (c = (Buffer[m_Index++] | (Buffer[m_Index++] << 8))) != 0 )
{
if ( IsSafeChar( c ) )
sb.Append( (char)c );
@ -176,7 +174,7 @@ namespace Server.Network
int c;
while ( (m_Index + 1) < m_Size && (c = (m_Data[m_Index++] | (m_Data[m_Index++] << 8))) != 0 )
while ( (m_Index + 1) < Size && (c = (Buffer[m_Index++] | (Buffer[m_Index++] << 8))) != 0 )
{
if ( IsSafeChar( c ) )
sb.Append( (char)c );
@ -191,7 +189,7 @@ namespace Server.Network
int c;
while ( (m_Index + 1) < m_Size && (c = ((m_Data[m_Index++] << 8) | m_Data[m_Index++])) != 0 )
while ( (m_Index + 1) < Size && (c = ((Buffer[m_Index++] << 8) | Buffer[m_Index++])) != 0 )
{
if ( IsSafeChar( c ) )
sb.Append( (char)c );
@ -206,7 +204,7 @@ namespace Server.Network
int c;
while ( (m_Index + 1) < m_Size && (c = ((m_Data[m_Index++] << 8) | m_Data[m_Index++])) != 0 )
while ( (m_Index + 1) < Size && (c = ((Buffer[m_Index++] << 8) | Buffer[m_Index++])) != 0 )
sb.Append( (char)c );
return sb.ToString();
@ -219,7 +217,7 @@ namespace Server.Network
public string ReadUTF8StringSafe( int fixedLength )
{
if ( m_Index >= m_Size )
if ( m_Index >= Size )
{
m_Index += fixedLength;
return string.Empty;
@ -228,14 +226,14 @@ namespace Server.Network
int bound = m_Index + fixedLength;
//int end = bound;
if ( bound > m_Size )
bound = m_Size;
if ( bound > Size )
bound = Size;
int count = 0;
int index = m_Index;
int start = m_Index;
while ( index < bound && m_Data[index++] != 0 )
while ( index < bound && Buffer[index++] != 0 )
++count;
index = 0;
@ -243,7 +241,7 @@ namespace Server.Network
byte[] buffer = new byte[count];
int value = 0;
while ( m_Index < bound && (value = m_Data[m_Index++]) != 0 )
while ( m_Index < bound && (value = Buffer[m_Index++]) != 0 )
buffer[index++] = (byte)value;
string s = Utility.UTF8.GetString( buffer );
@ -269,13 +267,13 @@ namespace Server.Network
public string ReadUTF8StringSafe()
{
if ( m_Index >= m_Size )
if ( m_Index >= Size )
return string.Empty;
int count = 0;
int index = m_Index;
while ( index < m_Size && m_Data[index++] != 0 )
while ( index < Size && Buffer[index++] != 0 )
++count;
index = 0;
@ -283,7 +281,7 @@ namespace Server.Network
byte[] buffer = new byte[count];
int value = 0;
while ( m_Index < m_Size && (value = m_Data[m_Index++]) != 0 )
while ( m_Index < Size && (value = Buffer[m_Index++]) != 0 )
buffer[index++] = (byte)value;
string s = Utility.UTF8.GetString( buffer );
@ -309,13 +307,13 @@ namespace Server.Network
public string ReadUTF8String()
{
if ( m_Index >= m_Size )
if ( m_Index >= Size )
return string.Empty;
int count = 0;
int index = m_Index;
while ( index < m_Size && m_Data[index++] != 0 )
while ( index < Size && Buffer[index++] != 0 )
++count;
index = 0;
@ -323,7 +321,7 @@ namespace Server.Network
byte[] buffer = new byte[count];
int value = 0;
while ( m_Index < m_Size && (value = m_Data[m_Index++]) != 0 )
while ( m_Index < Size && (value = Buffer[m_Index++]) != 0 )
buffer[index++] = (byte)value;
return Utility.UTF8.GetString( buffer );
@ -335,7 +333,7 @@ namespace Server.Network
int c;
while ( m_Index < m_Size && (c = m_Data[m_Index++]) != 0 )
while ( m_Index < Size && (c = Buffer[m_Index++]) != 0 )
sb.Append( (char)c );
return sb.ToString();
@ -347,7 +345,7 @@ namespace Server.Network
int c;
while ( m_Index < m_Size && (c = m_Data[m_Index++]) != 0 )
while ( m_Index < Size && (c = Buffer[m_Index++]) != 0 )
{
if ( IsSafeChar( c ) )
sb.Append( (char)c );
@ -361,14 +359,14 @@ namespace Server.Network
int bound = m_Index + (fixedLength << 1);
int end = bound;
if ( bound > m_Size )
bound = m_Size;
if ( bound > Size )
bound = Size;
StringBuilder sb = new StringBuilder();
int c;
while ( (m_Index + 1) < bound && (c = ((m_Data[m_Index++] << 8) | m_Data[m_Index++])) != 0 )
while ( (m_Index + 1) < bound && (c = ((Buffer[m_Index++] << 8) | Buffer[m_Index++])) != 0 )
{
if ( IsSafeChar( c ) )
sb.Append( (char)c );
@ -384,14 +382,14 @@ namespace Server.Network
int bound = m_Index + (fixedLength << 1);
int end = bound;
if ( bound > m_Size )
bound = m_Size;
if ( bound > Size )
bound = Size;
StringBuilder sb = new StringBuilder();
int c;
while ( (m_Index + 1) < bound && (c = ((m_Data[m_Index++] << 8) | m_Data[m_Index++])) != 0 )
while ( (m_Index + 1) < bound && (c = ((Buffer[m_Index++] << 8) | Buffer[m_Index++])) != 0 )
sb.Append( (char)c );
m_Index = end;
@ -404,14 +402,14 @@ namespace Server.Network
int bound = m_Index + fixedLength;
int end = bound;
if ( bound > m_Size )
bound = m_Size;
if ( bound > Size )
bound = Size;
StringBuilder sb = new StringBuilder();
int c;
while ( m_Index < bound && (c = m_Data[m_Index++]) != 0 )
while ( m_Index < bound && (c = Buffer[m_Index++]) != 0 )
{
if ( IsSafeChar( c ) )
sb.Append( (char)c );
@ -427,14 +425,14 @@ namespace Server.Network
int bound = m_Index + fixedLength;
int end = bound;
if ( bound > m_Size )
bound = m_Size;
if ( bound > Size )
bound = Size;
StringBuilder sb = new StringBuilder();
int c;
while ( m_Index < bound && (c = m_Data[m_Index++]) != 0 )
while ( m_Index < bound && (c = Buffer[m_Index++]) != 0 )
sb.Append( (char)c );
m_Index = end;

View file

@ -477,12 +477,9 @@ namespace Server.Network
public class EquipInfoAttribute
{
private int m_Number;
private int m_Charges;
public int Number { get; }
public int Number => m_Number;
public int Charges => m_Charges;
public int Charges { get; }
public EquipInfoAttribute( int number ) : this( number, -1 )
{
@ -490,32 +487,27 @@ namespace Server.Network
public EquipInfoAttribute( int number, int charges )
{
m_Number = number;
m_Charges = charges;
Number = number;
Charges = charges;
}
}
public class EquipmentInfo
{
private int m_Number;
private Mobile m_Crafter;
private bool m_Unidentified;
private EquipInfoAttribute[] m_Attributes;
public int Number { get; }
public int Number => m_Number;
public Mobile Crafter { get; }
public Mobile Crafter => m_Crafter;
public bool Unidentified { get; }
public bool Unidentified => m_Unidentified;
public EquipInfoAttribute[] Attributes => m_Attributes;
public EquipInfoAttribute[] Attributes { get; }
public EquipmentInfo( int number, Mobile crafter, bool unidentified, EquipInfoAttribute[] attributes )
{
m_Number = number;
m_Crafter = crafter;
m_Unidentified = unidentified;
m_Attributes = attributes;
Number = number;
Crafter = crafter;
Unidentified = unidentified;
Attributes = attributes;
}
}
@ -2353,14 +2345,9 @@ namespace Server.Network
public sealed class DisplayGumpPacked : Packet, IGumpWriter
{
private int m_TextEntries, m_Switches;
public int TextEntries { get; set; }
public int TextEntries { get => m_TextEntries;
set => m_TextEntries = value;
}
public int Switches { get => m_Switches;
set => m_Switches = value;
}
public int Switches { get; set; }
private Gump m_Gump;
@ -2507,16 +2494,11 @@ namespace Server.Network
public sealed class DisplayGumpFast : Packet, IGumpWriter
{
private int m_TextEntries, m_Switches;
private int m_LayoutLength;
public int TextEntries{ get => m_TextEntries;
set => m_TextEntries = value;
}
public int Switches{ get => m_Switches;
set => m_Switches = value;
}
public int TextEntries { get; set; }
public int Switches { get; set; }
public DisplayGumpFast( Gump g ) : base( 0xB0 )
{
@ -2799,11 +2781,7 @@ namespace Server.Network
public sealed class SupportedFeatures : Packet
{
private static FeatureFlags m_AdditionalFlags;
public static FeatureFlags Value{ get => m_AdditionalFlags;
set => m_AdditionalFlags = value;
}
public static FeatureFlags Value { get; set; }
public static SupportedFeatures Instantiate( NetState ns )
{
@ -2814,7 +2792,7 @@ namespace Server.Network
{
FeatureFlags flags = ExpansionInfo.CoreExpansion.SupportedFeatures;
flags |= m_AdditionalFlags;
flags |= Value;
if ( ns.Account is IAccount acct && acct.Limit >= 6 )
{
@ -2837,27 +2815,16 @@ namespace Server.Network
public static class AttributeNormalizer
{
private static int m_Maximum = 25;
private static bool m_Enabled = true;
public static int Maximum { get; set; } = 25;
public static int Maximum
{
get => m_Maximum;
set => m_Maximum = value;
}
public static bool Enabled
{
get => m_Enabled;
set => m_Enabled = value;
}
public static bool Enabled { get; set; } = true;
public static void Write( PacketWriter stream, int cur, int max )
{
if ( m_Enabled && max != 0 )
if ( Enabled && max != 0 )
{
stream.Write( (short) m_Maximum );
stream.Write( (short) ((cur * m_Maximum) / max) );
stream.Write( (short) Maximum );
stream.Write( (short) ((cur * Maximum) / max) );
}
else
{
@ -2868,10 +2835,10 @@ namespace Server.Network
public static void WriteReverse( PacketWriter stream, int cur, int max )
{
if ( m_Enabled && max != 0 )
if ( Enabled && max != 0 )
{
stream.Write( (short) ((cur * m_Maximum) / max) );
stream.Write( (short) m_Maximum );
stream.Write( (short) ((cur * Maximum) / max) );
stream.Write( (short) Maximum );
}
else
{
@ -3857,19 +3824,15 @@ namespace Server.Network
public sealed class CityInfo
{
private string m_City;
private string m_Building;
private int m_Description;
private Point3D m_Location;
private Map m_Map;
public CityInfo( string city, string building, int description, int x, int y, int z, Map m )
{
m_City = city;
m_Building = building;
m_Description = description;
City = city;
Building = building;
Description = description;
m_Location = new Point3D( x, y, z );
m_Map = m;
Map = m;
}
public CityInfo( string city, string building, int x, int y, int z, Map m ) : this( city, building, 0, x, y, z, m )
@ -3884,23 +3847,11 @@ namespace Server.Network
{
}
public string City
{
get => m_City;
set => m_City = value;
}
public string City { get; set; }
public string Building
{
get => m_Building;
set => m_Building = value;
}
public string Building { get; set; }
public int Description
{
get => m_Description;
set => m_Description = value;
}
public int Description { get; set; }
public int X
{
@ -3926,11 +3877,7 @@ namespace Server.Network
set => m_Location = value;
}
public Map Map
{
get => m_Map;
set => m_Map = value;
}
public Map Map { get; set; }
}
public sealed class CharacterListUpdate : Packet
@ -4011,9 +3958,7 @@ namespace Server.Network
public static class FeatureProtection
{
private static ThirdPartyFeature m_Disabled = 0;
public static ThirdPartyFeature DisabledFeatures => m_Disabled;
public static ThirdPartyFeature DisabledFeatures { get; private set; } = 0;
public static void Disable( ThirdPartyFeature feature )
{
@ -4028,9 +3973,9 @@ namespace Server.Network
public static void SetDisabled( ThirdPartyFeature feature, bool value )
{
if ( value )
m_Disabled |= feature;
DisabledFeatures |= feature;
else
m_Disabled &= ~feature;
DisabledFeatures &= ~feature;
}
}
@ -4091,7 +4036,7 @@ namespace Server.Network
else if ( a.Limit == 1 )
flags |= (CharacterListFlags.SlotLimit & CharacterListFlags.OneCharacterSlot); // Limit Characters & One Character
m_Stream.Write( (int)(flags | m_AdditionalFlags) ); // Additional Flags
m_Stream.Write( (int)(flags | AdditionalFlags) ); // Additional Flags
m_Stream.Write( (short) -1 );
@ -4126,13 +4071,7 @@ namespace Server.Network
private static System.Security.Cryptography.MD5CryptoServiceProvider m_MD5Provider;
private static CharacterListFlags m_AdditionalFlags;
public static CharacterListFlags AdditionalFlags
{
get => m_AdditionalFlags;
set => m_AdditionalFlags = value;
}
public static CharacterListFlags AdditionalFlags { get; set; }
}
public sealed class CharacterListOld : Packet
@ -4285,41 +4224,20 @@ namespace Server.Network
public sealed class ServerInfo
{
private string m_Name;
private int m_FullPercent;
private int m_TimeZone;
private IPEndPoint m_Address;
public string Name { get; set; }
public string Name
{
get => m_Name;
set => m_Name = value;
}
public int FullPercent { get; set; }
public int FullPercent
{
get => m_FullPercent;
set => m_FullPercent = value;
}
public int TimeZone { get; set; }
public int TimeZone
{
get => m_TimeZone;
set => m_TimeZone = value;
}
public IPEndPoint Address
{
get => m_Address;
set => m_Address = value;
}
public IPEndPoint Address { get; set; }
public ServerInfo( string name, int fullPercent, TimeZone tz, IPEndPoint address )
{
m_Name = name;
m_FullPercent = fullPercent;
m_TimeZone = tz.GetUtcOffset( DateTime.Now ).Hours;
m_Address = address;
Name = name;
FullPercent = fullPercent;
TimeZone = tz.GetUtcOffset( DateTime.Now ).Hours;
Address = address;
}
}
@ -4413,15 +4331,14 @@ namespace Server.Network
}
protected PacketWriter m_Stream;
private int m_PacketID;
private int m_Length;
private State m_State;
public int PacketID => m_PacketID;
public int PacketID { get; }
protected Packet( int packetID )
{
m_PacketID = packetID;
PacketID = packetID;
if (Core.Profiling) {
PacketSendProfile prof = PacketSendProfile.Acquire( GetType() );
@ -4432,13 +4349,13 @@ namespace Server.Network
public void EnsureCapacity( int length )
{
m_Stream = PacketWriter.CreateInstance( length );// new PacketWriter( length );
m_Stream.Write( (byte) m_PacketID );
m_Stream.Write( (byte) PacketID );
m_Stream.Write( (short) 0 );
}
protected Packet( int packetID, int length )
{
m_PacketID = packetID;
PacketID = packetID;
m_Length = length;
m_Stream = PacketWriter.CreateInstance( length );// new PacketWriter( length );
@ -4609,7 +4526,7 @@ namespace Server.Network
{
int diff = (int)m_Stream.Length - m_Length;
Console.WriteLine( "Packet: 0x{0:X2}: Bad packet length! ({1}{2} bytes)", m_PacketID, diff >= 0 ? "+" : "", diff );
Console.WriteLine( "Packet: 0x{0:X2}: Bad packet length! ({1}{2} bytes)", PacketID, diff >= 0 ? "+" : "", diff );
}
MemoryStream ms = m_Stream.UnderlyingStream;
@ -4625,10 +4542,10 @@ namespace Server.Network
Compression.Compress(m_CompiledBuffer, 0, length, buffer, ref length);
if (length <= 0) {
Console.WriteLine("Warning: Compression buffer overflowed on packet 0x{0:X2} ('{1}') (length={2})", m_PacketID, GetType().Name, length);
Console.WriteLine("Warning: Compression buffer overflowed on packet 0x{0:X2} ('{1}') (length={2})", PacketID, GetType().Name, length);
using (StreamWriter op = new StreamWriter("compression_overflow.log", true))
{
op.WriteLine("{0} Warning: Compression buffer overflowed on packet 0x{1:X2} ('{2}') (length={3})", DateTime.UtcNow, m_PacketID, GetType().Name, length);
op.WriteLine("{0} Warning: Compression buffer overflowed on packet 0x{1:X2} ('{2}') (length={3})", DateTime.UtcNow, PacketID, GetType().Name, length);
op.WriteLine(new System.Diagnostics.StackTrace());
}
} else {

View file

@ -36,23 +36,20 @@ namespace Server.Network {
gram = new Gram();
}
gram._buffer = AcquireBuffer();
gram._length = 0;
gram.Buffer = AcquireBuffer();
gram.Length = 0;
return gram;
}
}
private byte[] _buffer;
private int _length;
public byte[] Buffer { get; private set; }
public byte[] Buffer => _buffer;
public int Length { get; private set; }
public int Length => _length;
public int Available => ( Buffer.Length - Length );
public int Available => ( _buffer.Length - _length );
public bool IsFull => ( _length == _buffer.Length );
public bool IsFull => ( Length == Buffer.Length );
private Gram() {
}
@ -60,9 +57,9 @@ namespace Server.Network {
public int Write( byte[] buffer, int offset, int length ) {
int write = Math.Min( length, Available );
System.Buffer.BlockCopy( buffer, offset, _buffer, _length, write );
System.Buffer.BlockCopy( buffer, offset, Buffer, Length, write );
_length += write;
Length += write;
return write;
}
@ -70,7 +67,7 @@ namespace Server.Network {
public void Release() {
lock ( _pool ) {
_pool.Push( this );
ReleaseBuffer( _buffer );
ReleaseBuffer( Buffer );
}
}
}

View file

@ -32,42 +32,31 @@ namespace Server
public const int Murderer = 6;
public const int Invulnerable = 7;
private static NotorietyHandler m_Handler;
public static NotorietyHandler Handler { get; set; }
public static NotorietyHandler Handler
public static int[] Hues { get; set; } =
{
get => m_Handler;
set => m_Handler = value;
}
private static int[] m_Hues = {
0x000,
0x059,
0x03F,
0x3B2,
0x3B2,
0x090,
0x022,
0x035
};
public static int[] Hues
{
get => m_Hues;
set => m_Hues = value;
}
0x000,
0x059,
0x03F,
0x3B2,
0x3B2,
0x090,
0x022,
0x035
};
public static int GetHue( int noto )
{
if ( noto < 0 || noto >= m_Hues.Length )
if ( noto < 0 || noto >= Hues.Length )
return 0;
return m_Hues[noto];
return Hues[noto];
}
public static int Compute( Mobile source, Mobile target )
{
return m_Handler?.Invoke( source, target ) ?? CanBeAttacked;
return Handler?.Invoke( source, target ) ?? CanBeAttacked;
}
}
}

View file

@ -26,33 +26,24 @@ namespace Server
{
public sealed class ObjectPropertyList : Packet
{
private IEntity m_Entity;
private int m_Hash;
private int m_Header;
private int m_Strings;
private string m_HeaderArgs;
public IEntity Entity => m_Entity;
public IEntity Entity { get; }
public int Hash => 0x40000000 + m_Hash;
public int Header{ get => m_Header;
set => m_Header = value;
}
public string HeaderArgs{ get => m_HeaderArgs;
set => m_HeaderArgs = value;
}
public int Header { get; set; }
private static bool m_Enabled;
public string HeaderArgs { get; set; }
public static bool Enabled{ get => m_Enabled;
set => m_Enabled = value;
}
public static bool Enabled { get; set; }
public ObjectPropertyList( IEntity e ) : base( 0xD6 )
{
EnsureCapacity( 128 );
m_Entity = e;
Entity = e;
m_Stream.Write( (short) 1 );
m_Stream.Write( (int) e.Serial );
@ -68,10 +59,10 @@ namespace Server
AddHash( number );
if ( m_Header == 0 )
if ( Header == 0 )
{
m_Header = number;
m_HeaderArgs = "";
Header = number;
HeaderArgs = "";
}
m_Stream.Write( number );
@ -103,10 +94,10 @@ namespace Server
if ( arguments == null )
arguments = "";
if ( m_Header == 0 )
if ( Header == 0 )
{
m_Header = number;
m_HeaderArgs = arguments;
Header = number;
HeaderArgs = arguments;
}
AddHash( number );

View file

@ -22,11 +22,7 @@ namespace Server
{
public abstract class PartyCommands
{
private static PartyCommands m_Handler;
public static PartyCommands Handler{ get => m_Handler;
set => m_Handler = value;
}
public static PartyCommands Handler { get; set; }
public abstract void OnAdd( Mobile from );
public abstract void OnRemove( Mobile from, Mobile target );

View file

@ -40,44 +40,30 @@ namespace Server {
}
#endif
private static int bufferSize = 1 * MB;
private static int concurrency = 1;
public static int BufferSize { get; set; } = 1 * MB;
private static bool unbuffered = true;
public static int Concurrency { get; set; } = 1;
public static int BufferSize {
get => bufferSize;
set => bufferSize = value;
}
public static bool Unbuffered { get; set; } = true;
public static int Concurrency {
get => concurrency;
set => concurrency = value;
}
public static bool AreSynchronous => ( Concurrency < 1 );
public static bool Unbuffered {
get => unbuffered;
set => unbuffered = value;
}
public static bool AreSynchronous => ( concurrency < 1 );
public static bool AreAsynchronous => ( concurrency > 0 );
public static bool AreAsynchronous => ( Concurrency > 0 );
public static FileStream OpenSequentialStream( string path, FileMode mode, FileAccess access, FileShare share ) {
FileOptions options = FileOptions.SequentialScan;
if ( concurrency > 0 ) {
if ( Concurrency > 0 ) {
options |= FileOptions.Asynchronous;
}
#if MONO
return new FileStream( path, mode, access, share, bufferSize, options );
#else
if ( unbuffered ) {
if ( Unbuffered ) {
options |= NoBuffering;
} else {
return new FileStream( path, mode, access, share, bufferSize, options );
return new FileStream( path, mode, access, share, BufferSize, options );
}
SafeFileHandle fileHandle = UnsafeNativeMethods.CreateFile(path, (int)access, share, IntPtr.Zero, mode, (int)options, IntPtr.Zero);
@ -86,7 +72,7 @@ namespace Server {
throw new IOException();
}
return new UnbufferedFileStream( fileHandle, access, bufferSize, ( concurrency > 0 ) );
return new UnbufferedFileStream( fileHandle, access, BufferSize, ( Concurrency > 0 ) );
#endif
}
@ -100,11 +86,11 @@ namespace Server {
}
public override void Write( byte[] array, int offset, int count ) {
base.Write( array, offset, bufferSize );
base.Write( array, offset, BufferSize );
}
public override IAsyncResult BeginWrite( byte[] array, int offset, int numBytes, AsyncCallback userCallback, object stateObject ) {
return base.BeginWrite( array, offset, bufferSize, userCallback, stateObject );
return base.BeginWrite( array, offset, BufferSize, userCallback, stateObject );
}
protected override void Dispose( bool disposing ) {

View file

@ -31,23 +31,21 @@ namespace Server {
private FileQueue owner;
private int slot;
private byte[] buffer;
private int offset;
private int size;
public byte[] Buffer => buffer;
public byte[] Buffer { get; }
public int Offset => 0;
public int Size => size;
public int Size { get; }
public Chunk( FileQueue owner, int slot, byte[] buffer, int offset, int size ) {
this.owner = owner;
this.slot = slot;
this.buffer = buffer;
this.Buffer = buffer;
this.offset = offset;
this.size = size;
this.Size = size;
}
public void Commit() {
@ -80,9 +78,7 @@ namespace Server {
private ManualResetEvent idle;
private long position;
public long Position => position;
public long Position { get; private set; }
public FileQueue( int concurrentWrites, FileCommitCallback callback ) {
if ( concurrentWrites < 1 ) {
@ -209,7 +205,7 @@ namespace Server {
throw new ArgumentException();
}
position += size;
Position += size;
while ( size > 0 ) {
if ( buffered.buffer == null ) { // nothing yet buffered

View file

@ -35,21 +35,18 @@ namespace Server {
public override string Name => "Standard";
private Queue<Item> _decayQueue;
private bool _permitBackgroundWrite;
public StandardSaveStrategy() {
_decayQueue = new Queue<Item>();
}
protected bool PermitBackgroundWrite { get => _permitBackgroundWrite;
set => _permitBackgroundWrite = value;
}
protected bool PermitBackgroundWrite { get; set; }
protected bool UseSequentialWriters => (SaveType == SaveOption.Normal || !_permitBackgroundWrite);
protected bool UseSequentialWriters => (SaveType == SaveOption.Normal || !PermitBackgroundWrite);
public override void Save(SaveMetrics metrics, bool permitBackgroundWrite)
{
_permitBackgroundWrite = permitBackgroundWrite;
PermitBackgroundWrite = permitBackgroundWrite;
SaveMobiles(metrics);
SaveItems(metrics);

View file

@ -23,28 +23,27 @@ namespace Server
public class Point3DList
{
private Point3D[] m_List;
private int m_Count;
public Point3DList()
{
m_List = new Point3D[8];
m_Count = 0;
Count = 0;
}
public int Count => m_Count;
public int Count { get; private set; }
public void Clear()
{
m_Count = 0;
Count = 0;
}
public Point3D Last => m_List[m_Count - 1];
public Point3D Last => m_List[Count - 1];
public Point3D this[int index] => m_List[index];
public void Add( int x, int y, int z )
{
if ( (m_Count + 1) > m_List.Length )
if ( (Count + 1) > m_List.Length )
{
Point3D[] old = m_List;
m_List = new Point3D[old.Length * 2];
@ -53,15 +52,15 @@ namespace Server
m_List[i] = old[i];
}
m_List[m_Count].m_X = x;
m_List[m_Count].m_Y = y;
m_List[m_Count].m_Z = z;
++m_Count;
m_List[Count].m_X = x;
m_List[Count].m_Y = y;
m_List[Count].m_Z = z;
++Count;
}
public void Add( Point3D p )
{
if ( (m_Count + 1) > m_List.Length )
if ( (Count + 1) > m_List.Length )
{
Point3D[] old = m_List;
m_List = new Point3D[old.Length * 2];
@ -70,25 +69,25 @@ namespace Server
m_List[i] = old[i];
}
m_List[m_Count].m_X = p.m_X;
m_List[m_Count].m_Y = p.m_Y;
m_List[m_Count].m_Z = p.m_Z;
++m_Count;
m_List[Count].m_X = p.m_X;
m_List[Count].m_Y = p.m_Y;
m_List[Count].m_Z = p.m_Z;
++Count;
}
private static Point3D[] m_EmptyList = new Point3D[0];
public Point3D[] ToArray()
{
if ( m_Count == 0 )
if ( Count == 0 )
return m_EmptyList;
Point3D[] list = new Point3D[m_Count];
Point3D[] list = new Point3D[Count];
for ( int i = 0; i < m_Count; ++i )
for ( int i = 0; i < Count; ++i )
list[i] = m_List[i];
m_Count = 0;
Count = 0;
return list;
}

View file

@ -39,21 +39,19 @@ namespace Server
}
private static List<Poison> m_Poisons = new List<Poison>();
public static void Register( Poison reg )
public static void Register( Poison reg )
{
string regName = reg.Name.ToLower();
for ( int i = 0; i < m_Poisons.Count; i++ )
for ( int i = 0; i < Poisons.Count; i++ )
{
if ( reg.Level == m_Poisons[i].Level )
if ( reg.Level == Poisons[i].Level )
throw new Exception( "A poison with that level already exists." );
if ( regName == m_Poisons[i].Name.ToLower() )
if ( regName == Poisons[i].Name.ToLower() )
throw new Exception( "A poison with that name already exists." );
}
m_Poisons.Add( reg );
Poisons.Add( reg );
}
public static Poison Lesser => GetPoison( "Lesser" );
@ -62,7 +60,7 @@ namespace Server
public static Poison Deadly => GetPoison( "Deadly" );
public static Poison Lethal => GetPoison( "Lethal" );
public static List<Poison> Poisons => m_Poisons;
public static List<Poison> Poisons { get; } = new List<Poison>();
public static Poison Parse( string value )
{
@ -81,9 +79,9 @@ namespace Server
public static Poison GetPoison( int level )
{
for ( int i = 0; i < m_Poisons.Count; ++i )
for ( int i = 0; i < Poisons.Count; ++i )
{
Poison p = m_Poisons[i];
Poison p = Poisons[i];
if ( p.Level == level )
return p;
@ -94,9 +92,9 @@ namespace Server
public static Poison GetPoison( string name )
{
for ( int i = 0; i < m_Poisons.Count; ++i )
for ( int i = 0; i < Poisons.Count; ++i )
{
Poison p = m_Poisons[i];
Poison p = Poisons[i];
if ( Utility.InsensitiveCompare( p.Name, name ) == 0 )
return p;

View file

@ -22,17 +22,16 @@ namespace Server.Prompts
{
public abstract class Prompt
{
private int m_Serial;
private static int m_Serials;
public int Serial => m_Serial;
public int Serial { get; }
protected Prompt()
{
do
{
m_Serial = ++m_Serials;
} while ( m_Serial == 0 );
Serial = ++m_Serials;
} while ( Serial == 0 );
}
public virtual void OnCancel( Mobile from )

View file

@ -24,59 +24,55 @@ namespace Server
{
public class QuestArrow
{
private Mobile m_Mobile;
private Mobile m_Target;
private bool m_Running;
public Mobile Mobile { get; }
public Mobile Mobile => m_Mobile;
public Mobile Target { get; }
public Mobile Target => m_Target;
public bool Running => m_Running;
public bool Running { get; private set; }
public void Update()
{
Update( m_Target.X, m_Target.Y );
Update( Target.X, Target.Y );
}
public void Update( int x, int y )
{
if ( !m_Running )
if ( !Running )
return;
NetState ns = m_Mobile.NetState;
NetState ns = Mobile.NetState;
if ( ns == null )
return;
if ( ns.HighSeas )
ns.Send( new SetArrowHS( x, y, m_Target.Serial ) );
ns.Send( new SetArrowHS( x, y, Target.Serial ) );
else
ns.Send( new SetArrow( x, y ) );
}
public void Stop()
{
Stop( m_Target.X, m_Target.Y );
Stop( Target.X, Target.Y );
}
public void Stop( int x, int y )
{
if ( !m_Running )
if ( !Running )
return;
m_Mobile.ClearQuestArrow();
Mobile.ClearQuestArrow();
NetState ns = m_Mobile.NetState;
NetState ns = Mobile.NetState;
if ( ns != null ) {
if ( ns.HighSeas )
ns.Send( new CancelArrowHS( x, y, m_Target.Serial ) );
ns.Send( new CancelArrowHS( x, y, Target.Serial ) );
else
ns.Send( new CancelArrow() );
}
m_Running = false;
Running = false;
OnStop();
}
@ -90,9 +86,9 @@ namespace Server
public QuestArrow( Mobile m, Mobile t )
{
m_Running = true;
m_Mobile = m;
m_Target = t;
Running = true;
Mobile = m;
Target = t;
}
public QuestArrow( Mobile m, Mobile t, int x, int y ) : this( m, t )

View file

@ -26,23 +26,15 @@ namespace Server
[Parsable]
public abstract class Race
{
public static Race DefaultRace => m_Races[0];
public static Race DefaultRace => Races[0];
private static Race[] m_Races = new Race[0x100];
public static Race[] Races { get; } = new Race[0x100];
public static Race[] Races => m_Races;
public static Race Human => Races[0];
public static Race Elf => Races[1];
public static Race Gargoyle => Races[2];
public static Race Human => m_Races[0];
public static Race Elf => m_Races[1];
public static Race Gargoyle => m_Races[2];
private static List<Race> m_AllRaces = new List<Race>();
public static List<Race> AllRaces => m_AllRaces;
private int m_RaceID, m_RaceIndex;
private string m_Name, m_PluralName;
public static List<Race> AllRaces { get; } = new List<Race>();
private static string[] m_RaceNames;
private static Race[] m_RaceValues;
@ -72,8 +64,8 @@ namespace Server
int index;
if ( int.TryParse( value, out index ) )
{
if ( index >= 0 && index < m_Races.Length && m_Races[index] != null )
return m_Races[index];
if ( index >= 0 && index < Races.Length && Races[index] != null )
return Races[index];
}
throw new ArgumentException( "Invalid race name" );
@ -81,15 +73,15 @@ namespace Server
private static void CheckNamesAndValues()
{
if ( m_RaceNames != null && m_RaceNames.Length == m_AllRaces.Count )
if ( m_RaceNames != null && m_RaceNames.Length == AllRaces.Count )
return;
m_RaceNames = new string[m_AllRaces.Count];
m_RaceValues = new Race[m_AllRaces.Count];
m_RaceNames = new string[AllRaces.Count];
m_RaceValues = new Race[AllRaces.Count];
for( int i = 0; i < m_AllRaces.Count; ++i )
for( int i = 0; i < AllRaces.Count; ++i )
{
Race race = m_AllRaces[i];
Race race = AllRaces[i];
m_RaceNames[i] = race.Name;
m_RaceValues[i] = race;
@ -98,35 +90,33 @@ namespace Server
public override string ToString()
{
return m_Name;
return Name;
}
private int m_MaleBody, m_FemaleBody, m_MaleGhostBody, m_FemaleGhostBody;
public Expansion RequiredExpansion { get; }
private Expansion m_RequiredExpansion;
public int MaleBody { get; }
public Expansion RequiredExpansion => m_RequiredExpansion;
public int MaleGhostBody { get; }
public int MaleBody => m_MaleBody;
public int MaleGhostBody => m_MaleGhostBody;
public int FemaleBody { get; }
public int FemaleBody => m_FemaleBody;
public int FemaleGhostBody => m_FemaleGhostBody;
public int FemaleGhostBody { get; }
protected Race( int raceID, int raceIndex, string name, string pluralName, int maleBody, int femaleBody, int maleGhostBody, int femaleGhostBody, Expansion requiredExpansion )
{
m_RaceID = raceID;
m_RaceIndex = raceIndex;
RaceID = raceID;
RaceIndex = raceIndex;
m_Name = name;
Name = name;
m_MaleBody = maleBody;
m_FemaleBody = femaleBody;
m_MaleGhostBody = maleGhostBody;
m_FemaleGhostBody = femaleGhostBody;
MaleBody = maleBody;
FemaleBody = femaleBody;
MaleGhostBody = maleGhostBody;
FemaleGhostBody = femaleGhostBody;
m_RequiredExpansion = requiredExpansion;
m_PluralName = pluralName;
RequiredExpansion = requiredExpansion;
PluralName = pluralName;
}
public virtual bool ValidateHair( Mobile m, int itemID ) { return ValidateHair( m.Female, itemID ); }
@ -158,29 +148,21 @@ namespace Server
public virtual int AliveBody( Mobile m ) { return AliveBody( m.Female ); }
public virtual int AliveBody( bool female )
{
return (female ? m_FemaleBody : m_MaleBody);
return (female ? FemaleBody : MaleBody);
}
public virtual int GhostBody( Mobile m ) { return GhostBody( m.Female ); }
public virtual int GhostBody( bool female )
{
return (female ? m_FemaleGhostBody : m_MaleGhostBody);
return (female ? FemaleGhostBody : MaleGhostBody);
}
public int RaceID => m_RaceID;
public int RaceID { get; }
public int RaceIndex => m_RaceIndex;
public int RaceIndex { get; }
public string Name
{
get => m_Name;
set => m_Name = value;
}
public string Name { get; set; }
public string PluralName
{
get => m_PluralName;
set => m_PluralName = value;
}
public string PluralName { get; set; }
}
}

View file

@ -100,9 +100,7 @@ namespace Server
public class Region : IComparable
{
private static List<Region> m_Regions = new List<Region>();
public static List<Region> Regions => m_Regions;
public static List<Region> Regions { get; } = new List<Region>();
public static Region Find( Point3D p, Map map )
{
@ -123,20 +121,11 @@ namespace Server
return map.DefaultRegion;
}
private static Type m_DefaultRegionType = typeof( Region );
public static Type DefaultRegionType{ get => m_DefaultRegionType;
set => m_DefaultRegionType = value;
}
public static Type DefaultRegionType { get; set; } = typeof( Region );
private static TimeSpan m_StaffLogoutDelay = TimeSpan.Zero;
private static TimeSpan m_DefaultLogoutDelay = TimeSpan.FromMinutes( 5.0 );
public static TimeSpan StaffLogoutDelay { get; set; } = TimeSpan.Zero;
public static TimeSpan StaffLogoutDelay{ get => m_StaffLogoutDelay;
set => m_StaffLogoutDelay = value;
}
public static TimeSpan DefaultLogoutDelay{ get => m_DefaultLogoutDelay;
set => m_DefaultLogoutDelay = value;
}
public static TimeSpan DefaultLogoutDelay { get; set; } = TimeSpan.FromMinutes( 5.0 );
public static readonly int DefaultPriority = 50;
@ -162,39 +151,35 @@ namespace Server
private string m_Name;
private Map m_Map;
private Region m_Parent;
private List<Region> m_Children = new List<Region>();
private Rectangle3D[] m_Area;
private Sector[] m_Sectors;
private bool m_Dynamic;
private int m_Priority;
private int m_ChildLevel;
private bool m_Registered;
private Point3D m_GoLocation;
private MusicName m_Music;
public string Name => m_Name;
public Map Map => m_Map;
public Region Parent => m_Parent;
public List<Region> Children => m_Children;
public Rectangle3D[] Area => m_Area;
public Sector[] Sectors => m_Sectors;
public bool Dynamic => m_Dynamic;
public Map Map { get; }
public Region Parent { get; }
public List<Region> Children { get; } = new List<Region>();
public Rectangle3D[] Area { get; }
public Sector[] Sectors { get; private set; }
public bool Dynamic { get; }
public int Priority => m_Priority;
public int ChildLevel => m_ChildLevel;
public bool Registered => m_Registered;
public int ChildLevel { get; }
public bool Registered { get; private set; }
public Point3D GoLocation{ get => m_GoLocation;
set => m_GoLocation = value;
}
public MusicName Music{ get => m_Music;
set => m_Music = value;
}
public MusicName Music { get; set; }
public bool IsDefault => m_Map.DefaultRegion == this;
public virtual MusicName DefaultMusic => m_Parent?.Music ?? MusicName.Invalid;
public bool IsDefault => Map.DefaultRegion == this;
public virtual MusicName DefaultMusic => Parent?.Music ?? MusicName.Invalid;
public Region( string name, Map map, int priority, params Rectangle2D[] area ) : this( name, map, priority, ConvertTo3D( area ) )
{
@ -212,60 +197,60 @@ namespace Server
public Region( string name, Map map, Region parent, params Rectangle3D[] area )
{
m_Name = name;
m_Map = map;
m_Parent = parent;
m_Area = area;
m_Dynamic = true;
m_Music = DefaultMusic;
Map = map;
Parent = parent;
Area = area;
Dynamic = true;
Music = DefaultMusic;
if ( m_Parent == null )
if ( Parent == null )
{
m_ChildLevel = 0;
ChildLevel = 0;
m_Priority = DefaultPriority;
}
else
{
m_ChildLevel = m_Parent.ChildLevel + 1;
m_Priority = m_Parent.Priority;
ChildLevel = Parent.ChildLevel + 1;
m_Priority = Parent.Priority;
}
}
public void Register()
{
if ( m_Registered )
if ( Registered )
return;
OnRegister();
m_Registered = true;
Registered = true;
if ( m_Parent != null )
if ( Parent != null )
{
m_Parent.m_Children.Add( this );
m_Parent.OnChildAdded( this );
Parent.Children.Add( this );
Parent.OnChildAdded( this );
}
m_Regions.Add( this );
Regions.Add( this );
m_Map.RegisterRegion( this );
Map.RegisterRegion( this );
List<Sector> sectors = new List<Sector>();
for ( int i = 0; i < m_Area.Length; i++ )
for ( int i = 0; i < Area.Length; i++ )
{
Rectangle3D rect = m_Area[i];
Rectangle3D rect = Area[i];
Point2D start = m_Map.Bound( new Point2D( rect.Start ) );
Point2D end = m_Map.Bound( new Point2D( rect.End ) );
Point2D start = Map.Bound( new Point2D( rect.Start ) );
Point2D end = Map.Bound( new Point2D( rect.End ) );
Sector startSector = m_Map.GetSector( start );
Sector endSector = m_Map.GetSector( end );
Sector startSector = Map.GetSector( start );
Sector endSector = Map.GetSector( end );
for ( int x = startSector.X; x <= endSector.X; x++ )
{
for ( int y = startSector.Y; y <= endSector.Y; y++ )
{
Sector sector = m_Map.GetRealSector( x, y );
Sector sector = Map.GetRealSector( x, y );
sector.OnEnter( this, rect );
@ -275,45 +260,45 @@ namespace Server
}
}
m_Sectors = sectors.ToArray();
Sectors = sectors.ToArray();
}
public void Unregister()
{
if ( !m_Registered )
if ( !Registered )
return;
OnUnregister();
m_Registered = false;
Registered = false;
if ( m_Children.Count > 0 )
if ( Children.Count > 0 )
Console.WriteLine( "Warning: Unregistering region '{0}' with children", this );
if ( m_Parent != null )
if ( Parent != null )
{
m_Parent.m_Children.Remove( this );
m_Parent.OnChildRemoved( this );
Parent.Children.Remove( this );
Parent.OnChildRemoved( this );
}
m_Regions.Remove( this );
Regions.Remove( this );
m_Map.UnregisterRegion( this );
Map.UnregisterRegion( this );
if ( m_Sectors != null )
if ( Sectors != null )
{
for ( int i = 0; i < m_Sectors.Length; i++ )
m_Sectors[i].OnLeave( this );
for ( int i = 0; i < Sectors.Length; i++ )
Sectors[i].OnLeave( this );
}
m_Sectors = null;
Sectors = null;
}
public bool Contains( Point3D p )
{
for ( int i = 0; i < m_Area.Length; i++ )
for ( int i = 0; i < Area.Length; i++ )
{
Rectangle3D rect = m_Area[i];
Rectangle3D rect = Area[i];
if ( rect.Contains( p ) )
return true;
@ -327,14 +312,14 @@ namespace Server
if ( region == null )
return false;
Region p = m_Parent;
Region p = Parent;
while ( p != null )
{
if ( p == region )
return true;
p = p.m_Parent;
p = p.Parent;
}
return false;
@ -352,7 +337,7 @@ namespace Server
if ( regionType.IsAssignableFrom( r.GetType() ) )
return r;
r = r.m_Parent;
r = r.Parent;
}
while ( r != null );
@ -371,7 +356,7 @@ namespace Server
if ( r.m_Name == regionName )
return r;
r = r.m_Parent;
r = r.Parent;
}
while ( r != null );
@ -404,8 +389,8 @@ namespace Server
if ( region == this )
return true;
if ( m_Parent != null )
return m_Parent.AcceptsSpawnsFrom( region );
if ( Parent != null )
return Parent.AcceptsSpawnsFrom( region );
return false;
}
@ -414,11 +399,11 @@ namespace Server
{
List<Mobile> list = new List<Mobile>();
if ( m_Sectors != null )
if ( Sectors != null )
{
for ( int i = 0; i < m_Sectors.Length; i++ )
for ( int i = 0; i < Sectors.Length; i++ )
{
Sector sector = m_Sectors[i];
Sector sector = Sectors[i];
foreach ( Mobile player in sector.Players )
{
@ -435,11 +420,11 @@ namespace Server
{
int count = 0;
if ( m_Sectors != null )
if ( Sectors != null )
{
for ( int i = 0; i < m_Sectors.Length; i++ )
for ( int i = 0; i < Sectors.Length; i++ )
{
Sector sector = m_Sectors[i];
Sector sector = Sectors[i];
foreach ( Mobile player in sector.Players )
{
@ -456,11 +441,11 @@ namespace Server
{
List<Mobile> list = new List<Mobile>();
if ( m_Sectors != null )
if ( Sectors != null )
{
for ( int i = 0; i < m_Sectors.Length; i++ )
for ( int i = 0; i < Sectors.Length; i++ )
{
Sector sector = m_Sectors[i];
Sector sector = Sectors[i];
foreach ( Mobile mobile in sector.Mobiles )
{
@ -477,11 +462,11 @@ namespace Server
{
int count = 0;
if ( m_Sectors != null )
if ( Sectors != null )
{
for ( int i = 0; i < m_Sectors.Length; i++ )
for ( int i = 0; i < Sectors.Length; i++ )
{
Sector sector = m_Sectors[i];
Sector sector = Sectors[i];
foreach ( Mobile mobile in sector.Mobiles )
{
@ -561,97 +546,97 @@ namespace Server
public virtual void MakeGuard( Mobile focus )
{
m_Parent?.MakeGuard( focus );
Parent?.MakeGuard( focus );
}
public virtual Type GetResource( Type type )
{
if ( m_Parent != null )
return m_Parent.GetResource( type );
if ( Parent != null )
return Parent.GetResource( type );
return type;
}
public virtual bool CanUseStuckMenu( Mobile m )
{
if ( m_Parent != null )
return m_Parent.CanUseStuckMenu( m );
if ( Parent != null )
return Parent.CanUseStuckMenu( m );
return true;
}
public virtual void OnAggressed( Mobile aggressor, Mobile aggressed, bool criminal )
{
m_Parent?.OnAggressed( aggressor, aggressed, criminal );
Parent?.OnAggressed( aggressor, aggressed, criminal );
}
public virtual void OnDidHarmful( Mobile harmer, Mobile harmed )
{
m_Parent?.OnDidHarmful( harmer, harmed );
Parent?.OnDidHarmful( harmer, harmed );
}
public virtual void OnGotHarmful( Mobile harmer, Mobile harmed )
{
m_Parent?.OnGotHarmful( harmer, harmed );
Parent?.OnGotHarmful( harmer, harmed );
}
public virtual void OnLocationChanged( Mobile m, Point3D oldLocation )
{
m_Parent?.OnLocationChanged( m, oldLocation );
Parent?.OnLocationChanged( m, oldLocation );
}
public virtual bool OnTarget( Mobile m, Target t, object o )
{
if ( m_Parent != null )
return m_Parent.OnTarget( m, t, o );
if ( Parent != null )
return Parent.OnTarget( m, t, o );
return true;
}
public virtual bool OnCombatantChange( Mobile m, Mobile Old, Mobile New )
{
if ( m_Parent != null )
return m_Parent.OnCombatantChange( m, Old, New );
if ( Parent != null )
return Parent.OnCombatantChange( m, Old, New );
return true;
}
public virtual bool AllowHousing( Mobile from, Point3D p )
{
if ( m_Parent != null )
return m_Parent.AllowHousing( from, p );
if ( Parent != null )
return Parent.AllowHousing( from, p );
return true;
}
public virtual bool SendInaccessibleMessage( Item item, Mobile from )
{
if ( m_Parent != null )
return m_Parent.SendInaccessibleMessage( item, from );
if ( Parent != null )
return Parent.SendInaccessibleMessage( item, from );
return false;
}
public virtual bool CheckAccessibility( Item item, Mobile from )
{
if ( m_Parent != null )
return m_Parent.CheckAccessibility( item, from );
if ( Parent != null )
return Parent.CheckAccessibility( item, from );
return true;
}
public virtual bool OnDecay( Item item )
{
if ( m_Parent != null )
return m_Parent.OnDecay( item );
if ( Parent != null )
return Parent.OnDecay( item );
return true;
}
public virtual bool AllowHarmful( Mobile from, Mobile target )
{
if ( m_Parent != null )
return m_Parent.AllowHarmful( from, target );
if ( Parent != null )
return Parent.AllowHarmful( from, target );
if ( Mobile.AllowHarmfulHandler != null )
return Mobile.AllowHarmfulHandler( from, target );
@ -661,16 +646,16 @@ namespace Server
public virtual void OnCriminalAction( Mobile m, bool message )
{
if ( m_Parent != null )
m_Parent.OnCriminalAction( m, message );
if ( Parent != null )
Parent.OnCriminalAction( m, message );
else if ( message )
m.SendLocalizedMessage( 1005040 ); // You've committed a criminal act!!
}
public virtual bool AllowBeneficial( Mobile from, Mobile target )
{
if ( m_Parent != null )
return m_Parent.AllowBeneficial( from, target );
if ( Parent != null )
return Parent.AllowBeneficial( from, target );
if ( Mobile.AllowBeneficialHandler != null )
return Mobile.AllowBeneficialHandler( from, target );
@ -680,118 +665,118 @@ namespace Server
public virtual void OnBeneficialAction( Mobile helper, Mobile target )
{
m_Parent?.OnBeneficialAction( helper, target );
Parent?.OnBeneficialAction( helper, target );
}
public virtual void OnGotBeneficialAction( Mobile helper, Mobile target )
{
m_Parent?.OnGotBeneficialAction( helper, target );
Parent?.OnGotBeneficialAction( helper, target );
}
public virtual void SpellDamageScalar( Mobile caster, Mobile target, ref double damage )
{
m_Parent?.SpellDamageScalar( caster, target, ref damage );
Parent?.SpellDamageScalar( caster, target, ref damage );
}
public virtual void OnSpeech( SpeechEventArgs args )
{
m_Parent?.OnSpeech( args );
Parent?.OnSpeech( args );
}
public virtual bool OnSkillUse( Mobile m, int Skill )
{
if ( m_Parent != null )
return m_Parent.OnSkillUse( m, Skill );
if ( Parent != null )
return Parent.OnSkillUse( m, Skill );
return true;
}
public virtual bool OnBeginSpellCast( Mobile m, ISpell s )
{
if ( m_Parent != null )
return m_Parent.OnBeginSpellCast( m, s );
if ( Parent != null )
return Parent.OnBeginSpellCast( m, s );
return true;
}
public virtual void OnSpellCast( Mobile m, ISpell s )
{
m_Parent?.OnSpellCast( m, s );
Parent?.OnSpellCast( m, s );
}
public virtual bool OnResurrect( Mobile m )
{
if ( m_Parent != null )
return m_Parent.OnResurrect( m );
if ( Parent != null )
return Parent.OnResurrect( m );
return true;
}
public virtual bool OnBeforeDeath( Mobile m )
{
if ( m_Parent != null )
return m_Parent.OnBeforeDeath( m );
if ( Parent != null )
return Parent.OnBeforeDeath( m );
return true;
}
public virtual void OnDeath( Mobile m )
{
m_Parent?.OnDeath( m );
Parent?.OnDeath( m );
}
public virtual bool OnDamage( Mobile m, ref int Damage )
{
if ( m_Parent != null )
return m_Parent.OnDamage( m, ref Damage );
if ( Parent != null )
return Parent.OnDamage( m, ref Damage );
return true;
}
public virtual bool OnHeal( Mobile m, ref int Heal )
{
if ( m_Parent != null )
return m_Parent.OnHeal( m, ref Heal );
if ( Parent != null )
return Parent.OnHeal( m, ref Heal );
return true;
}
public virtual bool OnDoubleClick( Mobile m, object o )
{
if ( m_Parent != null )
return m_Parent.OnDoubleClick( m, o );
if ( Parent != null )
return Parent.OnDoubleClick( m, o );
return true;
}
public virtual bool OnSingleClick( Mobile m, object o )
{
if ( m_Parent != null )
return m_Parent.OnSingleClick( m, o );
if ( Parent != null )
return Parent.OnSingleClick( m, o );
return true;
}
public virtual bool AllowSpawn()
{
if ( m_Parent != null )
return m_Parent.AllowSpawn();
if ( Parent != null )
return Parent.AllowSpawn();
return true;
}
public virtual void AlterLightLevel( Mobile m, ref int global, ref int personal )
{
m_Parent?.AlterLightLevel( m, ref global, ref personal );
Parent?.AlterLightLevel( m, ref global, ref personal );
}
public virtual TimeSpan GetLogoutDelay( Mobile m )
{
if ( m_Parent != null )
return m_Parent.GetLogoutDelay( m );
if ( Parent != null )
return Parent.GetLogoutDelay( m );
if ( m.AccessLevel > AccessLevel.Player )
return m_StaffLogoutDelay;
return m_DefaultLogoutDelay;
return StaffLogoutDelay;
return DefaultLogoutDelay;
}
@ -805,10 +790,10 @@ namespace Server
if ( !newRegion.OnMoveInto( m, d, newLocation, oldLocation ) )
return false;
if ( newRegion.m_Parent == null )
if ( newRegion.Parent == null )
return true;
newRegion = newRegion.m_Parent;
newRegion = newRegion.Parent;
}
return true;
@ -919,19 +904,19 @@ namespace Server
public Region( XmlElement xml, Map map, Region parent )
{
m_Map = map;
m_Parent = parent;
m_Dynamic = false;
Map = map;
Parent = parent;
Dynamic = false;
if ( m_Parent == null )
if ( Parent == null )
{
m_ChildLevel = 0;
ChildLevel = 0;
m_Priority = DefaultPriority;
}
else
{
m_ChildLevel = m_Parent.ChildLevel + 1;
m_Priority = m_Parent.Priority;
ChildLevel = Parent.ChildLevel + 1;
m_Priority = Parent.Priority;
}
ReadString( xml, "name", ref m_Name, false );
@ -956,21 +941,21 @@ namespace Server
area.Add( rect );
}
m_Area = area.ToArray();
Area = area.ToArray();
if ( m_Area.Length == 0 )
if ( Area.Length == 0 )
Console.WriteLine( "Empty area for region '{0}'", this );
if ( !ReadPoint3D( xml["go"], map, ref m_GoLocation, false ) && m_Area.Length > 0 )
if ( !ReadPoint3D( xml["go"], map, ref m_GoLocation, false ) && Area.Length > 0 )
{
Point3D start = m_Area[0].Start;
Point3D end = m_Area[0].End;
Point3D start = Area[0].Start;
Point3D end = Area[0].End;
int x = start.X + (end.X - start.X) / 2;
int y = start.Y + (end.Y - start.Y) / 2;
m_GoLocation = new Point3D( x, y, m_Map.GetAverageZ( x, y ) );
m_GoLocation = new Point3D( x, y, Map.GetAverageZ( x, y ) );
}
@ -978,7 +963,7 @@ namespace Server
ReadEnum( xml["music"], "name", ref music, false );
m_Music = music;
Music = music;
}
protected static string GetAttribute( XmlElement xml, string attribute, bool mandatory )

View file

@ -31,13 +31,7 @@ namespace Server
{
public static class ScriptCompiler
{
private static Assembly[] m_Assemblies;
public static Assembly[] Assemblies
{
get => m_Assemblies;
set => m_Assemblies = value;
}
public static Assembly[] Assemblies { get; set; }
private static List<string> m_AdditionalReferences = new List<string>();
@ -595,7 +589,7 @@ namespace Server
return false;
}
m_Assemblies = assemblies.ToArray();
Assemblies = assemblies.ToArray();
Console.Write( "Scripts: Verifying..." );
@ -614,9 +608,9 @@ namespace Server
{
List<MethodInfo> invoke = new List<MethodInfo>();
for( int a = 0; a < m_Assemblies.Length; ++a )
for( int a = 0; a < Assemblies.Length; ++a )
{
Type[] types = m_Assemblies[a].GetTypes();
Type[] types = Assemblies[a].GetTypes();
for( int i = 0; i < types.Length; ++i )
{
@ -664,8 +658,8 @@ namespace Server
{
Type type = null;
for( int i = 0; type == null && i < m_Assemblies.Length; ++i )
type = GetTypeCache( m_Assemblies[i] ).GetTypeByFullName( fullName, ignoreCase );
for( int i = 0; type == null && i < Assemblies.Length; ++i )
type = GetTypeCache( Assemblies[i] ).GetTypeByFullName( fullName, ignoreCase );
if ( type == null )
type = GetTypeCache( Core.Assembly ).GetTypeByFullName( fullName, ignoreCase );
@ -682,8 +676,8 @@ namespace Server
{
Type type = null;
for( int i = 0; type == null && i < m_Assemblies.Length; ++i )
type = GetTypeCache( m_Assemblies[i] ).GetTypeByName( name, ignoreCase );
for( int i = 0; type == null && i < Assemblies.Length; ++i )
type = GetTypeCache( Assemblies[i] ).GetTypeByName( name, ignoreCase );
if ( type == null )
type = GetTypeCache( Core.Assembly ).GetTypeByName( name, ignoreCase );
@ -719,41 +713,40 @@ namespace Server
public class TypeCache
{
private Type[] m_Types;
private TypeTable m_Names, m_FullNames;
public Type[] Types { get; }
public Type[] Types => m_Types;
public TypeTable Names => m_Names;
public TypeTable FullNames => m_FullNames;
public TypeTable Names { get; }
public TypeTable FullNames { get; }
public Type GetTypeByName( string name, bool ignoreCase )
{
return m_Names.Get( name, ignoreCase );
return Names.Get( name, ignoreCase );
}
public Type GetTypeByFullName( string fullName, bool ignoreCase )
{
return m_FullNames.Get( fullName, ignoreCase );
return FullNames.Get( fullName, ignoreCase );
}
public TypeCache( Assembly asm )
{
if ( asm == null )
m_Types = Type.EmptyTypes;
Types = Type.EmptyTypes;
else
m_Types = asm.GetTypes();
Types = asm.GetTypes();
m_Names = new TypeTable( m_Types.Length );
m_FullNames = new TypeTable( m_Types.Length );
Names = new TypeTable( Types.Length );
FullNames = new TypeTable( Types.Length );
Type typeofTypeAliasAttribute = typeof( TypeAliasAttribute );
for( int i = 0; i < m_Types.Length; ++i )
for( int i = 0; i < Types.Length; ++i )
{
Type type = m_Types[i];
Type type = Types[i];
m_Names.Add( type.Name, type );
m_FullNames.Add( type.FullName, type );
Names.Add( type.Name, type );
FullNames.Add( type.FullName, type );
if ( type.IsDefined( typeofTypeAliasAttribute, false ) )
{
@ -764,7 +757,7 @@ namespace Server
if ( attrs[0] is TypeAliasAttribute attr )
{
for( int j = 0; j < attr.Aliases.Length; ++j )
m_FullNames.Add( attr.Aliases[j], type );
FullNames.Add( attr.Aliases[j], type );
}
}
}

View file

@ -25,14 +25,14 @@ using Server.Network;
namespace Server {
public class RegionRect : IComparable {
private Region m_Region;
private Rectangle3D m_Rect;
public Region Region => m_Region;
public Region Region { get; }
public Rectangle3D Rect => m_Rect;
public RegionRect( Region region, Rectangle3D rect ) {
m_Region = region;
Region = region;
m_Rect = rect;
}
@ -47,14 +47,12 @@ namespace Server {
if ( !(obj is RegionRect regRect) )
throw new ArgumentException( "obj is not a RegionRect", nameof(obj) );
return ( ( IComparable ) m_Region ).CompareTo( regRect.m_Region );
return ( ( IComparable ) Region ).CompareTo( regRect.Region );
}
}
public class Sector {
private int m_X, m_Y;
private Map m_Owner;
private List<Mobile> m_Mobiles;
private List<Mobile> m_Players;
private List<Item> m_Items;
@ -71,9 +69,9 @@ namespace Server {
private static List<RegionRect> m_DefaultRectList = new List<RegionRect>();
public Sector( int x, int y, Map owner ) {
m_X = x;
m_Y = y;
m_Owner = owner;
X = x;
Y = y;
Owner = owner;
m_Active = false;
}
@ -132,7 +130,7 @@ namespace Server {
if ( mob.Player ) {
if ( m_Players == null ) {
m_Owner.ActivateSectors( m_X, m_Y );
Owner.ActivateSectors( X, Y );
}
Add( ref m_Players, mob );
@ -150,7 +148,7 @@ namespace Server {
Remove( ref m_Players, mob );
if ( m_Players == null ) {
m_Owner.DeactivateSectors( m_X, m_Y );
Owner.DeactivateSectors( X, Y );
}
}
}
@ -200,7 +198,7 @@ namespace Server {
}
public void Activate() {
if ( !Active && m_Owner != Map.Internal ) {
if ( !Active && Owner != Map.Internal ) {
if ( m_Items != null ) {
foreach ( Item item in m_Items ) {
item.OnSectorActivate();
@ -289,12 +287,12 @@ namespace Server {
}
}
public bool Active => ( m_Active && m_Owner != Map.Internal );
public bool Active => ( m_Active && Owner != Map.Internal );
public Map Owner => m_Owner;
public Map Owner { get; }
public int X => m_X;
public int X { get; }
public int Y => m_Y;
public int Y { get; }
}
}

View file

@ -30,17 +30,12 @@ namespace Server
{
public class SecureTrade
{
private readonly SecureTradeInfo m_From;
private readonly SecureTradeInfo m_To;
private bool m_Valid;
public SecureTrade(Mobile from, Mobile to)
{
m_Valid = true;
Valid = true;
m_From = new SecureTradeInfo(this, from, new SecureTradeContainer(this));
m_To = new SecureTradeInfo(this, to, new SecureTradeContainer(this));
From = new SecureTradeInfo(this, from, new SecureTradeContainer(this));
To = new SecureTradeInfo(this, to, new SecureTradeContainer(this));
var from6017 = (from.NetState != null && from.NetState.ContainerGridLines);
var to6017 = (to.NetState != null && to.NetState.ContainerGridLines);
@ -49,82 +44,83 @@ namespace Server
var to704565 = (to.NetState != null && to.NetState.NewSecureTrading);
from.Send(new MobileStatus(from, to));
from.Send(new UpdateSecureTrade(m_From.Container, false, false));
from.Send(new UpdateSecureTrade(From.Container, false, false));
if (from6017)
{
from.Send(new SecureTradeEquip6017(m_To.Container, to));
from.Send(new SecureTradeEquip6017(To.Container, to));
}
else
{
from.Send(new SecureTradeEquip(m_To.Container, to));
from.Send(new SecureTradeEquip(To.Container, to));
}
from.Send(new UpdateSecureTrade(m_From.Container, false, false));
from.Send(new UpdateSecureTrade(From.Container, false, false));
if (from6017)
{
from.Send(new SecureTradeEquip6017(m_From.Container, from));
from.Send(new SecureTradeEquip6017(From.Container, from));
}
else
{
from.Send(new SecureTradeEquip(m_From.Container, from));
from.Send(new SecureTradeEquip(From.Container, from));
}
from.Send(new DisplaySecureTrade(to, m_From.Container, m_To.Container, to.Name));
from.Send(new UpdateSecureTrade(m_From.Container, false, false));
from.Send(new DisplaySecureTrade(to, From.Container, To.Container, to.Name));
from.Send(new UpdateSecureTrade(From.Container, false, false));
if (from.Account != null && from704565)
{
from.Send(
new UpdateSecureTrade(m_From.Container, TradeFlag.UpdateLedger, from.Account.TotalGold, from.Account.TotalPlat));
new UpdateSecureTrade(From.Container, TradeFlag.UpdateLedger, from.Account.TotalGold, from.Account.TotalPlat));
}
to.Send(new MobileStatus(to, from));
to.Send(new UpdateSecureTrade(m_To.Container, false, false));
to.Send(new UpdateSecureTrade(To.Container, false, false));
if (to6017)
{
to.Send(new SecureTradeEquip6017(m_From.Container, from));
to.Send(new SecureTradeEquip6017(From.Container, from));
}
else
{
to.Send(new SecureTradeEquip(m_From.Container, from));
to.Send(new SecureTradeEquip(From.Container, from));
}
to.Send(new UpdateSecureTrade(m_To.Container, false, false));
to.Send(new UpdateSecureTrade(To.Container, false, false));
if (to6017)
{
to.Send(new SecureTradeEquip6017(m_To.Container, to));
to.Send(new SecureTradeEquip6017(To.Container, to));
}
else
{
to.Send(new SecureTradeEquip(m_To.Container, to));
to.Send(new SecureTradeEquip(To.Container, to));
}
to.Send(new DisplaySecureTrade(from, m_To.Container, m_From.Container, from.Name));
to.Send(new UpdateSecureTrade(m_To.Container, false, false));
to.Send(new DisplaySecureTrade(from, To.Container, From.Container, from.Name));
to.Send(new UpdateSecureTrade(To.Container, false, false));
if (to.Account != null && to704565)
{
to.Send(new UpdateSecureTrade(m_To.Container, TradeFlag.UpdateLedger, to.Account.TotalGold, to.Account.TotalPlat));
to.Send(new UpdateSecureTrade(To.Container, TradeFlag.UpdateLedger, to.Account.TotalGold, to.Account.TotalPlat));
}
}
public SecureTradeInfo From => m_From;
public SecureTradeInfo To => m_To;
public SecureTradeInfo From { get; }
public bool Valid => m_Valid;
public SecureTradeInfo To { get; }
public bool Valid { get; private set; }
public void Cancel()
{
if (!m_Valid)
if (!Valid)
{
return;
}
var list = m_From.Container.Items;
var list = From.Container.Items;
for (var i = list.Count - 1; i >= 0; --i)
{
@ -132,21 +128,21 @@ namespace Server
{
var item = list[i];
if (item == m_From.VirtualCheck)
if (item == From.VirtualCheck)
{
continue;
}
item.OnSecureTrade(m_From.Mobile, m_To.Mobile, m_From.Mobile, false);
item.OnSecureTrade(From.Mobile, To.Mobile, From.Mobile, false);
if (!item.Deleted)
{
m_From.Mobile.AddToBackpack(item);
From.Mobile.AddToBackpack(item);
}
}
}
list = m_To.Container.Items;
list = To.Container.Items;
for (var i = list.Count - 1; i >= 0; --i)
{
@ -154,16 +150,16 @@ namespace Server
{
var item = list[i];
if (item == m_To.VirtualCheck)
if (item == To.VirtualCheck)
{
continue;
}
item.OnSecureTrade(m_To.Mobile, m_From.Mobile, m_To.Mobile, false);
item.OnSecureTrade(To.Mobile, From.Mobile, To.Mobile, false);
if (!item.Deleted)
{
m_To.Mobile.AddToBackpack(item);
To.Mobile.AddToBackpack(item);
}
}
}
@ -173,36 +169,36 @@ namespace Server
public void Close()
{
if (!m_Valid)
if (!Valid)
{
return;
}
m_From.Mobile.Send(new CloseSecureTrade(m_From.Container));
m_To.Mobile.Send(new CloseSecureTrade(m_To.Container));
From.Mobile.Send(new CloseSecureTrade(From.Container));
To.Mobile.Send(new CloseSecureTrade(To.Container));
m_Valid = false;
Valid = false;
var ns = m_From.Mobile.NetState;
var ns = From.Mobile.NetState;
ns?.RemoveTrade(this);
ns = m_To.Mobile.NetState;
ns = To.Mobile.NetState;
ns?.RemoveTrade(this);
Timer.DelayCall(m_From.Dispose);
Timer.DelayCall(m_To.Dispose);
Timer.DelayCall(From.Dispose);
Timer.DelayCall(To.Dispose);
}
public void UpdateFromCurrency()
{
UpdateCurrency(m_From, m_To);
UpdateCurrency(From, To);
}
public void UpdateToCurrency()
{
UpdateCurrency(m_To, m_From);
UpdateCurrency(To, From);
}
private static void UpdateCurrency(SecureTradeInfo left, SecureTradeInfo right)
@ -223,14 +219,14 @@ namespace Server
public void Update()
{
if (!m_Valid)
if (!Valid)
{
return;
}
if (!m_From.IsDisposed && m_From.Accepted && !m_To.IsDisposed && m_To.Accepted)
if (!From.IsDisposed && From.Accepted && !To.IsDisposed && To.Accepted)
{
var list = m_From.Container.Items;
var list = From.Container.Items;
var allowed = true;
@ -240,19 +236,19 @@ namespace Server
{
var item = list[i];
if (item == m_From.VirtualCheck)
if (item == From.VirtualCheck)
{
continue;
}
if (!item.AllowSecureTrade(m_From.Mobile, m_To.Mobile, m_To.Mobile, true))
if (!item.AllowSecureTrade(From.Mobile, To.Mobile, To.Mobile, true))
{
allowed = false;
}
}
}
list = m_To.Container.Items;
list = To.Container.Items;
for (var i = list.Count - 1; allowed && i >= 0; --i)
{
@ -260,12 +256,12 @@ namespace Server
{
var item = list[i];
if (item == m_To.VirtualCheck)
if (item == To.VirtualCheck)
{
continue;
}
if (!item.AllowSecureTrade(m_To.Mobile, m_From.Mobile, m_From.Mobile, true))
if (!item.AllowSecureTrade(To.Mobile, From.Mobile, From.Mobile, true))
{
allowed = false;
}
@ -274,48 +270,48 @@ namespace Server
if (AccountGold.Enabled)
{
if (m_From.Mobile.Account != null)
if (From.Mobile.Account != null)
{
int totalPlat = m_From.Mobile.Account.TotalPlat;
int totalGold = m_From.Mobile.Account.TotalGold;
int totalPlat = From.Mobile.Account.TotalPlat;
int totalGold = From.Mobile.Account.TotalGold;
if (totalPlat < m_From.Plat || totalGold < m_From.Gold)
if (totalPlat < From.Plat || totalGold < From.Gold)
{
allowed = false;
m_From.Mobile.SendMessage("You do not have enough currency to complete this trade.");
From.Mobile.SendMessage("You do not have enough currency to complete this trade.");
}
}
if (m_To.Mobile.Account != null)
if (To.Mobile.Account != null)
{
int totalPlat = m_To.Mobile.Account.TotalPlat;
int totalGold = m_To.Mobile.Account.TotalGold;
int totalPlat = To.Mobile.Account.TotalPlat;
int totalGold = To.Mobile.Account.TotalGold;
if (totalPlat < m_To.Plat || totalGold < m_To.Gold)
if (totalPlat < To.Plat || totalGold < To.Gold)
{
allowed = false;
m_To.Mobile.SendMessage("You do not have enough currency to complete this trade.");
To.Mobile.SendMessage("You do not have enough currency to complete this trade.");
}
}
}
if (!allowed)
{
m_From.Accepted = false;
m_To.Accepted = false;
From.Accepted = false;
To.Accepted = false;
m_From.Mobile.Send(new UpdateSecureTrade(m_From.Container, m_From.Accepted, m_To.Accepted));
m_To.Mobile.Send(new UpdateSecureTrade(m_To.Container, m_To.Accepted, m_From.Accepted));
From.Mobile.Send(new UpdateSecureTrade(From.Container, From.Accepted, To.Accepted));
To.Mobile.Send(new UpdateSecureTrade(To.Container, To.Accepted, From.Accepted));
return;
}
if (AccountGold.Enabled && m_From.Mobile.Account != null && m_To.Mobile.Account != null)
if (AccountGold.Enabled && From.Mobile.Account != null && To.Mobile.Account != null)
{
HandleAccountGoldTrade();
}
list = m_From.Container.Items;
list = From.Container.Items;
for (var i = list.Count - 1; i >= 0; --i)
{
@ -323,21 +319,21 @@ namespace Server
{
var item = list[i];
if (item == m_From.VirtualCheck)
if (item == From.VirtualCheck)
{
continue;
}
item.OnSecureTrade(m_From.Mobile, m_To.Mobile, m_To.Mobile, true);
item.OnSecureTrade(From.Mobile, To.Mobile, To.Mobile, true);
if (!item.Deleted)
{
m_To.Mobile.AddToBackpack(item);
To.Mobile.AddToBackpack(item);
}
}
}
list = m_To.Container.Items;
list = To.Container.Items;
for (var i = list.Count - 1; i >= 0; --i)
{
@ -345,26 +341,26 @@ namespace Server
{
var item = list[i];
if (item == m_To.VirtualCheck)
if (item == To.VirtualCheck)
{
continue;
}
item.OnSecureTrade(m_To.Mobile, m_From.Mobile, m_From.Mobile, true);
item.OnSecureTrade(To.Mobile, From.Mobile, From.Mobile, true);
if (!item.Deleted)
{
m_From.Mobile.AddToBackpack(item);
From.Mobile.AddToBackpack(item);
}
}
}
Close();
}
else if (!m_From.IsDisposed && !m_To.IsDisposed)
else if (!From.IsDisposed && !To.IsDisposed)
{
m_From.Mobile.Send(new UpdateSecureTrade(m_From.Container, m_From.Accepted, m_To.Accepted));
m_To.Mobile.Send(new UpdateSecureTrade(m_To.Container, m_To.Accepted, m_From.Accepted));
From.Mobile.Send(new UpdateSecureTrade(From.Container, From.Accepted, To.Accepted));
To.Mobile.Send(new UpdateSecureTrade(To.Container, To.Accepted, From.Accepted));
}
}
@ -373,48 +369,48 @@ namespace Server
int fromPlatSend = 0, fromGoldSend = 0, fromPlatRecv = 0, fromGoldRecv = 0;
int toPlatSend = 0, toGoldSend = 0, toPlatRecv = 0, toGoldRecv = 0;
if (m_From.Plat > 0 & m_From.Mobile.Account.WithdrawPlat(m_From.Plat))
if (From.Plat > 0 & From.Mobile.Account.WithdrawPlat(From.Plat))
{
fromPlatSend = m_From.Plat;
fromPlatSend = From.Plat;
if (m_To.Mobile.Account.DepositPlat(m_From.Plat))
if (To.Mobile.Account.DepositPlat(From.Plat))
{
toPlatRecv = fromPlatSend;
}
}
if (m_From.Gold > 0 & m_From.Mobile.Account.WithdrawGold(m_From.Gold))
if (From.Gold > 0 & From.Mobile.Account.WithdrawGold(From.Gold))
{
fromGoldSend = m_From.Gold;
fromGoldSend = From.Gold;
if (m_To.Mobile.Account.DepositGold(m_From.Gold))
if (To.Mobile.Account.DepositGold(From.Gold))
{
toGoldRecv = fromGoldSend;
}
}
if (m_To.Plat > 0 & m_To.Mobile.Account.WithdrawPlat(m_To.Plat))
if (To.Plat > 0 & To.Mobile.Account.WithdrawPlat(To.Plat))
{
toPlatSend = m_To.Plat;
toPlatSend = To.Plat;
if (m_From.Mobile.Account.DepositPlat(m_To.Plat))
if (From.Mobile.Account.DepositPlat(To.Plat))
{
fromPlatRecv = toPlatSend;
}
}
if (m_To.Gold > 0 & m_To.Mobile.Account.WithdrawGold(m_To.Gold))
if (To.Gold > 0 & To.Mobile.Account.WithdrawGold(To.Gold))
{
toGoldSend = m_To.Gold;
toGoldSend = To.Gold;
if (m_From.Mobile.Account.DepositGold(m_To.Gold))
if (From.Mobile.Account.DepositGold(To.Gold))
{
fromGoldRecv = toGoldSend;
}
}
HandleAccountGoldTrade(m_From.Mobile, m_To.Mobile, fromPlatSend, fromGoldSend, fromPlatRecv, fromGoldRecv);
HandleAccountGoldTrade(m_To.Mobile, m_From.Mobile, toPlatSend, toGoldSend, toPlatRecv, toGoldRecv);
HandleAccountGoldTrade(From.Mobile, To.Mobile, fromPlatSend, fromGoldSend, fromPlatRecv, fromGoldRecv);
HandleAccountGoldTrade(To.Mobile, From.Mobile, toPlatSend, toGoldSend, toPlatRecv, toGoldRecv);
}
private static void HandleAccountGoldTrade(

View file

@ -24,13 +24,9 @@ namespace Server
{
public struct Serial : IComparable, IComparable<Serial>
{
private int m_Serial;
public static Serial LastMobile { get; private set; } = Zero;
private static Serial m_LastMobile = Zero;
private static Serial m_LastItem = 0x40000000;
public static Serial LastMobile => m_LastMobile;
public static Serial LastItem => m_LastItem;
public static Serial LastItem { get; private set; } = 0x40000000;
public static readonly Serial MinusOne = new Serial( -1 );
public static readonly Serial Zero = new Serial( 0 );
@ -39,9 +35,9 @@ namespace Server
{
get
{
while ( World.FindMobile( m_LastMobile = (m_LastMobile + 1) ) != null );
while ( World.FindMobile( LastMobile = (LastMobile + 1) ) != null );
return m_LastMobile;
return LastMobile;
}
}
@ -49,33 +45,33 @@ namespace Server
{
get
{
while ( World.FindItem( m_LastItem = (m_LastItem + 1) ) != null );
while ( World.FindItem( LastItem = (LastItem + 1) ) != null );
return m_LastItem;
return LastItem;
}
}
private Serial( int serial )
{
m_Serial = serial;
Value = serial;
}
public int Value => m_Serial;
public int Value { get; }
public bool IsMobile => ( m_Serial > 0 && m_Serial < 0x40000000 );
public bool IsMobile => ( Value > 0 && Value < 0x40000000 );
public bool IsItem => ( m_Serial >= 0x40000000 && m_Serial <= 0x7FFFFFFF );
public bool IsItem => ( Value >= 0x40000000 && Value <= 0x7FFFFFFF );
public bool IsValid => ( m_Serial > 0 );
public bool IsValid => ( Value > 0 );
public override int GetHashCode()
{
return m_Serial;
return Value;
}
public int CompareTo( Serial other )
{
return m_Serial.CompareTo( other.m_Serial );
return Value.CompareTo( other.Value );
}
public int CompareTo( object other )
@ -94,37 +90,37 @@ namespace Server
if ( !(o is Serial serial) )
return false;
return serial.m_Serial == m_Serial;
return serial.Value == Value;
}
public static bool operator == ( Serial l, Serial r )
{
return l.m_Serial == r.m_Serial;
return l.Value == r.Value;
}
public static bool operator != ( Serial l, Serial r )
{
return l.m_Serial != r.m_Serial;
return l.Value != r.Value;
}
public static bool operator > ( Serial l, Serial r )
{
return l.m_Serial > r.m_Serial;
return l.Value > r.Value;
}
public static bool operator < ( Serial l, Serial r )
{
return l.m_Serial < r.m_Serial;
return l.Value < r.Value;
}
public static bool operator >= ( Serial l, Serial r )
{
return l.m_Serial >= r.m_Serial;
return l.Value >= r.Value;
}
public static bool operator <= ( Serial l, Serial r )
{
return l.m_Serial <= r.m_Serial;
return l.Value <= r.Value;
}
/*public static Serial operator ++ ( Serial l )
@ -134,12 +130,12 @@ namespace Server
public override string ToString()
{
return $"0x{m_Serial:X8}";
return $"0x{Value:X8}";
}
public static implicit operator int( Serial a )
{
return a.m_Serial;
return a.Value;
}
public static implicit operator Serial( int a )

View file

@ -1385,8 +1385,7 @@ namespace Server
public sealed class AsyncWriter : GenericWriter
{
private static int m_ThreadCount;
public static int ThreadCount => m_ThreadCount;
public static int ThreadCount { get; private set; }
private int BufferSize;
@ -1442,7 +1441,7 @@ namespace Server
public void Worker()
{
m_ThreadCount++;
ThreadCount++;
int lastCount = 0;
@ -1461,9 +1460,9 @@ namespace Server
if ( m_Owner.m_Closed )
m_Owner.m_File.Close();
m_ThreadCount--;
ThreadCount--;
if (m_ThreadCount <= 0)
if (ThreadCount <= 0)
World.NotifyDiskWriteComplete();
}
}

View file

@ -101,11 +101,8 @@ namespace Server
[PropertyObject]
public class Skill
{
private Skills m_Owner;
private SkillInfo m_Info;
private ushort m_Base;
private ushort m_Cap;
private SkillLock m_Lock;
public override string ToString()
{
@ -114,8 +111,8 @@ namespace Server
public Skill( Skills owner, SkillInfo info, GenericReader reader )
{
m_Owner = owner;
m_Info = info;
Owner = owner;
Info = info;
int version = reader.ReadByte();
@ -125,7 +122,7 @@ namespace Server
{
m_Base = reader.ReadUShort();
m_Cap = reader.ReadUShort();
m_Lock = (SkillLock)reader.ReadByte();
Lock = (SkillLock)reader.ReadByte();
break;
}
@ -133,7 +130,7 @@ namespace Server
{
m_Base = 0;
m_Cap = 1000;
m_Lock = SkillLock.Up;
Lock = SkillLock.Up;
break;
}
@ -150,27 +147,27 @@ namespace Server
m_Cap = 1000;
if ( (version & 0x4) != 0 )
m_Lock = (SkillLock)reader.ReadByte();
Lock = (SkillLock)reader.ReadByte();
}
break;
}
}
if ( m_Lock < SkillLock.Up || m_Lock > SkillLock.Locked )
if ( Lock < SkillLock.Up || Lock > SkillLock.Locked )
{
Console.WriteLine( "Bad skill lock -> {0}.{1}", owner.Owner, m_Lock );
m_Lock = SkillLock.Up;
Console.WriteLine( "Bad skill lock -> {0}.{1}", owner.Owner, Lock );
Lock = SkillLock.Up;
}
}
public Skill( Skills owner, SkillInfo info, int baseValue, int cap, SkillLock skillLock )
{
m_Owner = owner;
m_Info = info;
Owner = owner;
Info = info;
m_Base = (ushort)baseValue;
m_Cap = (ushort)cap;
m_Lock = skillLock;
Lock = skillLock;
}
public void SetLockNoRelay( SkillLock skillLock )
@ -178,12 +175,12 @@ namespace Server
if ( skillLock < SkillLock.Up || skillLock > SkillLock.Locked )
return;
m_Lock = skillLock;
Lock = skillLock;
}
public void Serialize( GenericWriter writer )
{
if ( m_Base == 0 && m_Cap == 1000 && m_Lock == SkillLock.Up )
if ( m_Base == 0 && m_Cap == 1000 && Lock == SkillLock.Up )
{
writer.Write( (byte) 0xFF ); // default
}
@ -197,7 +194,7 @@ namespace Server
if ( m_Cap != 1000 )
flags |= 0x2;
if ( m_Lock != SkillLock.Up )
if ( Lock != SkillLock.Up )
flags |= 0x4;
writer.Write( (byte) flags ); // version
@ -208,24 +205,24 @@ namespace Server
if ( m_Cap != 1000 )
writer.Write( (short) m_Cap );
if ( m_Lock != SkillLock.Up )
writer.Write( (byte) m_Lock );
if ( Lock != SkillLock.Up )
writer.Write( (byte) Lock );
}
}
public Skills Owner => m_Owner;
public Skills Owner { get; }
public SkillName SkillName => (SkillName)m_Info.SkillID;
public SkillName SkillName => (SkillName)Info.SkillID;
public int SkillID => m_Info.SkillID;
public int SkillID => Info.SkillID;
[CommandProperty( AccessLevel.Counselor )]
public string Name => m_Info.Name;
public string Name => Info.Name;
public SkillInfo Info => m_Info;
public SkillInfo Info { get; }
[CommandProperty( AccessLevel.Counselor )]
public SkillLock Lock => m_Lock;
public SkillLock Lock { get; private set; }
public int BaseFixedPoint
{
@ -243,13 +240,13 @@ namespace Server
if ( m_Base != sv )
{
m_Owner.Total = (m_Owner.Total - m_Base) + sv;
Owner.Total = (Owner.Total - m_Base) + sv;
m_Base = sv;
m_Owner.OnSkillChange( this );
Owner.OnSkillChange( this );
Mobile m = m_Owner.Owner;
Mobile m = Owner.Owner;
m?.OnSkillChange( SkillName, (double)oldBase / 10 );
}
@ -279,7 +276,7 @@ namespace Server
{
m_Cap = sv;
m_Owner.OnSkillChange( this );
Owner.OnSkillChange( this );
}
}
}
@ -291,11 +288,7 @@ namespace Server
set => CapFixedPoint = (int)(value * 10.0);
}
private static bool m_UseStatMods;
public static bool UseStatMods{ get => m_UseStatMods;
set => m_UseStatMods = value;
}
public static bool UseStatMods { get; set; }
public int Fixed => (int)(Value * 10);
@ -307,7 +300,7 @@ namespace Server
//There has to be this distinction between the racial values and not to account for gaining skills and these skills aren't displayed nor Totaled up.
double value = NonRacialValue;
double raceBonus = m_Owner.Owner.RacialSkillBonus;
double raceBonus = Owner.Owner.RacialSkillBonus;
if ( raceBonus > value )
value = raceBonus;
@ -328,8 +321,8 @@ namespace Server
inv /= 100.0;
double statsOffset = ((m_UseStatMods ? m_Owner.Owner.Str : m_Owner.Owner.RawStr) * m_Info.StrScale) + ((m_UseStatMods ? m_Owner.Owner.Dex : m_Owner.Owner.RawDex) * m_Info.DexScale) + ((m_UseStatMods ? m_Owner.Owner.Int : m_Owner.Owner.RawInt) * m_Info.IntScale);
double statTotal = m_Info.StatTotal * inv;
double statsOffset = ((UseStatMods ? Owner.Owner.Str : Owner.Owner.RawStr) * Info.StrScale) + ((UseStatMods ? Owner.Owner.Dex : Owner.Owner.RawDex) * Info.DexScale) + ((UseStatMods ? Owner.Owner.Int : Owner.Owner.RawInt) * Info.IntScale);
double statTotal = Info.StatTotal * inv;
statsOffset *= inv;
@ -338,9 +331,9 @@ namespace Server
double value = baseValue + statsOffset;
m_Owner.Owner.ValidateSkillMods();
Owner.Owner.ValidateSkillMods();
List<SkillMod> mods = m_Owner.Owner.SkillMods;
List<SkillMod> mods = Owner.Owner.SkillMods;
double bonusObey = 0.0, bonusNotObey = 0.0;
@ -348,7 +341,7 @@ namespace Server
{
SkillMod mod = mods[i];
if ( mod.Skill == (SkillName)m_Info.SkillID )
if ( mod.Skill == (SkillName)Info.SkillID )
{
if ( mod.Relative )
{
@ -382,185 +375,120 @@ namespace Server
public void Update()
{
m_Owner.OnSkillChange( this );
Owner.OnSkillChange( this );
}
}
public class SkillInfo
{
private int m_SkillID;
private string m_Name;
private string m_Title;
private double m_StrScale;
private double m_DexScale;
private double m_IntScale;
private double m_StatTotal;
private SkillUseCallback m_Callback;
private double m_StrGain;
private double m_DexGain;
private double m_IntGain;
private double m_GainFactor;
public SkillInfo( int skillID, string name, double strScale, double dexScale, double intScale, string title, SkillUseCallback callback, double strGain, double dexGain, double intGain, double gainFactor )
{
m_Name = name;
m_Title = title;
m_SkillID = skillID;
m_StrScale = strScale / 100.0;
m_DexScale = dexScale / 100.0;
m_IntScale = intScale / 100.0;
m_Callback = callback;
m_StrGain = strGain;
m_DexGain = dexGain;
m_IntGain = intGain;
m_GainFactor = gainFactor;
Name = name;
Title = title;
SkillID = skillID;
StrScale = strScale / 100.0;
DexScale = dexScale / 100.0;
IntScale = intScale / 100.0;
Callback = callback;
StrGain = strGain;
DexGain = dexGain;
IntGain = intGain;
GainFactor = gainFactor;
m_StatTotal = strScale + dexScale + intScale;
StatTotal = strScale + dexScale + intScale;
}
public SkillUseCallback Callback
public SkillUseCallback Callback { get; set; }
public int SkillID { get; }
public string Name { get; set; }
public string Title { get; set; }
public double StrScale { get; set; }
public double DexScale { get; set; }
public double IntScale { get; set; }
public double StatTotal { get; set; }
public double StrGain { get; set; }
public double DexGain { get; set; }
public double IntGain { get; set; }
public double GainFactor { get; set; }
public static SkillInfo[] Table { get; set; } = new SkillInfo[58]
{
get => m_Callback;
set => m_Callback = value;
}
public int SkillID => m_SkillID;
public string Name
{
get => m_Name;
set => m_Name = value;
}
public string Title
{
get => m_Title;
set => m_Title = value;
}
public double StrScale
{
get => m_StrScale;
set => m_StrScale = value;
}
public double DexScale
{
get => m_DexScale;
set => m_DexScale = value;
}
public double IntScale
{
get => m_IntScale;
set => m_IntScale = value;
}
public double StatTotal
{
get => m_StatTotal;
set => m_StatTotal = value;
}
public double StrGain
{
get => m_StrGain;
set => m_StrGain = value;
}
public double DexGain
{
get => m_DexGain;
set => m_DexGain = value;
}
public double IntGain
{
get => m_IntGain;
set => m_IntGain = value;
}
public double GainFactor
{
get => m_GainFactor;
set => m_GainFactor = value;
}
private static SkillInfo[] m_Table = new SkillInfo[58]
{
new SkillInfo( 0, "Alchemy", 0.0, 5.0, 5.0, "Alchemist", null, 0.0, 0.5, 0.5, 1.0 ),
new SkillInfo( 1, "Anatomy", 0.0, 0.0, 0.0, "Biologist", null, 0.15, 0.15, 0.7, 1.0 ),
new SkillInfo( 2, "Animal Lore", 0.0, 0.0, 0.0, "Naturalist", null, 0.0, 0.0, 1.0, 1.0 ),
new SkillInfo( 3, "Item Identification", 0.0, 0.0, 0.0, "Merchant", null, 0.0, 0.0, 1.0, 1.0 ),
new SkillInfo( 4, "Arms Lore", 0.0, 0.0, 0.0, "Weapon Master", null, 0.75, 0.15, 0.1, 1.0 ),
new SkillInfo( 5, "Parrying", 7.5, 2.5, 0.0, "Duelist", null, 0.75, 0.25, 0.0, 1.0 ),
new SkillInfo( 6, "Begging", 0.0, 0.0, 0.0, "Beggar", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 7, "Blacksmithy", 10.0, 0.0, 0.0, "Blacksmith", null, 1.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 8, "Bowcraft/Fletching", 6.0, 16.0, 0.0, "Bowyer", null, 0.6, 1.6, 0.0, 1.0 ),
new SkillInfo( 9, "Peacemaking", 0.0, 0.0, 0.0, "Pacifier", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 10, "Camping", 20.0, 15.0, 15.0, "Explorer", null, 2.0, 1.5, 1.5, 1.0 ),
new SkillInfo( 11, "Carpentry", 20.0, 5.0, 0.0, "Carpenter", null, 2.0, 0.5, 0.0, 1.0 ),
new SkillInfo( 12, "Cartography", 0.0, 7.5, 7.5, "Cartographer", null, 0.0, 0.75, 0.75, 1.0 ),
new SkillInfo( 13, "Cooking", 0.0, 20.0, 30.0, "Chef", null, 0.0, 2.0, 3.0, 1.0 ),
new SkillInfo( 14, "Detecting Hidden", 0.0, 0.0, 0.0, "Scout", null, 0.0, 0.4, 0.6, 1.0 ),
new SkillInfo( 15, "Discordance", 0.0, 2.5, 2.5, "Demoralizer", null, 0.0, 0.25, 0.25, 1.0 ),
new SkillInfo( 16, "Evaluating Intelligence", 0.0, 0.0, 0.0, "Scholar", null, 0.0, 0.0, 1.0, 1.0 ),
new SkillInfo( 17, "Healing", 6.0, 6.0, 8.0, "Healer", null, 0.6, 0.6, 0.8, 1.0 ),
new SkillInfo( 18, "Fishing", 0.0, 0.0, 0.0, "Fisherman", null, 0.5, 0.5, 0.0, 1.0 ),
new SkillInfo( 19, "Forensic Evaluation", 0.0, 0.0, 0.0, "Detective", null, 0.0, 0.2, 0.8, 1.0 ),
new SkillInfo( 20, "Herding", 16.25, 6.25, 2.5, "Shepherd", null, 1.625, 0.625, 0.25, 1.0 ),
new SkillInfo( 21, "Hiding", 0.0, 0.0, 0.0, "Shade", null, 0.0, 0.8, 0.2, 1.0 ),
new SkillInfo( 22, "Provocation", 0.0, 4.5, 0.5, "Rouser", null, 0.0, 0.45, 0.05, 1.0 ),
new SkillInfo( 23, "Inscription", 0.0, 2.0, 8.0, "Scribe", null, 0.0, 0.2, 0.8, 1.0 ),
new SkillInfo( 24, "Lockpicking", 0.0, 25.0, 0.0, "Infiltrator", null, 0.0, 2.0, 0.0, 1.0 ),
new SkillInfo( 25, "Magery", 0.0, 0.0, 15.0, "Mage", null, 0.0, 0.0, 1.5, 1.0 ),
new SkillInfo( 26, "Resisting Spells", 0.0, 0.0, 0.0, "Warder", null, 0.25, 0.25, 0.5, 1.0 ),
new SkillInfo( 27, "Tactics", 0.0, 0.0, 0.0, "Tactician", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 28, "Snooping", 0.0, 25.0, 0.0, "Spy", null, 0.0, 2.5, 0.0, 1.0 ),
new SkillInfo( 29, "Musicianship", 0.0, 0.0, 0.0, "Bard", null, 0.0, 0.8, 0.2, 1.0 ),
new SkillInfo( 30, "Poisoning", 0.0, 4.0, 16.0, "Assassin", null, 0.0, 0.4, 1.6, 1.0 ),
new SkillInfo( 31, "Archery", 2.5, 7.5, 0.0, "Archer", null, 0.25, 0.75, 0.0, 1.0 ),
new SkillInfo( 32, "Spirit Speak", 0.0, 0.0, 0.0, "Medium", null, 0.0, 0.0, 1.0, 1.0 ),
new SkillInfo( 33, "Stealing", 0.0, 10.0, 0.0, "Pickpocket", null, 0.0, 1.0, 0.0, 1.0 ),
new SkillInfo( 34, "Tailoring", 3.75, 16.25, 5.0, "Tailor", null, 0.38, 1.63, 0.5, 1.0 ),
new SkillInfo( 35, "Animal Taming", 14.0, 2.0, 4.0, "Tamer", null, 1.4, 0.2, 0.4, 1.0 ),
new SkillInfo( 36, "Taste Identification", 0.0, 0.0, 0.0, "Praegustator", null, 0.2, 0.0, 0.8, 1.0 ),
new SkillInfo( 37, "Tinkering", 5.0, 2.0, 3.0, "Tinker", null, 0.5, 0.2, 0.3, 1.0 ),
new SkillInfo( 38, "Tracking", 0.0, 12.5, 12.5, "Ranger", null, 0.0, 1.25, 1.25, 1.0 ),
new SkillInfo( 39, "Veterinary", 8.0, 4.0, 8.0, "Veterinarian", null, 0.8, 0.4, 0.8, 1.0 ),
new SkillInfo( 40, "Swordsmanship", 7.5, 2.5, 0.0, "Swordsman", null, 0.75, 0.25, 0.0, 1.0 ),
new SkillInfo( 41, "Mace Fighting", 9.0, 1.0, 0.0, "Armsman", null, 0.9, 0.1, 0.0, 1.0 ),
new SkillInfo( 42, "Fencing", 4.5, 5.5, 0.0, "Fencer", null, 0.45, 0.55, 0.0, 1.0 ),
new SkillInfo( 43, "Wrestling", 9.0, 1.0, 0.0, "Wrestler", null, 0.9, 0.1, 0.0, 1.0 ),
new SkillInfo( 44, "Lumberjacking", 20.0, 0.0, 0.0, "Lumberjack", null, 2.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 45, "Mining", 20.0, 0.0, 0.0, "Miner", null, 2.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 46, "Meditation", 0.0, 0.0, 0.0, "Stoic", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 47, "Stealth", 0.0, 0.0, 0.0, "Rogue", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 48, "Remove Trap", 0.0, 0.0, 0.0, "Trap Specialist", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 49, "Necromancy", 0.0, 0.0, 0.0, "Necromancer", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 50, "Focus", 0.0, 0.0, 0.0, "Driven", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 51, "Chivalry", 0.0, 0.0, 0.0, "Paladin", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 52, "Bushido", 0.0, 0.0, 0.0, "Samurai", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 53, "Ninjitsu", 0.0, 0.0, 0.0, "Ninja", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 54, "Spellweaving", 0.0, 0.0, 0.0, "Arcanist", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 55, "Mysticism", 0.0, 0.0, 0.0, "Mystic", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 56, "Imbuing", 0.0, 0.0, 0.0, "Artificer", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 57, "Throwing", 0.0, 0.0, 0.0, "Bladeweaver", null, 0.0, 0.0, 0.0, 1.0 ),
};
public static SkillInfo[] Table
{
get => m_Table;
set => m_Table = value;
}
new SkillInfo( 0, "Alchemy", 0.0, 5.0, 5.0, "Alchemist", null, 0.0, 0.5, 0.5, 1.0 ),
new SkillInfo( 1, "Anatomy", 0.0, 0.0, 0.0, "Biologist", null, 0.15, 0.15, 0.7, 1.0 ),
new SkillInfo( 2, "Animal Lore", 0.0, 0.0, 0.0, "Naturalist", null, 0.0, 0.0, 1.0, 1.0 ),
new SkillInfo( 3, "Item Identification", 0.0, 0.0, 0.0, "Merchant", null, 0.0, 0.0, 1.0, 1.0 ),
new SkillInfo( 4, "Arms Lore", 0.0, 0.0, 0.0, "Weapon Master", null, 0.75, 0.15, 0.1, 1.0 ),
new SkillInfo( 5, "Parrying", 7.5, 2.5, 0.0, "Duelist", null, 0.75, 0.25, 0.0, 1.0 ),
new SkillInfo( 6, "Begging", 0.0, 0.0, 0.0, "Beggar", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 7, "Blacksmithy", 10.0, 0.0, 0.0, "Blacksmith", null, 1.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 8, "Bowcraft/Fletching", 6.0, 16.0, 0.0, "Bowyer", null, 0.6, 1.6, 0.0, 1.0 ),
new SkillInfo( 9, "Peacemaking", 0.0, 0.0, 0.0, "Pacifier", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 10, "Camping", 20.0, 15.0, 15.0, "Explorer", null, 2.0, 1.5, 1.5, 1.0 ),
new SkillInfo( 11, "Carpentry", 20.0, 5.0, 0.0, "Carpenter", null, 2.0, 0.5, 0.0, 1.0 ),
new SkillInfo( 12, "Cartography", 0.0, 7.5, 7.5, "Cartographer", null, 0.0, 0.75, 0.75, 1.0 ),
new SkillInfo( 13, "Cooking", 0.0, 20.0, 30.0, "Chef", null, 0.0, 2.0, 3.0, 1.0 ),
new SkillInfo( 14, "Detecting Hidden", 0.0, 0.0, 0.0, "Scout", null, 0.0, 0.4, 0.6, 1.0 ),
new SkillInfo( 15, "Discordance", 0.0, 2.5, 2.5, "Demoralizer", null, 0.0, 0.25, 0.25, 1.0 ),
new SkillInfo( 16, "Evaluating Intelligence", 0.0, 0.0, 0.0, "Scholar", null, 0.0, 0.0, 1.0, 1.0 ),
new SkillInfo( 17, "Healing", 6.0, 6.0, 8.0, "Healer", null, 0.6, 0.6, 0.8, 1.0 ),
new SkillInfo( 18, "Fishing", 0.0, 0.0, 0.0, "Fisherman", null, 0.5, 0.5, 0.0, 1.0 ),
new SkillInfo( 19, "Forensic Evaluation", 0.0, 0.0, 0.0, "Detective", null, 0.0, 0.2, 0.8, 1.0 ),
new SkillInfo( 20, "Herding", 16.25, 6.25, 2.5, "Shepherd", null, 1.625, 0.625, 0.25, 1.0 ),
new SkillInfo( 21, "Hiding", 0.0, 0.0, 0.0, "Shade", null, 0.0, 0.8, 0.2, 1.0 ),
new SkillInfo( 22, "Provocation", 0.0, 4.5, 0.5, "Rouser", null, 0.0, 0.45, 0.05, 1.0 ),
new SkillInfo( 23, "Inscription", 0.0, 2.0, 8.0, "Scribe", null, 0.0, 0.2, 0.8, 1.0 ),
new SkillInfo( 24, "Lockpicking", 0.0, 25.0, 0.0, "Infiltrator", null, 0.0, 2.0, 0.0, 1.0 ),
new SkillInfo( 25, "Magery", 0.0, 0.0, 15.0, "Mage", null, 0.0, 0.0, 1.5, 1.0 ),
new SkillInfo( 26, "Resisting Spells", 0.0, 0.0, 0.0, "Warder", null, 0.25, 0.25, 0.5, 1.0 ),
new SkillInfo( 27, "Tactics", 0.0, 0.0, 0.0, "Tactician", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 28, "Snooping", 0.0, 25.0, 0.0, "Spy", null, 0.0, 2.5, 0.0, 1.0 ),
new SkillInfo( 29, "Musicianship", 0.0, 0.0, 0.0, "Bard", null, 0.0, 0.8, 0.2, 1.0 ),
new SkillInfo( 30, "Poisoning", 0.0, 4.0, 16.0, "Assassin", null, 0.0, 0.4, 1.6, 1.0 ),
new SkillInfo( 31, "Archery", 2.5, 7.5, 0.0, "Archer", null, 0.25, 0.75, 0.0, 1.0 ),
new SkillInfo( 32, "Spirit Speak", 0.0, 0.0, 0.0, "Medium", null, 0.0, 0.0, 1.0, 1.0 ),
new SkillInfo( 33, "Stealing", 0.0, 10.0, 0.0, "Pickpocket", null, 0.0, 1.0, 0.0, 1.0 ),
new SkillInfo( 34, "Tailoring", 3.75, 16.25, 5.0, "Tailor", null, 0.38, 1.63, 0.5, 1.0 ),
new SkillInfo( 35, "Animal Taming", 14.0, 2.0, 4.0, "Tamer", null, 1.4, 0.2, 0.4, 1.0 ),
new SkillInfo( 36, "Taste Identification", 0.0, 0.0, 0.0, "Praegustator", null, 0.2, 0.0, 0.8, 1.0 ),
new SkillInfo( 37, "Tinkering", 5.0, 2.0, 3.0, "Tinker", null, 0.5, 0.2, 0.3, 1.0 ),
new SkillInfo( 38, "Tracking", 0.0, 12.5, 12.5, "Ranger", null, 0.0, 1.25, 1.25, 1.0 ),
new SkillInfo( 39, "Veterinary", 8.0, 4.0, 8.0, "Veterinarian", null, 0.8, 0.4, 0.8, 1.0 ),
new SkillInfo( 40, "Swordsmanship", 7.5, 2.5, 0.0, "Swordsman", null, 0.75, 0.25, 0.0, 1.0 ),
new SkillInfo( 41, "Mace Fighting", 9.0, 1.0, 0.0, "Armsman", null, 0.9, 0.1, 0.0, 1.0 ),
new SkillInfo( 42, "Fencing", 4.5, 5.5, 0.0, "Fencer", null, 0.45, 0.55, 0.0, 1.0 ),
new SkillInfo( 43, "Wrestling", 9.0, 1.0, 0.0, "Wrestler", null, 0.9, 0.1, 0.0, 1.0 ),
new SkillInfo( 44, "Lumberjacking", 20.0, 0.0, 0.0, "Lumberjack", null, 2.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 45, "Mining", 20.0, 0.0, 0.0, "Miner", null, 2.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 46, "Meditation", 0.0, 0.0, 0.0, "Stoic", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 47, "Stealth", 0.0, 0.0, 0.0, "Rogue", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 48, "Remove Trap", 0.0, 0.0, 0.0, "Trap Specialist", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 49, "Necromancy", 0.0, 0.0, 0.0, "Necromancer", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 50, "Focus", 0.0, 0.0, 0.0, "Driven", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 51, "Chivalry", 0.0, 0.0, 0.0, "Paladin", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 52, "Bushido", 0.0, 0.0, 0.0, "Samurai", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 53, "Ninjitsu", 0.0, 0.0, 0.0, "Ninja", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 54, "Spellweaving", 0.0, 0.0, 0.0, "Arcanist", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 55, "Mysticism", 0.0, 0.0, 0.0, "Mystic", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 56, "Imbuing", 0.0, 0.0, 0.0, "Artificer", null, 0.0, 0.0, 0.0, 1.0 ),
new SkillInfo( 57, "Throwing", 0.0, 0.0, 0.0, "Bladeweaver", null, 0.0, 0.0, 0.0, 1.0 ),
};
}
[PropertyObject]
public class Skills : IEnumerable<Skill>
{
private Mobile m_Owner;
private Skill[] m_Skills;
private int m_Total, m_Cap;
private Skill m_Highest;
#region Skill Getters & Setters
@ -799,19 +727,11 @@ namespace Server
#endregion
[CommandProperty( AccessLevel.Counselor, AccessLevel.GameMaster )]
public int Cap
{
get => m_Cap;
set => m_Cap = value;
}
public int Cap { get; set; }
public int Total
{
get => m_Total;
set => m_Total = value;
}
public int Total { get; set; }
public Mobile Owner => m_Owner;
public Mobile Owner { get; }
public int Length => m_Skills.Length;
@ -910,11 +830,11 @@ namespace Server
public void Serialize( GenericWriter writer )
{
m_Total = 0;
Total = 0;
writer.Write( (int) 3 ); // version
writer.Write( (int) m_Cap );
writer.Write( (int) Cap );
writer.Write( (int) m_Skills.Length );
for ( int i = 0; i < m_Skills.Length; ++i )
@ -928,15 +848,15 @@ namespace Server
else
{
sk.Serialize( writer );
m_Total += sk.BaseFixedPoint;
Total += sk.BaseFixedPoint;
}
}
}
public Skills( Mobile owner )
{
m_Owner = owner;
m_Cap = 7000;
Owner = owner;
Cap = 7000;
SkillInfo[] info = SkillInfo.Table;
@ -948,7 +868,7 @@ namespace Server
public Skills( Mobile owner, GenericReader reader )
{
m_Owner = owner;
Owner = owner;
int version = reader.ReadInt();
@ -957,14 +877,14 @@ namespace Server
case 3:
case 2:
{
m_Cap = reader.ReadInt();
Cap = reader.ReadInt();
goto case 1;
}
case 1:
{
if ( version < 2 )
m_Cap = 7000;
Cap = 7000;
if ( version < 3 )
/*m_Total =*/ reader.ReadInt();
@ -984,7 +904,7 @@ namespace Server
if ( sk.BaseFixedPoint != 0 || sk.CapFixedPoint != 1000 || sk.Lock != SkillLock.Up )
{
m_Skills[i] = sk;
m_Total += sk.BaseFixedPoint;
Total += sk.BaseFixedPoint;
}
}
else
@ -1014,9 +934,9 @@ namespace Server
else if ( m_Highest != null && skill.BaseFixedPoint > m_Highest.BaseFixedPoint )
m_Highest = skill;
m_Owner.OnSkillInvalidated( skill );
Owner.OnSkillInvalidated( skill );
NetState ns = m_Owner.NetState;
NetState ns = Owner.NetState;
ns?.Send( new SkillChange( skill ) );
}

View file

@ -23,7 +23,6 @@ namespace Server.Targeting
public class LandTarget : IPoint3D
{
private Point3D m_Location;
private int m_TileID;
public LandTarget( Point3D location, Map map )
{
@ -32,18 +31,18 @@ namespace Server.Targeting
if ( map != null )
{
m_Location.Z = map.GetAverageZ( m_Location.X, m_Location.Y );
m_TileID = map.Tiles.GetLandTile( m_Location.X, m_Location.Y ).ID & TileData.MaxLandValue;
TileID = map.Tiles.GetLandTile( m_Location.X, m_Location.Y ).ID & TileData.MaxLandValue;
}
}
[CommandProperty( AccessLevel.Counselor )]
public string Name => TileData.LandTable[m_TileID].Name;
public string Name => TileData.LandTable[TileID].Name;
[CommandProperty( AccessLevel.Counselor )]
public TileFlag Flags => TileData.LandTable[m_TileID].Flags;
public TileFlag Flags => TileData.LandTable[TileID].Flags;
[CommandProperty( AccessLevel.Counselor )]
public int TileID => m_TileID;
public int TileID { get; }
[CommandProperty( AccessLevel.Counselor )]
public Point3D Location => m_Location;

View file

@ -24,20 +24,9 @@ namespace Server.Targeting
{
public abstract class MultiTarget : Target
{
private int m_MultiID;
private Point3D m_Offset;
public int MultiID { get; set; }
public int MultiID
{
get => m_MultiID;
set => m_MultiID = value;
}
public Point3D Offset
{
get => m_Offset;
set => m_Offset = value;
}
public Point3D Offset { get; set; }
protected MultiTarget( int multiID, Point3D offset )
: this( multiID, offset, 10, true, TargetFlags.None )
@ -47,8 +36,8 @@ namespace Server.Targeting
protected MultiTarget( int multiID, Point3D offset, int range, bool allowGround, TargetFlags flags )
: base( range, allowGround, flags )
{
m_MultiID = multiID;
m_Offset = offset;
MultiID = multiID;
Offset = offset;
}
public override Packet GetPacketFor( NetState ns )

View file

@ -23,23 +23,22 @@ namespace Server.Targeting
public class StaticTarget : IPoint3D
{
private Point3D m_Location;
private int m_ItemID;
public StaticTarget( Point3D location, int itemID )
{
m_Location = location;
m_ItemID = itemID & TileData.MaxItemValue;
m_Location.Z += TileData.ItemTable[m_ItemID].CalcHeight;
ItemID = itemID & TileData.MaxItemValue;
m_Location.Z += TileData.ItemTable[ItemID].CalcHeight;
}
[CommandProperty( AccessLevel.Counselor )]
public Point3D Location => m_Location;
[CommandProperty( AccessLevel.Counselor )]
public string Name => TileData.ItemTable[m_ItemID].Name;
public string Name => TileData.ItemTable[ItemID].Name;
[CommandProperty( AccessLevel.Counselor )]
public TileFlag Flags => TileData.ItemTable[m_ItemID].Flags;
public TileFlag Flags => TileData.ItemTable[ItemID].Flags;
[CommandProperty( AccessLevel.Counselor )]
public int X => m_Location.X;
@ -51,6 +50,6 @@ namespace Server.Targeting
public int Z => m_Location.Z;
[CommandProperty( AccessLevel.Counselor )]
public int ItemID => m_ItemID;
public int ItemID { get; }
}
}

View file

@ -27,33 +27,18 @@ namespace Server.Targeting
{
private static int m_NextTargetID;
private static bool m_TargetIDValidation = true;
public static bool TargetIDValidation { get; set; } = true;
public static bool TargetIDValidation
{
get => m_TargetIDValidation;
set => m_TargetIDValidation = value;
}
private int m_TargetID;
private int m_Range;
private bool m_AllowGround;
private bool m_CheckLOS;
private bool m_AllowNonlocal;
private bool m_DisallowMultis;
private TargetFlags m_Flags;
private DateTime m_TimeoutTime;
public DateTime TimeoutTime => m_TimeoutTime;
public DateTime TimeoutTime { get; private set; }
protected Target( int range, bool allowGround, TargetFlags flags )
{
m_TargetID = ++m_NextTargetID;
m_Range = range;
m_AllowGround = allowGround;
m_Flags = flags;
TargetID = ++m_NextTargetID;
Range = range;
AllowGround = allowGround;
Flags = flags;
m_CheckLOS = true;
CheckLOS = true;
}
public static void Cancel( Mobile m )
@ -71,7 +56,7 @@ namespace Server.Targeting
public void BeginTimeout( Mobile from, TimeSpan delay )
{
m_TimeoutTime = DateTime.UtcNow + delay;
TimeoutTime = DateTime.UtcNow + delay;
m_TimeoutTimer?.Stop();
@ -128,25 +113,13 @@ namespace Server.Targeting
}
}
public bool CheckLOS
{
get => m_CheckLOS;
set => m_CheckLOS = value;
}
public bool CheckLOS { get; set; }
public bool DisallowMultis
{
get => m_DisallowMultis;
set => m_DisallowMultis = value;
}
public bool DisallowMultis { get; set; }
public bool AllowNonlocal
{
get => m_AllowNonlocal;
set => m_AllowNonlocal = value;
}
public bool AllowNonlocal { get; set; }
public int TargetID => m_TargetID;
public int TargetID { get; }
public virtual Packet GetPacketFor( NetState ns )
{
@ -227,7 +200,7 @@ namespace Server.Targeting
object root = item.RootParent;
if ( !m_AllowNonlocal && root is Mobile && root != from && from.AccessLevel == AccessLevel.Player )
if ( !AllowNonlocal && root is Mobile && root != from && from.AccessLevel == AccessLevel.Player )
{
OnNonlocalTarget( from, item );
OnTargetFinish( from );
@ -244,7 +217,7 @@ namespace Server.Targeting
return;
}
if ( map == null || map != from.Map || ( m_Range != -1 && !from.InRange( loc, m_Range ) ) )
if ( map == null || map != from.Map || ( Range != -1 && !from.InRange( loc, Range ) ) )
{
OnTargetOutOfRange( from, targeted );
}
@ -252,7 +225,7 @@ namespace Server.Targeting
{
if ( !from.CanSee( targeted ) )
OnCantSeeTarget( from, targeted );
else if ( m_CheckLOS && !from.InLOS( targeted ) )
else if ( CheckLOS && !from.InLOS( targeted ) )
OnTargetOutOfLOS( from, targeted );
else if ( item?.InSecureTrade == true )
OnTargetInSecureTrade( from, targeted );
@ -320,22 +293,10 @@ namespace Server.Targeting
{
}
public int Range
{
get => m_Range;
set => m_Range = value;
}
public int Range { get; set; }
public bool AllowGround
{
get => m_AllowGround;
set => m_AllowGround = value;
}
public bool AllowGround { get; set; }
public TargetFlags Flags
{
get => m_Flags;
set => m_Flags = value;
}
public TargetFlags Flags { get; set; }
}
}

View file

@ -26,32 +26,19 @@ namespace Server
{
public struct LandData
{
private string m_Name;
private TileFlag m_Flags;
public LandData( string name, TileFlag flags )
{
m_Name = name;
m_Flags = flags;
Name = name;
Flags = flags;
}
public string Name
{
get => m_Name;
set => m_Name = value;
}
public string Name { get; set; }
public TileFlag Flags
{
get => m_Flags;
set => m_Flags = value;
}
public TileFlag Flags { get; set; }
}
public struct ItemData
{
private string m_Name;
private TileFlag m_Flags;
private byte m_Weight;
private byte m_Quality;
private byte m_Quantity;
@ -60,8 +47,8 @@ namespace Server
public ItemData( string name, TileFlag flags, int weight, int quality, int quantity, int value, int height )
{
m_Name = name;
m_Flags = flags;
Name = name;
Flags = flags;
m_Weight = (byte)weight;
m_Quality = (byte)quality;
m_Quantity = (byte)quantity;
@ -69,51 +56,43 @@ namespace Server
m_Height = (byte)height;
}
public string Name
{
get => m_Name;
set => m_Name = value;
}
public string Name { get; set; }
public TileFlag Flags
{
get => m_Flags;
set => m_Flags = value;
}
public TileFlag Flags { get; set; }
public bool Bridge
{
get => (m_Flags & TileFlag.Bridge) != 0;
get => (Flags & TileFlag.Bridge) != 0;
set
{
if ( value )
m_Flags |= TileFlag.Bridge;
Flags |= TileFlag.Bridge;
else
m_Flags &= ~TileFlag.Bridge;
Flags &= ~TileFlag.Bridge;
}
}
public bool Impassable
{
get => (m_Flags & TileFlag.Impassable) != 0;
get => (Flags & TileFlag.Impassable) != 0;
set
{
if ( value )
m_Flags |= TileFlag.Impassable;
Flags |= TileFlag.Impassable;
else
m_Flags &= ~TileFlag.Impassable;
Flags &= ~TileFlag.Impassable;
}
}
public bool Surface
{
get => (m_Flags & TileFlag.Surface) != 0;
get => (Flags & TileFlag.Surface) != 0;
set
{
if ( value )
m_Flags |= TileFlag.Surface;
Flags |= TileFlag.Surface;
else
m_Flags &= ~TileFlag.Surface;
Flags &= ~TileFlag.Surface;
}
}
@ -151,7 +130,7 @@ namespace Server
{
get
{
if ( (m_Flags & TileFlag.Bridge) != 0 )
if ( (Flags & TileFlag.Bridge) != 0 )
return m_Height / 2;
return m_Height;
}
@ -198,19 +177,13 @@ namespace Server
public static class TileData
{
private static LandData[] m_LandData;
private static ItemData[] m_ItemData;
public static LandData[] LandTable { get; }
public static LandData[] LandTable => m_LandData;
public static ItemData[] ItemTable { get; }
public static ItemData[] ItemTable => m_ItemData;
public static int MaxLandValue { get; }
private static int m_MaxLandValue;
private static int m_MaxItemValue;
public static int MaxLandValue => m_MaxLandValue;
public static int MaxItemValue => m_MaxItemValue;
public static int MaxItemValue { get; }
private static byte[] m_StringBuffer = new byte[20];
@ -236,7 +209,7 @@ namespace Server
BinaryReader bin = new BinaryReader( fs );
if ( fs.Length == 3188736 ) { // 7.0.9.0
m_LandData = new LandData[0x4000];
LandTable = new LandData[0x4000];
for ( int i = 0; i < 0x4000; ++i )
{
@ -248,10 +221,10 @@ namespace Server
TileFlag flags = (TileFlag)bin.ReadInt64();
bin.ReadInt16(); // skip 2 bytes -- textureID
m_LandData[i] = new LandData( ReadNameString( bin ), flags );
LandTable[i] = new LandData( ReadNameString( bin ), flags );
}
m_ItemData = new ItemData[0x10000];
ItemTable = new ItemData[0x10000];
for ( int i = 0; i < 0x10000; ++i )
{
@ -271,10 +244,10 @@ namespace Server
int value = bin.ReadByte();
int height = bin.ReadByte();
m_ItemData[i] = new ItemData( ReadNameString( bin ), flags, weight, quality, quantity, value, height );
ItemTable[i] = new ItemData( ReadNameString( bin ), flags, weight, quality, quantity, value, height );
}
} else {
m_LandData = new LandData[0x4000];
LandTable = new LandData[0x4000];
for ( int i = 0; i < 0x4000; ++i )
{
@ -286,11 +259,11 @@ namespace Server
TileFlag flags = (TileFlag)bin.ReadInt32();
bin.ReadInt16(); // skip 2 bytes -- textureID
m_LandData[i] = new LandData( ReadNameString( bin ), flags );
LandTable[i] = new LandData( ReadNameString( bin ), flags );
}
if ( fs.Length == 1644544 ) { // 7.0.0.0
m_ItemData = new ItemData[0x8000];
ItemTable = new ItemData[0x8000];
for ( int i = 0; i < 0x8000; ++i )
{
@ -310,10 +283,10 @@ namespace Server
int value = bin.ReadByte();
int height = bin.ReadByte();
m_ItemData[i] = new ItemData( ReadNameString( bin ), flags, weight, quality, quantity, value, height );
ItemTable[i] = new ItemData( ReadNameString( bin ), flags, weight, quality, quantity, value, height );
}
} else {
m_ItemData = new ItemData[0x4000];
ItemTable = new ItemData[0x4000];
for ( int i = 0; i < 0x4000; ++i )
{
@ -333,14 +306,14 @@ namespace Server
int value = bin.ReadByte();
int height = bin.ReadByte();
m_ItemData[i] = new ItemData( ReadNameString( bin ), flags, weight, quality, quantity, value, height );
ItemTable[i] = new ItemData( ReadNameString( bin ), flags, weight, quality, quantity, value, height );
}
}
}
}
m_MaxLandValue = m_LandData.Length - 1;
m_MaxItemValue = m_ItemData.Length - 1;
MaxLandValue = LandTable.Length - 1;
MaxItemValue = ItemTable.Length - 1;
}
else
{

View file

@ -23,34 +23,33 @@ namespace Server
public class TileList
{
private StaticTile[] m_Tiles;
private int m_Count;
public TileList()
{
m_Tiles = new StaticTile[8];
m_Count = 0;
Count = 0;
}
public int Count => m_Count;
public int Count { get; private set; }
public void AddRange( StaticTile[] tiles )
{
if ( (m_Count + tiles.Length) > m_Tiles.Length )
if ( (Count + tiles.Length) > m_Tiles.Length )
{
StaticTile[] old = m_Tiles;
m_Tiles = new StaticTile[(m_Count + tiles.Length) * 2];
m_Tiles = new StaticTile[(Count + tiles.Length) * 2];
for ( int i = 0; i < old.Length; ++i )
m_Tiles[i] = old[i];
}
for ( int i = 0; i < tiles.Length; ++i )
m_Tiles[m_Count++] = tiles[i];
m_Tiles[Count++] = tiles[i];
}
public void Add( ushort id, sbyte z )
{
if ( (m_Count + 1) > m_Tiles.Length )
if ( (Count + 1) > m_Tiles.Length )
{
StaticTile[] old = m_Tiles;
m_Tiles = new StaticTile[old.Length * 2];
@ -59,24 +58,24 @@ namespace Server
m_Tiles[i] = old[i];
}
m_Tiles[m_Count].m_ID = id;
m_Tiles[m_Count].m_Z = z;
++m_Count;
m_Tiles[Count].m_ID = id;
m_Tiles[Count].m_Z = z;
++Count;
}
private static StaticTile[] m_EmptyTiles = new StaticTile[0];
public StaticTile[] ToArray()
{
if ( m_Count == 0 )
if ( Count == 0 )
return m_EmptyTiles;
StaticTile[] tiles = new StaticTile[m_Count];
StaticTile[] tiles = new StaticTile[Count];
for ( int i = 0; i < m_Count; ++i )
for ( int i = 0; i < Count; ++i )
tiles[i] = m_Tiles[i];
m_Count = 0;
Count = 0;
return tiles;
}

View file

@ -32,23 +32,14 @@ namespace Server
private LandTile[][][] m_LandTiles;
private LandTile[] m_InvalidLandBlock;
private StaticTile[][][] m_EmptyStaticBlock;
private FileStream m_Map;
private UOPIndex m_MapIndex;
private FileStream m_Index;
private BinaryReader m_IndexReader;
private FileStream m_Statics;
private int m_FileIndex;
private int m_BlockWidth, m_BlockHeight;
private int m_Width, m_Height;
private Map m_Owner;
private TileMatrixPatch m_Patch;
private int[][] m_StaticPatches;
private int[][] m_LandPatches;
@ -60,11 +51,11 @@ namespace Server
}
}*/
public TileMatrixPatch Patch => m_Patch;
public TileMatrixPatch Patch { get; }
public int BlockWidth => m_BlockWidth;
public int BlockWidth { get; }
public int BlockHeight => m_BlockHeight;
public int BlockHeight { get; }
/*public int Width
{
@ -82,36 +73,20 @@ namespace Server
}
}*/
public FileStream MapStream
{
get => m_Map;
set => m_Map = value;
}
public FileStream MapStream { get; set; }
/*public bool MapUOPPacked
{
get{ return ( m_MapIndex != null ); }
}*/
public FileStream IndexStream
{
get => m_Index;
set => m_Index = value;
}
public FileStream IndexStream { get; set; }
public FileStream DataStream
{
get => m_Statics;
set => m_Statics = value;
}
public FileStream DataStream { get; set; }
public BinaryReader IndexReader
{
get => m_IndexReader;
set => m_IndexReader = value;
}
public BinaryReader IndexReader { get; set; }
public bool Exists => ( m_Map != null && m_Index != null && m_Statics != null );
public bool Exists => ( MapStream != null && IndexStream != null && DataStream != null );
private static List<TileMatrix> m_Instances = new List<TileMatrix>();
private List<TileMatrix> m_FileShare = new List<TileMatrix>();
@ -140,8 +115,8 @@ namespace Server
m_FileIndex = fileIndex;
m_Width = width;
m_Height = height;
m_BlockWidth = width >> 3;
m_BlockHeight = height >> 3;
BlockWidth = width >> 3;
BlockHeight = height >> 3;
m_Owner = owner;
@ -151,7 +126,7 @@ namespace Server
if ( File.Exists( mapPath ) )
{
m_Map = new FileStream( mapPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
MapStream = new FileStream( mapPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
}
else
{
@ -159,8 +134,8 @@ namespace Server
if ( File.Exists( mapPath ) )
{
m_Map = new FileStream( mapPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
m_MapIndex = new UOPIndex( m_Map );
MapStream = new FileStream( mapPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
m_MapIndex = new UOPIndex( MapStream );
}
}
@ -168,51 +143,51 @@ namespace Server
if ( File.Exists( indexPath ) )
{
m_Index = new FileStream( indexPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
m_IndexReader = new BinaryReader( m_Index );
IndexStream = new FileStream( indexPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
IndexReader = new BinaryReader( IndexStream );
}
string staticsPath = Core.FindDataFile( "statics{0}.mul", fileIndex );
if ( File.Exists( staticsPath ) )
m_Statics = new FileStream( staticsPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
DataStream = new FileStream( staticsPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
}
m_EmptyStaticBlock = new StaticTile[8][][];
EmptyStaticBlock = new StaticTile[8][][];
for ( int i = 0; i < 8; ++i )
{
m_EmptyStaticBlock[i] = new StaticTile[8][];
EmptyStaticBlock[i] = new StaticTile[8][];
for ( int j = 0; j < 8; ++j )
m_EmptyStaticBlock[i][j] = new StaticTile[0];
EmptyStaticBlock[i][j] = new StaticTile[0];
}
m_InvalidLandBlock = new LandTile[196];
m_LandTiles = new LandTile[m_BlockWidth][][];
m_StaticTiles = new StaticTile[m_BlockWidth][][][][];
m_StaticPatches = new int[m_BlockWidth][];
m_LandPatches = new int[m_BlockWidth][];
m_LandTiles = new LandTile[BlockWidth][][];
m_StaticTiles = new StaticTile[BlockWidth][][][][];
m_StaticPatches = new int[BlockWidth][];
m_LandPatches = new int[BlockWidth][];
m_Patch = new TileMatrixPatch( this, mapID );
Patch = new TileMatrixPatch( this, mapID );
}
public StaticTile[][][] EmptyStaticBlock => m_EmptyStaticBlock;
public StaticTile[][][] EmptyStaticBlock { get; }
[MethodImpl(MethodImplOptions.Synchronized)]
public void SetStaticBlock( int x, int y, StaticTile[][][] value )
{
if ( x < 0 || y < 0 || x >= m_BlockWidth || y >= m_BlockHeight )
if ( x < 0 || y < 0 || x >= BlockWidth || y >= BlockHeight )
return;
if ( m_StaticTiles[x] == null )
m_StaticTiles[x] = new StaticTile[m_BlockHeight][][][];
m_StaticTiles[x] = new StaticTile[BlockHeight][][][];
m_StaticTiles[x][y] = value;
if ( m_StaticPatches[x] == null )
m_StaticPatches[x] = new int[(m_BlockHeight + 31) >> 5];
m_StaticPatches[x] = new int[(BlockHeight + 31) >> 5];
m_StaticPatches[x][y >> 5] |= 1 << (y & 0x1F);
}
@ -220,11 +195,11 @@ namespace Server
[MethodImpl(MethodImplOptions.Synchronized)]
public StaticTile[][][] GetStaticBlock( int x, int y )
{
if ( x < 0 || y < 0 || x >= m_BlockWidth || y >= m_BlockHeight || m_Statics == null || m_Index == null )
return m_EmptyStaticBlock;
if ( x < 0 || y < 0 || x >= BlockWidth || y >= BlockHeight || DataStream == null || IndexStream == null )
return EmptyStaticBlock;
if ( m_StaticTiles[x] == null )
m_StaticTiles[x] = new StaticTile[m_BlockHeight][][][];
m_StaticTiles[x] = new StaticTile[BlockHeight][][][];
StaticTile[][][] tiles = m_StaticTiles[x][y];
@ -236,7 +211,7 @@ namespace Server
TileMatrix shared = m_FileShare[i];
lock (shared) {
if ( x >= 0 && x < shared.m_BlockWidth && y >= 0 && y < shared.m_BlockHeight )
if ( x >= 0 && x < shared.BlockWidth && y >= 0 && y < shared.BlockHeight )
{
StaticTile[][][][] theirTiles = shared.m_StaticTiles[x];
@ -311,16 +286,16 @@ namespace Server
[MethodImpl(MethodImplOptions.Synchronized)]
public void SetLandBlock( int x, int y, LandTile[] value )
{
if ( x < 0 || y < 0 || x >= m_BlockWidth || y >= m_BlockHeight )
if ( x < 0 || y < 0 || x >= BlockWidth || y >= BlockHeight )
return;
if ( m_LandTiles[x] == null )
m_LandTiles[x] = new LandTile[m_BlockHeight][];
m_LandTiles[x] = new LandTile[BlockHeight][];
m_LandTiles[x][y] = value;
if ( m_LandPatches[x] == null )
m_LandPatches[x] = new int[(m_BlockHeight + 31) >> 5];
m_LandPatches[x] = new int[(BlockHeight + 31) >> 5];
m_LandPatches[x][y >> 5] |= 1 << (y & 0x1F);
}
@ -328,11 +303,11 @@ namespace Server
[MethodImpl(MethodImplOptions.Synchronized)]
public LandTile[] GetLandBlock( int x, int y )
{
if ( x < 0 || y < 0 || x >= m_BlockWidth || y >= m_BlockHeight || m_Map == null )
if ( x < 0 || y < 0 || x >= BlockWidth || y >= BlockHeight || MapStream == null )
return m_InvalidLandBlock;
if ( m_LandTiles[x] == null )
m_LandTiles[x] = new LandTile[m_BlockHeight][];
m_LandTiles[x] = new LandTile[BlockHeight][];
LandTile[] tiles = m_LandTiles[x][y];
@ -344,7 +319,7 @@ namespace Server
TileMatrix shared = m_FileShare[i];
lock (shared) {
if ( x >= 0 && x < shared.m_BlockWidth && y >= 0 && y < shared.m_BlockHeight )
if ( x >= 0 && x < shared.BlockWidth && y >= 0 && y < shared.BlockHeight )
{
LandTile[][] theirTiles = shared.m_LandTiles[x];
@ -388,19 +363,19 @@ namespace Server
{
try
{
m_IndexReader.BaseStream.Seek( ((x * m_BlockHeight) + y) * 12, SeekOrigin.Begin );
IndexReader.BaseStream.Seek( ((x * BlockHeight) + y) * 12, SeekOrigin.Begin );
int lookup = m_IndexReader.ReadInt32();
int length = m_IndexReader.ReadInt32();
int lookup = IndexReader.ReadInt32();
int length = IndexReader.ReadInt32();
if ( lookup < 0 || length <= 0 )
{
return m_EmptyStaticBlock;
return EmptyStaticBlock;
}
int count = length / 7;
m_Statics.Seek( lookup, SeekOrigin.Begin );
DataStream.Seek( lookup, SeekOrigin.Begin );
if ( m_TileBuffer.Length < count )
m_TileBuffer = new StaticTile[count];
@ -410,7 +385,7 @@ namespace Server
fixed ( StaticTile *pTiles = staTiles )
{
#if !MONO
NativeReader.Read( m_Statics.SafeFileHandle.DangerousGetHandle(), pTiles, length );
NativeReader.Read( DataStream.SafeFileHandle.DangerousGetHandle(), pTiles, length );
#else
NativeReader.Read( m_Statics.Handle, pTiles, length );
#endif
@ -458,7 +433,7 @@ namespace Server
m_NextStaticWarning = DateTime.UtcNow + TimeSpan.FromMinutes( 1.0 );
}
return m_EmptyStaticBlock;
return EmptyStaticBlock;
}
}
@ -476,19 +451,19 @@ namespace Server
{
try
{
int offset = ((x * m_BlockHeight) + y) * 196 + 4;
int offset = ((x * BlockHeight) + y) * 196 + 4;
if ( m_MapIndex != null )
offset = m_MapIndex.Lookup( offset );
m_Map.Seek( offset, SeekOrigin.Begin );
MapStream.Seek( offset, SeekOrigin.Begin );
LandTile[] tiles = new LandTile[64];
fixed ( LandTile *pTiles = tiles )
{
#if !MONO
NativeReader.Read( m_Map.SafeFileHandle.DangerousGetHandle(), pTiles, 192 );
NativeReader.Read( MapStream.SafeFileHandle.DangerousGetHandle(), pTiles, 192 );
#else
NativeReader.Read( m_Map.Handle, pTiles, 192 );
#endif
@ -514,12 +489,12 @@ namespace Server
m_MapIndex.Close();
else
{
m_Map?.Close();
MapStream?.Close();
}
m_Statics?.Close();
DataStream?.Close();
m_IndexReader?.Close();
IndexReader?.Close();
}
}
@ -663,10 +638,9 @@ namespace Server
private BinaryReader m_Reader;
private int m_Length;
private int m_Version;
private UOPEntry[] m_Entries;
public int Version => m_Version;
public int Version { get; }
public UOPIndex( FileStream stream )
{
@ -676,7 +650,7 @@ namespace Server
if ( m_Reader.ReadInt32() != 0x50594D )
throw new ArgumentException( "Invalid UOP file." );
m_Version = m_Reader.ReadInt32();
Version = m_Reader.ReadInt32();
m_Reader.ReadInt32();
int nextTable = m_Reader.ReadInt32();

View file

@ -27,13 +27,7 @@ namespace Server
{
private int m_LandBlocks, m_StaticBlocks;
private static bool m_Enabled = true;
public static bool Enabled
{
get => m_Enabled;
set => m_Enabled = value;
}
public static bool Enabled { get; set; } = true;
public int LandBlocks
{
@ -55,7 +49,7 @@ namespace Server
public TileMatrixPatch( TileMatrix matrix, int index )
{
if ( !m_Enabled )
if ( !Enabled )
return;
string mapDataPath = Core.FindDataFile( "mapdif{0}.mul", index );

View file

@ -355,11 +355,8 @@ namespace Server
}
private static Queue<Timer> m_Queue = new Queue<Timer>();
private static int m_BreakCount = 20000;
public static int BreakCount{ get => m_BreakCount;
set => m_BreakCount = value;
}
public static int BreakCount { get; set; } = 20000;
private static int m_QueueCountAtSlice;
@ -373,7 +370,7 @@ namespace Server
int index = 0;
while ( index < m_BreakCount && m_Queue.Count != 0 )
while ( index < BreakCount && m_Queue.Count != 0 )
{
Timer t = m_Queue.Dequeue();
TimerProfile prof = t.GetProfile();
@ -550,41 +547,38 @@ namespace Server
#region DelayCall Timers
private class DelayCallTimer : Timer
{
private TimerCallback m_Callback;
public TimerCallback Callback => m_Callback;
public TimerCallback Callback { get; }
public override bool DefRegCreation => false;
public DelayCallTimer( TimeSpan delay, TimeSpan interval, int count, TimerCallback callback ) : base( delay, interval, count )
{
m_Callback = callback;
Callback = callback;
RegCreation();
}
protected override void OnTick()
{
m_Callback?.Invoke();
Callback?.Invoke();
}
public override string ToString()
{
return $"DelayCallTimer[{FormatDelegate(m_Callback)}]";
return $"DelayCallTimer[{FormatDelegate(Callback)}]";
}
}
private class DelayStateCallTimer : Timer
{
private TimerStateCallback m_Callback;
private object m_State;
public TimerStateCallback Callback => m_Callback;
public TimerStateCallback Callback { get; }
public override bool DefRegCreation => false;
public DelayStateCallTimer( TimeSpan delay, TimeSpan interval, int count, TimerStateCallback callback, object state ) : base( delay, interval, count )
{
m_Callback = callback;
Callback = callback;
m_State = state;
RegCreation();
@ -592,28 +586,27 @@ namespace Server
protected override void OnTick()
{
m_Callback?.Invoke( m_State );
Callback?.Invoke( m_State );
}
public override string ToString()
{
return $"DelayStateCall[{FormatDelegate(m_Callback)}]";
return $"DelayStateCall[{FormatDelegate(Callback)}]";
}
}
private class DelayStateCallTimer<T> : Timer
{
private TimerStateCallback<T> m_Callback;
private T m_State;
public TimerStateCallback<T> Callback => m_Callback;
public TimerStateCallback<T> Callback { get; }
public override bool DefRegCreation => false;
public DelayStateCallTimer( TimeSpan delay, TimeSpan interval, int count, TimerStateCallback<T> callback, T state )
: base( delay, interval, count )
{
m_Callback = callback;
Callback = callback;
m_State = state;
RegCreation();
@ -621,12 +614,12 @@ namespace Server
protected override void OnTick()
{
m_Callback?.Invoke( m_State );
Callback?.Invoke( m_State );
}
public override string ToString()
{
return $"DelayStateCall[{FormatDelegate(m_Callback)}]";
return $"DelayStateCall[{FormatDelegate(Callback)}]";
}
}
#endregion

View file

@ -23,23 +23,21 @@ namespace Server
[PropertyObject]
public class VirtueInfo
{
private int[] m_Values;
public int[] Values => m_Values;
public int[] Values { get; private set; }
public int GetValue( int index )
{
if ( m_Values == null )
if ( Values == null )
return 0;
return m_Values[index];
return Values[index];
}
public void SetValue( int index, int value )
{
if ( m_Values == null )
m_Values = new int[8];
if ( Values == null )
Values = new int[8];
m_Values[index] = value;
Values[index] = value;
}
public override string ToString()
@ -104,11 +102,11 @@ namespace Server
if ( mask != 0 )
{
m_Values = new int[8];
Values = new int[8];
for ( int i = 0; i < 8; ++i )
if ( (mask & (1 << i)) != 0 )
m_Values[i] = reader.ReadInt();
Values[i] = reader.ReadInt();
}
break;
@ -131,7 +129,7 @@ namespace Server
{
writer.Write( (byte) 1 ); // version
if ( info.m_Values == null )
if ( info.Values == null )
{
writer.Write( (byte) 0 );
}
@ -140,14 +138,14 @@ namespace Server
int mask = 0;
for ( int i = 0; i < 8; ++i )
if ( info.m_Values[i] != 0 )
if ( info.Values[i] != 0 )
mask |= 1 << i;
writer.Write( (byte) mask );
for ( int i = 0; i < 8; ++i )
if ( info.m_Values[i] != 0 )
writer.Write( (int) info.m_Values[i] );
if ( info.Values[i] != 0 )
writer.Write( (int) info.Values[i] );
}
}
}

View file

@ -29,21 +29,15 @@ using Server.Guilds;
namespace Server {
public static class World {
private static Dictionary<Serial, Mobile> m_Mobiles;
private static Dictionary<Serial, Item> m_Items;
private static bool m_Loading;
private static bool m_Loaded;
private static bool m_Saving;
private static ManualResetEvent m_DiskWriteHandle = new ManualResetEvent(true);
private static Queue<IEntity> _addQueue, _deleteQueue;
public static bool Saving => m_Saving;
public static bool Loaded => m_Loaded;
public static bool Loading => m_Loading;
public static bool Saving { get; private set; }
public static bool Loaded { get; private set; }
public static bool Loading { get; private set; }
public readonly static string MobileIndexPath = Path.Combine( "Saves/Mobiles/", "Mobiles.idx" );
public readonly static string MobileTypesPath = Path.Combine( "Saves/Mobiles/", "Mobiles.tdb" );
@ -69,13 +63,13 @@ namespace Server {
m_DiskWriteHandle.WaitOne();
}
public static Dictionary<Serial, Mobile> Mobiles => m_Mobiles;
public static Dictionary<Serial, Mobile> Mobiles { get; private set; }
public static Dictionary<Serial, Item> Items => m_Items;
public static Dictionary<Serial, Item> Items { get; private set; }
public static bool OnDelete( IEntity entity ) {
if ( m_Saving || m_Loading ) {
if ( m_Saving ) {
if ( Saving || Loading ) {
if ( Saving ) {
AppendSafetyLog( "delete", entity );
}
@ -121,86 +115,68 @@ namespace Server {
}
private sealed class GuildEntry : IEntityEntry {
private BaseGuild m_Guild;
private long m_Position;
private int m_Length;
public BaseGuild Guild { get; }
public BaseGuild Guild => m_Guild;
public Serial Serial => m_Guild?.Id ?? 0;
public Serial Serial => Guild?.Id ?? 0;
public int TypeID => 0;
public long Position => m_Position;
public long Position { get; }
public int Length => m_Length;
public int Length { get; }
public GuildEntry( BaseGuild g, long pos, int length ) {
m_Guild = g;
m_Position = pos;
m_Length = length;
Guild = g;
Position = pos;
Length = length;
}
}
private sealed class ItemEntry : IEntityEntry {
private Item m_Item;
private int m_TypeID;
private string m_TypeName;
private long m_Position;
private int m_Length;
public Item Item { get; }
public Item Item => m_Item;
public Serial Serial => Item?.Serial ?? Serial.MinusOne;
public Serial Serial => m_Item?.Serial ?? Serial.MinusOne;
public int TypeID { get; }
public int TypeID => m_TypeID;
public string TypeName { get; }
public string TypeName => m_TypeName;
public long Position { get; }
public long Position => m_Position;
public int Length => m_Length;
public int Length { get; }
public ItemEntry( Item item, int typeID, string typeName, long pos, int length ) {
m_Item = item;
m_TypeID = typeID;
m_TypeName = typeName;
m_Position = pos;
m_Length = length;
Item = item;
TypeID = typeID;
TypeName = typeName;
Position = pos;
Length = length;
}
}
private sealed class MobileEntry : IEntityEntry {
private Mobile m_Mobile;
private int m_TypeID;
private string m_TypeName;
private long m_Position;
private int m_Length;
public Mobile Mobile { get; }
public Mobile Mobile => m_Mobile;
public Serial Serial => Mobile?.Serial ?? Serial.MinusOne;
public Serial Serial => m_Mobile?.Serial ?? Serial.MinusOne;
public int TypeID { get; }
public int TypeID => m_TypeID;
public string TypeName { get; }
public string TypeName => m_TypeName;
public long Position { get; }
public long Position => m_Position;
public int Length => m_Length;
public int Length { get; }
public MobileEntry( Mobile mobile, int typeID, string typeName, long pos, int length ) {
m_Mobile = mobile;
m_TypeID = typeID;
m_TypeName = typeName;
m_Position = pos;
m_Length = length;
Mobile = mobile;
TypeID = typeID;
TypeName = typeName;
Position = pos;
Length = length;
}
}
private static string m_LoadingType;
public static string LoadingType => m_LoadingType;
public static string LoadingType { get; private set; }
private static readonly Type[] m_SerialTypeArray = new Type[1] { typeof(Serial) };
@ -257,17 +233,17 @@ namespace Server {
}
public static void Load() {
if ( m_Loaded )
if ( Loaded )
return;
m_Loaded = true;
m_LoadingType = null;
Loaded = true;
LoadingType = null;
Console.Write( "World: Loading..." );
Stopwatch watch = Stopwatch.StartNew();
m_Loading = true;
Loading = true;
_addQueue = new Queue<IEntity>();
_deleteQueue = new Queue<IEntity>();
@ -291,7 +267,7 @@ namespace Server {
mobileCount = idxReader.ReadInt32();
m_Mobiles = new Dictionary<Serial, Mobile>( mobileCount );
Mobiles = new Dictionary<Serial, Mobile>( mobileCount );
for ( int i = 0; i < mobileCount; ++i ) {
int typeID = idxReader.ReadInt32();
@ -326,7 +302,7 @@ namespace Server {
idxReader.Close();
}
} else {
m_Mobiles = new Dictionary<Serial, Mobile>();
Mobiles = new Dictionary<Serial, Mobile>();
}
if ( File.Exists( ItemIndexPath ) && File.Exists( ItemTypesPath ) ) {
@ -340,7 +316,7 @@ namespace Server {
itemCount = idxReader.ReadInt32();
m_Items = new Dictionary<Serial, Item>( itemCount );
Items = new Dictionary<Serial, Item>( itemCount );
for ( int i = 0; i < itemCount; ++i ) {
int typeID = idxReader.ReadInt32();
@ -375,7 +351,7 @@ namespace Server {
idxReader.Close();
}
} else {
m_Items = new Dictionary<Serial, Item>();
Items = new Dictionary<Serial, Item>();
}
if ( File.Exists( GuildIndexPath ) ) {
@ -420,7 +396,7 @@ namespace Server {
reader.Seek( entry.Position, SeekOrigin.Begin );
try {
m_LoadingType = entry.TypeName;
LoadingType = entry.TypeName;
m.Deserialize( reader );
if ( reader.Position != ( entry.Position + entry.Length ) )
@ -455,7 +431,7 @@ namespace Server {
reader.Seek( entry.Position, SeekOrigin.Begin );
try {
m_LoadingType = entry.TypeName;
LoadingType = entry.TypeName;
item.Deserialize( reader );
if ( reader.Position != ( entry.Position + entry.Length ) )
@ -478,7 +454,7 @@ namespace Server {
}
}
m_LoadingType = null;
LoadingType = null;
if ( !failedMobiles && !failedItems && File.Exists( GuildDataPath ) ) {
using ( FileStream bin = new FileStream( GuildDataPath, FileMode.Open, FileAccess.Read, FileShare.Read ) ) {
@ -563,18 +539,18 @@ namespace Server {
EventSink.InvokeWorldLoad();
m_Loading = false;
Loading = false;
ProcessSafetyQueues();
foreach ( Item item in m_Items.Values ) {
foreach ( Item item in Items.Values ) {
if ( item.Parent == null )
item.UpdateTotals();
item.ClearProperties();
}
foreach ( Mobile m in m_Mobiles.Values ) {
foreach ( Mobile m in Mobiles.Values ) {
m.UpdateRegion(); // Is this really needed?
m.UpdateTotals();
@ -583,7 +559,7 @@ namespace Server {
watch.Stop();
Console.WriteLine( "done ({1} items, {2} mobiles) ({0:F2} seconds)", watch.Elapsed.TotalSeconds, m_Items.Count, m_Mobiles.Count );
Console.WriteLine( "done ({1} items, {2} mobiles) ({0:F2} seconds)", watch.Elapsed.TotalSeconds, Items.Count, Mobiles.Count );
}
private static void ProcessSafetyQueues() {
@ -661,7 +637,7 @@ namespace Server {
}
public static void Save( bool message, bool permitBackgroundWrite ) {
if ( m_Saving )
if ( Saving )
return;
++m_Saves;
@ -671,7 +647,7 @@ namespace Server {
WaitForWriteCompletion();//Blocks Save until current disk flush is done.
m_Saving = true;
Saving = true;
m_DiskWriteHandle.Reset();
@ -705,7 +681,7 @@ namespace Server {
watch.Stop();
m_Saving = false;
Saving = false;
if (!permitBackgroundWrite)
NotifyDiskWriteComplete(); //Sets the DiskWriteHandle. If we allow background writes, we leave this upto the individual save strategies.
@ -737,43 +713,43 @@ namespace Server {
public static Mobile FindMobile( Serial serial ) {
Mobile mob;
m_Mobiles.TryGetValue( serial, out mob );
Mobiles.TryGetValue( serial, out mob );
return mob;
}
public static void AddMobile( Mobile m ) {
if ( m_Saving ) {
if ( Saving ) {
AppendSafetyLog( "add", m );
_addQueue.Enqueue( m );
} else {
m_Mobiles[m.Serial] = m;
Mobiles[m.Serial] = m;
}
}
public static Item FindItem( Serial serial ) {
Item item;
m_Items.TryGetValue( serial, out item );
Items.TryGetValue( serial, out item );
return item;
}
public static void AddItem( Item item ) {
if ( m_Saving ) {
if ( Saving ) {
AppendSafetyLog( "add", item );
_addQueue.Enqueue( item );
} else {
m_Items[item.Serial] = item;
Items[item.Serial] = item;
}
}
public static void RemoveMobile( Mobile m ) {
m_Mobiles.Remove( m.Serial );
Mobiles.Remove( m.Serial );
}
public static void RemoveItem( Item item ) {
m_Items.Remove( item.Serial );
Items.Remove( item.Serial );
}
}
}