mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: default ini parser
This commit is contained in:
1 parent
1957d960aa
commit
51fe0fe41f
4 files changed
+77
-93
No files matched your search
@@ -6,8 +6,8 @@ namespace CLI.Functions
|
|||||||
{
|
{
|
||||||
class Unpacker
|
class Unpacker
|
||||||
{
|
{
|
||||||
public static string ZlibPath = "../../temp/zlib.dll";
|
private const string contentGroup = "p14y73c7_p5e_b10gg3RS_big_play";
|
||||||
public static string VFSWriteDir = "../../temp/vfs/";
|
private const string vfs = "../../temp/vfs/";
|
||||||
|
|
||||||
// this may be different from the one provided in args so check this and not args[1]
|
// this may be different from the one provided in args so check this and not args[1]
|
||||||
// we don't wanna delete my local installation of the game when debugging haha!
|
// we don't wanna delete my local installation of the game when debugging haha!
|
||||||
@@ -22,7 +22,26 @@ namespace CLI.Functions
|
|||||||
|
|
||||||
AgnosticZlibHelper.Initialize();
|
AgnosticZlibHelper.Initialize();
|
||||||
|
|
||||||
string workingDirectory = args[1];
|
UnpackDepot(args[1]);
|
||||||
|
UnpackDLC();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void UnpackDLC()
|
||||||
|
{
|
||||||
|
string defaultDlcPath = Path.Combine(vfs, "Blitz/Config/DefaultDlc.ini");
|
||||||
|
IniParser iniParser = new(defaultDlcPath);
|
||||||
|
string? contentBuildId = iniParser.GetString("DefaultContentBuildId");
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(contentBuildId))
|
||||||
|
{
|
||||||
|
throw new Exception("Failed to read content build id from DefaultDlc.ini");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Exploring DLC {contentBuildId} within group {contentGroup}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void UnpackDepot(string workingDirectory)
|
||||||
|
{
|
||||||
string paksDirectory = Path.Combine(workingDirectory, "Blitz/Content/Paks");
|
string paksDirectory = Path.Combine(workingDirectory, "Blitz/Content/Paks");
|
||||||
string[] containers = Directory.GetFiles(paksDirectory, "*.pak");
|
string[] containers = Directory.GetFiles(paksDirectory, "*.pak");
|
||||||
|
|
||||||
@@ -38,7 +57,7 @@ namespace CLI.Functions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Exergy(string container)
|
private static void Exergy(string container)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Filtering {container}");
|
Console.WriteLine($"Filtering {container}");
|
||||||
|
|
||||||
@@ -56,7 +75,7 @@ namespace CLI.Functions
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
string writePath = Path.Combine(VFSWriteDir, gameFile.Path);
|
string writePath = Path.Combine(vfs, gameFile.Path);
|
||||||
|
|
||||||
if (File.Exists(writePath))
|
if (File.Exists(writePath))
|
||||||
{
|
{
|
||||||
@@ -77,9 +96,9 @@ namespace CLI.Functions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string[] ExergizableFiles = ["Blitz/Config/DefaultDlc.ini"];
|
private static string[] ExergizableFiles = ["Blitz/Config/DefaultDlc.ini"];
|
||||||
|
|
||||||
public static bool ShouldExergize(string path)
|
private static bool ShouldExergize(string path)
|
||||||
{
|
{
|
||||||
return ExergizableFiles.Contains(path);
|
return ExergizableFiles.Contains(path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
using CUE4Parse.UE4.Versions;
|
|
||||||
|
|
||||||
namespace CLI.Constants
|
|
||||||
{
|
|
||||||
public static class ContainerConstants
|
|
||||||
{
|
|
||||||
public const string ContentGroup = "p14y73c7_p5e_b10gg3RS_big_play";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class BlitzConstants { }
|
|
||||||
}
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
// using CUE4Parse.Compression;
|
|
||||||
// using CUE4Parse.FileProvider.Vfs;
|
|
||||||
// using CUE4Parse.UE4.Versions;
|
|
||||||
|
|
||||||
// namespace CLI.Utils
|
|
||||||
// {
|
|
||||||
// public class BlitzVfs : AbstractVfsFileProvider
|
|
||||||
// {
|
|
||||||
// public const EGame EngineVersion = EGame.GAME_UE5_3;
|
|
||||||
// public const string InstallationDirectory =
|
|
||||||
// "C:/Program Files (x86)/Steam/steamapps/common/World of Tanks Blitz Playtest";
|
|
||||||
// public const string AppDataDirectory = "C:/Users/coola/AppData/Local/Blitz";
|
|
||||||
|
|
||||||
// private static string[] IndexDirectories()
|
|
||||||
// {
|
|
||||||
// return
|
|
||||||
// [
|
|
||||||
// Path.Combine(InstallationDirectory, "Blitz/Content/Paks"),
|
|
||||||
// Path.Combine(AppDataDirectory, "Saved/PersistentDownloadDir/Dlc/PakCache"),
|
|
||||||
// ];
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private static List<string> IndexContainers()
|
|
||||||
// {
|
|
||||||
// string[] directories = IndexDirectories();
|
|
||||||
// List<string> files = [];
|
|
||||||
|
|
||||||
// foreach (string directory in directories)
|
|
||||||
// {
|
|
||||||
// if (!Directory.Exists(directory))
|
|
||||||
// {
|
|
||||||
// throw new Exception($"Directory \"{directory}\" does not exist");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// string[] directoryFiles = Directory.GetFiles(directory, "*.pak");
|
|
||||||
// files.AddRange(directoryFiles);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return files;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public override void Initialize()
|
|
||||||
// {
|
|
||||||
// ZlibHelper.DownloadDll("temp/zlib.dll");
|
|
||||||
// ZlibHelper.Initialize("temp/zlib.dll");
|
|
||||||
|
|
||||||
// List<string> containers = IndexContainers();
|
|
||||||
|
|
||||||
// foreach (string container in containers)
|
|
||||||
// {
|
|
||||||
// PakFileReader reader = new(container);
|
|
||||||
|
|
||||||
// reader.Mount();
|
|
||||||
|
|
||||||
// foreach (var gameFile in reader.Files)
|
|
||||||
// {
|
|
||||||
// Console.WriteLine($"Reading \"{gameFile.Key}\"");
|
|
||||||
|
|
||||||
// byte[] bytes = gameFile.Value.Read();
|
|
||||||
// string path = $"temp/container/{gameFile.Key}";
|
|
||||||
// string? directory = Path.GetDirectoryName(path);
|
|
||||||
|
|
||||||
// if (directory != null && !Directory.Exists(directory))
|
|
||||||
// {
|
|
||||||
// Directory.CreateDirectory(directory);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// File.WriteAllBytes(path, bytes);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
namespace CLI.Utils
|
||||||
|
{
|
||||||
|
public class IniParser
|
||||||
|
{
|
||||||
|
private readonly Dictionary<string, string> strings = [];
|
||||||
|
private readonly Dictionary<string, List<string>> arrays = [];
|
||||||
|
|
||||||
|
public IniParser(string file)
|
||||||
|
{
|
||||||
|
string content = File.ReadAllText(file);
|
||||||
|
|
||||||
|
foreach (string line in content.Split('\n'))
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(line))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string[] parts = line.Split('=');
|
||||||
|
if (parts.Length < 2)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string key = parts[0].Trim();
|
||||||
|
string value = string.Join("=", parts, 1, parts.Length - 1).Trim();
|
||||||
|
|
||||||
|
if (key.StartsWith('+'))
|
||||||
|
{
|
||||||
|
string keySuffix = key[1..];
|
||||||
|
|
||||||
|
if (arrays.TryGetValue(keySuffix, out List<string>? listValue))
|
||||||
|
{
|
||||||
|
listValue.Add(value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
arrays[keySuffix] = [value];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Overwrite existing key instead of throwing an exception
|
||||||
|
strings[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? GetString(string key) =>
|
||||||
|
strings.TryGetValue(key, out string? value) ? value : null;
|
||||||
|
|
||||||
|
public List<string>? GetArray(string key) =>
|
||||||
|
arrays.TryGetValue(key, out List<string>? value) ? value : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user