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

fix: don't use gzip for inventory responses pre-U8 (#3825)

Closes #3822 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3825 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

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

代码差异

2 个文件 +11 -2
Modified src/controllers/api/inventoryController.ts +8 -1
@@ -1,4 +1,4 @@
1 import type { RequestHandler } from "express";
1 import type { Request, RequestHandler } from "express";
2 2 import { getAccountForRequest } from "../../services/loginService.ts";
3 3 import type { TInventoryDatabaseDocument } from "../../models/inventoryModels/inventoryModel.ts";
4 4 import { Inventory } from "../../models/inventoryModels/inventoryModel.ts";
@@ -339,6 +339,7 @@ export const inventoryController: RequestHandler = async (request, response) =>
339 339
340 340 response.json(
341 341 await getInventoryResponse(
342 request,
342 343 inventory,
343 344 "xpBasedLevelCapDisabled" in request.query,
344 345 "ignoreBuildLabel" in request.query ? undefined : account.BuildLabel,
@@ -348,6 +349,7 @@ export const inventoryController: RequestHandler = async (request, response) =>
348 349 };
349 350
350 351 export const getInventoryResponse = async (
352 request: Request,
351 353 inventory: TInventoryDatabaseDocument,
352 354 xpBasedLevelCapDisabled: boolean,
353 355 buildLabel: string | undefined,
@@ -934,6 +936,11 @@ export const getInventoryResponse = async (
934 936 }
935 937 }
936 938
939 if (buildLabel && version_compare(buildLabel, gameToBuildVersion["8.0.0"]) < 0) {
940 // < U8 clients advertise gzip decompression support, but for inventory responses roughly >100k bytes, if we actually made use of that, it would buffer overrun.
941 request.headers["accept-encoding"] = "";
942 }
943 //(inventoryResponse as any).Deez = "a".repeat(100_000);
937 944 return inventoryResponse;
938 945 };
939 946
Modified src/controllers/api/missionInventoryUpdateController.ts +3 -1
@@ -82,7 +82,7 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res)
82 82 inventory.RewardSeed = generateRewardSeed();
83 83 }
84 84 await inventory.save();
85 const inventoryResponse = await getInventoryResponse(inventory, true, account.BuildLabel);
85 const inventoryResponse = await getInventoryResponse(req, inventory, true, account.BuildLabel);
86 86 res.json({
87 87 InventoryJson: JSON.stringify(inventoryResponse),
88 88 MissionRewards: []
@@ -135,6 +135,7 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res)
135 135 } else if (missionReport.RewardInfo) {
136 136 logger.debug(`classic mission completion, sending everything`);
137 137 const inventoryResponse = await getInventoryResponse(
138 req,
138 139 inventory,
139 140 "xpBasedLevelCapDisabled" in req.query,
140 141 account.BuildLabel
@@ -150,6 +151,7 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res)
150 151 } else {
151 152 logger.debug(`no reward info, assuming this wasn't a mission completion and we should just sync inventory`);
152 153 const inventoryResponse = await getInventoryResponse(
154 req,
153 155 inventory,
154 156 "xpBasedLevelCapDisabled" in req.query,
155 157 account.BuildLabel