mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix: Epic games get their manifest launch command
Epic manifests carry a launch command next to the launch executable, which the Epic launcher passes to the game. It was read and dropped, so Caravan SandWitch never got -PCStore=EGS and quit with "started outside of any known PC store". The manifest's launch command now joins the game's arguments, including for games already installed.
This commit is contained in:
1 parent
6e1621fe53
commit
46cd8e1777
6 files changed
+94
-4
No files matched your search
@@ -358,7 +358,11 @@ internal object EpicClientLibrary {
|
||||
write(File(manifests, "$guid.item"), item(install, tags, ownership == true).toString(2))
|
||||
runCatching { egstore(install, guid) { token } }.onFailure { Log.w(TAG, "${install.appName}: .egstore not written (${it.javaClass.simpleName})") }
|
||||
after.put(install.appName, JSONObject().put("guid", guid).put("signature", install.signature).apply { if (ownership != null) put("ownership", ownership) })
|
||||
StoreGameSidecar.read(install.folder)?.let { StoreLaunch.refreshLauncher(install.folder, it) }
|
||||
StoreGameSidecar.read(install.folder)?.let { sidecar ->
|
||||
val next = runCatching { manifestArgs(install, guid) }.getOrNull()?.let { withLaunchArgs(sidecar, it) } ?: sidecar
|
||||
if (next !== sidecar) next.write(install.folder)
|
||||
StoreLaunch.refreshLauncher(install.folder, next)
|
||||
}
|
||||
}
|
||||
for (name in before.keys().asSequence().toList()) {
|
||||
if (after.has(name)) continue
|
||||
@@ -376,6 +380,23 @@ internal object EpicClientLibrary {
|
||||
return changed
|
||||
}
|
||||
|
||||
private const val LAUNCH_ARGS = "launchArgs"
|
||||
|
||||
private fun manifestArgs(install: Install, guid: String): List<String>? {
|
||||
val manifest = File(install.folder, ".egstore/$guid.manifest").takeIf { it.isFile } ?: return null
|
||||
val args = EpicNative.inspect(manifest.readBytes(), JSONObject().put("op", "launch"))?.optJSONArray("args") ?: return null
|
||||
return List(args.length()) { args.optString(it) }.filter { it.isNotEmpty() }
|
||||
}
|
||||
|
||||
internal fun withLaunchArgs(sidecar: StoreGameSidecar, args: List<String>): StoreGameSidecar {
|
||||
val previous = sidecar.extra[LAUNCH_ARGS]?.split('\n')?.filter { it.isNotEmpty() }.orEmpty()
|
||||
val kept = sidecar.args.filterNot { it in previous }
|
||||
val next = kept + args.filterNot { it in kept }
|
||||
val extra = LinkedHashMap(sidecar.extra).apply { if (args.isEmpty()) remove(LAUNCH_ARGS) else put(LAUNCH_ARGS, args.joinToString("\n")) }
|
||||
if (next == sidecar.args && extra == sidecar.extra) return sidecar
|
||||
return sidecar.copy(args = next, extra = extra)
|
||||
}
|
||||
|
||||
private fun ownershipToken(token: String, install: Install): Boolean? =
|
||||
runCatching { EpicApiClient.getCustomAttribute(token, install.namespace, install.catalogItemId, "OwnershipToken") }
|
||||
.getOrNull()?.trim()?.lowercase()?.let { it == "true" }
|
||||
|
||||
Reference in new issue
Block a user