diff --git a/CRBDL/Arguments/ArgParser.cs b/CRBDL/Arguments/ArgParser.cs index 1a36373..362b24e 100644 --- a/CRBDL/Arguments/ArgParser.cs +++ b/CRBDL/Arguments/ArgParser.cs @@ -399,5 +399,19 @@ public static string ParseArgsFromSettings(Stream stream) } return hargs + args; } + + public static bool IsNewArgument(string arg) + { + bool result = arg.Equals("+set"); + if (!result ) + { + if (arg.Length> 1) + { + result = arg[0] == '-' && int.TryParse(arg.Substring(1), out int test); + } + } + + return result; + } } } diff --git a/CRBDL/CDL.cs b/CRBDL/CDL.cs index 549ec76..d002889 100644 --- a/CRBDL/CDL.cs +++ b/CRBDL/CDL.cs @@ -25,6 +25,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE using System.Diagnostics; using System.IO; using System.Threading; +using System.Threading.Tasks; namespace CDL { @@ -129,5 +130,18 @@ public void LaunchGame(string args) crbd.StartInfo.Arguments = args; // if you need some this.isRunning = crbd.Start(); } + + public void LaunchAndWaitGame(string args) + { + this.LaunchGame(args); + Task task = Task.Run(() => { + while (this.isRunning) + { + Thread.Sleep(4000); + } + }); + + Task.WaitAny(task); + } } } diff --git a/CRBDL/Program.cs b/CRBDL/Program.cs index bcf61c1..594137b 100644 --- a/CRBDL/Program.cs +++ b/CRBDL/Program.cs @@ -66,16 +66,34 @@ static void Main(string[] args) string path = ""; if (pathIndex != -1) { - path = eargs[pathIndex + 1]; + int index = 1; + while (!ArgParser.IsNewArgument(eargs[pathIndex + index])) + { + path += " " + eargs[pathIndex + index]; + index++; + if ((pathIndex + index) >= eargs.Length) + { + break; + } + } + path = path.Trim().Replace('\"', ' ').Trim(); } - CDL.CDL cdl = new CDL.CDL(new UFS(true, path)); + UFS ufs = new UFS(true, path); + CDL.CDL cdl = new CDL.CDL(ufs); if (cdl.CheckFiles() == 0) { Console.WriteLine("Main Executable not found"); throw new Exception("Main Executable not found"); } Console.WriteLine(largs); - cdl.LaunchGame(largs); + if (ufs.isRunningPackaged()) + { + cdl.LaunchAndWaitGame(largs); + } + else + { + cdl.LaunchGame(largs); + } } } } diff --git a/CRBDL/filesystem/UFS.cs b/CRBDL/filesystem/UFS.cs index 59ea28d..22facb0 100644 --- a/CRBDL/filesystem/UFS.cs +++ b/CRBDL/filesystem/UFS.cs @@ -59,6 +59,18 @@ public UFS(bool waitThread = false, string selectedPath = "") if (selectedPath.Length > 0) { this.selectedPath = selectedPath; + this.paths.Add(selectedPath); + string filePath = selectedPath + GetPathSeparator() + "base" + GetPathSeparator() + "_common.resources"; + byte[] data = File.ReadAllBytes(filePath); + string fileSha256 = BitConverter.ToString(sHA256.ComputeHash(data)).ToUpper().Replace("-", ""); + if (fileSha256.Equals(SHA256s[0]) ) + { + BFGPaths.Add(selectedPath); + } + else if (fileSha256.Equals(SHA256s[1])) + { + NewD3Paths.Add(selectedPath); + } } else {