mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 13:55:58 +00:00
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).
This commit is contained in:
1 parent
e6e3673709
commit
f8fb1db3c8
2 files changed
+32
-6
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in new issue
Block a user