fix: apply spoofing stuff to missionInventoryUpdate's InventoryJson (#866)
This commit is contained in:
		
							parent
							
								
									57061073be
								
							
						
					
					
						commit
						b72a0d12ef
					
				@ -59,6 +59,15 @@ export const inventoryController: RequestHandler = async (request, response) =>
 | 
			
		||||
    );
 | 
			
		||||
    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) {
 | 
			
		||||
        inventoryResponse.RegularCredits = 999999999;
 | 
			
		||||
    }
 | 
			
		||||
@ -175,7 +184,7 @@ export const inventoryController: RequestHandler = async (request, response) =>
 | 
			
		||||
 | 
			
		||||
    if (typeof config.spoofMasteryRank === "number" && config.spoofMasteryRank >= 0) {
 | 
			
		||||
        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.
 | 
			
		||||
            inventoryResponse.XPInfo = [];
 | 
			
		||||
            let numFrames = getExpRequiredForMr(Math.min(config.spoofMasteryRank, 5030)) / 6000;
 | 
			
		||||
@ -251,8 +260,6 @@ export const inventoryController: RequestHandler = async (request, response) =>
 | 
			
		||||
    inventoryResponse.HasOwnedVoidProjectionsPreviously = true;
 | 
			
		||||
 | 
			
		||||
    inventoryResponse.LastInventorySync = toOid(new Types.ObjectId());
 | 
			
		||||
 | 
			
		||||
    response.json(inventoryResponse);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const addString = (arr: string[], str: string): void => {
 | 
			
		||||
 | 
			
		||||
@ -8,6 +8,8 @@ import {
 | 
			
		||||
    calculateFinalCredits
 | 
			
		||||
} from "@/src/services/missionInventoryUpdateService";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { applyInventoryResponseOverrides } from "./inventoryController";
 | 
			
		||||
import { IInventoryClient } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
**** INPUT ****
 | 
			
		||||
@ -58,9 +60,13 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res)
 | 
			
		||||
    const inventoryUpdates = addMissionInventoryUpdates(inventory, missionReport);
 | 
			
		||||
 | 
			
		||||
    if (missionReport.MissionStatus !== "GS_SUCCESS") {
 | 
			
		||||
        const InventoryJson = JSON.stringify((await inventory.save()).toJSON());
 | 
			
		||||
 | 
			
		||||
        res.json({ InventoryJson, MissionRewards: [] });
 | 
			
		||||
        await inventory.save();
 | 
			
		||||
        const inventoryResponse = inventory.toJSON<IInventoryClient>();
 | 
			
		||||
        applyInventoryResponseOverrides(inventoryResponse, true);
 | 
			
		||||
        res.json({
 | 
			
		||||
            InventoryJson: JSON.stringify(inventoryResponse),
 | 
			
		||||
            MissionRewards: []
 | 
			
		||||
        });
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    const missionRewardsResults = await addMissionRewards(inventory, missionReport);
 | 
			
		||||
@ -76,11 +82,13 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res)
 | 
			
		||||
        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.
 | 
			
		||||
    res.json({
 | 
			
		||||
        InventoryJson,
 | 
			
		||||
        InventoryJson: JSON.stringify(inventoryResponse),
 | 
			
		||||
        InventoryChanges: inventoryChanges,
 | 
			
		||||
        MissionRewards,
 | 
			
		||||
        ...credits,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user