[core/utils] Add automatic exe overrides to workarounds

This commit is contained in:
derrod 2022-06-01 09:42:01 +02:00
parent b7f4a9f45a
commit a3bc07e15a
2 changed files with 27 additions and 2 deletions

View file

@ -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,

View file

@ -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'])