Set correct data to favoriteItems array (!411)
This PR fixes an inconsistency in favoriteItems, at least in the latest EFT it deserializes an actual item rather than a string of item id's I also made it empty out the array if the profile is converted, I tacked this onto the karma system as it only needs to happen and I was lazy to write more code to check for this, however if it's required for this PR to be merged feel free to say so. Reviewed-on: https://dev.sp-tarkov.com/SPT/Server/pulls/411 Co-authored-by: Archangel <jesse@archangel.wtf> Co-committed-by: Archangel <jesse@archangel.wtf>
This commit is contained in:
parent
4851784626
commit
fefa9b3b39
@ -245,10 +245,14 @@ export class GameController {
|
||||
}
|
||||
|
||||
protected migrate39xProfile(fullProfile: ISptProfile) {
|
||||
// Karma
|
||||
// Karma & Favorite items
|
||||
if (typeof fullProfile.characters.pmc.karmaValue === "undefined") {
|
||||
this.logger.warning("Migration: Added karma value of 0.2 to profile");
|
||||
fullProfile.characters.pmc.karmaValue = 0.2;
|
||||
|
||||
// Reset the PMC's favorite items, as the previous data was incorrect.
|
||||
this.logger.warning("Migration: Emptied out favoriteItems array on profile.");
|
||||
fullProfile.characters.pmc.Inventory.favoriteItems = [];
|
||||
}
|
||||
|
||||
// Equipment area
|
||||
|
@ -933,11 +933,18 @@ export class InventoryController {
|
||||
|
||||
for (const itemId of request.items) {
|
||||
// If id already exists in array, we're removing it
|
||||
const indexOfItemAlreadyFavorited = pmcData.Inventory.favoriteItems.findIndex((x) => x === itemId);
|
||||
const indexOfItemAlreadyFavorited = pmcData.Inventory.favoriteItems.findIndex(x => x._id === itemId);
|
||||
if (indexOfItemAlreadyFavorited > -1) {
|
||||
pmcData.Inventory.favoriteItems.splice(indexOfItemAlreadyFavorited, 1);
|
||||
} else {
|
||||
pmcData.Inventory.favoriteItems.push(itemId);
|
||||
let item = pmcData.Inventory.items.find(i => i._id === itemId);
|
||||
|
||||
if (item === undefined)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
pmcData.Inventory.favoriteItems.push(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ export interface Inventory {
|
||||
/** Key is hideout area enum numeric as string e.g. "24", value is area _id */
|
||||
hideoutAreaStashes: Record<string, string>;
|
||||
fastPanel: Record<string, string>;
|
||||
favoriteItems: string[];
|
||||
favoriteItems: Item[];
|
||||
}
|
||||
|
||||
export interface IBaseJsonSkills {
|
||||
|
@ -9,7 +9,7 @@ export interface IGetOtherProfileResponse {
|
||||
skills: Skills;
|
||||
equipment: IOtherProfileEquipment;
|
||||
achievements: Record<string, number>;
|
||||
favoriteItems: string[];
|
||||
favoriteItems: Item[];
|
||||
pmcStats: IOtherProfileStats;
|
||||
scavStats: IOtherProfileStats;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user