chore: add a helper for skinLookupTable
All checks were successful
Build / build (pull_request) Successful in 1m15s
All checks were successful
Build / build (pull_request) Successful in 1m15s
This commit is contained in:
parent
3a3d5de5dc
commit
fc0090e4c7
@ -20,13 +20,14 @@ import type {
|
||||
} from "../../types/inventoryTypes/inventoryTypes.ts";
|
||||
import { LoadoutIndex } from "../../types/inventoryTypes/inventoryTypes.ts";
|
||||
import type { RequestHandler } from "express";
|
||||
import { catBreadHash, getJSONfromString } from "../../helpers/stringHelpers.ts";
|
||||
import { ExportCustoms, ExportDojoRecipes } from "warframe-public-export-plus";
|
||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
|
||||
import { ExportDojoRecipes } from "warframe-public-export-plus";
|
||||
import type { IStatsClient } from "../../types/statTypes.ts";
|
||||
import { toStoreItem } from "../../services/itemDataService.ts";
|
||||
import type { FlattenMaps } from "mongoose";
|
||||
import type { IEquipmentClient } from "../../types/equipmentTypes.ts";
|
||||
import type { ILoadoutConfigClient } from "../../types/saveLoadoutTypes.ts";
|
||||
import { skinLookupTable } from "../../helpers/skinLookupTable.ts";
|
||||
|
||||
const getProfileViewingDataByPlayerIdImpl = async (playerId: string): Promise<IProfileViewingData | undefined> => {
|
||||
const account = await Account.findById(playerId, "DisplayName");
|
||||
@ -261,8 +262,6 @@ interface IXPComponentClient {
|
||||
locTags?: Record<string, string>;
|
||||
}
|
||||
|
||||
let skinLookupTable: Record<number, string> | undefined;
|
||||
|
||||
const resolveAndCollectSkins = (
|
||||
inventory: TInventoryDatabaseDocument,
|
||||
skins: Set<string>,
|
||||
@ -274,12 +273,6 @@ const resolveAndCollectSkins = (
|
||||
// Resolve oids to type names
|
||||
if (config.Skins[i].length == 24) {
|
||||
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)];
|
||||
} else {
|
||||
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 type { TAccountDocument } from "./loginService.ts";
|
||||
import { unixTimesInMs } from "../constants/timeConstants.ts";
|
||||
import { addString, catBreadHash } from "../helpers/stringHelpers.ts";
|
||||
import { addString } from "../helpers/stringHelpers.ts";
|
||||
import type {
|
||||
IEquipmentClient,
|
||||
IEquipmentDatabase,
|
||||
@ -92,6 +92,7 @@ import type {
|
||||
} from "../types/equipmentTypes.ts";
|
||||
import { EquipmentFeatures, Status } from "../types/equipmentTypes.ts";
|
||||
import type { ITypeCount } from "../types/commonTypes.ts";
|
||||
import { skinLookupTable } from "../helpers/skinLookupTable.ts";
|
||||
|
||||
export const createInventory = async (
|
||||
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 => {
|
||||
inventory.DialogueHistory ??= {};
|
||||
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