Changes properties to use automatic property initializers
This commit is contained in:
parent
f0a48ad431
commit
06fa31a7bf
623 changed files with 13072 additions and 19304 deletions
132
Server/Map.cs
132
Server/Map.cs
|
|
@ -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 )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue