Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00c0c6174e |
No files matched your search
@@ -252,13 +252,15 @@ self-extractor stops at "Path not found", so the values it installs are applied
|
||||
`goggame-<id>.info`, and a script's own `setRegistry` entries always win over the built-in table.
|
||||
|
||||
The script's `supportData` actions run right after: files and folders from the game folder
|
||||
(`{app}`) or its support files (`{supportDir}`, `support/<id>/`) are copied to `{userdocs}` and
|
||||
`{localappdata}` in the prefix, and `type: folder` without a source creates the folder. Mods such
|
||||
as one-click editions ship their `Plugins.txt` and INI files this way. Paths match without regard
|
||||
(`{app}`) or its support files (`{supportDir}`, `support/<id>/`) are copied to `{userdocs}`,
|
||||
`{localappdata}` or `{userappdata}` in the prefix, and `type: folder` without a source creates the
|
||||
folder. Mods such as one-click editions ship their `Plugins.txt` and INI files this way. The
|
||||
`savePath` action's `savePath` folder is created with the same path rules, including the common
|
||||
case where a one-click edition names it again as a `supportData` folder. Paths match without regard
|
||||
to case, links are copied as links, and a path outside those folders is refused. A file the
|
||||
player already has is replaced only when the action says `overwrite`. `.droiddeck-gog-support` in
|
||||
the prefix holds the actions' hash, so they run once per script revision and a player's later
|
||||
edits stay.
|
||||
player already has is replaced only when the action says `overwrite`. `.droiddeck-gog-support` and
|
||||
`.droiddeck-gog-save-path` in the prefix hold the actions' hashes, so they run once per script
|
||||
revision and a player's later edits stay.
|
||||
|
||||
A GOG game's exe comes from its own manifest first: `goggame-<id>.info`'s play task in category
|
||||
`game` (`isPrimary` first), or a primary `launcher` task for launcher games, whose `path` stays
|
||||
|
||||
@@ -968,6 +968,7 @@ def prepare_gog(sidecar, compat_data, launch_dir):
|
||||
GOG_SCRIPTS = "goggame-*.script"
|
||||
GOG_REGISTRY_MARK = ".droiddeck-gog-registry"
|
||||
GOG_SUPPORT_MARK = ".droiddeck-gog-support"
|
||||
GOG_SAVE_PATH_MARK = ".droiddeck-gog-save-path"
|
||||
GOG_ROOTS = {"HKEY_LOCAL_MACHINE": "HKEY_LOCAL_MACHINE", "HKLM": "HKEY_LOCAL_MACHINE",
|
||||
"HKEY_CURRENT_USER": "HKEY_CURRENT_USER", "HKCU": "HKEY_CURRENT_USER",
|
||||
"HKEY_CLASSES_ROOT": "HKEY_CLASSES_ROOT", "HKCR": "HKEY_CLASSES_ROOT"}
|
||||
@@ -1716,7 +1717,7 @@ def prepare_steam_ea(argv, compat_data, launch_dir):
|
||||
return REPLACED
|
||||
|
||||
|
||||
def gog_support_actions(folder):
|
||||
def gog_script_actions(folder, name):
|
||||
found = []
|
||||
for script in sorted(Path(folder).glob(GOG_SCRIPTS)):
|
||||
product = script.name[len("goggame-"):-len(".script")]
|
||||
@@ -1726,17 +1727,22 @@ def gog_support_actions(folder):
|
||||
continue
|
||||
for action in actions if isinstance(actions, list) else []:
|
||||
install = action.get("install") if isinstance(action, dict) else None
|
||||
if isinstance(install, dict) and install.get("action") == "supportData" \
|
||||
if isinstance(install, dict) and install.get("action") == name \
|
||||
and isinstance(install.get("arguments"), dict):
|
||||
found.append((product, install["arguments"]))
|
||||
return found
|
||||
|
||||
|
||||
def gog_support_actions(folder):
|
||||
return gog_script_actions(folder, "supportData")
|
||||
|
||||
|
||||
def gog_support_bases(folder, product, pfx):
|
||||
user = Path(pfx) / "drive_c" / "users" / "steamuser"
|
||||
support = Path(folder) / "support" / product
|
||||
return {"app": Path(folder), "supportdir": support, "support": support,
|
||||
"userdocs": user / "Documents", "localappdata": user / "AppData" / "Local"}
|
||||
"userdocs": user / "Documents", "localappdata": user / "AppData" / "Local",
|
||||
"userappdata": user / "AppData" / "Roaming"}
|
||||
|
||||
|
||||
def gog_inside(path, base):
|
||||
@@ -1830,6 +1836,44 @@ def gog_support_data(folder, compat_data, proton):
|
||||
return "copied=%d%s" % (copied, note)
|
||||
|
||||
|
||||
def gog_save_paths(folder, compat_data, proton):
|
||||
actions = gog_script_actions(folder, "savePath")
|
||||
if not actions:
|
||||
return "none"
|
||||
pfx = Path(compat_data) / "pfx" if compat_data else None
|
||||
if not pfx or not (pfx / "drive_c" / "users" / "steamuser").is_dir():
|
||||
made = create_prefix(compat_data, proton)
|
||||
if made not in ("present", "created") or not (pfx / "drive_c" / "users" / "steamuser").is_dir():
|
||||
return "no-prefix"
|
||||
stamp = hashlib.sha256(json.dumps(actions, sort_keys=True).encode("utf-8")).hexdigest()
|
||||
marker = pfx / GOG_SAVE_PATH_MARK
|
||||
try:
|
||||
if marker.is_file() and marker.read_text() == stamp:
|
||||
return "ready"
|
||||
except OSError:
|
||||
pass
|
||||
paths = skipped = 0
|
||||
for product, arguments in actions:
|
||||
bases = gog_support_bases(folder, product, pfx)
|
||||
found = gog_support_path(arguments.get("savePath") or arguments.get("target"), bases)
|
||||
if found is None:
|
||||
skipped += 1
|
||||
continue
|
||||
target, _root = found
|
||||
try:
|
||||
target.mkdir(parents=True, exist_ok=True)
|
||||
paths += 1
|
||||
except OSError:
|
||||
skipped += 1
|
||||
note = " skipped=%d" % skipped if skipped else ""
|
||||
if not skipped:
|
||||
try:
|
||||
marker.write_text(stamp)
|
||||
except OSError:
|
||||
pass
|
||||
return "paths=%d%s" % (paths, note)
|
||||
|
||||
|
||||
def main(argv):
|
||||
if os.environ.get("DROIDDECK_GOG_MAINTENANCE") == "1":
|
||||
return 0
|
||||
@@ -1876,6 +1920,7 @@ def main(argv):
|
||||
prepare_gog(sidecar, compat_data, launch_dir)
|
||||
log("gog registry: " + apply_gog_registry(folder, compat_data, os.environ.get("DD_STORE_PROTON", "")))
|
||||
log("gog support data: " + gog_support_data(folder, compat_data, os.environ.get("DD_STORE_PROTON", "")))
|
||||
log("gog save paths: " + gog_save_paths(folder, compat_data, os.environ.get("DD_STORE_PROTON", "")))
|
||||
if store == "rockstar":
|
||||
if game not in ROCKSTAR_TITLES and not rockstar_sdk(folder, sidecar):
|
||||
if compat_data:
|
||||
|
||||
@@ -626,6 +626,10 @@ def support_data(**arguments):
|
||||
return {'install': {'action': 'supportData', 'arguments': arguments}, 'name': 'supportData'}
|
||||
|
||||
|
||||
def save_path(**arguments):
|
||||
return {'install': {'action': 'savePath', 'arguments': arguments}, 'name': 'saveFolders'}
|
||||
|
||||
|
||||
class GogSupportData(unittest.TestCase):
|
||||
def prefix(self, root):
|
||||
user = Path(root) / 'compat/pfx/drive_c/users/steamuser'
|
||||
@@ -809,6 +813,101 @@ class GogSupportData(unittest.TestCase):
|
||||
self.assertTrue((Path(root) / 'compat/pfx/drive_c/users/steamuser/Documents/My Games/G').is_dir())
|
||||
|
||||
|
||||
class GogSavePaths(unittest.TestCase):
|
||||
def prefix(self, root):
|
||||
user = Path(root) / 'compat/pfx/drive_c/users/steamuser'
|
||||
user.mkdir(parents=True)
|
||||
return user
|
||||
|
||||
def test_the_london_script_creates_its_save_path_and_keeps_player_settings(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
folder = game(root, store_id='gog', ident='1897848199')
|
||||
user = self.prefix(root)
|
||||
support = folder / 'support/1897848199'
|
||||
(support / 'docs').mkdir(parents=True)
|
||||
(folder / '__AppData').mkdir()
|
||||
(folder / '__AppData/save.dat').write_text('save')
|
||||
for name in ('Fallout4Prefs.ini', 'Fallout4.ini'):
|
||||
(support / 'docs' / name).write_text('[Archive]\n')
|
||||
for name in ('DLCList.txt', 'Plugins.txt', 'UserDownloadedContent.txt'):
|
||||
(support / name).write_text('*LondonWorldSpace.esm\n')
|
||||
gog_script(folder, '1897848199', [
|
||||
save_path(savePath='{userdocs}/My Games/Fallout4', type='folder'),
|
||||
set_registry(root='HKLM', subkey='Software\\Bethesda Softworks\\Fallout4',
|
||||
valueName='Installed Path', valueData='{app}\\', valueType='string'),
|
||||
support_data(type='folder', target='{userdocs}/My Games/Fallout4'),
|
||||
support_data(type='folder', target='{localappdata}/Fallout4'),
|
||||
support_data(type='file', overwrite=True, source='{supportDir}/docs/Fallout4Prefs.ini',
|
||||
target='{userdocs}/My Games/Fallout4/Fallout4Prefs.ini'),
|
||||
support_data(type='file', overwrite=True, source='{supportDir}/docs/Fallout4.ini',
|
||||
target='{userdocs}/My Games/Fallout4/Fallout4.ini'),
|
||||
support_data(type='file', overwrite=True, source='{supportDir}/DLCList.txt',
|
||||
target='{localappdata}/Fallout4/DLCList.txt'),
|
||||
support_data(type='file', overwrite=True, source='{supportDir}/Plugins.txt',
|
||||
target='{localappdata}/Fallout4/Plugins.txt'),
|
||||
support_data(type='file', overwrite=True, source='{supportDir}/UserDownloadedContent.txt',
|
||||
target='{localappdata}/Fallout4/UserDownloadedContent.txt'),
|
||||
support_data(type='folder', overwrite=True, source='{app}/__AppData', target='{localappdata}/Fallout4'),
|
||||
])
|
||||
with patch.object(store, 'create_prefix') as create:
|
||||
self.assertEqual('copied=6', store.gog_support_data(folder, root + '/compat', '/proton'))
|
||||
self.assertEqual('paths=1', store.gog_save_paths(folder, root + '/compat', '/proton'))
|
||||
create.assert_not_called()
|
||||
saves = user / 'Documents/My Games/Fallout4'
|
||||
self.assertTrue(saves.is_dir())
|
||||
self.assertEqual('[Archive]\n', (saves / 'Fallout4.ini').read_text())
|
||||
self.assertEqual('*LondonWorldSpace.esm\n', (user / 'AppData/Local/Fallout4/Plugins.txt').read_text())
|
||||
self.assertTrue((Path(root) / 'compat/pfx' / store.GOG_SAVE_PATH_MARK).is_file())
|
||||
(saves / 'my settings.ini').write_text('player')
|
||||
self.assertEqual('ready', store.gog_save_paths(folder, root + '/compat', '/proton'))
|
||||
self.assertEqual('player', (saves / 'my settings.ini').read_text())
|
||||
|
||||
def test_only_save_path_actions_create_known_folders(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
folder = game(root, store_id='gog', ident='9')
|
||||
user = self.prefix(root)
|
||||
saves = user / 'Documents/My Games/Fallout4'
|
||||
saves.mkdir(parents=True)
|
||||
(saves / 'Fallout4Prefs.ini').write_text('player')
|
||||
gog_script(folder, '9', [
|
||||
set_registry(root='HKLM', subkey='Software\\Game', valueName='a', valueData='b', valueType='string'),
|
||||
{'install': {'action': 'createFolder', 'arguments': {'savePath': '{userdocs}/Other'}}},
|
||||
save_path(savePath='{windir}/evil'),
|
||||
save_path(savePath='{userdocs}/../../escape'),
|
||||
save_path(savePath='{userappdata}/Ubisoft/Anno1404/Config'),
|
||||
])
|
||||
self.assertEqual('paths=1 skipped=2', store.gog_save_paths(folder, root + '/compat', '/proton'))
|
||||
self.assertTrue((user / 'AppData/Roaming/Ubisoft/Anno1404/Config').is_dir())
|
||||
self.assertFalse((user / 'Documents/Other').exists())
|
||||
self.assertFalse((Path(root) / 'escape').exists())
|
||||
self.assertEqual('player', (saves / 'Fallout4Prefs.ini').read_text())
|
||||
self.assertFalse((Path(root) / 'compat/pfx' / store.GOG_SAVE_PATH_MARK).exists())
|
||||
|
||||
def test_without_save_paths_no_prefix_is_made(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
folder = game(root, store_id='gog', ident='9')
|
||||
gog_script(folder, '9', [set_registry(root='HKLM', subkey='Software\\Game', valueName='a',
|
||||
valueData='b', valueType='string')])
|
||||
with patch.object(store, 'create_prefix') as create:
|
||||
self.assertEqual('none', store.gog_save_paths(folder, root + '/compat', '/proton'))
|
||||
create.assert_not_called()
|
||||
|
||||
def test_a_missing_prefix_is_made_first(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
folder = game(root, store_id='gog', ident='9')
|
||||
gog_script(folder, '9', [save_path(savePath='{userdocs}/My Games/G')])
|
||||
with patch.object(store, 'create_prefix', return_value='failed') as create:
|
||||
self.assertEqual('no-prefix', store.gog_save_paths(folder, root + '/compat', '/proton'))
|
||||
create.assert_called_once_with(root + '/compat', '/proton')
|
||||
|
||||
def made(compat_data, proton):
|
||||
self.prefix(root)
|
||||
return 'created'
|
||||
with patch.object(store, 'create_prefix', side_effect=made):
|
||||
self.assertEqual('paths=1', store.gog_save_paths(folder, root + '/compat', '/proton'))
|
||||
self.assertTrue((Path(root) / 'compat/pfx/drive_c/users/steamuser/Documents/My Games/G').is_dir())
|
||||
|
||||
|
||||
class GogRegistry(unittest.TestCase):
|
||||
def test_patch_registration_uses_authentic_build_and_the_prefix_registry_executable(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
|
||||
Reference in new issue
Block a user