feat: oodle

This commit is contained in:
tresabhi committed 2025-01-26 12:28:14 -06:00
1 parent 3883eddd5d
commit 55ef1ecbd8
4 files changed
+106 -49

No files matched your search

+1
View File
@@ -127,6 +127,7 @@
"noout",
"normalmap",
"oneof",
"Oodle",
"oopsies",
"Oopsy",
"opentest",
+4 -1
View File
@@ -25,7 +25,7 @@ namespace CLI.Functions
throw new ArgumentException("Missing required initial paks directory");
}
AgnosticZlibHelper.Initialize();
AgnosticHelpers.Initialize();
UnpackDepot(args[1]);
await UnpackDLC();
@@ -64,6 +64,9 @@ namespace CLI.Functions
PakFileReader reader = new(archive);
Exergize(reader);
memoryStream.Dispose();
httpStream.Dispose();
}
}
+101
View File
@@ -0,0 +1,101 @@
using System.IO.Compression;
using System.Runtime.InteropServices;
using CUE4Parse.Compression;
namespace CLI.Utils
{
public static class AgnosticHelpers
{
public const string BINARY_DIR = "../../temp/";
public const string ZLIB_BINARY_URL_PREFIX =
"https://github.com/NotOfficer/Zlib-ng.NET/releases/download/1.0.0";
public const string OODLE_BINARY_URL_PREFIX =
"https://github.com/WorkingRobot/OodleUE/releases/download/2024-11-01-726";
public static void Initialize()
{
InitializeZlib();
InitializeOodle();
}
public static async Task InitializeOodle()
{
string url;
string extension;
string entry;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
url = $"{OODLE_BINARY_URL_PREFIX}/msvc.zip";
entry = "bin/Release/oodle-data-shared.dll";
extension = "dll";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
url = $"{ZLIB_BINARY_URL_PREFIX}/gcc.zip";
entry = "lib/Release/liboodle-data-shared.so";
extension = "so";
}
else
{
throw new PlatformNotSupportedException();
}
HttpClient client = new();
using var response = await client.GetAsync(url).ConfigureAwait(false);
response.EnsureSuccessStatusCode();
await using var responseStream = await response
.Content.ReadAsStreamAsync()
.ConfigureAwait(false);
using var zip = new ZipArchive(responseStream, ZipArchiveMode.Read);
var zipEntry = zip.GetEntry(entry);
ArgumentNullException.ThrowIfNull(zipEntry, "oodle entry in zip not found");
string path = Path.Combine(BINARY_DIR, $"oodle.{extension}");
await using var entryStream = zipEntry.Open();
await using var fs = File.Create(path);
await entryStream.CopyToAsync(fs).ConfigureAwait(false);
OodleHelper.Initialize(path);
}
public static void InitializeZlib()
{
string url;
string extension;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
url = $"{ZLIB_BINARY_URL_PREFIX}/zlib-ng2.dll";
extension = "dll";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
url = $"{ZLIB_BINARY_URL_PREFIX}/libz-ng.so";
extension = "so";
}
else
{
throw new PlatformNotSupportedException();
}
string fileName = $"zlib.{extension}";
string filePath = Path.Combine(BINARY_DIR, fileName);
if (File.Exists(filePath))
{
Console.WriteLine($"Zlib found at {filePath}; using that...");
}
else
{
Console.WriteLine($"Zlib not found; downloading to {filePath} from {url}...");
ZlibHelper.DownloadDll(filePath, url);
}
ZlibHelper.Initialize(filePath);
}
}
}
-48
View File
@@ -1,48 +0,0 @@
using System.Runtime.InteropServices;
using CUE4Parse.Compression;
namespace CLI.Utils
{
public static class AgnosticZlibHelper
{
public const string ZLIB_BINARY_DIR = "../../temp/";
public const string ZLIB_BINARY_URL_PREFIX =
"https://github.com/NotOfficer/Zlib-ng.NET/releases/download/1.0.0";
public static void Initialize()
{
string binariesUrl;
string fileExtension;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
binariesUrl = $"{ZLIB_BINARY_URL_PREFIX}/zlib-ng2.dll";
fileExtension = "dll";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
binariesUrl = $"{ZLIB_BINARY_URL_PREFIX}/libz-ng.so";
fileExtension = "so";
}
else
{
throw new PlatformNotSupportedException();
}
string fileName = $"zlib.{fileExtension}";
string filePath = Path.Combine(ZLIB_BINARY_DIR, fileName);
if (File.Exists(filePath))
{
Console.WriteLine($"Zlib found at {filePath}; using that...");
}
else
{
Console.WriteLine($"Zlib not found; downloading to {filePath} from {binariesUrl}...");
ZlibHelper.DownloadDll(filePath, binariesUrl);
}
ZlibHelper.Initialize(filePath);
}
}
}