Skip to content

Commit

Permalink
Merge branch 'main' into feat-restyle-res-gumps
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman authored Oct 19, 2024
2 parents 1cc0c69 + 8bea149 commit 760aa19
Show file tree
Hide file tree
Showing 129 changed files with 2,479 additions and 3,008 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,19 @@ dotnet_style_qualification_for_field=false:suggestion
dotnet_style_qualification_for_method=false:suggestion
dotnet_style_qualification_for_property=false:suggestion
dotnet_style_require_accessibility_modifiers=for_non_interface_members:suggestion
# Added by Derek
dotnet_diagnostic.IDE0022.severity = none # expression bodies
dotnet_diagnostic.IDE0130.severity = none # namespace not matching file location
dotnet_diagnostic.IDE0290.severity = none # primary constructors
dotnet_diagnostic.IDE1006.severity = none # naming violations with "_"
dotnet_diagnostic.IDE0038.severity = none # pattern matching
dotnet_diagnostic.IDE0008.severity = none # using var
# probably should be ruled var or not var across the board but it's just suggestions anyway.
# Leave this here in case we want to turn it on in the future
# csharp_style_var_for_built_in_types = true:suggestion # suggest using var (implied) variables
# csharp_style_var_when_type_is_apparent = true:suggestion # suggest using var (implied) variables
# csharp_style_var_elsewhere = true:suggestion # suggest using var (implied) variables
dotnet_diagnostic.RCS1123.severity = none

# ReSharper properties
resharper_apply_auto_detected_rules=false
Expand Down
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@
<AnalysisLevel>latest</AnalysisLevel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Serilog" Version="4.0.1" />
<PackageReference Include="Serilog" Version="4.0.2" />
<PackageReference Include="Serilog.Sinks.Async" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Nerdbank.GitVersioning" Condition="!Exists('packages.config')">
<Version>3.6.139</Version>
<Version>3.6.143</Version>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<AdditionalFiles Include="..\..\Rules.ruleset" />
Expand Down
2 changes: 1 addition & 1 deletion Distribution/Data/Decoration/Felucca/ocllo.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ TreatiseOnAlchemy 0x0FF4
3672 2475 4

# spinning wheel
Static 0x1019
SpinningWheelEastAddon 0x1019
3667 2597 0

# pile of wool
Expand Down
12 changes: 1 addition & 11 deletions Projects/Application/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ public class Application
{
public static void Main(string[] args)
{
bool profiling = false;

foreach (var a in args)
{
if (a.InsensitiveEquals("-profile"))
{
profiling = true;
}
}

Core.Setup(profiling, Assembly.GetEntryAssembly(), Process.GetCurrentProcess());
Core.Setup(Assembly.GetEntryAssembly(), Process.GetCurrentProcess());
}
}
13 changes: 0 additions & 13 deletions Projects/Server.Tests/Helpers/Packet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Buffers;
using System.Diagnostics;
using System.IO;
using Server.Diagnostics;

namespace Server.Network
{
Expand All @@ -19,12 +18,6 @@ public abstract class Packet
protected Packet(int packetID)
{
PacketID = packetID;

if (Core.Profiling)
{
var prof = PacketSendProfile.Acquire(PacketID);
prof.Increment();
}
}

protected Packet(int packetID, int length)
Expand All @@ -34,12 +27,6 @@ protected Packet(int packetID, int length)

Stream = PacketWriter.CreateInstance(length); // new PacketWriter( length );
Stream.Write((byte)packetID);

if (Core.Profiling)
{
var prof = PacketSendProfile.Acquire(PacketID);
prof.Increment();
}
}

public int PacketID { get; }
Expand Down
4 changes: 2 additions & 2 deletions Projects/Server.Tests/Server.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<RootNamespace>Server.Tests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public Mobile this[int index]
public Serial Serial { get; }
public void Deserialize(IGenericReader reader) => throw new NotImplementedException();

public byte SerializedThread { get; set; }
public int SerializedPosition { get; set; }
public int SerializedLength { get; set; }

public void Serialize(IGenericWriter writer) => throw new NotImplementedException();

public bool Deleted { get; }
Expand Down
50 changes: 48 additions & 2 deletions Projects/Server/Buffers/STArrayPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ namespace Server.Buffers;
*/
public class STArrayPool<T> : ArrayPool<T>
{
#if DEBUG_ARRAYPOOL
private class RentReturnStatus
{
public string StackTrace { get; set; }
public bool IsRented { get; set; }
}

private static readonly ConditionalWeakTable<T[], RentReturnStatus> _rentedArrays = new();
#endif

private const int StackArraySize = 32;
private const int BucketCount = 27; // SelectBucketIndex(1024 * 1024 * 1024 + 1)
private static readonly STArrayPool<T> _shared = new();
Expand All @@ -39,6 +49,12 @@ public override T[] Rent(int minimumLength)
if (buffer is not null)
{
cachedBuckets[bucketIndex].Array = null;
#if DEBUG_ARRAYPOOL
_rentedArrays.AddOrUpdate(
buffer,
new RentReturnStatus { IsRented = true }
);
#endif
return buffer;
}
}
Expand All @@ -52,6 +68,12 @@ public override T[] Rent(int minimumLength)
buffer = b.TryPop();
if (buffer is not null)
{
#if DEBUG_ARRAYPOOL
_rentedArrays.AddOrUpdate(
buffer,
new RentReturnStatus { IsRented = true }
);
#endif
return buffer;
}
}
Expand All @@ -70,8 +92,16 @@ public override T[] Rent(int minimumLength)
throw new ArgumentOutOfRangeException(nameof(minimumLength));
}

buffer = GC.AllocateUninitializedArray<T>(minimumLength);
return buffer;
var array = GC.AllocateUninitializedArray<T>(minimumLength);

#if DEBUG_ARRAYPOOL
_rentedArrays.AddOrUpdate(
array,
new RentReturnStatus { IsRented = true, StackTrace = Environment.StackTrace }
);
#endif

return array;
}

public override void Return(T[]? array, bool clearArray = false)
Expand All @@ -91,10 +121,26 @@ public override void Return(T[]? array, bool clearArray = false)
Array.Clear(array);
}

#if DEBUG_ARRAYPOOL
if (array.Length != GetMaxSizeForBucket(bucketIndex) || !_rentedArrays.TryGetValue(array, out var status))
{
throw new ArgumentException("Buffer is not from the pool", nameof(array));
}

if (!status!.IsRented)
{
throw new InvalidOperationException($"Array has already been returned.\nOriginal StackTrace:{status.StackTrace}\n");
}

// Mark it as returned
status.IsRented = false;
status.StackTrace = Environment.StackTrace;
#else
if (array.Length != GetMaxSizeForBucket(bucketIndex))
{
throw new ArgumentException("Buffer is not from the pool", nameof(array));
}
#endif

ref var bucketArray = ref cacheBuckets[bucketIndex];
var prev = bucketArray.Array;
Expand Down
79 changes: 0 additions & 79 deletions Projects/Server/Diagnostics/BaseProfile.cs

This file was deleted.

88 changes: 0 additions & 88 deletions Projects/Server/Diagnostics/PacketProfile.cs

This file was deleted.

Loading

0 comments on commit 760aa19

Please sign in to comment.