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

This commit is contained in:
Sainan 2025-01-24 21:09:34 +01:00 committed by GitHub
parent 57061073be
commit b72a0d12ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 8 deletions

View File

@ -59,6 +59,15 @@ export const inventoryController: RequestHandler = async (request, response) =>
); );
const inventoryResponse = inventoryWithLoadOutPresetsAndShips.toJSON<IInventoryClient>(); const inventoryResponse = inventoryWithLoadOutPresetsAndShips.toJSON<IInventoryClient>();
applyInventoryResponseOverrides(inventoryResponse, "xpBasedLevelCapDisabled" in request.query);
response.json(inventoryResponse);
};
export const applyInventoryResponseOverrides = (
inventoryResponse: IInventoryClient,
xpBasedLevelCapDisabled: boolean
): void => {
if (config.infiniteCredits) { if (config.infiniteCredits) {
inventoryResponse.RegularCredits = 999999999; inventoryResponse.RegularCredits = 999999999;
} }
@ -175,7 +184,7 @@ export const inventoryController: RequestHandler = async (request, response) =>
if (typeof config.spoofMasteryRank === "number" && config.spoofMasteryRank >= 0) { if (typeof config.spoofMasteryRank === "number" && config.spoofMasteryRank >= 0) {
inventoryResponse.PlayerLevel = config.spoofMasteryRank; inventoryResponse.PlayerLevel = config.spoofMasteryRank;
if (!("xpBasedLevelCapDisabled" in request.query)) { if (!xpBasedLevelCapDisabled) {
// This client has not been patched to accept any mastery rank, need to fake the XP. // This client has not been patched to accept any mastery rank, need to fake the XP.
inventoryResponse.XPInfo = []; inventoryResponse.XPInfo = [];
let numFrames = getExpRequiredForMr(Math.min(config.spoofMasteryRank, 5030)) / 6000; let numFrames = getExpRequiredForMr(Math.min(config.spoofMasteryRank, 5030)) / 6000;
@ -251,8 +260,6 @@ export const inventoryController: RequestHandler = async (request, response) =>
inventoryResponse.HasOwnedVoidProjectionsPreviously = true; inventoryResponse.HasOwnedVoidProjectionsPreviously = true;
inventoryResponse.LastInventorySync = toOid(new Types.ObjectId()); inventoryResponse.LastInventorySync = toOid(new Types.ObjectId());
response.json(inventoryResponse);
}; };
const addString = (arr: string[], str: string): void => { const addString = (arr: string[], str: string): void => {

View File

@ -8,6 +8,8 @@ import {
calculateFinalCredits calculateFinalCredits
} from "@/src/services/missionInventoryUpdateService"; } from "@/src/services/missionInventoryUpdateService";
import { getInventory } from "@/src/services/inventoryService"; import { getInventory } from "@/src/services/inventoryService";
import { applyInventoryResponseOverrides } from "./inventoryController";
import { IInventoryClient } from "@/src/types/inventoryTypes/inventoryTypes";
/* /*
**** INPUT **** **** INPUT ****
@ -58,9 +60,13 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res)
const inventoryUpdates = addMissionInventoryUpdates(inventory, missionReport); const inventoryUpdates = addMissionInventoryUpdates(inventory, missionReport);
if (missionReport.MissionStatus !== "GS_SUCCESS") { if (missionReport.MissionStatus !== "GS_SUCCESS") {
const InventoryJson = JSON.stringify((await inventory.save()).toJSON()); await inventory.save();
const inventoryResponse = inventory.toJSON<IInventoryClient>();
res.json({ InventoryJson, MissionRewards: [] }); applyInventoryResponseOverrides(inventoryResponse, true);
res.json({
InventoryJson: JSON.stringify(inventoryResponse),
MissionRewards: []
});
return; return;
} }
const missionRewardsResults = await addMissionRewards(inventory, missionReport); const missionRewardsResults = await addMissionRewards(inventory, missionReport);
@ -76,11 +82,13 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res)
rngRewardCredits: inventoryChanges.RegularCredits as number rngRewardCredits: inventoryChanges.RegularCredits as number
}); });
const InventoryJson = JSON.stringify((await inventory.save()).toJSON()); await inventory.save();
const inventoryResponse = inventory.toJSON<IInventoryClient>();
applyInventoryResponseOverrides(inventoryResponse, true);
//TODO: figure out when to send inventory. it is needed for many cases. //TODO: figure out when to send inventory. it is needed for many cases.
res.json({ res.json({
InventoryJson, InventoryJson: JSON.stringify(inventoryResponse),
InventoryChanges: inventoryChanges, InventoryChanges: inventoryChanges,
MissionRewards, MissionRewards,
...credits, ...credits,