From 2a8618ab5c64af4195fcbedea6758728b070ca4c Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Tue, 20 Oct 2026 14:58:56 -0400 Subject: [PATCH] feat: launch Easy Anti-Cheat games offline when they support it (#1039) --- .../launcher/core/GameEnvironment.kt | 1 + .../launcher/core/GameEnvironmentOptions.kt | 1 + app/src/main/res/values/strings.xml | 1 + .../launcher/core/GameEnvironmentTest.kt | 1 + .../overlay/usr/local/bin/droiddeck-game-env | 31 ++++++++++ tools/tests/test_game_environment.py | 58 +++++++++++++++++++ 6 files changed, 93 insertions(+) diff --git a/app/src/main/java/com/droiddeck/launcher/core/GameEnvironment.kt b/app/src/main/java/com/droiddeck/launcher/core/GameEnvironment.kt index c8341afc26..4672cc651b 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/GameEnvironment.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/GameEnvironment.kt @@ -29,6 +29,7 @@ object GameEnvironment { fun defaults(preset: String, forceSsbs: Boolean = false): Map = linkedMapOf( "MESA_SHADER_CACHE_DISABLE" to "false", + "DROIDDECK_ANTICHEAT_OFFLINE" to "1", "VKD3D_FEATURE_LEVEL" to "12_2", "VKD3D_SHADER_MODEL" to "6_9", "DOTNET_GCRegionRange" to "800000000", diff --git a/app/src/main/java/com/droiddeck/launcher/core/GameEnvironmentOptions.kt b/app/src/main/java/com/droiddeck/launcher/core/GameEnvironmentOptions.kt index 078ae8165c..3ad45c1fa6 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/GameEnvironmentOptions.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/GameEnvironmentOptions.kt @@ -32,6 +32,7 @@ object GameEnvironmentOptions { Option("MESA_EXTENSION_MAX_YEAR", "", 0, Type.TEXT), Option("MESA_GL_VERSION_OVERRIDE", "", 0, Type.TEXT), Option("PULSE_LATENCY_MSEC", "", 0, Type.NUMBER), + Option("DROIDDECK_ANTICHEAT_OFFLINE", "1", R.string.game_env_anticheat_offline, Type.TOGGLE, listOf("0", "1")), Option("WINE_LARGE_ADDRESS_AWARE", "0", 0, Type.TOGGLE, listOf("0", "1")), Option("WINEDLLOVERRIDES", "", 0, Type.TEXT), Option("GALLIUM_HUD", "simple", 0, Type.MULTIPLE, listOf("simple", "fps", "frametime")), diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9af9fccc40..bd51f4ebe2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -90,6 +90,7 @@ Set to 1 to keep this game off droiddeck-fsync; it uses droiddeck-esync where a pack exists, otherwise droiddeck-ntsync. Set to 1 to run this game on droiddeck-fsync, or 0 to put droiddeck-esync first where a pack fits its Proton. Set to 0 to disable Proton’s gamepad-navigation helper for this game. + On by default. Starts an Easy Anti-Cheat game without its anti-cheat when the game supports offline play. Turn off to launch through Easy Anti-Cheat as usual. Online modes that require Easy Anti-Cheat remain unavailable. DXVK overlay for D3D9–11. fps displays frame rate; unset hides it. DXVK settings separated by semicolons. Recent builds use dxvk.maxFrameRate for frame limiting; prefer the session frame limiter for ordinary play. D3D12 frame-rate limit. 0 disables the limit. diff --git a/app/src/test/java/com/droiddeck/launcher/core/GameEnvironmentTest.kt b/app/src/test/java/com/droiddeck/launcher/core/GameEnvironmentTest.kt index 4fe40920d1..281a782246 100644 --- a/app/src/test/java/com/droiddeck/launcher/core/GameEnvironmentTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/core/GameEnvironmentTest.kt @@ -7,6 +7,7 @@ class GameEnvironmentTest { @Test fun defaultsIncludeRequestedGraphicsLevelsAndKeepCaching() { val values = GameEnvironment.defaults("") assertEquals("false", values["MESA_SHADER_CACHE_DISABLE"]) + assertEquals("1", values["DROIDDECK_ANTICHEAT_OFFLINE"]) assertEquals("12_2", values["VKD3D_FEATURE_LEVEL"]) assertEquals("6_9", values["VKD3D_SHADER_MODEL"]) } diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env index 21d0f8ebc8..827ad60e85 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env @@ -126,6 +126,35 @@ def skip_red_launcher(command): return command +def offline_without_anticheat(command, env): + """Start the configured game executable when the player opts into launching without EAC.""" + if (env.get("DROIDDECK_ANTICHEAT_OFFLINE") != "1" or len(command) <= 2 + or command[1] != "waitforexitandrun" + or not re.fullmatch(r"start_protected_game(?:_?x64|_?64)?\.exe", + os.path.basename(command[2]), re.IGNORECASE)): + return command + folder = os.path.dirname(command[2]) + try: + with open(os.path.join(folder, "EasyAntiCheat", "settings.json"), encoding="utf-8-sig") as source: + executable = json.load(source).get("executable") + except (OSError, ValueError, AttributeError): + return command + if not isinstance(executable, str) or not executable: + return command + relative = os.path.normpath(executable.replace("\\", "/")) + game = os.path.join(folder, relative) + if os.path.isabs(relative) or relative.startswith("..") or not os.path.isfile(game): + return command + # Resolve symlinks before accepting an executable inside the game directory. + root = os.path.realpath(folder) + if os.path.commonpath((root, os.path.realpath(game))) != root: + return command + if os.path.normcase(os.path.abspath(game)) == os.path.normcase(os.path.abspath(command[2])): + return command + print("droiddeck-game-env: started without Easy Anti-Cheat (offline only)", file=sys.stderr) + return command[:2] + [game] + command[3:] + + def engine_fixes(exe, args): """Environment and extra arguments a game needs because of what it is built with.""" game = Game(exe, args) @@ -326,6 +355,8 @@ def main(): env = apply_config(env, {"version": 1}, app_id, fixes) except (OSError, ValueError, TypeError, AttributeError): print("droiddeck-game-env: invalid configuration; using inherited environment", file=sys.stderr) + if app_id and len(command) > 1 and command[1] == "waitforexitandrun": + command = offline_without_anticheat(command, env) if mic_enabled == "0": env["BANNER_AUDIO_DIRECT_MIC"] = "0" env = force_ssbs(command, env) diff --git a/tools/tests/test_game_environment.py b/tools/tests/test_game_environment.py index 908e72e976..70c5f7cbf5 100644 --- a/tools/tests/test_game_environment.py +++ b/tools/tests/test_game_environment.py @@ -201,6 +201,64 @@ class GameEnvironmentTest(unittest.TestCase): (other / "Other.exe").touch() self.assertEqual(MODULE["engine_fixes"](str(other / "Other.exe"), []), ({}, [], [])) + def test_easy_anti_cheat_games_start_offline_only_when_opted_in(self): + with tempfile.TemporaryDirectory() as tmp: + game = Path(tmp) / "ELDEN RING/Game" + (game / "EasyAntiCheat").mkdir(parents=True) + for name in ("start_protected_game.exe", "eldenring.exe"): + (game / name).touch() + (game / "EasyAntiCheat/settings.json").write_text('\ufeff{ "executable" : "eldenring.exe" }', encoding="utf-8") + command = ["proton", "waitforexitandrun", str(game / "start_protected_game.exe"), "-arg"] + offline = MODULE["offline_without_anticheat"] + self.assertEqual(offline(command, {}), command) + self.assertEqual(offline(command, {"DROIDDECK_ANTICHEAT_OFFLINE": "0"}), command) + self.assertEqual(offline(command, {"DROIDDECK_ANTICHEAT_OFFLINE": "1"}), + ["proton", "waitforexitandrun", str(game / "eldenring.exe"), "-arg"]) + (game / "EasyAntiCheat/settings.json").write_text('{ "executable" : "../../escape.exe" }') + (Path(tmp) / "escape.exe").touch() + self.assertEqual(offline(command, {"DROIDDECK_ANTICHEAT_OFFLINE": "1"}), command) + (game / "EasyAntiCheat/settings.json").write_text('{ "executable" : "missing.exe" }') + self.assertEqual(offline(command, {"DROIDDECK_ANTICHEAT_OFFLINE": "1"}), command) + (game / "EasyAntiCheat/settings.json").write_text('{ "executable" : "link/escape.exe" }') + outside = Path(tmp) / "outside" + outside.mkdir() + (outside / "escape.exe").touch() + (game / "link").symlink_to(outside, target_is_directory=True) + self.assertEqual(offline(command, {"DROIDDECK_ANTICHEAT_OFFLINE": "1"}), command) + (game / "EasyAntiCheat/settings.json").write_text('{ "executable" : "eldenring.exe" }') + plain = ["proton", "waitforexitandrun", str(game / "eldenring.exe")] + self.assertEqual(offline(plain, {"DROIDDECK_ANTICHEAT_OFFLINE": "1"}), plain) + self.assertEqual(offline(["proton", "run", command[2]], + {"DROIDDECK_ANTICHEAT_OFFLINE": "1"}), + ["proton", "run", command[2]]) + + def test_easy_anti_cheat_forwarding_through_entrypoint(self): + with tempfile.TemporaryDirectory() as tmp: + home = Path(tmp) + game = home / "ELDEN RING/Game" + (game / "EasyAntiCheat").mkdir(parents=True) + bootstrapper = game / "start_protected_game.exe" + target = game / "eldenring.exe" + bootstrapper.touch() + target.touch() + (game / "EasyAntiCheat/settings.json").write_text(json.dumps({"executable": "eldenring.exe"})) + proton = home / "fake-proton" + proton.write_text("#!" + sys.executable + "\nimport json, sys\nprint(json.dumps(sys.argv[1:]))\n") + proton.chmod(0o755) + config = home / ".config/droiddeck/game-environment.json" + config.parent.mkdir(parents=True) + env = dict(os.environ, HOME=tmp, STEAM_COMPAT_DATA_PATH="/compatdata/42") + env.pop("DROIDDECK_ANTICHEAT_OFFLINE", None) + for setting, expected in (("1", target), ("0", bootstrapper), (None, bootstrapper)): + with self.subTest(setting=setting): + values = {} if setting is None else {"DROIDDECK_ANTICHEAT_OFFLINE": setting} + config.write_text(json.dumps({"version": 1, "games": {"42": values}})) + result = subprocess.run([sys.executable, str(BIN / "droiddeck-game-env"), + str(proton), "waitforexitandrun", str(bootstrapper), "-arg"], + env=env, text=True, capture_output=True, check=True) + self.assertEqual(json.loads(result.stdout.strip()), + ["waitforexitandrun", str(expected), "-arg"]) + def test_deep_rock_gdk_avoids_the_raytracing_pipeline_crash(self): game = "/game/FSD/Binaries/WinGDK/FSD-WinGDK-Shipping.exe" env, extra, notes = MODULE["engine_fixes"](game, [])