Skip to content

[FIX] Switch to sniper runtime #2792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jul 24, 2023
31 changes: 27 additions & 4 deletions src/backend/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
appendFileSync,
writeFileSync
} from 'graceful-fs'
import { join } from 'path'
import { join, normalize } from 'path'

import {
defaultWinePrefix,
Expand Down Expand Up @@ -51,14 +51,17 @@ import {
LaunchPreperationResult,
RpcClient,
WineInstallation,
WineCommandArgs
WineCommandArgs,
SteamRuntime
} from 'common/types'
import { spawn } from 'child_process'
import shlex from 'shlex'
import { isOnline } from './online_monitor'
import { showDialogBoxModalAuto } from './dialog/dialog'
import { setupUbisoftConnect } from './storeManagers/legendary/setup'
import { gameManagerMap } from 'backend/storeManagers'
import * as VDF from '@node-steam/vdf'
import { readFileSync } from 'fs'

async function prepareLaunch(
gameSettings: GameSettings,
Expand Down Expand Up @@ -121,16 +124,36 @@ async function prepareLaunch(
gameSettings.useSteamRuntime &&
(isNative || gameSettings.wineVersion.type === 'proton')
if (shouldUseRuntime) {
// Determine which runtime to use based on toolmanifest.vdf which is shipped with proton
let nonNativeRuntime: SteamRuntime['type'] = 'soldier'
if (!isNative) {
try {
const parentPath = normalize(join(gameSettings.wineVersion.bin, '..'))
const requiredAppId = VDF.parse(
readFileSync(join(parentPath, 'toolmanifest.vdf'), 'utf-8')
).manifest?.require_tool_appid
if (requiredAppId === 1628350) nonNativeRuntime = 'sniper'
} catch (error) {
logError(
['Failed to parse toolmanifest.vdf:', error],
LogPrefix.Backend
)
}
}
// for native games lets use scout for now
const runtimeType = isNative ? 'scout' : 'soldier'
const runtimeType = isNative ? 'scout' : nonNativeRuntime
const { path, args } = await getSteamRuntime(runtimeType)
if (!path) {
return {
success: false,
failureReason:
'Steam Runtime is enabled, but no runtimes could be found\n' +
`Make sure Steam ${
isNative ? 'is' : 'and the "SteamLinuxRuntime - Soldier" are'
isNative
? 'is'
: `and the SteamLinuxRuntime - ${
nonNativeRuntime === 'sniper' ? 'Sniper' : 'Soldier'
} are`
} installed`
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/backend/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,15 @@ async function searchForExecutableOnPath(executable: string): Promise<string> {
}
}
async function getSteamRuntime(
requestedType: 'scout' | 'soldier'
requestedType: SteamRuntime['type']
): Promise<SteamRuntime> {
const steamLibraries = await getSteamLibraries()
const runtimeTypes: SteamRuntime[] = [
{
path: 'steamapps/common/SteamLinuxRuntime_sniper/run',
type: 'sniper',
args: ['--']
},
{
path: 'steamapps/common/SteamLinuxRuntime_soldier/run',
type: 'soldier',
Expand Down
2 changes: 1 addition & 1 deletion src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ interface GamepadInputEventMouse {

export interface SteamRuntime {
path: string
type: 'soldier' | 'scout'
type: 'sniper' | 'scout' | 'soldier'
args: string[]
}

Expand Down