Skip to content
Merged
Show file tree
Hide file tree
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
61 changes: 40 additions & 21 deletions ShinRyuModManager-CE/GameModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public static void DoY5HActProcedure(MLO mlo) {
var filePath = Path.Combine("mods", mod, file.Name.Trim('/'));
var fileInfo = new FileInfo(filePath);
// Get the folder from a path like so -> data/hact/h5000_some_hact/cmn/cmn.bin
var hactDir = fileInfo.Directory.Parent.Name;
var hactDir = fileInfo.Directory!.Parent!.Name;

if (fileInfo.Directory.Parent.Parent.Name == "hact") {
if (fileInfo.Directory.Parent.Parent!.Name == "hact") {
var hactPath = fileInfo.Directory.Parent.FullName;

var parPath = Path.Combine(fileInfo.Directory.Parent.Parent.FullName, hactDir + ".par");
Expand Down Expand Up @@ -65,7 +65,7 @@ public static void DoY5HActProcedure(MLO mlo) {

foreach (var hactDirPath in hactDirs) {
var hactDir = new DirectoryInfo(hactDirPath);
var parlessDir = new DirectoryInfo(Path.Combine(GamePath.ModsPath, "Parless", "hact", hactDir.Name));
var parlessDir = new DirectoryInfo(Path.Combine(GamePath.ParlessDir, "hact", hactDir.Name));

if (!parlessDir.Exists)
parlessDir.Create();
Expand Down Expand Up @@ -94,7 +94,28 @@ public static void DoY5HActProcedure(MLO mlo) {
}
}

Gibbed.Yakuza0.Pack.Program.Main([parlessDir.FullName], Path.Combine(parlessDir.Parent.FullName, $"{hactDir.Name}.par"));
Gibbed.Yakuza0.Pack.Program.Main([parlessDir.FullName], Path.Combine(parlessDir.Parent!.FullName, $"{hactDir.Name}.par"));
}
}

public static void DoY0DCLegacyModelSupport(MLO mlo) {
var parlessDir = new DirectoryInfo(GamePath.ParlessDir);

parlessDir.Create();

foreach (var modName in mlo.Mods) {
var modDir = Path.Combine(GamePath.ModsPath, modName);

if (!Directory.Exists(modDir))
continue;

var legacyCharaDir = Path.Combine(modDir, "chara", "w64");
var newCharaDir = Path.Combine(parlessDir.FullName, "chara", "ngen");

if (!Directory.Exists(legacyCharaDir))
continue;

Utils.CopyDirectory(legacyCharaDir, newCharaDir);
}
}

Expand All @@ -111,9 +132,9 @@ public static void DoOEHActProcedure(MLO mlo) {
var fileInfo = new FileInfo(filePath);

//get the folder from a path like this -> data/hact/h5000_some_hact/cmn/cmn.bin
var hactDir = fileInfo.Directory.Parent.Name;
var hactDir = fileInfo.Directory!.Parent!.Name;

if (fileInfo.Directory.Parent.Parent.Name == "hact") {
if (fileInfo.Directory.Parent.Parent!.Name == "hact") {
var hactPath = fileInfo.Directory.Parent.FullName;

var parPath = Path.Combine(fileInfo.Directory.Parent.Parent.FullName, hactDir + ".par");
Expand All @@ -126,10 +147,8 @@ public static void DoOEHActProcedure(MLO mlo) {
if (!Directory.Exists(Path.Combine(hactPath, "000")) || !Directory.Exists(Path.Combine(hactPath, "cmn")))
continue;

if (hactDirs.Contains(hactPath))
if (!hactDirs.Add(hactPath))
continue;

hactDirs.Add(hactPath);
}

hasHacts = true;
Expand All @@ -142,22 +161,22 @@ public static void DoOEHActProcedure(MLO mlo) {

foreach (var hactDirPath in hactDirs) {
var hactDir = new DirectoryInfo(hactDirPath);
var parlessDir = new DirectoryInfo(Path.Combine(GamePath.ModsPath, "Parless", "hact", hactDir.Name));
var parlessDir = new DirectoryInfo(Path.Combine(GamePath.ParlessDir, "hact", hactDir.Name));

if (!parlessDir.Exists)
parlessDir.Create();

foreach (var dir in hactDir.GetDirectories()) {
foreach (var dirName in hactDir.EnumerateDirectories().Select(x => x.Name)) {
//We already repack ptc
if (dir.Name == "ptc" /*&& File.Exists(Path.Combine(hactDir.FullName, "ptc.par"))*/)
if (dirName == "ptc" /*&& File.Exists(Path.Combine(hactDir.FullName, "ptc.par"))*/)
continue;

var outputFakeDir = Path.Combine(parlessDir.FullName, dir.Name);
var outputFakeDir = Path.Combine(parlessDir.FullName, dirName);

if(!Directory.Exists(outputFakeDir))
Directory.CreateDirectory(outputFakeDir);

var outputPath = Path.Combine(parlessDir.FullName, dir.Name + ".par");
var outputPath = Path.Combine(parlessDir.FullName, dirName + ".par");

Gibbed.Yakuza0.Pack.Program.Main([outputFakeDir], outputPath);

Expand All @@ -168,7 +187,7 @@ public static void DoOEHActProcedure(MLO mlo) {
}
}

Gibbed.Yakuza0.Pack.Program.Main([parlessDir.FullName], Path.Combine(parlessDir.Parent.FullName, hactDir.Name + ".par"));
Gibbed.Yakuza0.Pack.Program.Main([parlessDir.FullName], Path.Combine(parlessDir.Parent!.FullName, hactDir.Name + ".par"));
}
}

Expand All @@ -185,9 +204,9 @@ public static void DoDEHActProcedure(MLO mlo, string codename) {
var fileInfo = new FileInfo(filePath);

//get the folder from a path like this -> data/hact_yazawa/h5000_some_hact/cmn/cmn.bin
var hactDir = fileInfo.Directory.Parent.Name;
var hactDir = fileInfo.Directory!.Parent!.Name;

if (fileInfo.Directory.Parent.Parent.Name == $"hact_{codename}") {
if (fileInfo.Directory.Parent.Parent!.Name == $"hact_{codename}") {
var hactPath = fileInfo.Directory.Parent.FullName;

var parPath = Path.Combine(fileInfo.Directory.Parent.Parent.FullName, hactDir + ".par");
Expand Down Expand Up @@ -219,7 +238,7 @@ public static void DoDEHActProcedure(MLO mlo, string codename) {

foreach (var hactDirPath in hactDirs) {
var hactDir = new DirectoryInfo(hactDirPath);
var parlessDir = new DirectoryInfo(Path.Combine(GamePath.ModsPath, "Parless", "hact_" + codename, hactDir.Name));
var parlessDir = new DirectoryInfo(Path.Combine(GamePath.ParlessDir, "hact_" + codename, hactDir.Name));

if (!parlessDir.Exists)
parlessDir.Create();
Expand All @@ -233,7 +252,7 @@ public static void DoDEHActProcedure(MLO mlo, string codename) {
Gibbed.Yakuza0.Pack.Program.Main([dir.FullName], outputPath);
}

Gibbed.Yakuza0.Pack.Program.Main([parlessDir.FullName], Path.Combine(parlessDir.Parent.FullName, hactDir.Name + ".par"));
Gibbed.Yakuza0.Pack.Program.Main([parlessDir.FullName], Path.Combine(parlessDir.Parent!.FullName, hactDir.Name + ".par"));

new DirectoryInfo(parlessDir.FullName).Delete(true);
}
Expand Down Expand Up @@ -267,12 +286,12 @@ public static void DoUBIKProcedure(MLO mlo) {
foreach (var node in ubik!.Children) {
var ubikFile = node.GetFormatAs<ParFile>();

if (ubikFile.IsCompressed)
if (ubikFile!.IsCompressed)
node.TransformWith<ParLibrary.Sllz.Decompressor>();

var filePath = Path.Combine(ubikDir, node.Name);

if (node.Stream.Length > 0)
if (node.Stream!.Length > 0)
node.Stream.WriteTo(filePath);
}

Expand Down
7 changes: 2 additions & 5 deletions ShinRyuModManager-CE/ModLoadOrder/CpkPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@ public static async Task RepackDictionary(Dictionary<string, List<string>> cpkDi

Log.Information("Repacking CPKs...");

var cpkPath = Path.Combine(GamePath.ModsPath, "Parless");

if (!Directory.Exists(cpkPath))
Directory.CreateDirectory(cpkPath);
Directory.CreateDirectory(GamePath.ParlessDir);

foreach (var kvp in cpkDict) {
var key = kvp.Key.Trim(Path.DirectorySeparatorChar);

var cpkDir = Path.Combine(cpkPath, key);
var cpkDir = Path.Combine(GamePath.ParlessDir, key);

string origCpk;

Expand Down
2 changes: 1 addition & 1 deletion ShinRyuModManager-CE/ModLoadOrder/Mods/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public void AddFiles(string path, string check) {
if (!Directory.Exists(gmtFolderPath))
break;

var baseParlessPath = Path.Combine(GamePath.ModsPath, "Parless", "motion", "gmt");
var baseParlessPath = Path.Combine(GamePath.ParlessDir, "motion", "gmt");

foreach (var p in Directory.GetFiles(gmtFolderPath).Where(f => !f.EndsWith(Constants.VORTEX_MANAGED_FILE)).Select(GamePath.GetDataPathFrom)) {
// Copy any gmts to the appropriate hash folder in Parless
Expand Down
20 changes: 10 additions & 10 deletions ShinRyuModManager-CE/ParRepacker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@
}

public static void RemoveOldRepackedPars() {
var pathToParlessMods = Path.Combine(GamePath.ModsPath, "Parless");

if (!Directory.Exists(pathToParlessMods))
if (!Directory.Exists(GamePath.ParlessDir))
return;

Log.Information("Removing old pars...");

try {
DeleteDirectory(pathToParlessMods);
DeleteDirectory(GamePath.ParlessDir);
} catch {
Log.Warning("Failed to remove old pars! {PathToParlessMods}", pathToParlessMods);
Log.Warning("Failed to remove old pars! {PathToParlessMods}", GamePath.ParlessDir);
}

Log.Information("Removed old pars.");
Expand All @@ -58,20 +56,22 @@
}

await Task.WhenAll(parTasks);

/*foreach (var parModPair in parDictionary) {
RepackPar(parModPair.Key, parModPair.Value);
}*/

Log.Information("Repacked {ParDictionaryCount} par(s)!", parDictionary.Count);
}

private static void RepackPar(string parPath, List<string> mods) {

Check failure on line 63 in ShinRyuModManager-CE/ParRepacker.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 16 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=TheTrueColonel_ShinRyuModManager-CE&issues=AZsD13icbGCaSk_YofXS&open=AZsD13icbGCaSk_YofXS&pullRequest=22
parPath = parPath.TrimStart(Path.DirectorySeparatorChar);

var parPathReal = GamePath.GetRootParPath(parPath + ".par");
var pathToPar = Path.Combine(GamePath.DataPath, parPathReal);
var pathToModPar = Path.Combine(GamePath.ModsPath, "Parless", parPath + ".par");
var pathToModPar = Path.Combine(GamePath.ParlessDir, parPath + ".par");

if (string.IsNullOrEmpty(parPathReal)) {
Log.Information("ParRepacker: ParPathReal is empty for {ParPath} - skipping", parPath);

return;
}

// Check if actual repackable par is nested
if (parPath + ".par" != parPathReal) {
Expand Down
Loading
Loading