From a3bc07e15a13a67931a9d10c84dc978a55b15f2b Mon Sep 17 00:00:00 2001 From: derrod Date: Wed, 1 Jun 2022 09:42:01 +0200 Subject: [PATCH] [core/utils] Add automatic exe overrides to workarounds --- legendary/core.py | 11 +++++++++-- legendary/utils/game_workarounds.py | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/legendary/core.py b/legendary/core.py index fa54ffb..cecb96b 100644 --- a/legendary/core.py +++ b/legendary/core.py @@ -38,7 +38,7 @@ from legendary.utils.crossover import * from legendary.utils.egl_crypt import decrypt_epic_data from legendary.utils.env import is_windows_mac_or_pyi from legendary.utils.eos import EOSOverlayApp, query_registry_entries -from legendary.utils.game_workarounds import is_opt_enabled, update_workarounds +from legendary.utils.game_workarounds import is_opt_enabled, update_workarounds, get_exe_override from legendary.utils.savegame_helper import SaveGameHelper from legendary.utils.selective_dl import games as sdl_games from legendary.utils.manifests import combine_manifests @@ -1432,10 +1432,17 @@ class LegendaryCore: if file_install_tag is None: file_install_tag = [] + + # Override exe at an install level to avoid breaking existing config overrides + executable = new_manifest.meta.launch_exe + if exe_override := get_exe_override(app_name=game.app_name): + self.log.info(f'Launch exe will be changed from "{executable}" to "{exe_override}" for compatibility') + executable = exe_override + igame = InstalledGame(app_name=game.app_name, title=game.app_title, version=new_manifest.meta.build_version, prereq_info=prereq, manifest_path=override_manifest, base_urls=base_urls, - install_path=install_path, executable=new_manifest.meta.launch_exe, + install_path=install_path, executable=executable, launch_parameters=new_manifest.meta.launch_command, can_run_offline=offline == 'true', requires_ot=ot == 'true', is_dlc=base_game is not None, install_size=anlres.install_size, diff --git a/legendary/utils/game_workarounds.py b/legendary/utils/game_workarounds.py index fe1dfcd..69aeb76 100644 --- a/legendary/utils/game_workarounds.py +++ b/legendary/utils/game_workarounds.py @@ -1,5 +1,7 @@ # coding: utf-8 +from sys import platform + # games where the download order optimizations are enabled by default # a set() of versions can be specified, empty set means all versions. _optimize_default = { @@ -11,6 +13,15 @@ _optimize_default = { } } +# Some games use launchers that don't work with Legendary, these are overriden here +_exe_overrides = { + 'kinglet': { + 'darwin': 'Base/Binaries/Win64EOS/CivilizationVI.exe', + 'linux': 'Base/Binaries/Win64EOS/CivilizationVI.exe', + 'win32': 'LaunchPad/LaunchPad.exe' + } +} + def is_opt_enabled(app_name, version): if (versions := _optimize_default.get(app_name.lower())) is not None: @@ -19,8 +30,15 @@ def is_opt_enabled(app_name, version): return False +def get_exe_override(app_name): + return _exe_overrides.get(app_name.lower(), {}).get(platform, None) + + def update_workarounds(api_data): if 'reorder_optimization' in api_data: _optimize_default.clear() _optimize_default.update(api_data['reorder_optimization']) + if 'executable_override' in api_data: + _exe_overrides.clear() + _exe_overrides.update(api_data['executable_override'])