From ba4e6dfd6876942b77fcf96cfb8535f603ad09ba Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Tue, 5 May 2026 16:48:16 -0500 Subject: [PATCH] feat: some implementation for client unmounted mode --- packages/closed | 2 +- packages/game/Models/BlitzFileProvider.cs | 18 ++---------------- packages/game/game.csproj | 2 +- packages/game/src/index.ts | 2 +- packages/website-ue/src/core/api/responses.ts | 3 +++ packages/website-ue/src/core/game/game.ts | 14 +++++++++++--- .../src/pages/api/tanks/[id].webp.ts | 14 ++++++++++---- 7 files changed, 29 insertions(+), 26 deletions(-) create mode 100644 packages/website-ue/src/core/api/responses.ts diff --git a/packages/closed b/packages/closed index 69c368890..cc81b4344 160000 --- a/packages/closed +++ b/packages/closed @@ -1 +1 @@ -Subproject commit 69c36889061a539efc15f046f698bb2c927b5a6b +Subproject commit cc81b43447706d340296513686dffed33861921a diff --git a/packages/game/Models/BlitzFileProvider.cs b/packages/game/Models/BlitzFileProvider.cs index 057567d8d..34b46cba3 100644 --- a/packages/game/Models/BlitzFileProvider.cs +++ b/packages/game/Models/BlitzFileProvider.cs @@ -21,21 +21,7 @@ public class BlitzFileProvider : DefaultFileProvider Initialize(); Mount(); - string libraryExtension; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - libraryExtension = "dll"; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - libraryExtension = "so"; - } - else - { - throw new Exception("Unsupported OS"); - } - - OodleHelper.DownloadOodleDll($"../../temp/oodle.{libraryExtension}"); - OodleHelper.Initialize($"../../temp/oodle.{libraryExtension}"); + // OodleHelper.DownloadOodleDll($"../../temp/oodle.so"); + OodleHelper.Initialize($"../../temp/oodle.so"); } } diff --git a/packages/game/game.csproj b/packages/game/game.csproj index 10270d57a..0441a3461 100644 --- a/packages/game/game.csproj +++ b/packages/game/game.csproj @@ -2,7 +2,7 @@ BlitzKit.Game net9.0 - win-x64 + enable enable esm diff --git a/packages/game/src/index.ts b/packages/game/src/index.ts index 29664b507..55045b8a2 100644 --- a/packages/game/src/index.ts +++ b/packages/game/src/index.ts @@ -1 +1 @@ -export * from "../bin/Debug/net9.0/win-x64/game"; +export * from "../bin/Debug/net9.0/game"; diff --git a/packages/website-ue/src/core/api/responses.ts b/packages/website-ue/src/core/api/responses.ts new file mode 100644 index 000000000..d996c987d --- /dev/null +++ b/packages/website-ue/src/core/api/responses.ts @@ -0,0 +1,3 @@ +export const clientUnmountedResponse = new Response(null, { status: 503 }); + +export const notFoundResponse = new Response(null, { status: 404 }); diff --git a/packages/website-ue/src/core/game/game.ts b/packages/website-ue/src/core/game/game.ts index 696ab4e8e..6ae49270e 100644 --- a/packages/website-ue/src/core/game/game.ts +++ b/packages/website-ue/src/core/game/game.ts @@ -1,5 +1,13 @@ import { GameInterface } from "@blitzkit/game"; -export const game = new GameInterface( - "C:/Program Files (x86)/Steam/steamapps/common/World of Tanks Blitz Playtest", -); +export const clientUnmounted = !("WOTB_CLIENT" in import.meta.env); + +let _game: GameInterface | null = null; + +if (!clientUnmounted) { + _game = new GameInterface(import.meta.env.WOTB_CLIENT); +} else { + console.warn("Running in client denied mode..."); +} + +export const game = _game; diff --git a/packages/website-ue/src/pages/api/tanks/[id].webp.ts b/packages/website-ue/src/pages/api/tanks/[id].webp.ts index 413b6aac2..6a70f1378 100644 --- a/packages/website-ue/src/pages/api/tanks/[id].webp.ts +++ b/packages/website-ue/src/pages/api/tanks/[id].webp.ts @@ -1,14 +1,20 @@ import type { APIContext } from "astro"; import { api } from "../../../core/api/dynamic"; -import { game } from "../../../core/game/game"; +import { + clientUnmountedResponse, + notFoundResponse, +} from "../../../core/api/responses"; +import { clientUnmounted, game } from "../../../core/game/game"; export { getStaticPaths } from "./[id].json"; export async function GET({ params }: APIContext) { - const tank = await api.tank(params.id); - const image = game.tankBigIcon(params.id, tank.tank!.visual_data); + if (clientUnmounted) return clientUnmountedResponse; - if (image.length === 0) return new Response(null, { status: 404 }); + const tank = await api.tank(params.id); + const image = game!.tankBigIcon(params.id, tank.tank!.visual_data); + + if (image.length === 0) return notFoundResponse; return new Response(new Uint8Array(image)); }