返回提交历史
Modified
src/controllers/api/inventoryController.ts
+1
-1
Modified
src/services/inventoryService.ts
+1
-95
XFEstudio/XFESpaceNinjaServer
chore: remove migration from unlockAllSkins (#3527)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3527 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
29c7dda6
代码差异
2 个文件
+2
-96
@@ -215,7 +215,7 @@ export const inventoryController: RequestHandler = async (request, response) =>
215
215
}
216
216
}
217
217
218
await cleanupInventory(inventory);
218
cleanupInventory(inventory);
219
219
220
220
inventory.NextRefill = new Date((today + 1) * 86400000); // tomorrow at 0 UTC
221
221
//await inventory.save();
@@ -94,7 +94,6 @@ import type {
94
94
} from "../types/equipmentTypes.ts";
95
95
import { EquipmentFeatures, Status } from "../types/equipmentTypes.ts";
96
96
import type { ITypeCount } from "../types/commonTypes.ts";
97
import { skinLookupTable } from "../helpers/skinLookupTable.ts";
98
97
import type { TLoadoutDatabaseDocument } from "../models/inventoryModels/loadoutModel.ts";
99
98
import gameToBuildVersion from "../constants/gameToBuildVersion.ts";
100
99
import suitDefaultUpgrades from "../constants/suitDefaultUpgrades.ts";
@@ -2619,7 +2618,7 @@ export const setupKahlSyndicate = (inventory: TInventoryDatabaseDocument): void
2619
2618
}
2620
2619
};
2621
2620
2622
export const cleanupInventory = async (inventory: TInventoryDatabaseDocument): Promise<void> => {
2621
export const cleanupInventory = (inventory: TInventoryDatabaseDocument): void => {
2623
2622
if (ensureOperatorSuitsRemasterData(inventory)) {
2624
2623
logger.debug(`added missing Operator suits for Operator remaster`);
2625
2624
}
@@ -2687,67 +2686,6 @@ export const cleanupInventory = async (inventory: TInventoryDatabaseDocument): P
2687
2686
}
2688
2687
}
2689
2688
2690
{
2691
const weaponMap = new Map<string, string>();
2692
for (const skin of inventory.WeaponSkins) {
2693
weaponMap.set(skin.ItemType, skin._id.toString());
2694
}
2695
2696
const itemsToAdd = new Set<string>();
2697
2698
for (const key of equipmentKeys) {
2699
if (key in inventory) {
2700
for (const equipment of inventory[key]) {
2701
for (const config of equipment.Configs) {
2702
if (config.Skins) collectSkins(config.Skins, weaponMap, itemsToAdd);
2703
}
2704
}
2705
}
2706
}
2707
2708
for (const key of ["AdultOperatorLoadOuts", "OperatorLoadOuts", "KahlLoadOuts"] as const) {
2709
if (key in inventory) {
2710
for (const loadOut of inventory[key]) {
2711
if (loadOut.Skins) collectSkins(loadOut.Skins, weaponMap, itemsToAdd);
2712
}
2713
}
2714
}
2715
2716
if (inventory.LotusCustomization?.Skins)
2717
collectSkins(inventory.LotusCustomization.Skins, weaponMap, itemsToAdd);
2718
2719
if (itemsToAdd.size > 0) {
2720
logger.debug(`Adding ${itemsToAdd.size} items due to migration from unlockAllSkins cheat`);
2721
const inventoryChanges = await addItems(inventory, Array.from(itemsToAdd));
2722
2723
if (inventoryChanges.WeaponSkins) {
2724
for (const skin of inventoryChanges.WeaponSkins as IWeaponSkinClient[]) {
2725
weaponMap.set(skin.ItemType, skin.ItemId.toString());
2726
}
2727
}
2728
2729
for (const key of equipmentKeys) {
2730
if (key in inventory) {
2731
for (const equipment of inventory[key]) {
2732
for (const config of equipment.Configs) {
2733
if (config.Skins) replaceSkinIds(config.Skins, weaponMap);
2734
}
2735
}
2736
}
2737
}
2738
2739
for (const key of ["AdultOperatorLoadOuts", "OperatorLoadOuts", "KahlLoadOuts"] as const) {
2740
if (key in inventory) {
2741
for (const loadOut of inventory[key]) {
2742
if (loadOut.Skins) replaceSkinIds(loadOut.Skins, weaponMap);
2743
}
2744
}
2745
}
2746
2747
if (inventory.LotusCustomization?.Skins) replaceSkinIds(inventory.LotusCustomization.Skins, weaponMap);
2748
}
2749
}
2750
2751
2689
{
2752
2690
let fixed = 0;
2753
2691
for (const key of equipmentKeys) {
@@ -2777,38 +2715,6 @@ export const cleanupInventory = async (inventory: TInventoryDatabaseDocument): P
2777
2715
}
2778
2716
};
2779
2717
2780
const collectSkins = (skins: string[], weaponMap: Map<string, string>, itemsToAdd: Set<string>): void => {
2781
for (const skinId of skins) {
2782
if (skinId.startsWith("ca70ca70ca70ca70")) {
2783
const typeName = skinLookupTable[parseInt(skinId.slice(16), 16)];
2784
if (!weaponMap.has(typeName)) {
2785
const req = ExportCustoms[typeName].requirement;
2786
if (req) {
2787
itemsToAdd.add(req);
2788
} else {
2789
itemsToAdd.add(typeName);
2790
}
2791
}
2792
}
2793
}
2794
};
2795
2796
const replaceSkinIds = (skins: string[], weaponMap: Map<string, string>): void => {
2797
for (let i = 0; i < skins.length; i++) {
2798
const skinId = skins[i];
2799
if (skinId.startsWith("ca70ca70ca70ca70")) {
2800
const typeName = skinLookupTable[parseInt(skinId.slice(16), 16)];
2801
const inventoryId = weaponMap.get(typeName);
2802
if (inventoryId) {
2803
skins[i] = inventoryId;
2804
} else if (typeName in ExportCustoms) {
2805
const { requirement } = ExportCustoms[typeName];
2806
skins[i] = typeof requirement == "string" ? typeName : "";
2807
}
2808
}
2809
}
2810
};
2811
2812
2718
export const getDialogue = (inventory: TInventoryDatabaseDocument, dialogueName: string): IDialogueDatabase => {
2813
2719
inventory.DialogueHistory ??= {};
2814
2720
inventory.DialogueHistory.Dialogues ??= [];