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

SpaceNinjaServer

A simple server for a small space ninja game

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

XFEstudio/SpaceNinjaServer

feat: respect client-supplied version information (#585)

d824b83c
Sainan <sainan@calamity.inc>
提交于

代码差异

3 个文件 +18 -6
Modified src/controllers/api/loginController.ts +7 -2
@@ -20,6 +20,11 @@ const loginController: RequestHandler = async (request, response) => {
20 20 const account = await Account.findOne({ email: loginRequest.email }); //{ _id: 0, __v: 0 }
21 21 const nonce = Math.round(Math.random() * Number.MAX_SAFE_INTEGER);
22 22
23 const buildLabel: string =
24 typeof request.query.buildLabel == "string"
25 ? request.query.buildLabel.split(" ").join("+")
26 : buildConfig.buildLabel;
27
23 28 if (!account && config.autoCreateAccount && loginRequest.ClientType != "webui") {
24 29 try {
25 30 const newAccount = await createAccount({
@@ -45,7 +50,7 @@ const loginController: RequestHandler = async (request, response) => {
45 50 DTLS: DTLS,
46 51 IRC: config.myIrcAddresses ?? [config.myAddress],
47 52 HUB: HUB,
48 BuildLabel: buildConfig.buildLabel,
53 BuildLabel: buildLabel,
49 54 MatchmakingBuildId: buildConfig.matchmakingBuildId
50 55 };
51 56
@@ -81,7 +86,7 @@ const loginController: RequestHandler = async (request, response) => {
81 86 DTLS: DTLS,
82 87 IRC: config.myIrcAddresses ?? [config.myAddress],
83 88 HUB: HUB,
84 BuildLabel: buildConfig.buildLabel,
89 BuildLabel: buildLabel,
85 90 MatchmakingBuildId: buildConfig.matchmakingBuildId
86 91 };
87 92
Modified src/controllers/dynamic/worldStateController.ts +5 -2
@@ -2,10 +2,13 @@ import { RequestHandler } from "express";
2 2 import worldState from "@/static/fixed_responses/worldState.json";
3 3 import buildConfig from "@/static/data/buildConfig.json";
4 4
5 const worldStateController: RequestHandler = (_req, res) => {
5 const worldStateController: RequestHandler = (req, res) => {
6 const buildLabel: string =
7 typeof req.query.buildLabel == "string" ? req.query.buildLabel.split(" ").join("+") : buildConfig.buildLabel;
8
6 9 res.json({
7 10 ...worldState,
8 BuildLabel: buildConfig.buildLabel,
11 BuildLabel: buildLabel,
9 12 Time: Math.round(Date.now() / 1000)
10 13 });
11 14 };
Modified src/routes/cache.ts +6 -2
@@ -4,8 +4,12 @@ import fs from "fs/promises";
4 4
5 5 const cacheRouter = express.Router();
6 6
7 cacheRouter.get(/^\/origin\/[a-zA-Z0-9]+\/[0-9]+\/H\.Cache\.bin.*$/, (_req, res) => {
8 res.sendFile(`static/data/H.Cache_${buildConfig.version}.bin`, { root: "./" });
7 cacheRouter.get(/^\/origin\/[a-zA-Z0-9]+\/[0-9]+\/H\.Cache\.bin.*$/, (req, res) => {
8 if (typeof req.query.version == "string" && req.query.version.match(/^\d\d\d\d\.\d\d\.\d\d\.\d\d\.\d\d$/)) {
9 res.sendFile(`static/data/H.Cache_${req.query.version}.bin`, { root: "./" });
10 } else {
11 res.sendFile(`static/data/H.Cache_${buildConfig.version}.bin`, { root: "./" });
12 }
9 13 });
10 14
11 15 // eslint-disable-next-line @typescript-eslint/no-misused-promises