Skip to content

Commit

Permalink
Merge pull request #2 from wowdev/master
Browse files Browse the repository at this point in the history
update from upstream
  • Loading branch information
KalopsiaTwilight authored Jan 5, 2025
2 parents 7e6de71 + 1868449 commit 3bf78cc
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 23 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ jobs:
# Install the .NET SDK indicated in the global.json file
- name: Setup .NET
uses: actions/setup-dotnet@v4

with:
dotnet-version: 9.x.x
# Create the NuGet package in the folder from the environment variable NuGetDirectory
- run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }} /p:ContinuousIntegrationBuild=true

# Publish the NuGet package as an artifact, so they can be used in the following jobs
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4.4.0
with:
name: nuget
if-no-files-found: error
Expand All @@ -47,9 +48,11 @@ jobs:
# Install the .NET SDK indicated in the global.json file
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x.x

# Download the NuGet package created in the previous job
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4.1.7
with:
name: nuget
path: ${{ env.NuGetDirectory }}
Expand All @@ -70,6 +73,8 @@ jobs:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x.x
- name: Run tests
run: dotnet test --configuration Release

Expand All @@ -82,14 +87,15 @@ jobs:
needs: [ validate_nuget, run_test ]
steps:
# Download the NuGet package created in the previous job
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4.1.7
with:
name: nuget
path: ${{ env.NuGetDirectory }}

# Install the .NET SDK indicated in the global.json file
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x.x

# Publish all NuGet packages to NuGet.org
# Use --skip-duplicate to prevent errors if a package with the same version already exists.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x.x
dotnet-version: 9.x.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion DBCD.Benchmark/DBCD.Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Optimize>true</Optimize>
Expand Down
2 changes: 1 addition & 1 deletion DBCD.IO/DBCD.IO.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net8.0;net9.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
2 changes: 1 addition & 1 deletion DBCD.IO/Readers/WDB3Reader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void GetFields<T>(FieldCache<T>[] fields, T entry)
for (int i = 0; i < fields.Length; i++)
{
FieldCache<T> info = fields[i];
if (fields[i].IndexMapField)
if (info.IndexMapField)
{
if (Id != -1)
indexFieldOffSet++;
Expand Down
2 changes: 1 addition & 1 deletion DBCD.IO/Readers/WDB4Reader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void GetFields<T>(FieldCache<T>[] fields, T entry)
for (int i = 0; i < fields.Length; i++)
{
FieldCache<T> info = fields[i];
if (fields[i].IndexMapField)
if (info.IndexMapField)
{
if (Id != -1)
indexFieldOffSet++;
Expand Down
9 changes: 7 additions & 2 deletions DBCD.IO/Readers/WDB5Reader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ public void GetFields<T>(FieldCache<T>[] fields, T entry)
for (int i = 0; i < fields.Length; i++)
{
FieldCache<T> info = fields[i];
if (info.IndexMapField)

/*
* Note: While WDB5 was introduced in build 21479, idFieldIndex wasn't added to it until build 21737.
* This means that the check below here will likely fail for the ~6 builds between those.
*/
if (i == m_reader.IdFieldIndex)
{
if (Id != -1)
indexFieldOffSet++;
Expand Down Expand Up @@ -185,7 +190,7 @@ public WDB5Reader(Stream stream)
Locale = reader.ReadInt32();
int copyTableSize = reader.ReadInt32();
Flags = (DB2Flags)reader.ReadUInt16();
IdFieldIndex = reader.ReadUInt16();
IdFieldIndex = reader.ReadUInt16(); // Only in build 21737+, what happens in the ~6 builds between 21479 and 21737?

// field meta data
Meta = reader.ReadArray<FieldMetaData>(FieldsCount);
Expand Down
8 changes: 4 additions & 4 deletions DBCD.Tests/DBCD.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable>
<LangVersion>9.0</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.3" />
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 18 additions & 0 deletions DBCD.Tests/ReadingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ public class ReadingTest
static GithubDBDProvider githubDBDProvider = new(true);
static readonly WagoDBCProvider wagoDBCProvider = new();

[TestMethod]
public void TestWDB5ReadingNoIndexData()
{
DBCD dbcd = new(wagoDBCProvider, githubDBDProvider);
IDBCDStorage storage = dbcd.Load("Achievement_Category", "7.1.0.23222");
var row = storage[1];
Assert.AreEqual("Statistics", row["Name_lang"]);
}

[TestMethod]
public void TestWDB5Reading()
{
DBCD dbcd = new(wagoDBCProvider, githubDBDProvider);
IDBCDStorage storage = dbcd.Load("Map", "7.1.0.23222");
var row = storage[451];
Assert.AreEqual("development", row["Directory"]);
}

[TestMethod]
public void TestWDC1Reading()
{
Expand Down
2 changes: 1 addition & 1 deletion DBCD/DBCD.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net8.0;net9.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand Down
9 changes: 4 additions & 5 deletions DBCD/DBCDStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ public DBCDStorage(DBParser parser, Storage<T> storage, DBCDInfo info) : base(ne

foreach (var record in storage)
base.Add(record.Key, new DBCDRow(record.Key, record.Value, fieldAccessor));

storage.Clear();
}

public void ApplyingHotfixes(HotfixReader hotfixReader)
Expand All @@ -166,7 +164,7 @@ public void ApplyingHotfixes(HotfixReader hotfixReader, HotfixReader.RowProcesso
foreach (var (id, row) in mutableStorage)
base[id] = new DBCDRow(id, row, fieldAccessor);
#endif
foreach (var key in mutableStorage.Keys.Except(base.Keys))
foreach (var key in base.Keys.Except(mutableStorage.Keys))
base.Remove(key);
}

Expand All @@ -182,6 +180,7 @@ IEnumerator<DynamicKeyValuePair<int>> IEnumerable<DynamicKeyValuePair<int>>.GetE

public void Save(string filename)
{
storage.Clear();
#if NETSTANDARD2_0
var sortedDictionary = new SortedDictionary<int, DBCDRow>(this);
foreach (var record in sortedDictionary)
Expand All @@ -191,10 +190,10 @@ public void Save(string filename)
storage.Add(id, record.AsType<T>());
#endif
storage.Save(filename);
storage.Clear();
}

public DBCDRow ConstructRow(int index) {
public DBCDRow ConstructRow(int index)
{
T raw = new();
var fields = typeof(T).GetFields();
// Array Fields need to be initialized to fill their length
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<DebugType>embedded</DebugType>
<LangVersion>latest</LangVersion>
<Version>2.0.1</Version>
<Version>2.1.0</Version>
</PropertyGroup>
<PropertyGroup>
<Authors>WoWDev</Authors>
Expand Down

0 comments on commit 3bf78cc

Please sign in to comment.