From f8fb1db3c86ee020e0b2295540181155b4febc76 Mon Sep 17 00:00:00 2001 From: The412Banner Date: Sat, 31 Oct 2026 23:39:19 +0000 Subject: [PATCH] fix(dual-screen): DiRT stand-in put back for the Proton the game ran on When a DiRT 3 / DiRT Showdown game was switched to another Proton, the first launch swapped the stand-in in for the old Proton's ws2_32.dll link; Proton then relinked the prefix's other DLLs to itself but left the stand-in, and the old link went back after the game. With telemetry off the game would then load the old Proton's ws2_32.dll under the new Wine. The launch now links the running Proton's ws2_32.dll back instead when the saved link belongs to another Proton (compared by real path, so esync packs that reach the stock files through a linked folder count as the same Proton). --- .../overlay/usr/local/bin/droiddeck-game-env | 18 +++++++++++------ tools/tests/test_game_environment.py | 20 +++++++++++++++++++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env index 5fb1168059..a043b5c757 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env @@ -811,17 +811,23 @@ def swap_dirt_ws2(prefix): def restore_dirt_ws2(prefix, proton): - """Puts the prefix's own syswow64/ws2_32.dll back if the stand-in is still there; true when it changed something.""" + """Puts a Wine syswow64/ws2_32.dll back if the stand-in is still there; true when it changed something. + + That is the prefix's own one, unless the game ran on another Proton since the swap: Proton then relinked the + prefix's other DLLs to itself but left the stand-in, so the running Proton's ws2_32.dll goes back instead.""" target = prefix_ws2(prefix) saved = target.with_name(target.name + DIRT_SAVED) - if os.path.lexists(saved): - if is_dirt_stand_in(target) or not os.path.lexists(target): + own = proton_ws2(proton) + had_saved = os.path.lexists(saved) + if had_saved: + if os.path.lexists(target) and not is_dirt_stand_in(target): + os.unlink(saved) + return False + if not own.is_file() or os.path.realpath(saved) == os.path.realpath(own): os.replace(saved, target) return True os.unlink(saved) - return False - own = proton_ws2(proton) - if is_dirt_stand_in(target) and own.is_file(): + if own.is_file() and (is_dirt_stand_in(target) or (had_saved and not os.path.lexists(target))): link = target.with_name(target.name + ".droiddeck-tmp") if os.path.lexists(link): os.unlink(link) diff --git a/tools/tests/test_game_environment.py b/tools/tests/test_game_environment.py index 463873fc69..49d3c15081 100644 --- a/tools/tests/test_game_environment.py +++ b/tools/tests/test_game_environment.py @@ -111,6 +111,26 @@ class DirtTelemetryFixTest(unittest.TestCase): self.assertEqual(os.readlink(self.target), str(newer)) self.assertFalse(os.path.lexists(self.target.with_name("ws2_32.dll.droiddeck-original"))) + def test_after_a_proton_switch_the_running_protons_file_goes_back(self): + MODULE["swap_dirt_ws2"](self.prefix) + other = Path(self.tmp.name) / "GE-Proton/proton" + other_own = other.parent / "files/lib/wine/i386-windows/ws2_32.dll" + other_own.parent.mkdir(parents=True) + other_own.write_bytes(b"MZ GE wine ws2_32") + other.write_text("") + self.assertTrue(MODULE["restore_dirt_ws2"](self.prefix, other)) + self.assertEqual(os.readlink(self.target), str(other_own)) + self.assertFalse(os.path.lexists(self.target.with_name("ws2_32.dll.droiddeck-original"))) + + def test_restore_follows_a_proton_reached_through_a_linked_folder(self): + MODULE["swap_dirt_ws2"](self.prefix) + pack = Path(self.tmp.name) / "pack" + (pack / "files/lib/wine").mkdir(parents=True) + (pack / "files/lib/wine/i386-windows").symlink_to(self.own.parent) + (pack / "proton").write_text("") + self.assertTrue(MODULE["restore_dirt_ws2"](self.prefix, pack / "proton")) + self.assertEqual(os.readlink(self.target), str(self.own)) + def test_a_stand_in_left_without_the_saved_link_is_replaced_by_protons_own_file(self): self.target.unlink() self.target.write_bytes(self.stand_in.read_bytes())