goatcorp / XIVLauncher.Core

Cross-platform version of XIVLauncher, optimized for Steam Deck
GNU General Public License v3.0
126 stars 42 forks source link

Cannot start the game on Linux if Dalamud isn't enabled #160

Open Toyoyo opened 3 months ago

Toyoyo commented 3 months ago

When I start the game without Dalamud, I get this error message from ffxiv_dx11.exe (see screenshot, basically saying to start the game from ffxivboot.exe, same message as if running ffxiv_dx11.exe directly).

This doesn't happen at all if Dalamud is enabled and injects fine, which is not going to be the case when 7.0 will launch. ffxivboot

Happened before the 7.0 maintenance as well, is the same with or without steam integration, happens the same with the managed wine, a system-wide wine and proton. Happens also in "fake login" mode. Can not reproduce on windows, it starts fine there.

See attached launcher.log launcher.log

Toyoyo commented 3 months ago

After some more debugging I just found that the Windows codepath does not executes ffxiv_dx11.exe directly but instead use the "ACLonly" load method instead.

    public Process Start(string path, string workingDirectory, string arguments, IDictionary<string, string> environment, DpiAwareness dpiAwareness)
    {
        if (dalamudOk)
        {
            var compat = "RunAsInvoker ";
            compat += dpiAwareness switch {
                DpiAwareness.Aware => "HighDPIAware",
                DpiAwareness.Unaware => "DPIUnaware",
                _ => throw new ArgumentOutOfRangeException()
            };
            environment.Add("__COMPAT_LAYER", compat);

            var prevDalamudRuntime = Environment.GetEnvironmentVariable("DALAMUD_RUNTIME");
            if (string.IsNullOrWhiteSpace(prevDalamudRuntime))
                environment.Add("DALAMUD_RUNTIME", dotnetRuntimePath.FullName);

            return this.dalamudLauncher.Run(new FileInfo(path), arguments, environment);
        }
        else
        {
            return NativeAclFix.LaunchGame(workingDirectory, path, arguments, environment, dpiAwareness, process => { });
        }
    }

When I do the same thing on the Linux launcher, the games loads fine.

For now I have the following patch working. Please note, I'm not familiar enough with the codebase to be sure my approach for setting the load method is correct, but did not find an existing way to do this.

diff '--exclude=.git' '--exclude=*.targets' -x '*.props' -rpuN XIVLauncher.orig/XIVLauncher.Core/lib/FFXIVQuickLauncher/src/XIVLauncher.Common/Dalamud/DalamudLauncher.cs XIVLauncher.Patched/XIVLauncher.Core/lib/FFXIVQuickLauncher/src/XIVLauncher.Common/Dalamud/DalamudLauncher.cs
--- XIVLauncher.orig/XIVLauncher.Core/lib/FFXIVQuickLauncher/src/XIVLauncher.Common/Dalamud/DalamudLauncher.cs  2024-06-27 20:39:28.238852926 +0200
+++ XIVLauncher.Patched/XIVLauncher.Core/lib/FFXIVQuickLauncher/src/XIVLauncher.Common/Dalamud/DalamudLauncher.cs   2024-06-27 20:55:33.716001777 +0200
@@ -11,7 +11,7 @@ namespace XIVLauncher.Common.Dalamud
 {
     public class DalamudLauncher
     {
-        private readonly DalamudLoadMethod loadMethod;
+        private DalamudLoadMethod loadMethod;
         private readonly DirectoryInfo gamePath;
         private readonly DirectoryInfo configDirectory;
         private readonly DirectoryInfo logPath;
@@ -24,6 +24,11 @@ namespace XIVLauncher.Common.Dalamud
         private readonly bool noThirdPlugin;
         private readonly string troubleshootingData;

+        public void SetLoadMethod(DalamudLoadMethod loadMethod)
+        {
+           this.loadMethod = loadMethod;
+        }
+
         public enum DalamudInstallState
         {
             Ok,
@@ -161,4 +166,4 @@ namespace XIVLauncher.Common.Dalamud
             return true;
         }
     }
-}
\ No newline at end of file
+}
diff '--exclude=.git' '--exclude=*.targets' -x '*.props' -rpuN XIVLauncher.orig/XIVLauncher.Core/lib/FFXIVQuickLauncher/src/XIVLauncher.Common.Unix/UnixGameRunner.cs XIVLauncher.Patched/XIVLauncher.Core/lib/FFXIVQuickLauncher/src/XIVLauncher.Common.Unix/UnixGameRunner.cs
--- XIVLauncher.orig/XIVLauncher.Core/lib/FFXIVQuickLauncher/src/XIVLauncher.Common.Unix/UnixGameRunner.cs  2024-06-27 20:39:28.226853111 +0200
+++ XIVLauncher.Patched/XIVLauncher.Core/lib/FFXIVQuickLauncher/src/XIVLauncher.Common.Unix/UnixGameRunner.cs   2024-06-27 20:55:50.083750286 +0200
@@ -28,7 +28,8 @@ public class UnixGameRunner : IGameRunne
         }
         else
         {
-            return compatibility.RunInPrefix($"\"{path}\" {arguments}", workingDirectory, environment, writeLog: true);
+            this.dalamudLauncher.SetLoadMethod(DalamudLoadMethod.ACLonly);
+            return this.dalamudLauncher.Run(new FileInfo(path), arguments, environment);
         }
     }
-}
\ No newline at end of file
+}