diff --git a/src/launcher/Haru.Eft.Models.ts b/src/launcher/Haru.Eft.Models.ts new file mode 100644 index 0000000..87a8110 --- /dev/null +++ b/src/launcher/Haru.Eft.Models.ts @@ -0,0 +1,11 @@ +export class ServerConfig +{ + public backendUrl: string; + public version: string; + + constructor(backendUrl: string = "http://localhost:8000", version: string = "live") + { + this.backendUrl = backendUrl; + this.version = version; + } +} \ No newline at end of file diff --git a/src/launcher/Haru.Launcher.ts b/src/launcher/Haru.Launcher.ts new file mode 100644 index 0000000..0c0e98b --- /dev/null +++ b/src/launcher/Haru.Launcher.ts @@ -0,0 +1,29 @@ +import { exec, ExecException } from "child_process"; +import { Json, Log } from "../common/Haru.Utils"; +import { ServerConfig } from "./Haru.Eft.Models"; + +export class GameStarter +{ + public static run(): void + { + const sessionId = "haru-singleplayer" + const serverConfig = Json.serialize(new ServerConfig()); + exec(`EscapeFromTarkov.exe -force-gfx-jobs native -token=${sessionId} -config=${serverConfig}`, GameStarter.onLaunch); + } + + private static onLaunch(error: ExecException | null, stdout: string, stderr: string): void + { + if (error) + { + throw error; + } + + Log.write(stdout); + GameStarter.exitSuccess(); + } + + private static exitSuccess(): void + { + process.exit(0); + } +} \ No newline at end of file diff --git a/src/launcher/Haru.ts b/src/launcher/Haru.ts index e3f5d6d..febaf49 100644 --- a/src/launcher/Haru.ts +++ b/src/launcher/Haru.ts @@ -1,14 +1,11 @@ import { Log } from "../common/Haru.Utils"; +import { GameStarter } from "./Haru.Launcher"; export class Program { public static main(args: string[]) { Log.init("./Logs/Haru.log"); - - for (const command of args) - { - Log.info(command); - } + GameStarter.run(); } } \ No newline at end of file diff --git a/src/server/Haru.Eft.Servers.ts b/src/server/Haru.Eft.Servers.ts index 1f3cb52..4672e04 100644 --- a/src/server/Haru.Eft.Servers.ts +++ b/src/server/Haru.Eft.Servers.ts @@ -1,7 +1,7 @@ -import { PingNotification } from "./Haru.Eft.Models"; -import { CachedResponseService, CachedResponseHelper, FileResponseHelper, FileService } from "./Haru.Eft.Services"; import { HttpServer, WsServer, IServer } from "../common/Haru.Http"; import { Json } from "../common/Haru.Utils"; +import { PingNotification } from "./Haru.Eft.Models"; +import { CachedResponseService, CachedResponseHelper, FileResponseHelper, FileService } from "./Haru.Eft.Services"; export class ServerCluster { diff --git a/src/server/Haru.Eft.Services.ts b/src/server/Haru.Eft.Services.ts index ea6a8f9..9f0a0bf 100644 --- a/src/server/Haru.Eft.Services.ts +++ b/src/server/Haru.Eft.Services.ts @@ -1,7 +1,7 @@ import { IncomingMessage, ServerResponse } from "http"; -import { CheckVersionResponse, FriendList, KeepAliveResponse, LogoutResponse, ResponseBody, ServerInfo } from "./Haru.Eft.Models"; -import { Json } from "../common/Haru.Utils"; import { Service } from "../common/Haru.Http"; +import { Json } from "../common/Haru.Utils"; +import { CheckVersionResponse, FriendList, KeepAliveResponse, LogoutResponse, ResponseBody, ServerInfo } from "./Haru.Eft.Models"; export class FileResponseHelper {