This repository has been archived by the owner on Mar 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
192 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using CommandLine; | ||
using RainbowForge; | ||
using RainbowForge.Archive; | ||
using RainbowForge.Dump; | ||
using RainbowForge.Forge; | ||
using RainbowForge.Forge.Container; | ||
|
||
namespace DumpTool | ||
{ | ||
[Verb("findallmeshprops", HelpText = "Find all MeshProperties containers which reference the given UID in all flat archives in the given forge file")] | ||
public class FindAllMeshPropsCommand | ||
{ | ||
[Value(0, HelpText = "The forge file to reference")] | ||
public string ForgeFilename { get; set; } | ||
|
||
[Value(1, HelpText = "The UID to search for")] | ||
public ulong Uid { get; set; } | ||
|
||
public static void Run(FindAllMeshPropsCommand args) | ||
{ | ||
try | ||
{ | ||
var forge = Program.GetForge(args.ForgeFilename); | ||
foreach (var entry in forge.Entries) | ||
if (SearchFlatArchive(forge, entry, args.Uid)) | ||
Console.WriteLine(entry.Uid); | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.Error.WriteLine($"Error while dumping: {e}"); | ||
} | ||
} | ||
|
||
public static bool SearchFlatArchive(Forge forge, Entry entry, ulong uid) | ||
{ | ||
var container = forge.GetContainer(entry.Uid); | ||
if (container is not ForgeAsset forgeAsset || MagicHelper.GetFiletype(entry.Name.FileType) != AssetType.FlatArchive) | ||
return false; | ||
|
||
var assetStream = forgeAsset.GetDataStream(forge); | ||
var arc = FlatArchive.Read(assetStream); | ||
|
||
foreach (var meshProp in arc.Entries) | ||
{ | ||
var unresolvedExterns = new List<ulong>(); | ||
|
||
try | ||
{ | ||
DumpHelper.SearchNonContainerChildren(assetStream, arc, meshProp, unresolvedExterns); | ||
} | ||
catch (NotSupportedException) | ||
{ | ||
continue; | ||
} | ||
|
||
if (unresolvedExterns.Contains(uid)) | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.IO; | ||
using CommandLine; | ||
|
||
namespace DumpTool | ||
{ | ||
[Verb("findallmeshpropsglobal", HelpText = "Find all MeshProperties containers which reference the given UID in all flat archives in the given forge file")] | ||
public class FindAllMeshPropsGlobalCommand | ||
{ | ||
[Value(0, HelpText = "The directory of forge files to search")] | ||
public string ForgeDirectory { get; set; } | ||
|
||
[Value(1, HelpText = "The UID to search for")] | ||
public ulong Uid { get; set; } | ||
|
||
public static void Run(FindAllMeshPropsGlobalCommand args) | ||
{ | ||
Program.AssertDirectoryExists(args.ForgeDirectory); | ||
|
||
foreach (var file in Directory.GetFiles(args.ForgeDirectory, "*.forge")) | ||
try | ||
{ | ||
var forge = Program.GetForge(file); | ||
for (var i = 0; i < forge.Entries.Length; i++) | ||
{ | ||
var entry = forge.Entries[i]; | ||
|
||
if (FindAllMeshPropsCommand.SearchFlatArchive(forge, entry, args.Uid)) | ||
Console.WriteLine($"{Path.GetFileName(file)}: {entry.Uid}"); | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.Error.WriteLine($"Error while dumping: {e}"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters