XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFESpaceNinjaServer

chore: use credentials in worldState request to determine buildLabel (#3947)

Luckily for us, U8 and below had this request authenticated, so we don't need heuristics to deal with U5. Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3947 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

525506ca
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

2 个文件 +7 -7
Modified src/controllers/dynamic/worldStateController.ts +6 -5
@@ -5,14 +5,15 @@ import {
5 5 populateFeaturedGuilds,
6 6 populateFissures
7 7 } from "../../services/worldStateService.ts";
8 import { buildConfig } from "../../services/buildConfigService.ts";
8 import { getAccountForRequest } from "../../services/loginService.ts";
9 9
10 10 export const worldStateController: RequestHandler = async (req, res) => {
11 11 let buildLabel = req.query.buildLabel as string | undefined;
12 // For /cdn/worldState.php, keep buildLabel=undefined to mean latest,
13 // but for /dynamic/worldState.php, we might be dealing with a U5 client, so grab buildLabel from buildConfig, instead.
14 if (!buildLabel && req.originalUrl == "/dynamic/worldState.php") {
15 buildLabel = buildConfig.buildLabel;
12 if (buildLabel) {
13 buildLabel = buildLabel.split(" ").join("+");
14 } else if (req.query.accountId) {
15 const account = await getAccountForRequest(req);
16 buildLabel = account.BuildLabel;
16 17 }
17 18
18 19 const worldState = getWorldState(buildLabel);
Modified src/services/worldStateService.ts +1 -2
@@ -9,7 +9,6 @@ import darvoDeals from "../constants/darvoDeals.ts";
9 9 import invasionNodes from "../../static/fixed_responses/worldState/invasionNodes.json" with { type: "json" };
10 10 import invasionRewards from "../../static/fixed_responses/worldState/invasionRewards.json" with { type: "json" };
11 11 import pvpChallenges from "../../static/fixed_responses/worldState/pvpChallenges.json" with { type: "json" };
12 import { buildConfig } from "./buildConfigService.ts";
13 12 import { EPOCH, unixTimesInMs } from "../constants/timeConstants.ts";
14 13 import { config } from "./configService.ts";
15 14 import { getRandomElement, getRandomInt, sequentiallyUniqueRandomElement, SRng } from "./rngService.ts";
@@ -1879,7 +1878,7 @@ export const getWorldState = (buildLabel?: string): IWorldState => {
1879 1878 const defenseWavesPerRotation = buildLabel && version_compare(buildLabel, gameToBuildVersion["38.5.0"]) < 0 ? 5 : 3;
1880 1879
1881 1880 const worldState: IWorldState = {
1882 BuildLabel: typeof buildLabel == "string" ? buildLabel.split(" ").join("+") : buildConfig.buildLabel,
1881 BuildLabel: buildLabel ?? "",
1883 1882 Time: timeSecs,
1884 1883 Goals: [],
1885 1884 Alerts: [],