feat(webui): skins #2816
@ -20,13 +20,14 @@ import type {
 | 
				
			|||||||
} from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
					} from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
				
			||||||
import { LoadoutIndex } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
					import { LoadoutIndex } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
				
			||||||
import type { RequestHandler } from "express";
 | 
					import type { RequestHandler } from "express";
 | 
				
			||||||
import { catBreadHash, getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
					import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
				
			||||||
import { ExportCustoms, ExportDojoRecipes } from "warframe-public-export-plus";
 | 
					import { ExportDojoRecipes } from "warframe-public-export-plus";
 | 
				
			||||||
import type { IStatsClient } from "../../types/statTypes.ts";
 | 
					import type { IStatsClient } from "../../types/statTypes.ts";
 | 
				
			||||||
import { toStoreItem } from "../../services/itemDataService.ts";
 | 
					import { toStoreItem } from "../../services/itemDataService.ts";
 | 
				
			||||||
import type { FlattenMaps } from "mongoose";
 | 
					import type { FlattenMaps } from "mongoose";
 | 
				
			||||||
import type { IEquipmentClient } from "../../types/equipmentTypes.ts";
 | 
					import type { IEquipmentClient } from "../../types/equipmentTypes.ts";
 | 
				
			||||||
import type { ILoadoutConfigClient } from "../../types/saveLoadoutTypes.ts";
 | 
					import type { ILoadoutConfigClient } from "../../types/saveLoadoutTypes.ts";
 | 
				
			||||||
 | 
					import { skinLookupTable } from "../../helpers/skinLookupTable.ts";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const getProfileViewingDataByPlayerIdImpl = async (playerId: string): Promise<IProfileViewingData | undefined> => {
 | 
					const getProfileViewingDataByPlayerIdImpl = async (playerId: string): Promise<IProfileViewingData | undefined> => {
 | 
				
			||||||
    const account = await Account.findById(playerId, "DisplayName");
 | 
					    const account = await Account.findById(playerId, "DisplayName");
 | 
				
			||||||
@ -261,8 +262,6 @@ interface IXPComponentClient {
 | 
				
			|||||||
    locTags?: Record<string, string>;
 | 
					    locTags?: Record<string, string>;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let skinLookupTable: Record<number, string> | undefined;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const resolveAndCollectSkins = (
 | 
					const resolveAndCollectSkins = (
 | 
				
			||||||
    inventory: TInventoryDatabaseDocument,
 | 
					    inventory: TInventoryDatabaseDocument,
 | 
				
			||||||
    skins: Set<string>,
 | 
					    skins: Set<string>,
 | 
				
			||||||
@ -274,12 +273,6 @@ const resolveAndCollectSkins = (
 | 
				
			|||||||
                // Resolve oids to type names
 | 
					                // Resolve oids to type names
 | 
				
			||||||
                if (config.Skins[i].length == 24) {
 | 
					                if (config.Skins[i].length == 24) {
 | 
				
			||||||
                    if (config.Skins[i].substring(0, 16) == "ca70ca70ca70ca70") {
 | 
					                    if (config.Skins[i].substring(0, 16) == "ca70ca70ca70ca70") {
 | 
				
			||||||
                        if (!skinLookupTable) {
 | 
					 | 
				
			||||||
                            skinLookupTable = {};
 | 
					 | 
				
			||||||
                            for (const key of Object.keys(ExportCustoms)) {
 | 
					 | 
				
			||||||
                                skinLookupTable[catBreadHash(key)] = key;
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        config.Skins[i] = skinLookupTable[parseInt(config.Skins[i].substring(16), 16)];
 | 
					                        config.Skins[i] = skinLookupTable[parseInt(config.Skins[i].substring(16), 16)];
 | 
				
			||||||
                    } else {
 | 
					                    } else {
 | 
				
			||||||
                        const skinItem = inventory.WeaponSkins.id(config.Skins[i]);
 | 
					                        const skinItem = inventory.WeaponSkins.id(config.Skins[i]);
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										8
									
								
								src/helpers/skinLookupTable.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/helpers/skinLookupTable.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					import { ExportCustoms } from "warframe-public-export-plus";
 | 
				
			||||||
 | 
					import { catBreadHash } from "./stringHelpers.ts";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const skinLookupTable: Record<number, string> = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					for (const key of Object.keys(ExportCustoms)) {
 | 
				
			||||||
 | 
					    skinLookupTable[catBreadHash(key)] = key;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -83,7 +83,7 @@ import type { INemesisProfile } from "../helpers/nemesisHelpers.ts";
 | 
				
			|||||||
import { generateNemesisProfile } from "../helpers/nemesisHelpers.ts";
 | 
					import { generateNemesisProfile } from "../helpers/nemesisHelpers.ts";
 | 
				
			||||||
import type { TAccountDocument } from "./loginService.ts";
 | 
					import type { TAccountDocument } from "./loginService.ts";
 | 
				
			||||||
import { unixTimesInMs } from "../constants/timeConstants.ts";
 | 
					import { unixTimesInMs } from "../constants/timeConstants.ts";
 | 
				
			||||||
import { addString, catBreadHash } from "../helpers/stringHelpers.ts";
 | 
					import { addString } from "../helpers/stringHelpers.ts";
 | 
				
			||||||
import type {
 | 
					import type {
 | 
				
			||||||
    IEquipmentClient,
 | 
					    IEquipmentClient,
 | 
				
			||||||
    IEquipmentDatabase,
 | 
					    IEquipmentDatabase,
 | 
				
			||||||
@ -92,6 +92,7 @@ import type {
 | 
				
			|||||||
} from "../types/equipmentTypes.ts";
 | 
					} from "../types/equipmentTypes.ts";
 | 
				
			||||||
import { EquipmentFeatures, Status } from "../types/equipmentTypes.ts";
 | 
					import { EquipmentFeatures, Status } from "../types/equipmentTypes.ts";
 | 
				
			||||||
import type { ITypeCount } from "../types/commonTypes.ts";
 | 
					import type { ITypeCount } from "../types/commonTypes.ts";
 | 
				
			||||||
 | 
					import { skinLookupTable } from "../helpers/skinLookupTable.ts";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const createInventory = async (
 | 
					export const createInventory = async (
 | 
				
			||||||
    accountOwnerId: Types.ObjectId,
 | 
					    accountOwnerId: Types.ObjectId,
 | 
				
			||||||
@ -2371,6 +2372,25 @@ export const cleanupInventory = async (inventory: TInventoryDatabaseDocument): P
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const collectSkins = (skins: string[], weaponMap: Map<string, string>, itemsToAdd: Set<string>): void => {
 | 
				
			||||||
 | 
					    for (const skinId of skins) {
 | 
				
			||||||
 | 
					        if (skinId.startsWith("ca70ca70ca70ca70")) {
 | 
				
			||||||
 | 
					            const typeName = skinLookupTable[parseInt(skinId.slice(16), 16)];
 | 
				
			||||||
 | 
					            if (!weaponMap.has(typeName)) itemsToAdd.add(typeName);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const replaceSkinIds = (skins: string[], weaponMap: Map<string, string>): void => {
 | 
				
			||||||
 | 
					    for (let i = 0; i < skins.length; i++) {
 | 
				
			||||||
 | 
					        const skinId = skins[i];
 | 
				
			||||||
 | 
					        if (skinId.startsWith("ca70ca70ca70ca70")) {
 | 
				
			||||||
 | 
					            const inventoryId = weaponMap.get(skinLookupTable[parseInt(skinId.slice(16), 16)]);
 | 
				
			||||||
 | 
					            if (inventoryId) skins[i] = inventoryId;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const getDialogue = (inventory: TInventoryDatabaseDocument, dialogueName: string): IDialogueDatabase => {
 | 
					export const getDialogue = (inventory: TInventoryDatabaseDocument, dialogueName: string): IDialogueDatabase => {
 | 
				
			||||||
    inventory.DialogueHistory ??= {};
 | 
					    inventory.DialogueHistory ??= {};
 | 
				
			||||||
    inventory.DialogueHistory.Dialogues ??= [];
 | 
					    inventory.DialogueHistory.Dialogues ??= [];
 | 
				
			||||||
@ -2560,27 +2580,3 @@ export const updateEntratiVault = (inventory: TInventoryDatabaseDocument): void
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					 | 
				
			||||||
const skinLookupTable: Record<number, string> = {};
 | 
					 | 
				
			||||||
for (const key of Object.keys(ExportCustoms)) {
 | 
					 | 
				
			||||||
    skinLookupTable[catBreadHash(key)] = key;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const collectSkins = (skins: string[], weaponMap: Map<string, string>, itemsToAdd: Set<string>): void => {
 | 
					 | 
				
			||||||
    for (const skinId of skins) {
 | 
					 | 
				
			||||||
        if (skinId.startsWith("ca70ca70ca70ca70")) {
 | 
					 | 
				
			||||||
            const typeName = skinLookupTable[parseInt(skinId.slice(16), 16)];
 | 
					 | 
				
			||||||
            if (!weaponMap.has(typeName)) itemsToAdd.add(typeName);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const replaceSkinIds = (skins: string[], weaponMap: Map<string, string>): void => {
 | 
					 | 
				
			||||||
    for (let i = 0; i < skins.length; i++) {
 | 
					 | 
				
			||||||
        const skinId = skins[i];
 | 
					 | 
				
			||||||
        if (skinId.startsWith("ca70ca70ca70ca70")) {
 | 
					 | 
				
			||||||
            const inventoryId = weaponMap.get(skinLookupTable[parseInt(skinId.slice(16), 16)]);
 | 
					 | 
				
			||||||
            if (inventoryId) skins[i] = inventoryId;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user