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

fix: apply spoofing stuff to missionInventoryUpdate's InventoryJson (#866)

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

代码差异

2 个文件 +23 -8
Modified src/controllers/api/inventoryController.ts +10 -3
@@ -59,6 +59,15 @@ export const inventoryController: RequestHandler = async (request, response) =>
59 59 );
60 60 const inventoryResponse = inventoryWithLoadOutPresetsAndShips.toJSON<IInventoryClient>();
61 61
62 applyInventoryResponseOverrides(inventoryResponse, "xpBasedLevelCapDisabled" in request.query);
63
64 response.json(inventoryResponse);
65 };
66
67 export const applyInventoryResponseOverrides = (
68 inventoryResponse: IInventoryClient,
69 xpBasedLevelCapDisabled: boolean
70 ): void => {
62 71 if (config.infiniteCredits) {
63 72 inventoryResponse.RegularCredits = 999999999;
64 73 }
@@ -175,7 +184,7 @@ export const inventoryController: RequestHandler = async (request, response) =>
175 184
176 185 if (typeof config.spoofMasteryRank === "number" && config.spoofMasteryRank >= 0) {
177 186 inventoryResponse.PlayerLevel = config.spoofMasteryRank;
178 if (!("xpBasedLevelCapDisabled" in request.query)) {
187 if (!xpBasedLevelCapDisabled) {
179 188 // This client has not been patched to accept any mastery rank, need to fake the XP.
180 189 inventoryResponse.XPInfo = [];
181 190 let numFrames = getExpRequiredForMr(Math.min(config.spoofMasteryRank, 5030)) / 6000;
@@ -251,8 +260,6 @@ export const inventoryController: RequestHandler = async (request, response) =>
251 260 inventoryResponse.HasOwnedVoidProjectionsPreviously = true;
252 261
253 262 inventoryResponse.LastInventorySync = toOid(new Types.ObjectId());
254
255 response.json(inventoryResponse);
256 263 };
257 264
258 265 const addString = (arr: string[], str: string): void => {
Modified src/controllers/api/missionInventoryUpdateController.ts +13 -5
@@ -8,6 +8,8 @@ import {
8 8 calculateFinalCredits
9 9 } from "@/src/services/missionInventoryUpdateService";
10 10 import { getInventory } from "@/src/services/inventoryService";
11 import { applyInventoryResponseOverrides } from "./inventoryController";
12 import { IInventoryClient } from "@/src/types/inventoryTypes/inventoryTypes";
11 13
12 14 /*
13 15 **** INPUT ****
@@ -58,9 +60,13 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res)
58 60 const inventoryUpdates = addMissionInventoryUpdates(inventory, missionReport);
59 61
60 62 if (missionReport.MissionStatus !== "GS_SUCCESS") {
61 const InventoryJson = JSON.stringify((await inventory.save()).toJSON());
62
63 res.json({ InventoryJson, MissionRewards: [] });
63 await inventory.save();
64 const inventoryResponse = inventory.toJSON<IInventoryClient>();
65 applyInventoryResponseOverrides(inventoryResponse, true);
66 res.json({
67 InventoryJson: JSON.stringify(inventoryResponse),
68 MissionRewards: []
69 });
64 70 return;
65 71 }
66 72 const missionRewardsResults = await addMissionRewards(inventory, missionReport);
@@ -76,11 +82,13 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res)
76 82 rngRewardCredits: inventoryChanges.RegularCredits as number
77 83 });
78 84
79 const InventoryJson = JSON.stringify((await inventory.save()).toJSON());
85 await inventory.save();
86 const inventoryResponse = inventory.toJSON<IInventoryClient>();
87 applyInventoryResponseOverrides(inventoryResponse, true);
80 88
81 89 //TODO: figure out when to send inventory. it is needed for many cases.
82 90 res.json({
83 InventoryJson,
91 InventoryJson: JSON.stringify(inventoryResponse),
84 92 InventoryChanges: inventoryChanges,
85 93 MissionRewards,
86 94 ...credits,