0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 08:10:44 -05:00

Add support for 'View Hideout' (#1072)

Adds missing data to the "view profile" endpoint.

NOTE: Causes severe freezes when viewing the hideout, but this happens
when loading your own too. I think this is a live issue.
This commit is contained in:
Lacyway 2025-01-13 01:55:06 -08:00 committed by GitHub
parent 67affbfaa3
commit 6800324a96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 4 deletions

View File

@ -132,7 +132,7 @@ export class GameController {
//3.9 migrations //3.9 migrations
if (fullProfile.spt.version.includes("3.9.") && !fullProfile.spt.migrations["39x"]) { if (fullProfile.spt.version.includes("3.9.") && !fullProfile.spt.migrations["39x"]) {
// Check every item has a valid mongoid // Check every item has a valid mongoid
this.inventoryHelper.validateInventoryUsesMonogoIds(fullProfile.characters.pmc.Inventory.items); this.inventoryHelper.validateInventoryUsesMongoIds(fullProfile.characters.pmc.Inventory.items);
this.migrate39xProfile(fullProfile); this.migrate39xProfile(fullProfile);

View File

@ -1,4 +1,5 @@
import { PlayerScavGenerator } from "@spt/generators/PlayerScavGenerator"; import { PlayerScavGenerator } from "@spt/generators/PlayerScavGenerator";
import { ItemHelper } from "@spt/helpers/ItemHelper";
import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper";
import { IPmcData } from "@spt/models/eft/common/IPmcData"; import { IPmcData } from "@spt/models/eft/common/IPmcData";
import { IMiniProfile } from "@spt/models/eft/launcher/IMiniProfile"; import { IMiniProfile } from "@spt/models/eft/launcher/IMiniProfile";
@ -29,7 +30,8 @@ export class ProfileController {
@inject("CreateProfileService") protected createProfileService: CreateProfileService, @inject("CreateProfileService") protected createProfileService: CreateProfileService,
@inject("PlayerScavGenerator") protected playerScavGenerator: PlayerScavGenerator, @inject("PlayerScavGenerator") protected playerScavGenerator: PlayerScavGenerator,
@inject("ProfileHelper") protected profileHelper: ProfileHelper, @inject("ProfileHelper") protected profileHelper: ProfileHelper,
) {} @inject("ItemHelper") protected itemHelper: ItemHelper,
) { }
/** /**
* Handle /launcher/profiles * Handle /launcher/profiles
@ -210,6 +212,14 @@ export class ProfileController {
} }
const playerPmc = profile.characters.pmc; const playerPmc = profile.characters.pmc;
const playerScav = profile.characters.scav; const playerScav = profile.characters.scav;
const hideoutKeys = [...Object.values(playerPmc.Inventory.hideoutAreaStashes), playerPmc.Inventory.hideoutCustomizationStashId];
const hideoutItems = playerPmc.Inventory.items.filter(x => hideoutKeys.includes(x._id));
const itemsToReturn = [];
for (const item of hideoutItems) {
const foundItems = this.itemHelper.findAndReturnChildrenAsItems(playerPmc.Inventory.items, item._id);
itemsToReturn.push(...foundItems);
}
return { return {
id: playerPmc._id, id: playerPmc._id,
@ -249,6 +259,10 @@ export class ProfileController {
overAllCounters: playerScav.Stats.Eft.OverallCounters, overAllCounters: playerScav.Stats.Eft.OverallCounters,
}, },
}, },
hideout: playerPmc.Hideout,
customizationStash: playerPmc.Inventory.hideoutCustomizationStashId,
hideoutAreaStashes: playerPmc.Inventory.hideoutAreaStashes,
items: itemsToReturn
}; };
} }

View File

@ -1,4 +1,4 @@
import { IOverallCounters, ISkills } from "@spt/models/eft/common/tables/IBotBase"; import { IHideout, IOverallCounters, ISkills } from "@spt/models/eft/common/tables/IBotBase";
import { IItem } from "@spt/models/eft/common/tables/IItem"; import { IItem } from "@spt/models/eft/common/tables/IItem";
export interface IGetOtherProfileResponse { export interface IGetOtherProfileResponse {
@ -12,6 +12,10 @@ export interface IGetOtherProfileResponse {
favoriteItems: IItem[]; favoriteItems: IItem[];
pmcStats: IOtherProfileStats; pmcStats: IOtherProfileStats;
scavStats: IOtherProfileStats; scavStats: IOtherProfileStats;
hideout: IHideout;
hideoutAreaStashes: Record<string, string>;
customizationStash: string;
items: IItem[];
} }
export interface IOtherProfileInfo { export interface IOtherProfileInfo {