Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Prima.Core.Server/Compression/Deflate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.IO.Compression;

namespace Prima.Core.Server.Compression;

public static class Deflate
{
[ThreadStatic]
private static LibDeflateBinding _standard;

public static LibDeflateBinding Standard => _standard ??= new LibDeflateBinding();
}
1 change: 1 addition & 0 deletions src/Prima.Core.Server/Prima.Core.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LibDeflate.Bindings" Version="1.0.2.120" />
<PackageReference Include="LiteDB" Version="5.0.21" />
<PackageReference Include="Orion.Core.Server" Version="0.30.1" />
</ItemGroup>
Expand Down
65 changes: 28 additions & 37 deletions src/Prima.UOData/Data/Geometry/Point2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/

using System.ComponentModel;
using System.Runtime.CompilerServices;
using Orion.Foundations.Extensions;
using Prima.UOData.Interfaces.Geometry;
Expand All @@ -22,25 +23,15 @@

public struct Point2D
: IPoint2D, IComparable<Point2D>, IComparable<IPoint2D>, IEquatable<object>, IEquatable<Point2D>,
IEquatable<IPoint2D>, ISpanFormattable, ISpanParsable<Point2D>
IEquatable<IPoint2D>, ISpanFormattable, ISpanParsable<Point2D>, INotifyPropertyChanged
{
internal int m_X;
internal int m_Y;
public event PropertyChangedEventHandler? PropertyChanged;

Check warning on line 28 in src/Prima.UOData/Data/Geometry/Point2D.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The event 'Point2D.PropertyChanged' is never used

Check warning on line 28 in src/Prima.UOData/Data/Geometry/Point2D.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The event 'Point2D.PropertyChanged' is never used

public static readonly Point2D Zero = new(0, 0);

public int X
{
get => m_X;
set => m_X = value;
}
public int X { get; set; }
public int Y { get; set; }

public static readonly Point2D Zero = new(0, 0);

public int Y
{
get => m_Y;
set => m_Y = value;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Point2D(IPoint2D p) : this(p.X, p.Y)
Expand All @@ -59,56 +50,56 @@

public Point2D(int x, int y)
{
m_X = x;
m_Y = y;
X = x;
Y = y;
}

public bool Equals(Point2D other) => m_X == other.m_X && m_Y == other.m_Y;
public bool Equals(Point2D other) => X == other.X && Y == other.Y;

public bool Equals(IPoint2D other) => m_X == other?.X && m_Y == other.Y;
public bool Equals(IPoint2D other) => X == other?.X && Y == other.Y;

public override bool Equals(object obj) => obj is Point2D other && Equals(other);

public override int GetHashCode() => HashCode.Combine(m_X, m_Y);
public override int GetHashCode() => HashCode.Combine(X, Y);

public static bool operator ==(Point2D l, Point2D r) => l.m_X == r.m_X && l.m_Y == r.m_Y;
public static bool operator ==(Point2D l, Point2D r) => l.X == r.X && l.Y == r.Y;

public static bool operator !=(Point2D l, Point2D r) => l.m_X != r.m_X || l.m_Y != r.m_Y;
public static bool operator !=(Point2D l, Point2D r) => l.X != r.X || l.Y != r.Y;

public static bool operator ==(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.m_X == r.X && l.m_Y == r.Y;
public static bool operator ==(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.X == r.X && l.Y == r.Y;

public static bool operator !=(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && (l.m_X != r.X || l.m_Y != r.Y);
public static bool operator !=(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && (l.X != r.X || l.Y != r.Y);

public static bool operator >(Point2D l, Point2D r) => l.m_X > r.m_X && l.m_Y > r.m_Y;
public static bool operator >(Point2D l, Point2D r) => l.X > r.X && l.Y > r.Y;

public static bool operator >(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.m_X > r.X && l.m_Y > r.Y;
public static bool operator >(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.X > r.X && l.Y > r.Y;

public static bool operator <(Point2D l, Point2D r) => l.m_X < r.m_X && l.m_Y < r.m_Y;
public static bool operator <(Point2D l, Point2D r) => l.X < r.X && l.Y < r.Y;

public static bool operator <(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.m_X < r.X && l.m_Y < r.Y;
public static bool operator <(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.X < r.X && l.Y < r.Y;

public static bool operator >=(Point2D l, Point2D r) => l.m_X >= r.m_X && l.m_Y >= r.m_Y;
public static bool operator >=(Point2D l, Point2D r) => l.X >= r.X && l.Y >= r.Y;

public static bool operator >=(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.m_X >= r.X && l.m_Y >= r.Y;
public static bool operator >=(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.X >= r.X && l.Y >= r.Y;

public static bool operator <=(Point2D l, Point2D r) => l.m_X <= r.m_X && l.m_Y <= r.m_Y;
public static bool operator <=(Point2D l, Point2D r) => l.X <= r.X && l.Y <= r.Y;

public static bool operator <=(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.m_X <= r.X && l.m_Y <= r.Y;
public static bool operator <=(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.X <= r.X && l.Y <= r.Y;

public int CompareTo(Point2D other)
{
var xComparison = m_X.CompareTo(other.m_X);
return xComparison != 0 ? xComparison : m_Y.CompareTo(other.m_Y);
var xComparison = X.CompareTo(other.X);
return xComparison != 0 ? xComparison : Y.CompareTo(other.Y);
}

public int CompareTo(IPoint2D other)
{
var xComparison = m_X.CompareTo(other.X);
return xComparison != 0 ? xComparison : m_Y.CompareTo(other.Y);
var xComparison = X.CompareTo(other.X);
return xComparison != 0 ? xComparison : Y.CompareTo(other.Y);
}

public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider provider)
=> destination.TryWrite(provider, $"({m_X}, {m_Y})", out charsWritten);
=> destination.TryWrite(provider, $"({X}, {Y})", out charsWritten);

public override string ToString()
{
Expand Down
86 changes: 30 additions & 56 deletions src/Prima.UOData/Data/Geometry/Point3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,22 @@

namespace Prima.UOData.Data.Geometry;


public struct Point3D
: IPoint3D, IComparable<Point3D>, IComparable<IPoint3D>, IEquatable<object>, IEquatable<Point3D>,
IEquatable<IPoint3D>, ISpanFormattable, ISpanParsable<Point3D>, INotifyPropertyChanged
{

#pragma warning disable 67
public event PropertyChangedEventHandler? PropertyChanged;

#pragma warning restore 67

internal int m_X;
internal int m_Y;
internal int m_Z;
public int X { get; set; }
public int Y { get; set; }
public int Z { get; set; }

public static readonly Point3D Zero = new(0, 0, 0);



public int X
{
get => m_X;
set => m_X = value;
}



public int Y
{
get => m_Y;
set => m_Y = value;
}



public int Z
{
get => m_Z;
set => m_Z = value;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Point3D(IPoint3D p) : this(p.X, p.Y, p.Z)
{
Expand All @@ -78,86 +55,86 @@ public Point3D(Point2D p, int z) : this(p.X, p.Y, z)

public Point3D(int x, int y, int z)
{
m_X = x;
m_Y = y;
m_Z = z;
X = x;
Y = y;
Z = z;
}

public bool Equals(Point3D other) => m_X == other.m_X && m_Y == other.m_Y && m_Z == other.m_Z;
public bool Equals(Point3D other) => X == other.X && Y == other.Y && Z == other.Z;

public bool Equals(IPoint3D other) =>
m_X == other?.X && m_Y == other.Y && m_Z == other.Z;
X == other?.X && Y == other.Y && Z == other.Z;

public override bool Equals(object obj) => obj is Point3D other && Equals(other);

public override int GetHashCode() => HashCode.Combine(m_X, m_Y, m_Z);
public override int GetHashCode() => HashCode.Combine(X, Y, Z);

public static bool operator ==(Point3D l, Point3D r) => l.m_X == r.m_X && l.m_Y == r.m_Y && l.m_Z == r.m_Z;
public static bool operator ==(Point3D l, Point3D r) => l.X == r.X && l.Y == r.Y && l.Z == r.Z;

public static bool operator ==(Point3D l, IPoint3D r) =>
!ReferenceEquals(r, null) && l.m_X == r.X && l.m_Y == r.Y && l.m_Z == r.Z;
!ReferenceEquals(r, null) && l.X == r.X && l.Y == r.Y && l.Z == r.Z;

public static bool operator !=(Point3D l, Point3D r) => l.m_X != r.m_X || l.m_Y != r.m_Y || l.m_Z != r.m_Z;
public static bool operator !=(Point3D l, Point3D r) => l.X != r.X || l.Y != r.Y || l.Z != r.Z;

public static bool operator !=(Point3D l, IPoint3D r) =>
!ReferenceEquals(r, null) && (l.m_X != r.X || l.m_Y != r.Y || l.m_Z != r.Z);
!ReferenceEquals(r, null) && (l.X != r.X || l.Y != r.Y || l.Z != r.Z);

public static bool operator >(Point3D l, Point3D r) => l.m_X > r.m_X && l.m_Y > r.m_Y && l.m_Z > r.m_Z;
public static bool operator >(Point3D l, Point3D r) => l.X > r.X && l.Y > r.Y && l.Z > r.Z;

public static bool operator >(Point3D l, IPoint3D r) =>
!ReferenceEquals(r, null) && l.m_X > r.X && l.m_Y > r.Y && l.m_Z > r.Z;
!ReferenceEquals(r, null) && l.X > r.X && l.Y > r.Y && l.Z > r.Z;

public static bool operator <(Point3D l, Point3D r) => l.m_X < r.m_X && l.m_Y < r.m_Y && l.m_Z > r.m_Z;
public static bool operator <(Point3D l, Point3D r) => l.X < r.X && l.Y < r.Y && l.Z > r.Z;

public static bool operator <(Point3D l, IPoint3D r) =>
!ReferenceEquals(r, null) && l.m_X < r.X && l.m_Y < r.Y && l.m_Z > r.Z;
!ReferenceEquals(r, null) && l.X < r.X && l.Y < r.Y && l.Z > r.Z;

public static bool operator >=(Point3D l, Point3D r) => l.m_X >= r.m_X && l.m_Y >= r.m_Y && l.m_Z > r.m_Z;
public static bool operator >=(Point3D l, Point3D r) => l.X >= r.X && l.Y >= r.Y && l.Z > r.Z;

public static bool operator >=(Point3D l, IPoint3D r) =>
!ReferenceEquals(r, null) && l.m_X >= r.X && l.m_Y >= r.Y && l.m_Z > r.Z;
!ReferenceEquals(r, null) && l.X >= r.X && l.Y >= r.Y && l.Z > r.Z;

public static bool operator <=(Point3D l, Point3D r) => l.m_X <= r.m_X && l.m_Y <= r.m_Y && l.m_Z > r.m_Z;
public static bool operator <=(Point3D l, Point3D r) => l.X <= r.X && l.Y <= r.Y && l.Z > r.Z;

public static bool operator <=(Point3D l, IPoint3D r) =>
!ReferenceEquals(r, null) && l.m_X <= r.X && l.m_Y <= r.Y && l.m_Z > r.Z;
!ReferenceEquals(r, null) && l.X <= r.X && l.Y <= r.Y && l.Z > r.Z;

public int CompareTo(Point3D other)
{
var xComparison = m_X.CompareTo(other.m_X);
var xComparison = X.CompareTo(other.X);
if (xComparison != 0)
{
return xComparison;
}

var yComparison = m_Y.CompareTo(other.m_Y);
var yComparison = Y.CompareTo(other.Y);
if (yComparison != 0)
{
return yComparison;
}

return m_Z.CompareTo(other.m_Z);
return Z.CompareTo(other.Z);
}

public int CompareTo(IPoint3D other)
{
var xComparison = m_X.CompareTo(other.X);
var xComparison = X.CompareTo(other.X);
if (xComparison != 0)
{
return xComparison;
}

var yComparison = m_Y.CompareTo(other.Y);
var yComparison = Y.CompareTo(other.Y);
if (yComparison != 0)
{
return yComparison;
}

return m_Z.CompareTo(other.Z);
return Z.CompareTo(other.Z);
}

public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider provider)
=> destination.TryWrite(provider, $"({m_X}, {m_Y}, {m_Z})", out charsWritten);
=> destination.TryWrite(provider, $"({X}, {Y}, {Z})", out charsWritten);

public override string ToString()
{
Expand Down Expand Up @@ -287,7 +264,4 @@ public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider provider, out
result = new Point3D(x, y, z);
return true;
}



}
12 changes: 6 additions & 6 deletions src/Prima.UOData/Data/Geometry/Point3DList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public void Add(int x, int y, int z)
}
}

m_List[Count].m_X = x;
m_List[Count].m_Y = y;
m_List[Count].m_Z = z;
m_List[Count].X = x;
m_List[Count].Y = y;
m_List[Count].Z = z;
++Count;
}

Expand All @@ -54,9 +54,9 @@ public void Add(Point3D p)
}
}

m_List[Count].m_X = p.m_X;
m_List[Count].m_Y = p.m_Y;
m_List[Count].m_Z = p.m_Z;
m_List[Count].X = p.X;
m_List[Count].Y = p.Y;
m_List[Count].Z = p.Z;
++Count;
}

Expand Down
Loading