fix: Cleans up core code (#1187)
**Only one functional change** * Fixes a bug in LogFactory where `Warning` is being logged as `Information` Non-functional changes: * Updates/Fixes copyright headers * Removes namespace scopes for core files. View with [whitespace off](https://github.com/modernuo/ModernUO/pull/1187/files?w=1).
This commit is contained in:
parent
0138d40bda
commit
f268d5d4e2
262 changed files with 28527 additions and 28646 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2020 - ModernUO Development Team *
|
||||
* Copyright 2019-2022 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: WorldLocation.cs *
|
||||
* *
|
||||
|
|
@ -16,153 +16,152 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server
|
||||
namespace Server;
|
||||
|
||||
[Parsable]
|
||||
public struct WorldLocation
|
||||
: IPoint3D, IComparable<WorldLocation>, IEquatable<object>, IEquatable<WorldLocation>, IEquatable<IEntity>
|
||||
{
|
||||
[Parsable]
|
||||
public struct WorldLocation
|
||||
: IPoint3D, IComparable<WorldLocation>, IEquatable<object>, IEquatable<WorldLocation>, IEquatable<IEntity>
|
||||
internal Point3D m_Loc;
|
||||
internal Map m_Map;
|
||||
|
||||
public static readonly WorldLocation Zero = new(0, 0, 0, Map.Internal);
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public Point3D Location
|
||||
{
|
||||
internal Point3D m_Loc;
|
||||
internal Map m_Map;
|
||||
get => m_Loc;
|
||||
set => m_Loc = value;
|
||||
}
|
||||
|
||||
public static readonly WorldLocation Zero = new(0, 0, 0, Map.Internal);
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int X
|
||||
{
|
||||
get => m_Loc.m_X;
|
||||
set => m_Loc.m_X = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public Point3D Location
|
||||
{
|
||||
get => m_Loc;
|
||||
set => m_Loc = value;
|
||||
}
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Y
|
||||
{
|
||||
get => m_Loc.m_Y;
|
||||
set => m_Loc.m_Y = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int X
|
||||
{
|
||||
get => m_Loc.m_X;
|
||||
set => m_Loc.m_X = value;
|
||||
}
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Z
|
||||
{
|
||||
get => m_Loc.m_Z;
|
||||
set => m_Loc.m_Z = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Y
|
||||
{
|
||||
get => m_Loc.m_Y;
|
||||
set => m_Loc.m_Y = value;
|
||||
}
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public Map Map
|
||||
{
|
||||
get => m_Map;
|
||||
set => m_Map = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Z
|
||||
{
|
||||
get => m_Loc.m_Z;
|
||||
set => m_Loc.m_Z = value;
|
||||
}
|
||||
public WorldLocation(IEntity e) : this(e.Location.X, e.Location.Y, e.Location.Z, e.Map)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public Map Map
|
||||
{
|
||||
get => m_Map;
|
||||
set => m_Map = value;
|
||||
}
|
||||
public WorldLocation(Point2D p, Map map) : this(p.X, p.Y, 0, map)
|
||||
{
|
||||
}
|
||||
|
||||
public WorldLocation(IEntity e) : this(e.Location.X, e.Location.Y, e.Location.Z, e.Map)
|
||||
{
|
||||
}
|
||||
public WorldLocation(int x, int y, Map map) : this(x, y, 0, map)
|
||||
{
|
||||
}
|
||||
|
||||
public WorldLocation(Point2D p, Map map) : this(p.X, p.Y, 0, map)
|
||||
{
|
||||
}
|
||||
public WorldLocation(Point3D p, Map map) : this(p.X, p.Y, p.Z, map)
|
||||
{
|
||||
}
|
||||
|
||||
public WorldLocation(int x, int y, Map map) : this(x, y, 0, map)
|
||||
{
|
||||
}
|
||||
public WorldLocation(int x, int y, int z, Map map)
|
||||
{
|
||||
m_Loc.m_X = x;
|
||||
m_Loc.m_Y = y;
|
||||
m_Loc.m_Z = z;
|
||||
m_Map = map;
|
||||
}
|
||||
|
||||
public WorldLocation(Point3D p, Map map) : this(p.X, p.Y, p.Z, map)
|
||||
{
|
||||
}
|
||||
public override string ToString() =>
|
||||
$"({m_Loc.m_X}, {m_Loc.m_Y}, {m_Loc.m_Z}, {m_Map?.ToString() ?? "(-null-)"})";
|
||||
|
||||
public WorldLocation(int x, int y, int z, Map map)
|
||||
{
|
||||
m_Loc.m_X = x;
|
||||
m_Loc.m_Y = y;
|
||||
m_Loc.m_Z = z;
|
||||
m_Map = map;
|
||||
}
|
||||
public bool Equals(WorldLocation other) =>
|
||||
m_Loc.Equals(other.m_Loc) && m_Map.MapID == other.m_Map.MapID;
|
||||
|
||||
public override string ToString() =>
|
||||
$"({m_Loc.m_X}, {m_Loc.m_Y}, {m_Loc.m_Z}, {m_Map?.ToString() ?? "(-null-)"})";
|
||||
public bool Equals(IEntity other) =>
|
||||
!ReferenceEquals(other, null) && m_Loc == other.Location &&
|
||||
m_Map.MapID == other.Map.MapID;
|
||||
|
||||
public bool Equals(WorldLocation other) =>
|
||||
m_Loc.Equals(other.m_Loc) && m_Map.MapID == other.m_Map.MapID;
|
||||
public override bool Equals(object obj) =>
|
||||
obj is WorldLocation other && Equals(other);
|
||||
|
||||
public bool Equals(IEntity other) =>
|
||||
!ReferenceEquals(other, null) && m_Loc == other.Location &&
|
||||
m_Map.MapID == other.Map.MapID;
|
||||
public override int GetHashCode() => HashCode.Combine(m_Loc, m_Map);
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
obj is WorldLocation other && Equals(other);
|
||||
public int CompareTo(WorldLocation other)
|
||||
{
|
||||
var locComparison = m_Loc.CompareTo(other.m_Loc);
|
||||
return locComparison != 0 ? locComparison : Comparer<Map>.Default.Compare(m_Map, other.m_Map);
|
||||
}
|
||||
|
||||
public override int GetHashCode() => HashCode.Combine(m_Loc, m_Map);
|
||||
public static implicit operator Point3D(WorldLocation worldLocation) => worldLocation.Location;
|
||||
|
||||
public int CompareTo(WorldLocation other)
|
||||
{
|
||||
var locComparison = m_Loc.CompareTo(other.m_Loc);
|
||||
return locComparison != 0 ? locComparison : Comparer<Map>.Default.Compare(m_Map, other.m_Map);
|
||||
}
|
||||
public static bool operator ==(WorldLocation l, WorldLocation r) =>
|
||||
l.m_Loc == r.m_Loc && l.m_Map == r.m_Map;
|
||||
|
||||
public static implicit operator Point3D(WorldLocation worldLocation) => worldLocation.Location;
|
||||
public static bool operator ==(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc == r.Location && l.m_Map == r.Map;
|
||||
|
||||
public static bool operator ==(WorldLocation l, WorldLocation r) =>
|
||||
l.m_Loc == r.m_Loc && l.m_Map == r.m_Map;
|
||||
public static bool operator !=(WorldLocation l, WorldLocation r) => l.m_Loc != r.m_Loc && l.m_Map != r.m_Map;
|
||||
|
||||
public static bool operator ==(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc == r.Location && l.m_Map == r.Map;
|
||||
public static bool operator !=(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc != r.Location && l.m_Map != r.Map;
|
||||
|
||||
public static bool operator !=(WorldLocation l, WorldLocation r) => l.m_Loc != r.m_Loc && l.m_Map != r.m_Map;
|
||||
public static bool operator >(WorldLocation l, WorldLocation r) => l.m_Loc > r.m_Loc && l.m_Map == r.m_Map;
|
||||
|
||||
public static bool operator !=(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc != r.Location && l.m_Map != r.Map;
|
||||
public static bool operator >(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc > r.Location && l.m_Map == r.Map;
|
||||
|
||||
public static bool operator >(WorldLocation l, WorldLocation r) => l.m_Loc > r.m_Loc && l.m_Map == r.m_Map;
|
||||
public static bool operator <(WorldLocation l, WorldLocation r) => l.m_Loc < r.m_Loc && l.m_Map == r.m_Map;
|
||||
|
||||
public static bool operator >(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc > r.Location && l.m_Map == r.Map;
|
||||
public static bool operator <(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc < r.Location && l.m_Map == r.Map;
|
||||
|
||||
public static bool operator <(WorldLocation l, WorldLocation r) => l.m_Loc < r.m_Loc && l.m_Map == r.m_Map;
|
||||
public static bool operator >=(WorldLocation l, WorldLocation r) => l.m_Loc >= r.m_Loc && l.m_Map == r.m_Map;
|
||||
|
||||
public static bool operator <(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc < r.Location && l.m_Map == r.Map;
|
||||
public static bool operator >=(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc >= r.Location && l.m_Map == r.Map;
|
||||
|
||||
public static bool operator >=(WorldLocation l, WorldLocation r) => l.m_Loc >= r.m_Loc && l.m_Map == r.m_Map;
|
||||
public static bool operator <=(WorldLocation l, WorldLocation r) => l.m_Loc <= r.m_Loc && l.m_Map == r.m_Map;
|
||||
|
||||
public static bool operator >=(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc >= r.Location && l.m_Map == r.Map;
|
||||
public static bool operator <=(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc <= r.Location && l.m_Map == r.Map;
|
||||
|
||||
public static bool operator <=(WorldLocation l, WorldLocation r) => l.m_Loc <= r.m_Loc && l.m_Map == r.m_Map;
|
||||
public static WorldLocation Parse(string value)
|
||||
{
|
||||
var start = value.IndexOfOrdinal('(');
|
||||
var end = value.IndexOf(',', start + 1);
|
||||
|
||||
public static bool operator <=(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc <= r.Location && l.m_Map == r.Map;
|
||||
Utility.ToInt32(value.AsSpan(start + 1, end - (start + 1)).Trim(), out var x);
|
||||
|
||||
public static WorldLocation Parse(string value)
|
||||
{
|
||||
var start = value.IndexOfOrdinal('(');
|
||||
var end = value.IndexOf(',', start + 1);
|
||||
start = end;
|
||||
end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.AsSpan(start + 1, end - (start + 1)).Trim(), out var x);
|
||||
Utility.ToInt32(value.AsSpan(start + 1, end - (start + 1)).Trim(), out var y);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(',', start + 1);
|
||||
start = end;
|
||||
end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.AsSpan(start + 1, end - (start + 1)).Trim(), out var y);
|
||||
Utility.ToInt32(value.AsSpan(start + 1, end - (start + 1)).Trim(), out var z);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(',', start + 1);
|
||||
start = end;
|
||||
end = value.IndexOf(')', start + 1);
|
||||
|
||||
Utility.ToInt32(value.AsSpan(start + 1, end - (start + 1)).Trim(), out var z);
|
||||
var map = Map.Parse(value.AsSpan(start + 1, end - (start + 1)).Trim());
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(')', start + 1);
|
||||
|
||||
var map = Map.Parse(value.AsSpan(start + 1, end - (start + 1)).Trim());
|
||||
|
||||
return new WorldLocation(x, y, z, map);
|
||||
}
|
||||
return new WorldLocation(x, y, z, map);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue