From 001def56a5b8e2c9b97e8be7d7cfaeb781c4a606 Mon Sep 17 00:00:00 2001 From: kiobu Date: Fri, 26 Apr 2024 07:37:42 +0000 Subject: [PATCH] feat: add /client/game/mode handling (!308) add `/client/game/mode` endpoint handling. gets into main menu Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/308 Co-authored-by: kiobu Co-committed-by: kiobu --- project/src/callbacks/GameCallbacks.ts | 15 +++++++++++++++ project/src/controllers/GameController.ts | 10 ++++++++++ .../src/models/eft/game/IGameModeRequestData.ts | 4 ++++ project/src/models/eft/game/IGameModeResponse.ts | 11 +++++++++++ project/src/routers/static/GameStaticRouter.ts | 4 ++++ 5 files changed, 44 insertions(+) create mode 100644 project/src/models/eft/game/IGameModeRequestData.ts create mode 100644 project/src/models/eft/game/IGameModeResponse.ts diff --git a/project/src/callbacks/GameCallbacks.ts b/project/src/callbacks/GameCallbacks.ts index 2a6cb781..b8ea950d 100644 --- a/project/src/callbacks/GameCallbacks.ts +++ b/project/src/callbacks/GameCallbacks.ts @@ -9,6 +9,8 @@ import { IGameConfigResponse } from "@spt-aki/models/eft/game/IGameConfigRespons import { IGameEmptyCrcRequestData } from "@spt-aki/models/eft/game/IGameEmptyCrcRequestData"; import { IGameKeepAliveResponse } from "@spt-aki/models/eft/game/IGameKeepAliveResponse"; import { IGameLogoutResponseData } from "@spt-aki/models/eft/game/IGameLogoutResponseData"; +import { IGameModeRequestData } from "@spt-aki/models/eft/game/IGameModeRequestData"; +import { IGameModeResponse } from "@spt-aki/models/eft/game/IGameModeResponse"; import { IGameStartResponse } from "@spt-aki/models/eft/game/IGameStartResponse"; import { IGetRaidTimeRequest } from "@spt-aki/models/eft/game/IGetRaidTimeRequest"; import { IGetRaidTimeResponse } from "@spt-aki/models/eft/game/IGetRaidTimeResponse"; @@ -91,6 +93,19 @@ export class GameCallbacks implements OnLoad return this.httpResponse.getBody(this.gameController.getGameConfig(sessionID)); } + /** + * Handle client/game/mode + * @returns IGameModeResponse + */ + public getGameMode( + url: string, + info: IGameModeRequestData, + sessionID: string, + ): IGetBodyResponseData + { + return this.httpResponse.getBody(this.gameController.getGameMode(sessionID, info)); + } + /** * Handle client/server/list */ diff --git a/project/src/controllers/GameController.ts b/project/src/controllers/GameController.ts index cafdf078..c1762567 100644 --- a/project/src/controllers/GameController.ts +++ b/project/src/controllers/GameController.ts @@ -15,6 +15,8 @@ import { ICheckVersionResponse } from "@spt-aki/models/eft/game/ICheckVersionRes import { ICurrentGroupResponse } from "@spt-aki/models/eft/game/ICurrentGroupResponse"; import { IGameConfigResponse } from "@spt-aki/models/eft/game/IGameConfigResponse"; import { IGameKeepAliveResponse } from "@spt-aki/models/eft/game/IGameKeepAliveResponse"; +import { IGameModeRequestData } from "@spt-aki/models/eft/game/IGameModeRequestData"; +import { ESessionMode } from "@spt-aki/models/eft/game/IGameModeResponse"; import { IGetRaidTimeRequest } from "@spt-aki/models/eft/game/IGetRaidTimeRequest"; import { IGetRaidTimeResponse } from "@spt-aki/models/eft/game/IGetRaidTimeResponse"; import { IServerDetails } from "@spt-aki/models/eft/game/IServerDetails"; @@ -479,6 +481,14 @@ export class GameController return config; } + /** + * Handle client/game/mode + */ + public getGameMode(sessionID: string, info: IGameModeRequestData): any + { + return { gameMode: ESessionMode.REGULAR, backendUrl: this.httpServerHelper.getBackendUrl() }; + } + /** * Handle client/server/list */ diff --git a/project/src/models/eft/game/IGameModeRequestData.ts b/project/src/models/eft/game/IGameModeRequestData.ts new file mode 100644 index 00000000..283be2bc --- /dev/null +++ b/project/src/models/eft/game/IGameModeRequestData.ts @@ -0,0 +1,4 @@ +export interface IGameModeRequestData +{ + sessionMode: string | null; +} diff --git a/project/src/models/eft/game/IGameModeResponse.ts b/project/src/models/eft/game/IGameModeResponse.ts new file mode 100644 index 00000000..e26a5944 --- /dev/null +++ b/project/src/models/eft/game/IGameModeResponse.ts @@ -0,0 +1,11 @@ +export enum ESessionMode +{ + REGULAR = "regular", + PVE = "pve", +} + +export interface IGameModeResponse +{ + gameMode: ESessionMode; + backendUrl: string; +} diff --git a/project/src/routers/static/GameStaticRouter.ts b/project/src/routers/static/GameStaticRouter.ts index 0527cc3c..224d0ffc 100644 --- a/project/src/routers/static/GameStaticRouter.ts +++ b/project/src/routers/static/GameStaticRouter.ts @@ -13,6 +13,10 @@ export class GameStaticRouter extends StaticRouter { return this.gameCallbacks.getGameConfig(url, info, sessionID); }), + new RouteAction("/client/game/mode", (url: string, info: any, sessionID: string, output: string): any => + { + return this.gameCallbacks.getGameMode(url, info, sessionID); + }), new RouteAction("/client/server/list", (url: string, info: any, sessionID: string, output: string): any => { return this.gameCallbacks.getServer(url, info, sessionID);