Skip to content

Commit

Permalink
[TECH]: ship comet's communication service dummy with Heroic (#3923)
Browse files Browse the repository at this point in the history
* tech: ship comet's communication service dummy with Heroic

* improv: use winepath to get unix location

* add ignoreLogging to runWineCommand allowing to bypass PROTON_LOG

* fix: paralel downloads for comet components
  • Loading branch information
imLinguin authored Aug 11, 2024
1 parent b279d61 commit 13e2451
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 43 deletions.
8 changes: 6 additions & 2 deletions electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ mac:
teamId: DLB2RYLUDX
extendInfo:
com.apple.security.cs.allow-jit: true
files: build/bin/*/darwin/*
files:
- build/bin/*/darwin/*
- build/bin/x64/win32/GalaxyCommunication.exe

dmg:
background: public/dmg.png
Expand All @@ -63,7 +65,9 @@ linux:
desktop:
Name: Heroic Games Launcher
Comment[de]: Ein Open Source Spielelauncher for GOG und Epic Games
files: build/bin/*/linux/*
files:
- build/bin/*/linux/*
- build/bin/x64/win32/GalaxyCommunication.exe

snap:
base: core20
Expand Down
26 changes: 19 additions & 7 deletions meta/downloadHelperBinaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ const pathExists = async (path: string): Promise<boolean> =>

async function downloadFile(url: string, dst: string) {
const response = await fetch(url, {
keepalive: true,
headers: {
'User-Agent': 'HeroicBinaryUpdater/1.0'
}
})
if (response.status !== 200) {
throw Error(`Failed to download ${url}: ${response.status}`)
}
await mkdir(dirname(dst), { recursive: true })
const fileStream = createWriteStream(dst, { flags: 'w' })
await finished(Readable.fromWeb(response.body).pipe(fileStream))
Expand Down Expand Up @@ -139,11 +143,19 @@ async function downloadNile() {
}

async function downloadComet() {
return downloadGithubAssets(
'comet',
'imLinguin/comet',
RELEASE_TAGS['comet'],
{
return Promise.all([
downloadGithubAssets(
'GalaxyCommunication',
'imLinguin/comet',
RELEASE_TAGS['comet'],
{
x64: {
win32: 'GalaxyCommunication-dummy.exe'
},
arm64: {}
}
),
downloadGithubAssets('comet', 'imLinguin/comet', RELEASE_TAGS['comet'], {
x64: {
linux: 'comet-x86_64-unknown-linux-gnu',
darwin: 'comet-x86_64-apple-darwin',
Expand All @@ -152,8 +164,8 @@ async function downloadComet() {
arm64: {
darwin: 'comet-aarch64-apple-darwin'
}
}
)
})
])
}

/**
Expand Down
1 change: 1 addition & 0 deletions public/bin/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
**/nile.exe
**/comet
**/comet.exe
**/GalaxyCommunication.exe
.release_tags
60 changes: 40 additions & 20 deletions src/backend/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import {
isSteamDeckGameMode,
runtimePath,
userHome,
defaultUmuPath
defaultUmuPath,
publicDir
} from './constants'
import {
constructAndUpdateRPC,
Expand Down Expand Up @@ -81,6 +82,7 @@ import { storeMap } from 'common/utils'
import { runWineCommandOnGame } from './storeManagers/legendary/games'
import { sendFrontendMessage } from './main_window'
import { getUmuPath, isUmuSupported } from './utils/compatibility_layers'
import { copyFile } from 'fs/promises'

async function prepareLaunch(
gameSettings: GameSettings,
Expand Down Expand Up @@ -372,26 +374,38 @@ async function prepareWineLaunch(
}
}

if (runner === 'gog' && experimentalFeatures?.cometSupport !== false) {
if (isOnline() && !(await isInstalled('comet_dummy_service'))) {
await download('comet_dummy_service')
}
const installerScript = join(
runtimePath,
'comet_dummy_service',
'install-dummy-service.bat'
)
if (existsSync(installerScript)) {
await runWineCommand({
commandParts: [installerScript],
try {
if (runner === 'gog' && experimentalFeatures?.cometSupport !== false) {
const communicationSource = join(
publicDir,
'bin/x64/win32/GalaxyCommunication.exe'
)

const galaxyCommPath =
'C:\\ProgramData\\GOG.com\\Galaxy\\redists\\GalaxyCommunication.exe'
const communicationDest = await getWinePath({
path: galaxyCommPath,
gameSettings,
protonVerb: 'runinprefix'
variant: 'unix'
})
} else {
logWarning(
"Comet dummy service isn't downloaded, online functionality may not work"
)

if (!existsSync(communicationDest)) {
mkdirSync(dirname(communicationDest), { recursive: true })
await copyFile(communicationSource, communicationDest)
await runWineCommand({
commandParts: [
'sc',
'create',
'GalaxyCommunication',
`binpath=${galaxyCommPath}`
],
gameSettings,
protonVerb: 'runinprefix'
})
}
}
} catch (err) {
logError('Failed to install GalaxyCommunication dummy into the prefix')
}

// If DXVK/VKD3D installation is enabled, install it
Expand Down Expand Up @@ -841,7 +855,8 @@ async function runWineCommand({
installFolderName,
options,
startFolder,
skipPrefixCheckIKnowWhatImDoing = false
skipPrefixCheckIKnowWhatImDoing = false,
ignoreLogging = false
}: WineCommandArgs): Promise<{
stderr: string
stdout: string
Expand Down Expand Up @@ -896,6 +911,10 @@ async function runWineCommand({
PROTON_VERB: protonVerb
}

if (ignoreLogging) {
delete env_vars['PROTON_LOG']
}

const wineBin = wineVersion.bin.replaceAll("'", '')
const umuSupported = await isUmuSupported(wineVersion.type)
const runnerBin = umuSupported ? await getUmuPath() : wineBin
Expand Down Expand Up @@ -1345,7 +1364,8 @@ async function getWinePath({
path
],
wait: false,
protonVerb: 'runinprefix'
protonVerb: 'runinprefix',
ignoreLogging: true
})
return stdout.trim()
}
Expand Down
10 changes: 1 addition & 9 deletions src/backend/wine/runtimes/runtimes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,7 @@ async function _get(): Promise<Runtime[]> {
if (!allRuntimes.data) {
logError('Failed to fetch runtime list', LogPrefix.Runtime)
}
const runtimes: Runtime[] = allRuntimes.data || []
runtimes.push({
id: 2000,
name: 'comet_dummy_service',
architecture: 'all',
created_at: '2024-07-27T19:35:07.389453Z',
url: 'https://github.com/imLinguin/comet/releases/download/v0.1.2/dummy-service.zip'
})
return runtimes
return allRuntimes.data || []
}

async function download(name: RuntimeName): Promise<boolean> {
Expand Down
7 changes: 2 additions & 5 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,7 @@ export interface Runtime {
url: string
}

export type RuntimeName =
| 'eac_runtime'
| 'battleye_runtime'
| 'comet_dummy_service'
| 'umu'
export type RuntimeName = 'eac_runtime' | 'battleye_runtime' | 'umu'

export type RecentGame = {
appName: string
Expand Down Expand Up @@ -591,6 +587,7 @@ export type WineCommandArgs = {
options?: CallRunnerOptions
startFolder?: string
skipPrefixCheckIKnowWhatImDoing?: boolean
ignoreLogging?: boolean
}

export interface SaveSyncArgs {
Expand Down

0 comments on commit 13e2451

Please sign in to comment.