mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
fix(game-env): keep DroidDeck's DLL overrides when a game sets its own (#2332)
* fix(game-env): keep DroidDeck's DLL overrides when a game sets its own * fix(game-env): keep the game row when the merged DLL overrides pass 8192 --------- Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
This commit is contained in:
1 parent
d0398fd853
commit
fc0f8a8530
2 files changed
+39
-1
No files matched your search
@@ -600,7 +600,16 @@ def apply_config(env, config, app_id, fixes=None):
|
||||
if name == "WINEDLLOVERRIDES" and entries.get(name, env.get(name)):
|
||||
value = entries.get(name, env.get(name)) + ";" + value
|
||||
entries[name] = value
|
||||
entries.update(config.get("games", {}).get(app_id, {}))
|
||||
game = config.get("games", {}).get(app_id, {})
|
||||
fix = (fixes or {}).get("WINEDLLOVERRIDES")
|
||||
if fix and isinstance(game.get("WINEDLLOVERRIDES"), str):
|
||||
own = game["WINEDLLOVERRIDES"]
|
||||
combined = fix + ";" + own if own else fix
|
||||
if len(combined) > 8192:
|
||||
print("droiddeck-game-env: game WINEDLLOVERRIDES too long to add DroidDeck's overrides; using the game value only", file=sys.stderr)
|
||||
combined = own
|
||||
game = dict(game, WINEDLLOVERRIDES=combined)
|
||||
entries.update(game)
|
||||
for name, value in entries.items():
|
||||
if not re.fullmatch(r"[A-Za-z_][A-Za-z0-9_]*", name):
|
||||
raise ValueError("invalid environment name")
|
||||
|
||||
@@ -1738,6 +1738,35 @@ class GameEnvironmentTest(unittest.TestCase):
|
||||
self.assertEqual(result["FEX_TSOENABLED"], "0")
|
||||
self.assertEqual(result["WINEDLLOVERRIDES"], "dxgi=n;libsentry=d")
|
||||
|
||||
def test_game_dll_overrides_follow_droiddecks_own(self):
|
||||
fixes = {"WINEDLLOVERRIDES": "msvcp100=n,b"}
|
||||
config = {"version": 1, "shared": {}, "games": {"42": {"WINEDLLOVERRIDES": "windowscodecs,windowscodecsext=n"}}}
|
||||
result = MODULE["apply_config"]({}, config, "42", fixes)
|
||||
self.assertEqual(result["WINEDLLOVERRIDES"], "msvcp100=n,b;windowscodecs,windowscodecsext=n")
|
||||
|
||||
def test_game_dll_overrides_edge_cases(self):
|
||||
fixes = {"WINEDLLOVERRIDES": "msvcp100=n,b"}
|
||||
env = {"WINEDLLOVERRIDES": "dxgi=n"}
|
||||
for game, shared, expected in (
|
||||
({"WINEDLLOVERRIDES": "msvcp100=b"}, {}, "msvcp100=n,b;msvcp100=b"),
|
||||
({"WINEDLLOVERRIDES": ""}, {}, "msvcp100=n,b"),
|
||||
({"WINEDLLOVERRIDES": None}, {}, None),
|
||||
({"WINEDLLOVERRIDES": "d3d9=n"}, {"WINEDLLOVERRIDES": "xinput1_3=n"}, "msvcp100=n,b;d3d9=n"),
|
||||
({}, {}, "dxgi=n;msvcp100=n,b"),
|
||||
({"WINEDLLOVERRIDES": "x" * 8179}, {}, "msvcp100=n,b;" + "x" * 8179),
|
||||
):
|
||||
with self.subTest(game=game, shared=shared):
|
||||
config = {"version": 1, "shared": shared, "games": {"42": game, "43": {"WINEDLLOVERRIDES": "d3d11=n"}}}
|
||||
result = MODULE["apply_config"](env, config, "42", fixes)
|
||||
self.assertEqual(result.get("WINEDLLOVERRIDES"), expected)
|
||||
self.assertEqual(MODULE["apply_config"](env, config, "43")["WINEDLLOVERRIDES"], "d3d11=n")
|
||||
stderr = io.StringIO()
|
||||
config = {"version": 1, "shared": {}, "games": {"42": {"WINEDLLOVERRIDES": "x" * 8192}}}
|
||||
with mock.patch("sys.stderr", stderr):
|
||||
result = MODULE["apply_config"](env, config, "42", fixes)
|
||||
self.assertEqual(result["WINEDLLOVERRIDES"], "x" * 8192)
|
||||
self.assertIn("too long", stderr.getvalue())
|
||||
|
||||
def test_invalid_configuration_is_atomic(self):
|
||||
env = {"ORIGINAL": "unchanged"}
|
||||
for entries in ({"A": "ok", "BAD=KEY": "x"}, {"A": "bad\0value"}, {"A": 1}):
|
||||
|
||||
Reference in new issue
Block a user