FIX: Fail to start game
This commit is contained in:
@@ -80,7 +80,7 @@ export function RemoveFile(path) {
|
||||
|
||||
/**
|
||||
* @param {string} path
|
||||
* @returns {$CancellablePromise<boolean>}
|
||||
* @returns {$CancellablePromise<[boolean, string]>}
|
||||
*/
|
||||
export function StartApp(path) {
|
||||
return $Call.ByID(1267568402, path);
|
||||
@@ -88,7 +88,7 @@ export function StartApp(path) {
|
||||
|
||||
/**
|
||||
* @param {string} path
|
||||
* @returns {$CancellablePromise<boolean>}
|
||||
* @returns {$CancellablePromise<[boolean, string]>}
|
||||
*/
|
||||
export function StartWithConsole(path) {
|
||||
return $Call.ByID(3249271428, path);
|
||||
|
||||
@@ -190,18 +190,18 @@ export default function LauncherPage() {
|
||||
try {
|
||||
setIsLoading(true)
|
||||
if (!proxyRunning && !gamePath.endsWith("launcher.exe")) {
|
||||
const resultProxy = await FSService.StartWithConsole(proxyPath)
|
||||
const [resultProxy, error] = await FSService.StartWithConsole(proxyPath)
|
||||
if (!resultProxy) {
|
||||
toast.error('Failed to start proxy')
|
||||
toast.error('Failed to start proxy: ' + error)
|
||||
return
|
||||
}
|
||||
setProxyRunning(true)
|
||||
}
|
||||
await sleep(500)
|
||||
if (!serverRunning) {
|
||||
const resultServer = await FSService.StartWithConsole(serverPath)
|
||||
const [resultServer, error] = await FSService.StartWithConsole(serverPath)
|
||||
if (!resultServer) {
|
||||
toast.error('Failed to start server')
|
||||
toast.error('Failed to start server: ' + error)
|
||||
return
|
||||
}
|
||||
setServerRunning(true)
|
||||
@@ -209,23 +209,27 @@ export default function LauncherPage() {
|
||||
await sleep(1000)
|
||||
const gameFolder = await FSService.GetDir(gamePath)
|
||||
const fileNeedRemove = await FSService.Join(gameFolder, "StarRail_Data", "Plugins", "x86_64", "AccountPlatNative.dll")
|
||||
await FSService.RemoveFile(fileNeedRemove)
|
||||
const fileExists = await FSService.FileExists(fileNeedRemove)
|
||||
if (fileExists) {
|
||||
await FSService.RemoveFile(fileNeedRemove)
|
||||
}
|
||||
if (gamePath.endsWith("launcher.exe")) {
|
||||
const resultGame = await FSService.StartWithConsole(gamePath)
|
||||
const [resultGame, error] = await FSService.StartWithConsole(gamePath)
|
||||
if (!resultGame) {
|
||||
toast.error('Failed to start game')
|
||||
toast.error('Failed to start game: ' + error)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
const resultGame = await FSService.StartApp(gamePath)
|
||||
const [resultGame, error] = await FSService.StartApp(gamePath)
|
||||
if (!resultGame) {
|
||||
toast.error('Failed to start game')
|
||||
toast.error('Failed to start game: ' + error)
|
||||
return
|
||||
}
|
||||
}
|
||||
setGameRunning(true)
|
||||
|
||||
} catch (err: any) {
|
||||
console.log(err)
|
||||
toast.error('StartGame error:', err)
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
|
||||
Reference in New Issue
Block a user