Skip to content

Commit f83d036

Browse files
Etaash-mathamsettyCommandMCimLinguin
authored
[FIX] Switch to sniper runtime (#2792)
* [FIX] Switch to sniper runtime * fall back to soldier runtime (if sniper not found) * read vdf file to determine runtime * fix remaining issues * Update launcher.ts * Update launcher.ts * Update src/backend/launcher.ts Co-authored-by: Mathis Dröge <[email protected]> * Update src/backend/launcher.ts Co-authored-by: Mathis Dröge <[email protected]> * Update src/backend/utils.ts Co-authored-by: Mathis Dröge <[email protected]> * Update src/backend/launcher.ts Co-authored-by: Paweł Lidwin <[email protected]> * Update launcher.ts * Update launcher.ts --------- Co-authored-by: Mathis Dröge <[email protected]> Co-authored-by: Paweł Lidwin <[email protected]>
1 parent adf275c commit f83d036

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

src/backend/launcher.ts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
appendFileSync,
88
writeFileSync
99
} from 'graceful-fs'
10-
import { join } from 'path'
10+
import { join, normalize } from 'path'
1111

1212
import {
1313
defaultWinePrefix,
@@ -51,14 +51,17 @@ import {
5151
LaunchPreperationResult,
5252
RpcClient,
5353
WineInstallation,
54-
WineCommandArgs
54+
WineCommandArgs,
55+
SteamRuntime
5556
} from 'common/types'
5657
import { spawn } from 'child_process'
5758
import shlex from 'shlex'
5859
import { isOnline } from './online_monitor'
5960
import { showDialogBoxModalAuto } from './dialog/dialog'
6061
import { setupUbisoftConnect } from './storeManagers/legendary/setup'
6162
import { gameManagerMap } from 'backend/storeManagers'
63+
import * as VDF from '@node-steam/vdf'
64+
import { readFileSync } from 'fs'
6265

6366
async function prepareLaunch(
6467
gameSettings: GameSettings,
@@ -121,16 +124,36 @@ async function prepareLaunch(
121124
gameSettings.useSteamRuntime &&
122125
(isNative || gameSettings.wineVersion.type === 'proton')
123126
if (shouldUseRuntime) {
127+
// Determine which runtime to use based on toolmanifest.vdf which is shipped with proton
128+
let nonNativeRuntime: SteamRuntime['type'] = 'soldier'
129+
if (!isNative) {
130+
try {
131+
const parentPath = normalize(join(gameSettings.wineVersion.bin, '..'))
132+
const requiredAppId = VDF.parse(
133+
readFileSync(join(parentPath, 'toolmanifest.vdf'), 'utf-8')
134+
).manifest?.require_tool_appid
135+
if (requiredAppId === 1628350) nonNativeRuntime = 'sniper'
136+
} catch (error) {
137+
logError(
138+
['Failed to parse toolmanifest.vdf:', error],
139+
LogPrefix.Backend
140+
)
141+
}
142+
}
124143
// for native games lets use scout for now
125-
const runtimeType = isNative ? 'scout' : 'soldier'
144+
const runtimeType = isNative ? 'scout' : nonNativeRuntime
126145
const { path, args } = await getSteamRuntime(runtimeType)
127146
if (!path) {
128147
return {
129148
success: false,
130149
failureReason:
131150
'Steam Runtime is enabled, but no runtimes could be found\n' +
132151
`Make sure Steam ${
133-
isNative ? 'is' : 'and the "SteamLinuxRuntime - Soldier" are'
152+
isNative
153+
? 'is'
154+
: `and the SteamLinuxRuntime - ${
155+
nonNativeRuntime === 'sniper' ? 'Sniper' : 'Soldier'
156+
} are`
134157
} installed`
135158
}
136159
}

src/backend/utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,10 +633,15 @@ async function searchForExecutableOnPath(executable: string): Promise<string> {
633633
}
634634
}
635635
async function getSteamRuntime(
636-
requestedType: 'scout' | 'soldier'
636+
requestedType: SteamRuntime['type']
637637
): Promise<SteamRuntime> {
638638
const steamLibraries = await getSteamLibraries()
639639
const runtimeTypes: SteamRuntime[] = [
640+
{
641+
path: 'steamapps/common/SteamLinuxRuntime_sniper/run',
642+
type: 'sniper',
643+
args: ['--']
644+
},
640645
{
641646
path: 'steamapps/common/SteamLinuxRuntime_soldier/run',
642647
type: 'soldier',

src/common/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ interface GamepadInputEventMouse {
312312

313313
export interface SteamRuntime {
314314
path: string
315-
type: 'soldier' | 'scout'
315+
type: 'sniper' | 'scout' | 'soldier'
316316
args: string[]
317317
}
318318

0 commit comments

Comments
 (0)