diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet b/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet index 6e695d930..68c3ea6d7 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet @@ -24,6 +24,7 @@ CLIENT = "Battle.net.exe" CONFIG = ("users", "steamuser", "AppData", "Roaming", "Battle.net", "Battle.net.config") DEFAULT_CONFIG = {"Client": {"HardwareAcceleration": "false", "Streaming": {"StreamingEnabled": "false"}}} LAUNCH_BEHAVIOR = ("GameLaunchWindowBehavior", "2") +CLIENT_32_BIT = ("s1",) CACHE = os.path.join(HOME, ".cache", "droiddeck", "battlenet") MENU = "/usr/local/share/applications/droiddeck-battlenet.desktop" WALLPAPER_DIR = ("users", "steamuser", "AppData", "Local", "DroidDeck") @@ -145,6 +146,12 @@ def write_config(root, library=None): and str(client["Install"].get("DefaultInstallPath", "")).rstrip("/\\") != install_path(library): client["Install"]["DefaultInstallPath"] = install_path(library) changes.append("library") + games = config.setdefault("Games", {}) + for uid in CLIENT_32_BIT if isinstance(games, dict) else (): + game = games.setdefault(uid, {}) + if isinstance(game, dict) and game.get("Run64BitSet") != "true": + game.update(Run64Bit="false", Run64BitSet="true") + changes.append("32-bit") if not changes: return None os.makedirs(os.path.dirname(path), exist_ok=True) @@ -361,7 +368,8 @@ def configure(root, library=None): say("Battle.net's desktop wallpaper not set: %s" % error) enable_gamepad(root) if change == "first": - say("wrote Battle.net's first config: hardware acceleration off, streaming off, closing itself as it launches a game") + say("wrote Battle.net's first config: hardware acceleration off, streaming off, closing itself as it launches a game, " + "StarCraft on its 32-bit client") elif change: if "launch" in change: say("Battle.net's config: closing itself as it launches a game") @@ -369,6 +377,8 @@ def configure(root, library=None): say("Battle.net's config: games install to %s" % library) if "acceleration" in change: say("Battle.net's config: browser hardware acceleration off") + if "32-bit" in change: + say("Battle.net's config: StarCraft starts its 32-bit client") def write_menu(path=MENU): diff --git a/tools/tests/test_battlenet.py b/tools/tests/test_battlenet.py index 34edd448e..1c0bc1921 100644 --- a/tools/tests/test_battlenet.py +++ b/tools/tests/test_battlenet.py @@ -139,13 +139,29 @@ class ConfigAndMenuTest(Temp): self.assertEqual(config["Client"]["GameLaunchWindowBehavior"], "2") self.assertIsNone(BNET["write_config"](root)) path.write_text('{"Client": {"HardwareAcceleration": "false", "GameLaunchWindowBehavior": "0"}, "Games": {"osi": {}}}') - self.assertEqual(BNET["write_config"](root), "launch") + self.assertEqual(BNET["write_config"](root), "launch 32-bit") config = json.loads(path.read_text()) - self.assertEqual(config, {"Client": {"HardwareAcceleration": "false", "GameLaunchWindowBehavior": "2"}, "Games": {"osi": {}}}) + self.assertEqual(config, {"Client": {"HardwareAcceleration": "false", "GameLaunchWindowBehavior": "2"}, + "Games": {"osi": {}, "s1": {"Run64Bit": "false", "Run64BitSet": "true"}}}) path.write_text('{"Client": {"HardwareAcceleration": "true", "GameLaunchWindowBehavior": "2"}}') - self.assertEqual(BNET["write_config"](root), "acceleration") + self.assertEqual(BNET["write_config"](root), "acceleration 32-bit") self.assertEqual(json.loads(path.read_text())["Client"]["HardwareAcceleration"], "false") + def test_starcraft_starts_its_32_bit_client_until_a_player_picks_one(self): + root = str(self.tmp) + BNET["write_config"](root) + self.assertEqual(json.loads(self.config_path().read_text())["Games"], {"s1": {"Run64Bit": "false", "Run64BitSet": "true"}}) + self.config_path().write_text('{"Client": {"HardwareAcceleration": "false", "GameLaunchWindowBehavior": "2"}, ' + '"Games": {"s1": {"ServerUid": "s1", "Run64Bit": "true"}}}') + self.assertEqual(BNET["write_config"](root), "32-bit") + self.assertEqual(json.loads(self.config_path().read_text())["Games"]["s1"], + {"ServerUid": "s1", "Run64Bit": "false", "Run64BitSet": "true"}) + self.config_path().write_text('{"Client": {"HardwareAcceleration": "false", "GameLaunchWindowBehavior": "2"}, ' + '"Games": {"s1": {"Run64Bit": "true", "Run64BitSet": "true"}}}') + self.assertIsNone(BNET["write_config"](root)) + self.config_path().write_text('{"Client": {"HardwareAcceleration": "false", "GameLaunchWindowBehavior": "2"}, "Games": []}') + self.assertIsNone(BNET["write_config"](root)) + def test_games_install_to_the_chosen_library(self): root = str(self.tmp) BNET["write_config"](root)