mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 21:15:43 +00:00
fix(game-env): skip Steam's evaluator when its scripts only run marked processes
DroidDeck skipped Steam's iscriptevaluator.exe only when the evaluator had once finished the exact same script file. Steam rewrites evaluatorscript_<app>.vdf between launches (on the Elite it wrote two different files for Brawlhalla within minutes), so the skip missed and the real evaluator ran again; on bionic that run hung. install_scripts_done() now also counts the scripts as done when every action in them is a "run process" entry and all their hasrunkeys are set in the prefix: Steam's evaluator would run nothing then. droiddeck-seed-redists sets those keys for Steam's common redistributables. Scripts with other actions (registry values and the like) still run once and are recorded as before. This applies to DroidDeck-Proton and DroidDeck-Bionic alike. Checked with the Elite's real script (Steamworks Shared 228980, VC++ 2019 x86 + x64) and prefix registry and a stamp that does not match: the old rule ran the evaluator, the new one skips it. Tests updated: a rewritten marked-only script counts as done, a script with a registry action still runs once and is recorded.
This commit is contained in:
1 parent
c1509a0c11
commit
d0796720b8
2 files changed
+67
-7
No files matched your search
@@ -827,18 +827,49 @@ def scripts_digest(scripts):
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def only_guarded_runs(items):
|
||||
# True when every action in the scripts is a "run process" entry. With all their hasrunkeys set, Steam's
|
||||
# evaluator would run nothing, so the scripts need no run even when Steam has rewritten the file (its
|
||||
# SteamID, language, install path or order change between launches).
|
||||
found = False
|
||||
for _, entries in items:
|
||||
if not isinstance(entries, list):
|
||||
return False
|
||||
for _, entry in entries:
|
||||
if not isinstance(entry, list):
|
||||
return False
|
||||
for _, block in entry:
|
||||
if not isinstance(block, list):
|
||||
continue
|
||||
for section, actions in block:
|
||||
if section.lower() != "run process" or not isinstance(actions, list):
|
||||
return False
|
||||
for _, action in actions:
|
||||
if not isinstance(action, list) or not any(
|
||||
isinstance(v, str) and re.fullmatch(r"process [0-9]+", n.lower()) for n, v in action):
|
||||
return False
|
||||
found = True
|
||||
return found
|
||||
|
||||
|
||||
def install_scripts_done(scripts, env):
|
||||
prefix = Path(env.get("STEAM_COMPAT_DATA_PATH", "/nonexistent")) / "pfx"
|
||||
try:
|
||||
if (prefix / INSTALL_STAMP).read_text().strip() != scripts_digest(scripts):
|
||||
return False
|
||||
keys = set()
|
||||
keys, parsed = set(), []
|
||||
for path in scripts:
|
||||
keys |= run_keys(read_vdf(Path(path).read_text(encoding="utf-8", errors="replace")))
|
||||
parsed.append(read_vdf(Path(path).read_text(encoding="utf-8", errors="replace")))
|
||||
keys |= run_keys(parsed[-1])
|
||||
values = registry_values(prefix / "system.reg")
|
||||
except (OSError, ValueError):
|
||||
return False
|
||||
return bool(keys) and all(has_run(key, value, values) for key, value in keys)
|
||||
if not keys or not all(has_run(key, value, values) for key, value in keys):
|
||||
return False
|
||||
try:
|
||||
if (prefix / INSTALL_STAMP).read_text().strip() == scripts_digest(scripts):
|
||||
return True
|
||||
except OSError:
|
||||
pass
|
||||
return all(only_guarded_runs(items) for items in parsed)
|
||||
|
||||
|
||||
def record_install_scripts(digest, env):
|
||||
|
||||
@@ -1031,12 +1031,35 @@ class GameEnvironmentTest(unittest.TestCase):
|
||||
self.assertFalse(done([str(script)], env))
|
||||
(prefix / "system.reg").write_text(self.REDIST + self.SETUP)
|
||||
self.assertTrue(done([str(script)], env))
|
||||
# Steam rewrote the file: only marked "run process" entries, so its evaluator would run nothing either
|
||||
script.write_text(self.SCRIPT.replace("x64.cmd", "x64-update.cmd"))
|
||||
self.assertTrue(done([str(script)], env))
|
||||
script.write_text(self.SCRIPT.replace('"Setup"', '"Setup 2"'))
|
||||
self.assertFalse(done([str(script)], env))
|
||||
script.write_text('"InstallScript" { "Registry" { "HKEY_LOCAL_MACHINE\\\\Software\\\\Game" { "string" { "Path" "%INSTALLDIR%" } } } }')
|
||||
MODULE["record_install_scripts"](MODULE["scripts_digest"]([str(script)]), env)
|
||||
self.assertFalse(done([str(script)], env))
|
||||
|
||||
def test_marked_run_process_scripts_count_as_done_without_a_record(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
script = Path(tmp) / "evaluatorscript_291550.vdf"
|
||||
script.write_text(self.SCRIPT.replace('"0" { "appid" "228980"',
|
||||
'"0" { "appid" "228980" "mode" "1" "language" "english" '
|
||||
'"install_path" "/root/x" "SteamID" "7656"'))
|
||||
prefix = Path(tmp) / "compat/pfx"
|
||||
prefix.mkdir(parents=True)
|
||||
env = {"STEAM_COMPAT_DATA_PATH": str(prefix.parent)}
|
||||
done = MODULE["install_scripts_done"]
|
||||
(prefix / "system.reg").write_text(self.REDIST)
|
||||
self.assertFalse(done([str(script)], env))
|
||||
(prefix / "system.reg").write_text(self.REDIST + self.SETUP)
|
||||
self.assertTrue(done([str(script)], env))
|
||||
(prefix / MODULE["INSTALL_STAMP"]).write_text("an older digest\n")
|
||||
self.assertTrue(done([str(script)], env))
|
||||
script.write_text(self.SCRIPT.replace('"run process" {',
|
||||
'"registry" { "HKEY_LOCAL_MACHINE\\\\Software\\\\Game" { "string" { "Path" "x" } } } "run process" {'))
|
||||
self.assertFalse(done([str(script)], env))
|
||||
|
||||
def test_the_evaluator_is_skipped_once_it_finished_the_same_scripts(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
@@ -1052,8 +1075,12 @@ class GameEnvironmentTest(unittest.TestCase):
|
||||
proton.write_text("#!/bin/sh\necho run >> %s\nexit ${EXIT_CODE:-0}\n" % shlex.quote(str(runs)))
|
||||
proton.chmod(0o755)
|
||||
|
||||
def evaluate(exit_code="0"):
|
||||
script.write_text(self.SCRIPT if exit_code != "changed" else self.SCRIPT.replace("setup.exe", "setup-update.exe"))
|
||||
# a registry action besides the marked runs: Steam's evaluator has work to do, so it runs once
|
||||
with_registry = self.SCRIPT.replace(
|
||||
'"run process" {', '"registry" { "HKEY_LOCAL_MACHINE\\\\Software\\\\Game" { "string" { "Path" "x" } } } "run process" {')
|
||||
|
||||
def evaluate(exit_code="0", text=None):
|
||||
script.write_text(text or (with_registry if exit_code != "changed" else with_registry.replace("setup.exe", "setup-update.exe")))
|
||||
env = dict(os.environ, HOME=tmp, STEAM_COMPAT_CLIENT_INSTALL_PATH=str(root),
|
||||
STEAM_COMPAT_DATA_PATH=str(prefix.parent), EXIT_CODE="0" if exit_code == "changed" else exit_code)
|
||||
result = subprocess.run([sys.executable, str(BIN / "droiddeck-game-env"), str(proton), "run",
|
||||
@@ -1066,6 +1093,8 @@ class GameEnvironmentTest(unittest.TestCase):
|
||||
self.assertEqual(evaluate(), (0, 2))
|
||||
self.assertEqual(evaluate(), (0, 2))
|
||||
self.assertEqual(evaluate("changed"), (0, 3))
|
||||
# only marked "run process" entries, all set: skipped even though the file differs from the recorded one
|
||||
self.assertEqual(evaluate(text=self.SCRIPT.replace("x64.cmd", "x64-update.cmd")), (0, 3))
|
||||
|
||||
def test_the_mali_bridge_caps_the_vkd3d_feature_level(self):
|
||||
bridge = {"BL_VKBRIDGE": "1", "VKD3D_FEATURE_LEVEL": "12_2"}
|
||||
|
||||
Reference in new issue
Block a user