Skip to content

Commit

Permalink
[FIX] Switch to sniper runtime (#2792)
Browse files Browse the repository at this point in the history
* [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]>
  • Loading branch information
3 people authored Jul 24, 2023
1 parent adf275c commit f83d036
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
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 @@ -312,7 +312,7 @@ interface GamepadInputEventMouse {

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

Expand Down

0 comments on commit f83d036

Please sign in to comment.