Adds back in old benchmarks. Cleans up tests. (#270)

This commit is contained in:
Kamron Batman 2020-10-04 11:45:07 -07:00 committed by GitHub
parent 09d80916b8
commit 4e799ddbd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 498 additions and 160 deletions

View file

@ -37,6 +37,16 @@
<PropertyGroup Condition="'$(IsOSX)'=='true' AND '$(RuntimeIdentifier)'==''">
<RuntimeIdentifier>osx-x64</RuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<Optimize>true</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Analyze'">
<CodeAnalysisRuleSet>..\..\Rules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup Condition="'$(Configuration)'=='Analyze'">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.205" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers">

View file

@ -1,4 +1,4 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29102.190
MinimumVisualStudioVersion = 10.0.40219.1
@ -10,6 +10,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server.Tests", "Projects\Se
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UOContent.Tests", "Projects\UOContent.Tests\UOContent.Tests.csproj", "{3C4797F9-603E-44EF-8E8C-9275CC9EA74B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Benchmarks", "Projects\Benchmarks\Benchmarks.csproj", "{38B7E4A1-FDDD-486C-98EE-BA7B13712528}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Analyze|x64 = Analyze|x64
@ -41,6 +43,10 @@ Global
{3C4797F9-603E-44EF-8E8C-9275CC9EA74B}.Debug|x64.Build.0 = Debug|x64
{3C4797F9-603E-44EF-8E8C-9275CC9EA74B}.Release|x64.ActiveCfg = Release|x64
{3C4797F9-603E-44EF-8E8C-9275CC9EA74B}.Release|x64.Build.0 = Release|x64
{38B7E4A1-FDDD-486C-98EE-BA7B13712528}.Debug|x64.ActiveCfg = Debug|x64
{38B7E4A1-FDDD-486C-98EE-BA7B13712528}.Debug|x64.Build.0 = Debug|x64
{38B7E4A1-FDDD-486C-98EE-BA7B13712528}.Release|x64.ActiveCfg = Release|x64
{38B7E4A1-FDDD-486C-98EE-BA7B13712528}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View file

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
<ProjectReference Include="..\Server\Server.csproj" />
<ProjectReference Include="..\UOContent\UOContent.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,90 @@
using System;
using System.Buffers.Binary;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Loader;
using System.Security.Cryptography;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using Server;
using Server.Items;
namespace Benchmarks
{
[SimpleJob(RuntimeMoniker.NetCoreApp31)]
public class BenchmarkFeatureFlags
{
public Dictionary<Type, FeatureFlag<Item>> m_Dictionary;
public ILookup<Type, FeatureFlag<Item>> m_Lookup;
public Type[] m_TypesToLookUp;
[GlobalSetup]
public void Setup()
{
RNGCryptoServiceProvider csp = new RNGCryptoServiceProvider();
string file = Path.Join(AppDomain.CurrentDomain.BaseDirectory, "UOContent.dll");
Assembly assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(file);
m_Dictionary = new Dictionary<Type, FeatureFlag<Item>>();
List<FeatureFlag<Item>> m_Types = new List<FeatureFlag<Item>>();
m_TypesToLookUp = new Type[100];
foreach (var type in assembly.GetTypes())
{
if (typeof(Item).IsAssignableFrom(type))
{
m_Dictionary.Add(type, new FeatureFlag<Item>());
m_Types.Add(new FeatureFlag<Item>{Type = type});
}
}
Console.WriteLine("Dictionary Size: {0}", m_Dictionary.Count);
Console.WriteLine("Lookup Size: {0}", m_Types.Count);
m_Dictionary.TrimExcess();
m_Lookup = m_Types.ToLookup(f => f.Type);
Span<byte> bytes = stackalloc byte[4];
for (int i = 0; i < 100; i++)
{
csp.GetBytes(bytes);
m_TypesToLookUp[i] = m_Types[(int)(BinaryPrimitives.ReadUInt32BigEndian(bytes) % m_Types.Count)].Type;
}
}
[Benchmark]
public FeatureFlag<Item> TestDictionary()
{
for (int i = 0; i < 100; i++)
{
m_Dictionary.TryGetValue(typeof(ExplosionPotion), out var ff);
if (i == 99)
{
return ff;
}
}
return null;
}
[Benchmark]
public FeatureFlag<Item> TestLookup()
{
FeatureFlag<Item> ff;
for (int i = 0; i < 100; i++)
{
ff = m_Lookup[typeof(ExplosionPotion)].GetEnumerator().Current;
if (i == 99)
{
return ff;
}
}
return null;
}
}
}

View file

@ -0,0 +1,9 @@
using System;
namespace Server
{
public class FeatureFlag<T> where T : Item
{
public Type Type { get; set; }
}
}

View file

@ -0,0 +1,157 @@
using System;
using System.Buffers.Binary;
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using Server;
using Server.Network;
namespace Benchmarks
{
[MemoryDiagnoser]
[SimpleJob(RuntimeMoniker.NetCoreApp31)]
public class BenchmarkPacketConstruction
{
public List<BuyItemState> m_States;
[GlobalSetup]
public void SetUp()
{
m_States = new List<BuyItemState>
{
new BuyItemState("Name 1", 0x1000, 0x2000, 1000, 1, 10, 1024),
new BuyItemState("Name 2", 0x1001, 0x2001, 1001, 1, 10, 1024),
new BuyItemState("Name 3", 0x1002, 0x2002, 1002, 1, 10, 1024),
new BuyItemState("Name 4", 0x1003, 0x2003, 1003, 1, 10, 1024),
new BuyItemState("Name 5", 0x1004, 0x2004, 1004, 1, 10, 1024),
new BuyItemState("Name 6", 0x1005, 0x2005, 1005, 1, 10, 1024),
new BuyItemState("Name 7", 0x1006, 0x2006, 1006, 1, 10, 1024),
new BuyItemState("Name 8", 0x1007, 0x2007, 1007, 1, 10, 1024),
new BuyItemState("Name 9", 0x1008, 0x2008, 1008, 1, 10, 1024),
new BuyItemState("Name A", 0x1009, 0x2009, 1009, 1, 10, 1024),
new BuyItemState("Name 10", 0x1000, 0x2000, 1000, 1, 10, 1024),
new BuyItemState("Name 20", 0x1001, 0x2001, 1001, 1, 10, 1024),
new BuyItemState("Name 30", 0x1002, 0x2002, 1002, 1, 10, 1024),
new BuyItemState("Name 40", 0x1003, 0x2003, 1003, 1, 10, 1024),
new BuyItemState("Name 50", 0x1004, 0x2004, 1004, 1, 10, 1024),
new BuyItemState("Name 60", 0x1005, 0x2005, 1005, 1, 10, 1024),
new BuyItemState("Name 70", 0x1006, 0x2006, 1006, 1, 10, 1024),
new BuyItemState("Name 80", 0x1007, 0x2007, 1007, 1, 10, 1024),
new BuyItemState("Name 90", 0x1008, 0x2008, 1008, 1, 10, 1024),
new BuyItemState("Name A0", 0x1009, 0x2009, 1009, 1, 10, 1024),
new BuyItemState("Name 11", 0x1000, 0x2000, 1000, 1, 10, 1024),
new BuyItemState("Name 21", 0x1001, 0x2001, 1001, 1, 10, 1024),
new BuyItemState("Name 31", 0x1002, 0x2002, 1002, 1, 10, 1024),
new BuyItemState("Name 41", 0x1003, 0x2003, 1003, 1, 10, 1024),
new BuyItemState("Name 51", 0x1004, 0x2004, 1004, 1, 10, 1024),
new BuyItemState("Name 61", 0x1005, 0x2005, 1005, 1, 10, 1024),
new BuyItemState("Name 71", 0x1006, 0x2006, 1006, 1, 10, 1024),
new BuyItemState("Name 81", 0x1007, 0x2007, 1007, 1, 10, 1024),
new BuyItemState("Name 91", 0x1008, 0x2008, 1008, 1, 10, 1024),
new BuyItemState("Name A1", 0x1009, 0x2009, 1009, 1, 10, 1024)
};
}
[Benchmark]
public Packet TestPacketConstruction()
{
Packet p = new VendorBuyContent(m_States);
p.Compile(false, out _);
return p;
}
[Benchmark]
public int TestInlineRefConstruction()
{
var buyStates = m_States;
int length = 5 + buyStates.Count * 19;
Span<byte> data = stackalloc byte[length];
int pos = 0;
data.Write(ref pos, (byte)0x3C);
data.Write(ref pos, (ushort)length);
data.Write(ref pos, (ushort)buyStates.Count);
for (int i = buyStates.Count - 1; i >= 0; i--)
{
BuyItemState buyState = buyStates[i];
data.Write(ref pos, buyState.MySerial);
data.Write(ref pos, (ushort)buyState.ItemID);
data.Write(ref pos, (byte)0);
data.Write(ref pos, (ushort)buyState.Amount);
data.Write(ref pos, (ushort)(i + 1));
data.Write(ref pos, (ushort)0x1);
data.Write(ref pos, buyState.ContainerSerial);
data.Write(ref pos, (ushort)buyState.Hue);
}
return data.Length;
}
[Benchmark]
public int TestInlineConstruction()
{
var buyStates = m_States;
Span<byte> data = stackalloc byte[5 + buyStates.Count * 19];
data[0] = 0x3C;
BinaryPrimitives.WriteUInt16BigEndian(data.Slice(1, 2), (ushort)data.Length);
BinaryPrimitives.WriteUInt16BigEndian(data.Slice(3, 2), (ushort)buyStates.Count);
int pos = 4;
for (int i = buyStates.Count - 1; i >= 0; i--)
{
BuyItemState buyState = buyStates[i];
BinaryPrimitives.WriteUInt32BigEndian(data.Slice(pos, 4), buyState.MySerial);
pos += 4;
BinaryPrimitives.WriteUInt16BigEndian(data.Slice(pos, 2), (ushort)buyState.ItemID);
pos += 2;
data[pos++] = 0;
BinaryPrimitives.WriteUInt16BigEndian(data.Slice(pos, 2), (ushort)buyState.Amount);
pos += 2;
BinaryPrimitives.WriteUInt16BigEndian(data.Slice(pos, 2), (ushort)(i + 1));
pos += 2;
BinaryPrimitives.WriteUInt16BigEndian(data.Slice(pos, 2), 0x1);
pos += 2;
BinaryPrimitives.WriteUInt32BigEndian(data.Slice(pos, 4), buyState.ContainerSerial);
pos += 4;
BinaryPrimitives.WriteUInt16BigEndian(data.Slice(pos, 2), (ushort)(buyState.Hue));
pos += 2;
}
return data.Length;
}
[Benchmark]
public int TestSpanWriterConstruction()
{
var buyStates = m_States;
int length = 5 + buyStates.Count * 19;
SpanWriter w = new SpanWriter(stackalloc byte[length]);
w.Write((byte)0x3C); // Packet ID
w.Write((ushort)length); // Length
w.Write((ushort)buyStates.Count); // Length
for (int i = buyStates.Count - 1; i >= 0; i--)
{
BuyItemState buyState = buyStates[i];
w.Write(buyState.MySerial);
w.Write((ushort)buyState.ItemID);
w.Write((byte)0);
w.Write((ushort)(i + 1)); // X
w.Write((ushort)0x1); // Y
w.Write(buyState.ContainerSerial);
w.Write((ushort)buyState.Hue);
}
return w.Pos;
}
}
}

View file

@ -0,0 +1,27 @@
using System;
using System.Buffers.Binary;
using System.Runtime.CompilerServices;
using Server;
namespace Benchmarks
{
public static class PacketTestUtilities
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Write(this Span<byte> data, ref int pos, Serial serial)
{
BinaryPrimitives.WriteUInt32BigEndian(data.Slice(pos, 4), serial);
pos += 4;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Write(this Span<byte> data, ref int pos, ushort value)
{
BinaryPrimitives.WriteUInt16BigEndian(data.Slice(pos, 2), value);
pos += 2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Write(this Span<byte> data, ref int pos, byte value) => data[pos++] = value;
}
}

View file

@ -0,0 +1,36 @@
using System;
using System.Buffers.Binary;
using System.Runtime.CompilerServices;
using Server;
namespace Benchmarks
{
public ref struct SpanWriter
{
public Span<byte> Span;
public int Pos;
public SpanWriter(Span<byte> span)
{
Span = span;
Pos = 0;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Write(Serial serial)
{
BinaryPrimitives.WriteUInt32BigEndian(Span.Slice(Pos), serial);
Pos += 4;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Write(ushort value)
{
BinaryPrimitives.WriteUInt16BigEndian(Span.Slice(Pos), value);
Pos += 2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Write(byte value) => Span[Pos++] = value;
}
}

View file

@ -0,0 +1,13 @@
using BenchmarkDotNet.Running;
namespace Benchmarks
{
public class Program
{
static void Main(string[] args)
{
var featureFlags = BenchmarkRunner.Run<BenchmarkFeatureFlags>();
var packetConstruction = BenchmarkRunner.Run<BenchmarkPacketConstruction>();
}
}
}

View file

@ -23,7 +23,7 @@ namespace Server.Tests.Network.Packets
if (length == 0)
{
#if NO_LOCAL_INIT
dest.Write(ref pos, 0);
dest.Write(ref pos, 0);
#else
pos += 4;
#endif

View file

@ -39,7 +39,7 @@ namespace Server.Tests.Network.Packets
if (m == null)
{
#if NO_LOCAL_INIT
expectedData.Clear(ref pos, 60);
expectedData.Clear(ref pos, 60);
#else
pos += 60;
#endif
@ -48,7 +48,7 @@ namespace Server.Tests.Network.Packets
{
expectedData.WriteAsciiFixed(ref pos, m.Name, 30);
#if NO_LOCAL_INIT
expectedData.Clear(ref pos, 30); // Password (empty)
expectedData.Clear(ref pos, 30); // Password (empty)
#else
pos += 30;
#endif
@ -178,7 +178,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (byte)0x1B); // Packet ID
expectedData.Write(ref pos, m.Serial);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, 0);
#else
pos += 4;
#endif
@ -189,13 +189,13 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (short)m.Z);
expectedData.Write(ref pos, (byte)m.Direction);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (byte)0);
#else
pos++;
#endif
expectedData.Write(ref pos, 0xFFFFFFFF);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, 0);
#else
pos += 4;
#endif
@ -263,11 +263,11 @@ namespace Server.Tests.Network.Packets
{
expectedData.WriteAsciiFixed(ref pos, m.Name, 30);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ushort)0);
#else
pos += 30;
#endif
@ -275,14 +275,14 @@ namespace Server.Tests.Network.Packets
else
{
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, 0);
#else
pos += 60;
#endif
@ -333,11 +333,11 @@ namespace Server.Tests.Network.Packets
{
expectedData.WriteAsciiFixed(ref pos, m.Name, 30);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ushort)0);
#else
pos += 30;
#endif
@ -345,14 +345,14 @@ namespace Server.Tests.Network.Packets
else
{
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, 0);
#else
pos += 60;
#endif
@ -373,7 +373,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, ci.Map.MapID);
expectedData.Write(ref pos, ci.Description);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, 0);
#else
pos += 4;
#endif
@ -442,11 +442,11 @@ namespace Server.Tests.Network.Packets
{
expectedData.WriteAsciiFixed(ref pos, m.Name, 30);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ushort)0);
#else
pos += 30;
#endif
@ -454,14 +454,14 @@ namespace Server.Tests.Network.Packets
else
{
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, 0);
#else
pos += 60;
#endif

View file

@ -55,7 +55,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (byte)0xBA); // Packet ID
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0); // Command
expectedData.Write(ref pos, (byte)0); // Command
#else
pos++;
#endif

View file

@ -20,7 +20,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (byte)0x2F); // Packet ID
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (byte)0);
#else
pos++;
#endif
@ -45,7 +45,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, warmode);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (byte)0);
#else
pos++;
#endif
@ -53,7 +53,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (byte)0x32);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (byte)0);
#else
pos++;
#endif

View file

@ -22,7 +22,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (byte)0x95);
expectedData.Write(ref pos, huePicker.Serial);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (ushort)0);
#else
pos += 2;
#endif

View file

@ -63,7 +63,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, speed);
expectedData.Write(ref pos, duration);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (ushort)0);
#else
pos += 2;
#endif
@ -125,7 +125,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, speed);
expectedData.Write(ref pos, duration);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (ushort)0);
#else
pos += 2;
#endif
@ -149,8 +149,8 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (byte)0x70); // Packet ID
expectedData.Write(ref pos, (byte)0x04); // Effect
#if NO_LOCAL_INIT
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, 0);
#else
pos += 8;
#endif
@ -158,10 +158,10 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (ushort)type); // Screen Effect Type
#if NO_LOCAL_INIT
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, 0);
#endif
AssertThat.Equal(data, expectedData);
@ -182,16 +182,16 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, entity.Serial);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ushort)0);
#else
pos += 6;
#endif
expectedData.Write(ref pos, entity.Location);
expectedData.Write(ref pos, entity.Location);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ushort)0);
#else
pos += 6;
#endif

View file

@ -88,7 +88,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (ushort)item.ItemID);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (byte)0);
#else
pos++;
#endif

View file

@ -205,7 +205,7 @@ namespace Server.Tests.Network.Packets
}
#if NO_LOCAL_INIT
buffer.Write(ref bufferPos, (byte)0); // Layout terminator
buffer.Write(ref bufferPos, (byte)0); // Layout terminator
#else
bufferPos++;
#endif

View file

@ -157,7 +157,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (ushort)(item.ItemID & (isMulti ? 0x3FFF : 0xFFFF)));
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0)
expectedData.Write(ref pos, (byte)0)
#else
pos++;
#endif
@ -212,7 +212,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (ushort)(item.ItemID & (isMulti ? 0x3FFF : 0xFFFF)));
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (byte)0);
#else
pos++;
#endif
@ -225,7 +225,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (byte)item.GetPacketFlags()); // Flags
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (ushort)0); // ??
expectedData.Write(ref pos, (ushort)0); // ??
#endif
AssertThat.Equal(data, expectedData);
@ -351,20 +351,20 @@ namespace Server.Tests.Network.Packets
{
expectedData.Write(ref pos, 0x7FFFFFFF - i);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (byte)0);
#else
pos += 3;
#endif
expectedData.Write(ref pos, (ushort)(i + offset));
#if NO_LOCAL_INIT
expectedData.Write(ref pos, 0); // X. Y
expectedData.Write(ref pos, 0); // X. Y
#else
pos += 4;
#endif
expectedData.Write(ref pos, serial);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (ushort)0);
#else
pos += 2;
#endif
@ -403,21 +403,21 @@ namespace Server.Tests.Network.Packets
{
expectedData.Write(ref pos, 0x7FFFFFFF - i);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (byte)0);
#else
pos += 3;
#endif
expectedData.Write(ref pos, (ushort)(i + offset));
#if NO_LOCAL_INIT
expectedData.Write(ref pos, 0); // X. Y
expectedData.Write(ref pos, (byte)0); // Grid Location
expectedData.Write(ref pos, 0); // X. Y
expectedData.Write(ref pos, (byte)0); // Grid Location
#else
pos += 5;
#endif
expectedData.Write(ref pos, serial);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (ushort)0);
#else
pos += 2;
#endif
@ -448,7 +448,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, item.Serial);
expectedData.Write(ref pos, (ushort)item.ItemID);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0); // ItemID offset
expectedData.Write(ref pos, (byte)0); // ItemID offset
#else
pos++;
#endif
@ -476,7 +476,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, item.Serial);
expectedData.Write(ref pos, (ushort)item.ItemID);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0); // ItemID offset
expectedData.Write(ref pos, (byte)0); // ItemID offset
#else
pos++;
#endif
@ -484,7 +484,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (ushort)item.X);
expectedData.Write(ref pos, (ushort)item.Y);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0); // Grid Location?
expectedData.Write(ref pos, (byte)0); // Grid Location?
#else
pos++;
#endif
@ -525,7 +525,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, child.Serial);
expectedData.Write(ref pos, (ushort)child.ItemID);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0); // ItemID offset
expectedData.Write(ref pos, (byte)0); // ItemID offset
#else
pos++;
#endif
@ -577,7 +577,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, child.Serial);
expectedData.Write(ref pos, (ushort)child.ItemID);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0); // ItemID offset
expectedData.Write(ref pos, (byte)0); // ItemID offset
#else
pos++;
#endif
@ -585,7 +585,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (ushort)child.X);
expectedData.Write(ref pos, (ushort)child.Y);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0); // Grid Location?
expectedData.Write(ref pos, (byte)0); // Grid Location?
#else
pos++;
#endif

View file

@ -128,7 +128,7 @@ namespace Server.Tests.Network.Packets
{
var answer = menu.Answers[i];
#if NO_LOCAL_INIT
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, 0);
#else
pos += 4;
#endif

View file

@ -23,7 +23,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, killed);
expectedData.Write(ref pos, corpse);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, 0);
#endif
AssertThat.Equal(data, expectedData);
@ -45,7 +45,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (ushort)0x19); // Sub-packet
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0); // Command
expectedData.Write(ref pos, (byte)0); // Command
#else
pos++;
#endif
@ -124,7 +124,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, m.Serial);
expectedData.WriteAsciiFixed(ref pos, m.Name ?? "", 29);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (byte)0);
#endif
AssertThat.Equal(data, expectedData);
@ -216,7 +216,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, canBeRenamed);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0); // type
expectedData.Write(ref pos, (byte)0); // type
#endif
AssertThat.Equal(data, expectedData);
@ -415,7 +415,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, m.Serial);
expectedData.Write(ref pos, (ushort)m.Body);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0); // Unknown
expectedData.Write(ref pos, (byte)0); // Unknown
#else
pos++;
#endif
@ -424,7 +424,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (ushort)m.X);
expectedData.Write(ref pos, (ushort)m.Y);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (ushort)2); // Unknown
expectedData.Write(ref pos, (ushort)2); // Unknown
#else
pos += 2;
#endif
@ -451,7 +451,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, m.Serial);
expectedData.Write(ref pos, (ushort)m.Body);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0); // Unknown
expectedData.Write(ref pos, (byte)0); // Unknown
#else
pos++;
#endif
@ -460,7 +460,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (ushort)m.X);
expectedData.Write(ref pos, (ushort)m.Y);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (ushort)2); // Unknown
expectedData.Write(ref pos, (ushort)2); // Unknown
#else
pos += 2;
#endif
@ -511,7 +511,7 @@ namespace Server.Tests.Network.Packets
Span<bool> layers = stackalloc bool[256];
#if NO_LOCAL_INIT
layers.Clear();
layers.Clear();
#endif
var items = beheld.Items;
@ -589,7 +589,7 @@ namespace Server.Tests.Network.Packets
}
#if NO_LOCAL_INIT
expectedData.Write(ref pos, 0); // Zero serial, terminate list
expectedData.Write(ref pos, 0); // Zero serial, terminate list
#else
pos += 4;
#endif
@ -659,7 +659,7 @@ namespace Server.Tests.Network.Packets
Span<bool> layers = stackalloc bool[256];
#if NO_LOCAL_INIT
layers.Clear();
layers.Clear();
#endif
var items = beheld.Items;
@ -760,7 +760,7 @@ namespace Server.Tests.Network.Packets
}
#if NO_LOCAL_INIT
expectedData.Write(ref pos, 0); // Zero serial, terminate list
expectedData.Write(ref pos, 0); // Zero serial, terminate list
#else
pos += 4;
#endif

View file

@ -98,12 +98,12 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (short)0x1); // Sub-packet
#if NO_LOCAL_INIT
expectedData.Write(ref pos, 0); // Key 1
expectedData.Write(ref pos, 0); // Key 2
expectedData.Write(ref pos, 0); // Key 3
expectedData.Write(ref pos, 0); // Key 4
expectedData.Write(ref pos, 0); // Key 5
expectedData.Write(ref pos, 0); // Key 6
expectedData.Write(ref pos, 0); // Key 1
expectedData.Write(ref pos, 0); // Key 2
expectedData.Write(ref pos, 0); // Key 3
expectedData.Write(ref pos, 0); // Key 4
expectedData.Write(ref pos, 0); // Key 5
expectedData.Write(ref pos, 0); // Key 6
#endif
AssertThat.Equal(data, expectedData);

View file

@ -188,8 +188,8 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (ushort)p.Y);
expectedData.Write(ref pos, (short)p.Z);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0); // Unknown
expectedData.Write(ref pos, 0); // Server X, Server Y
expectedData.Write(ref pos, (byte)0); // Unknown
expectedData.Write(ref pos, 0); // Server X, Server Y
#else
pos += 5;
#endif
@ -326,7 +326,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (ushort)itemID);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (byte)0);
#else
pos++;
#endif
@ -404,7 +404,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, soundID);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (ushort)0); // Volume
expectedData.Write(ref pos, (ushort)0); // Volume
#else
pos += 2;
#endif

View file

@ -152,7 +152,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, itemInCont.Serial);
expectedData.Write(ref pos, (short)itemInCont.ItemID);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (byte)0);
#else
pos++;
#endif
@ -160,7 +160,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (short)itemInCont.X);
expectedData.Write(ref pos, (short)itemInCont.Y);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (byte)0);
#else
pos++;
#endif

View file

@ -49,12 +49,12 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, t.TargetID);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (ushort)0);
#else
pos += 12;
#endif
@ -65,8 +65,8 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (short)t.Offset.Z);
#if NO_LOCAL_INIT
// Hue (4 bytes)
expectedData.Write(ref pos, 0);
// Hue (4 bytes)
expectedData.Write(ref pos, 0);
#endif
AssertThat.Equal(data, expectedData);
@ -89,12 +89,12 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, t.TargetID);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (ushort)0);
#else
pos += 12;
#endif
@ -121,12 +121,12 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (byte)3); // Beneficial / Harmful
#if NO_LOCAL_INIT
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (ushort)0);
#endif
AssertThat.Equal(data, expectedData);
@ -147,12 +147,12 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (byte)t.Flags);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, 0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (ushort)0);
#endif
AssertThat.Equal(data, expectedData);

View file

@ -27,8 +27,8 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, prompt.Serial);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ushort)0);
expectedData.Write(ref pos, (ulong)0);
expectedData.Write(ref pos, (ushort)0);
#endif
AssertThat.Equal(data, expectedData);

View file

@ -82,7 +82,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (ushort)(i + 1)); // X
expectedData.Write(ref pos, (ushort)1); // Y
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0); // Grid Location?
expectedData.Write(ref pos, (byte)0); // Grid Location?
#else
pos++;
#endif
@ -189,7 +189,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, vendor.Serial);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)-);
expectedData.Write(ref pos, (byte)-);
#endif
AssertThat.Equal(data, expectedData);

View file

@ -73,7 +73,7 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, vendor.Serial);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0);
expectedData.Write(ref pos, (byte)0);
#endif
AssertThat.Equal(data, expectedData);

View file

@ -39,16 +39,6 @@
<Delete Files="..\..\Distribution\$(AssemblyName).runtimeconfig.json" ContinueOnError="true" />
<Delete Files="..\..\Distribution\System.IO.Pipelines.dll" ContinueOnError="true" />
</Target>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<Optimize>true</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Analyze'">
<CodeAnalysisRuleSet>..\..\Rules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Connections.Abstractions" Version="3.1.5" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv" Version="3.1.5" />

View file

@ -33,16 +33,6 @@
<Delete Files="..\..\Distribution\Assemblies\libz.so" ContinueOnError="true" />
<Delete Files="..\..\Distribution\Assemblies\ZLib.Bindings.dll" ContinueOnError="true" />
</Target>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>TRACE;DEBUG;$(DefineConstants)</DefineConstants>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<Optimize>true</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Analyze'">
<CodeAnalysisRuleSet>..\..\Rules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Server\Server.csproj" Private="false" PrivateAssets="All" IncludeAssets="None">
<IncludeInPackage>false</IncludeInPackage>