diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml index 0ae58bc..eac604e 100644 --- a/.github/workflows/nuget.yml +++ b/.github/workflows/nuget.yml @@ -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 @@ -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 }} @@ -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 @@ -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. diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3626e6f..7ba1ba6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/DBCD.Benchmark/DBCD.Benchmark.csproj b/DBCD.Benchmark/DBCD.Benchmark.csproj index 6863e18..2b1529d 100644 --- a/DBCD.Benchmark/DBCD.Benchmark.csproj +++ b/DBCD.Benchmark/DBCD.Benchmark.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net9.0 enable enable true diff --git a/DBCD.IO/DBCD.IO.csproj b/DBCD.IO/DBCD.IO.csproj index f2fe959..8815ec4 100644 --- a/DBCD.IO/DBCD.IO.csproj +++ b/DBCD.IO/DBCD.IO.csproj @@ -1,7 +1,7 @@ - netstandard2.0;net6.0;net8.0 + netstandard2.0;net8.0;net9.0 diff --git a/DBCD.IO/Readers/WDB3Reader.cs b/DBCD.IO/Readers/WDB3Reader.cs index 47be082..23339e6 100644 --- a/DBCD.IO/Readers/WDB3Reader.cs +++ b/DBCD.IO/Readers/WDB3Reader.cs @@ -68,7 +68,7 @@ public void GetFields(FieldCache[] fields, T entry) for (int i = 0; i < fields.Length; i++) { FieldCache info = fields[i]; - if (fields[i].IndexMapField) + if (info.IndexMapField) { if (Id != -1) indexFieldOffSet++; diff --git a/DBCD.IO/Readers/WDB4Reader.cs b/DBCD.IO/Readers/WDB4Reader.cs index 8b5104a..ecf7569 100644 --- a/DBCD.IO/Readers/WDB4Reader.cs +++ b/DBCD.IO/Readers/WDB4Reader.cs @@ -68,7 +68,7 @@ public void GetFields(FieldCache[] fields, T entry) for (int i = 0; i < fields.Length; i++) { FieldCache info = fields[i]; - if (fields[i].IndexMapField) + if (info.IndexMapField) { if (Id != -1) indexFieldOffSet++; diff --git a/DBCD.IO/Readers/WDB5Reader.cs b/DBCD.IO/Readers/WDB5Reader.cs index 7cee954..d909a0e 100644 --- a/DBCD.IO/Readers/WDB5Reader.cs +++ b/DBCD.IO/Readers/WDB5Reader.cs @@ -70,7 +70,12 @@ public void GetFields(FieldCache[] fields, T entry) for (int i = 0; i < fields.Length; i++) { FieldCache 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++; @@ -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(FieldsCount); diff --git a/DBCD.Tests/DBCD.Tests.csproj b/DBCD.Tests/DBCD.Tests.csproj index 011f93f..18bd47a 100644 --- a/DBCD.Tests/DBCD.Tests.csproj +++ b/DBCD.Tests/DBCD.Tests.csproj @@ -1,15 +1,15 @@  - net8.0 + net9.0 false 9.0 - - - + + + diff --git a/DBCD.Tests/ReadingTest.cs b/DBCD.Tests/ReadingTest.cs index 3cb6b97..f53af8a 100644 --- a/DBCD.Tests/ReadingTest.cs +++ b/DBCD.Tests/ReadingTest.cs @@ -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() { diff --git a/DBCD/DBCD.csproj b/DBCD/DBCD.csproj index 482a890..ba7f161 100644 --- a/DBCD/DBCD.csproj +++ b/DBCD/DBCD.csproj @@ -1,7 +1,7 @@  - netstandard2.0;net6.0;net8.0 + netstandard2.0;net8.0;net9.0 diff --git a/DBCD/DBCDStorage.cs b/DBCD/DBCDStorage.cs index 5f185e5..253d362 100644 --- a/DBCD/DBCDStorage.cs +++ b/DBCD/DBCDStorage.cs @@ -144,8 +144,6 @@ public DBCDStorage(DBParser parser, Storage 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) @@ -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); } @@ -182,6 +180,7 @@ IEnumerator> IEnumerable>.GetE public void Save(string filename) { + storage.Clear(); #if NETSTANDARD2_0 var sortedDictionary = new SortedDictionary(this); foreach (var record in sortedDictionary) @@ -191,10 +190,10 @@ public void Save(string filename) storage.Add(id, record.AsType()); #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 diff --git a/Directory.Build.props b/Directory.Build.props index 379122c..e430d26 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ embedded latest - 2.0.1 + 2.1.0 WoWDev