mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 06:15:58 +00:00
fix(battlenet): follow the selected FEX instead of pinning an old build (#2987)
* fix(battlenet): follow the selected FEX instead of pinning a d2rfix build The Battle.net prefix forced the newest FEXCore d2rfix package from the Nightlies listing, which stopped updating. Its fixes are in the bundled and nightly FEX, so the prefix now uses whatever FEX is selected. Existing d2rfix selections for the Battle.net profile are cleared once; any other choice is kept. The DXVK memory cap and Start without Steam defaults are now applied when a session starts. * fix(battlenet): import the legacy plugin state before unpinning the Battle.net FEX
This commit is contained in:
1 parent
31dd8f9987
commit
088c8ff1cf
9 files changed
+79
-232
No files matched your search
@@ -37,9 +37,6 @@ USER_PREFERENCES = "UserPreferencesMask"
|
||||
WINE_USER_PREFERENCES = bytes((0x10, 0x00, 0x00, 0x80, 0x12, 0x00, 0x00, 0x00))
|
||||
CLIENT_AREA_ANIMATION = (4, 0x02)
|
||||
WALLPAPER_MAX = (1280, 720)
|
||||
FEX_REQUEST = "battlenet-fex.request"
|
||||
FEX_RESULT = "battlenet-fex.result"
|
||||
FEX_WAIT = 120
|
||||
START_GRACE = 90
|
||||
POLL = 2
|
||||
STOP_WAIT = 5
|
||||
@@ -779,32 +776,6 @@ def write_menu(path=MENU):
|
||||
say("menu entry not written: %s" % error)
|
||||
|
||||
|
||||
def ask_fex(launch_dir, wait=FEX_WAIT):
|
||||
if not launch_dir or not os.path.isdir(launch_dir):
|
||||
say("not inside a DroidDeck session; FEX stays as Components has it")
|
||||
return None
|
||||
result = os.path.join(launch_dir, FEX_RESULT)
|
||||
request = os.path.join(launch_dir, FEX_REQUEST)
|
||||
try:
|
||||
os.unlink(result)
|
||||
except OSError:
|
||||
pass
|
||||
with open(request + ".tmp", "w", encoding="utf-8") as f:
|
||||
f.write("appid=%s\n" % APP_ID)
|
||||
os.replace(request + ".tmp", request)
|
||||
deadline = time.monotonic() + wait
|
||||
while time.monotonic() < deadline:
|
||||
try:
|
||||
with open(result, encoding="utf-8") as f:
|
||||
answer = f.read().strip()
|
||||
except OSError:
|
||||
time.sleep(0.5)
|
||||
continue
|
||||
os.unlink(result)
|
||||
return answer
|
||||
return None
|
||||
|
||||
|
||||
def wine_processes(pfx, proc="/proc"):
|
||||
want = os.path.realpath(pfx).rstrip("/")
|
||||
found = []
|
||||
@@ -1148,8 +1119,6 @@ def stop_leftovers(pfx):
|
||||
def open_client(root, reinstall=False):
|
||||
pfx = os.path.join(prefix(root), "pfx")
|
||||
write_menu()
|
||||
answer = ask_fex(os.environ.get("DD_LAUNCH_DIR"))
|
||||
say("FEX: %s" % (answer or "no answer from the app; Components' choice stays"))
|
||||
if running(pfx):
|
||||
say("Battle.net is already running in its prefix; waiting for it to close")
|
||||
wait_while_open(pfx, grace=0)
|
||||
@@ -1238,8 +1207,6 @@ def launch(root, code):
|
||||
try:
|
||||
own = None
|
||||
if lock is not None and not running(pfx):
|
||||
answer = ask_fex(os.environ.get("DD_LAUNCH_DIR"))
|
||||
say("FEX: %s" % (answer or "no answer from the app; Components' choice stays"))
|
||||
verb = None if stop_leftovers(pfx) else "run"
|
||||
configure(root, LIBRARY)
|
||||
own = start(launcher(root), verb)
|
||||
|
||||
@@ -6,7 +6,6 @@ import re
|
||||
import runpy
|
||||
import shutil
|
||||
import tempfile
|
||||
import threading
|
||||
import time
|
||||
import unittest
|
||||
from unittest import mock
|
||||
@@ -93,8 +92,6 @@ class IdTest(unittest.TestCase):
|
||||
self.assertEqual(int(BNET["APP_ID"]), zlib.crc32(b'"droiddeck-battlenet"Battle.net') | 0x80000000)
|
||||
found = re.search(r"const val APP_ID = (\d+)L", KOTLIN.read_text())
|
||||
self.assertEqual(found.group(1), BNET["APP_ID"])
|
||||
for name in ("FEX_REQUEST", "FEX_RESULT"):
|
||||
self.assertIn('const val %s = "%s"' % (name, BNET[name]), KOTLIN.read_text())
|
||||
|
||||
|
||||
class ProtonRunOptionsTest(Temp):
|
||||
@@ -761,36 +758,6 @@ class TidyTest(unittest.TestCase):
|
||||
self.assertEqual(self.stopped, [])
|
||||
|
||||
|
||||
class FexRequestTest(Temp):
|
||||
def answer(self, text, delay=0.2):
|
||||
def respond():
|
||||
request = self.tmp / BNET["FEX_REQUEST"]
|
||||
deadline = time.monotonic() + 5
|
||||
while not request.exists() and time.monotonic() < deadline:
|
||||
time.sleep(0.02)
|
||||
self.requested = request.read_text()
|
||||
request.unlink()
|
||||
time.sleep(delay)
|
||||
(self.tmp / (BNET["FEX_RESULT"] + ".tmp")).write_text(text + "\n")
|
||||
os.replace(self.tmp / (BNET["FEX_RESULT"] + ".tmp"), self.tmp / BNET["FEX_RESULT"])
|
||||
thread = threading.Thread(target=respond)
|
||||
thread.start()
|
||||
self.addCleanup(thread.join)
|
||||
|
||||
def test_the_apps_answer_comes_back(self):
|
||||
(self.tmp / BNET["FEX_RESULT"]).write_text("ok an-old-answer\n")
|
||||
self.answer("ok FEXCore-2610-d2rfix28-linux.wcp")
|
||||
self.assertEqual(BNET["ask_fex"](str(self.tmp), wait=5), "ok FEXCore-2610-d2rfix28-linux.wcp")
|
||||
self.assertEqual(self.requested, "appid=%s\n" % BNET["APP_ID"])
|
||||
self.assertFalse((self.tmp / BNET["FEX_RESULT"]).exists())
|
||||
|
||||
def test_no_answer_or_no_session_starts_without_one(self):
|
||||
with mock.patch.dict(BNET, {"say": lambda message: None}):
|
||||
self.assertIsNone(BNET["ask_fex"](str(self.tmp), wait=0.3))
|
||||
self.assertIsNone(BNET["ask_fex"](None))
|
||||
self.assertIsNone(BNET["ask_fex"](str(self.tmp / "gone")))
|
||||
|
||||
|
||||
class OpenTest(Temp):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
@@ -799,7 +766,6 @@ class OpenTest(Temp):
|
||||
self.alive = []
|
||||
self.menu = self.tmp / "droiddeck-battlenet.desktop"
|
||||
patcher = mock.patch.dict(BNET, {
|
||||
"ask_fex": lambda launch_dir, wait=0: "ok fex.wcp",
|
||||
"say": lambda message: None, "notify": lambda *a, **k: self.calls.append(("notify", a[0])),
|
||||
"wine_processes": lambda pfx, proc="/proc": list(self.alive),
|
||||
"stop": lambda processes, wait=0: self.calls.append(("stop", [pid for pid, _ in processes])) or self.alive.clear(),
|
||||
@@ -988,7 +954,6 @@ class Harness(Temp):
|
||||
self.states = []
|
||||
self.last = []
|
||||
patcher = mock.patch.dict(BNET, {
|
||||
"ask_fex": lambda launch_dir, wait=0: self.calls.append(("fex",)) or "ok fex.wcp",
|
||||
"say": lambda message: None, "notify": lambda *a, **k: self.calls.append(("notify", a[0])),
|
||||
"wine_processes": self.processes,
|
||||
"stop": lambda processes, wait=0: self.calls.append(("stop", sorted(pid for pid, _ in processes))),
|
||||
@@ -1019,7 +984,7 @@ class LaunchTest(Harness):
|
||||
self.states = [[], [], up, up + [(40, self.GAME)], up, up]
|
||||
self.assertEqual(BNET["launch"](self.root, "Fen"), 0)
|
||||
self.assertEqual(self.calls, [
|
||||
("fex",), ("start", "Battle.net Launcher.exe", None),
|
||||
("start", "Battle.net Launcher.exe", None),
|
||||
("spawn", "Battle.net.exe", "run", ["--exec=launch Fen"]),
|
||||
("stop", [10, 11, 12, 13, 14, 30]),
|
||||
])
|
||||
@@ -1034,7 +999,7 @@ class LaunchTest(Harness):
|
||||
with mock.patch.dict(BNET, {"GAME_SETTLE": 0}):
|
||||
self.assertEqual(BNET["launch"](self.root, "Fen"), 0)
|
||||
self.assertEqual(self.calls, [
|
||||
("fex",), ("start", "Battle.net Launcher.exe", None),
|
||||
("start", "Battle.net Launcher.exe", None),
|
||||
("spawn", "Battle.net.exe", "run", ["--exec=launch Fen"]),
|
||||
("stop", [10, 11, 12, 13, 14, 30]),
|
||||
("stop", [50]),
|
||||
|
||||
Reference in new issue
Block a user