Skip to content

[FIX]: Libraries shadowing #2866

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 10 commits into from
Jul 24, 2023
Binary file modified public/bin/darwin/gogdl
Binary file not shown.
Binary file modified public/bin/darwin/nile
Binary file not shown.
Binary file modified public/bin/linux/gogdl
Binary file not shown.
Binary file modified public/bin/linux/nile
Binary file not shown.
Binary file modified public/bin/win32/gogdl.exe
Binary file not shown.
Binary file modified public/bin/win32/nile.exe
Binary file not shown.
4 changes: 3 additions & 1 deletion src/backend/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ class GlobalConfigV0 extends GlobalConfig {
},
wineCrossoverBottle: 'Heroic',
winePrefix: isWindows ? '' : defaultWinePrefix,
wineVersion: defaultWine
wineVersion: defaultWine,
enableEsync: true,
enableFsync: true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is changing the default to be true right? is this intentional?

I'm fine with that, just want to be sure this was the idea

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I find it weird that we didn't have esync and fsync as default

} as AppSettings
}

Expand Down
34 changes: 17 additions & 17 deletions src/backend/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,13 @@ async function prepareWineLaunch(
}
}

const { folder_name: installFolderName } =
const { folder_name: installFolderName, install } =
gameManagerMap[runner].getGameInfo(appName)
const envVars = setupWineEnvVars(gameSettings, installFolderName)
const envVars = setupWineEnvVars(
gameSettings,
installFolderName,
install.install_path
)

return { success: true, envVars: envVars }
}
Expand Down Expand Up @@ -282,7 +286,11 @@ function setupEnvVars(gameSettings: GameSettings) {
* @param gameId If Proton and the Steam Runtime are used, the SteamGameId variable will be set to `heroic-gameId`
* @returns A Record that can be passed to execAsync/spawn
*/
function setupWineEnvVars(gameSettings: GameSettings, gameId = '0') {
function setupWineEnvVars(
gameSettings: GameSettings,
gameId = '0',
installPath?: string
) {
const { wineVersion, winePrefix, wineCrossoverBottle } = gameSettings

const ret: Record<string, string> = {}
Expand Down Expand Up @@ -311,6 +319,9 @@ function setupWineEnvVars(gameSettings: GameSettings, gameId = '0') {
case 'proton':
ret.STEAM_COMPAT_CLIENT_INSTALL_PATH = steamInstallPath
ret.STEAM_COMPAT_DATA_PATH = winePrefix
if (installPath) {
ret.STEAM_COMPAT_INSTALL_PATH = installPath
}
break
case 'crossover':
ret.CX_BOTTLE = wineCrossoverBottle
Expand Down Expand Up @@ -539,6 +550,7 @@ function launchCleanup(rpcClient?: RpcClient) {
async function runWineCommand({
gameSettings,
commandParts,
gameInstallPath,
wait,
protonVerb = 'run',
installFolderName,
Expand Down Expand Up @@ -590,7 +602,7 @@ async function runWineCommand({
const env_vars = {
...process.env,
...setupEnvVars(settings),
...setupWineEnvVars(settings, installFolderName)
...setupWineEnvVars(settings, installFolderName, gameInstallPath)
}

const isProton = wineVersion.type === 'proton'
Expand Down Expand Up @@ -710,7 +722,6 @@ async function callRunner(
const safeCommand = getRunnerCallWithoutCredentials(
[...commandParts],
options?.env,
options?.wrappers,
fullRunnerPath
)

Expand All @@ -736,16 +747,7 @@ async function callRunner(
}
}

// If we have wrappers (things we want to run before the command), set bin to the first wrapper
// and add every other wrapper and the actual bin to the start of filteredArgs
const wrappers = options?.wrappers || []
let bin = ''
if (wrappers.length) {
bin = wrappers.shift()!
commandParts.unshift(...wrappers, runner.bin)
} else {
bin = runner.bin
}
const bin = runner.bin

// check if the same command is currently running
// if so, return the same promise instead of running it again
Expand Down Expand Up @@ -884,7 +886,6 @@ async function callRunner(
function getRunnerCallWithoutCredentials(
commandParts: string[],
env: Record<string, string> | NodeJS.ProcessEnv = {},
wrappers: string[] = [],
runnerPath: string
): string {
const modifiedCommandParts = [...commandParts]
Expand Down Expand Up @@ -912,7 +913,6 @@ function getRunnerCallWithoutCredentials(

return [
...formattedEnvVars,
...wrappers.map(quoteIfNecessary),
quoteIfNecessary(runnerPath),
...modifiedCommandParts.map(quoteIfNecessary)
].join(' ')
Expand Down
3 changes: 2 additions & 1 deletion src/backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,12 +577,13 @@ async function runWineCommandOnGame(
logError('runWineCommand called on native game!', LogPrefix.Gog)
return { stdout: '', stderr: '' }
}
const { folder_name } = gameManagerMap[runner].getGameInfo(appName)
const { folder_name, install } = gameManagerMap[runner].getGameInfo(appName)
const gameSettings = await gameManagerMap[runner].getSettings(appName)

return runWineCommand({
gameSettings,
installFolderName: folder_name,
gameInstallPath: install.install_path,
commandParts,
wait,
protonVerb,
Expand Down
19 changes: 10 additions & 9 deletions src/backend/storeManagers/gog/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,15 @@ export async function launch(
let commandEnv = isWindows
? process.env
: { ...process.env, ...setupEnvVars(gameSettings) }
let wineFlag: string[] = []

const wrappers = setupWrappers(
gameSettings,
mangoHudCommand,
gameModeBin,
steamRuntime?.length ? [...steamRuntime] : undefined
)

let wineFlag: string[] = ['--wrapper', shlex.join(wrappers)]

if (!isNative(appName)) {
const {
Expand Down Expand Up @@ -503,7 +511,7 @@ export async function launch(
? wineExec.replaceAll("'", '')
: wineExec

wineFlag = getWineFlags(wineBin, wineType)
wineFlag = [...getWineFlags(wineBin, wineType, shlex.join(wrappers))]
}

const commandParts = [
Expand All @@ -517,17 +525,10 @@ export async function launch(
...shlex.split(launchArguments ?? ''),
...shlex.split(gameSettings.launcherArgs ?? '')
]
const wrappers = setupWrappers(
gameSettings,
mangoHudCommand,
gameModeBin,
steamRuntime?.length ? [...steamRuntime] : undefined
)

const fullCommand = getRunnerCallWithoutCredentials(
commandParts,
commandEnv,
wrappers,
join(...Object.values(getGOGdlBin()))
)
appendFileSync(
Expand Down
3 changes: 3 additions & 0 deletions src/backend/storeManagers/gog/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ async function setup(
}
await runWineCommand({
gameSettings,
gameInstallPath: gameInfo.install.install_path,
commandParts: command,
wait: true,
protonVerb: 'runinprefix'
Expand Down Expand Up @@ -282,6 +283,7 @@ async function setup(

await runWineCommand({
gameSettings,
gameInstallPath: gameInfo.install.install_path,
commandParts: [executablePath, ...exeArguments],
wait: true,
protonVerb: 'waitforexitandrun',
Expand Down Expand Up @@ -485,6 +487,7 @@ async function setup(
logInfo(['Setup: Executing', command, `${supportDir}`], LogPrefix.Gog)
await runWineCommand({
gameSettings,
gameInstallPath: gameInfo.install.install_path,
commandParts: command,
wait: true,
protonVerb: 'waitforexitandrun',
Expand Down
23 changes: 13 additions & 10 deletions src/backend/storeManagers/legendary/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,16 @@ export async function launch(
let commandEnv = isWindows
? process.env
: { ...process.env, ...setupEnvVars(gameSettings) }
let wineFlag: string[] = []

const wrappers = setupWrappers(
gameSettings,
mangoHudCommand,
gameModeBin,
steamRuntime?.length ? [...steamRuntime] : undefined
)

let wineFlag: string[] = ['--wrapper', shlex.join(wrappers)]

if (!isNative(appName)) {
// -> We're using Wine/Proton on Linux or CX on Mac
const {
Expand Down Expand Up @@ -860,7 +869,7 @@ export async function launch(
? wineExec.replaceAll("'", '')
: wineExec

wineFlag = getWineFlags(wineBin, wineType)
wineFlag = [...getWineFlags(wineBin, wineType, shlex.join(wrappers))]
}

const commandParts = [
Expand All @@ -874,17 +883,10 @@ export async function launch(
isCLINoGui ? '--skip-version-check' : '',
...shlex.split(gameSettings.launcherArgs ?? '')
]
const wrappers = setupWrappers(
gameSettings,
mangoHudCommand,
gameModeBin,
steamRuntime?.length ? [...steamRuntime] : undefined
)

const fullCommand = getRunnerCallWithoutCredentials(
commandParts,
commandEnv,
wrappers,
join(...Object.values(getLegendaryBin()))
)
appendFileSync(
Expand Down Expand Up @@ -990,11 +992,12 @@ export async function runWineCommandOnGame(
return { stdout: '', stderr: '' }
}

const { folder_name } = getGameInfo(appName)
const { folder_name, install } = getGameInfo(appName)
const gameSettings = await getSettings(appName)

return runWineCommandUtil({
gameSettings,
gameInstallPath: install.install_path,
installFolderName: folder_name,
commandParts,
wait,
Expand Down
20 changes: 10 additions & 10 deletions src/backend/storeManagers/nile/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,15 @@ export async function launch(
let commandEnv = isWindows
? process.env
: { ...process.env, ...setupEnvVars(gameSettings) }
let wineFlag: string[] = []

const wrappers = setupWrappers(
gameSettings,
mangoHudCommand,
gameModeBin,
steamRuntime?.length ? [...steamRuntime] : undefined
)

let wineFlag: string[] = ['--wrapper', shlex.join(wrappers)]

if (!isNative()) {
// -> We're using Wine/Proton on Linux or CX on Mac
Expand Down Expand Up @@ -385,7 +393,7 @@ export async function launch(
: wineExec

wineFlag = [
...getWineFlags(wineBin, wineType),
...getWineFlags(wineBin, wineType, shlex.join(wrappers)),
'--wine-prefix',
gameSettings.winePrefix
]
Expand All @@ -399,17 +407,9 @@ export async function launch(
...shlex.split(gameSettings.launcherArgs ?? ''),
appName
]
const wrappers = setupWrappers(
gameSettings,
mangoHudCommand,
gameModeBin,
steamRuntime?.length ? [...steamRuntime] : undefined
)

const fullCommand = getRunnerCallWithoutCredentials(
commandParts,
commandEnv,
wrappers,
join(...Object.values(getNileBin()))
)
appendFileSync(
Expand Down
1 change: 1 addition & 0 deletions src/backend/storeManagers/nile/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export default async function setup(

await runWineCommand({
gameSettings,
gameInstallPath: basePath,
commandParts: [action.Command, ...exeArguments],
wait: true,
protonVerb: 'waitforexitandrun',
Expand Down
7 changes: 4 additions & 3 deletions src/backend/utils/compatibility_layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,15 @@ export async function getGamingPortingToolkitWine(): Promise<

export function getWineFlags(
wineBin: string,
wineType: WineInstallation['type']
wineType: WineInstallation['type'],
wrapper: string
) {
switch (wineType) {
case 'wine':
case 'toolkit':
return ['--wine', wineBin]
return ['--wine', wineBin, '--wrapper', wrapper]
case 'proton':
return ['--no-wine', '--wrapper', `'${wineBin}' run`]
return ['--no-wine', '--wrapper', `${wrapper} '${wineBin}' run`]
default:
return []
}
Expand Down
7 changes: 6 additions & 1 deletion src/backend/wiki_game_info/gamesdb/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ export async function getInfoFromGamesDB(
): Promise<GamesDBInfo | null> {
logInfo(`Getting GamesDB data for ${title}`, LogPrefix.ExtraGameInfo)

const storeMap = { legendary: 'epic', gog: 'gog', sideloaded: undefined }
const storeMap: { [key in Runner]: string | undefined } = {
legendary: 'epic',
gog: 'gog',
nile: 'amazon',
sideload: undefined
}
const storeName = storeMap[runner]
if (!storeName) {
return { steamID: '' }
Expand Down
1 change: 1 addition & 0 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ export type WineCommandArgs = {
wait?: boolean
protonVerb?: ProtonVerb
gameSettings?: GameSettings
gameInstallPath?: string
installFolderName?: string
options?: CallRunnerOptions
startFolder?: string
Expand Down
7 changes: 5 additions & 2 deletions src/frontend/hooks/useSettingsContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ const useSettingsContext = ({ appName, gameInfo, runner }: Props) => {
const isDefault = appName === 'default'
const isLinux = platform === 'linux'
const isMac = platform === 'darwin'
const isMacNative = isMac && (gameInfo?.is_mac_native || false)
const isLinuxNative = isLinux && (gameInfo?.is_linux_native || false)
const isMacNative =
isMac &&
(['Mac', 'osx'].includes(gameInfo?.install.platform ?? '') || false)
const isLinuxNative =
isLinux && (gameInfo?.install.platform === 'linux' || false)

// Load Heroic's or game's config, only if not loaded already
useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/state/GlobalState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class GlobalState extends PureComponent<Props> {
},
amazon: {
library: this.loadAmazonLibrary(),
username: nileConfigStore.get_nodefault('userData.name')
username: nileConfigStore.get_nodefault('userData.given_name')
},
wineVersions: wineDownloaderInfoStore.get('wine-releases', []),
error: false,
Expand Down