Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test writing minimal sdb for PIN #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
37 changes: 37 additions & 0 deletions Tests/SDBTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using FauFau.Formats;
using static FauFau.Formats.StaticDB;
Expand Down Expand Up @@ -92,5 +93,41 @@ public static void TestReadCustom()
Console.WriteLine();
}

public static void TestWriteMinimalPin()
{
var sdbLoader = @"X:\PIN\UdpHosts\GameServer\StaticDB\Loaders\StaticDBLoader.cs";
// var sdbLoader = new HttpClient().GetStreamAsync("https://raw.githubusercontent.com/themeldingwars/PIN/refs/heads/master/UdpHosts/GameServer/StaticDB/Loaders/StaticDBLoader.cs").Result;

Console.WriteLine("SDBTests.TestWriteMinimalPIN: Reading SDB: " + sdbPathRead);
StaticDB sdb = new StaticDB();
sdb.Read(sdbPathRead);

HashSet<uint> ids = new HashSet<uint>();

using (var reader = new StreamReader(sdbLoader))
{
string line;
while ((line = reader.ReadLine()) != null)
{
if (line.Contains(@">("""))
{
var idx = sdb.GetIndexByName(line.Split('"')[1]);

if (idx == -1)
{
Console.WriteLine($"Unknown table in line:\n{line}");
return;
}

ids.Add(sdb.Tables[idx].Id);
}
}
}

sdb.Tables.RemoveAll(table => !ids.Contains(table.Id));

Console.WriteLine("SDBTests.TestWriteMinimalPIN: Writing SDB: " + sdbPathWrite);
sdb.Write(sdbPathWrite);
}
}
}
Loading