0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-12 16:30:42 -05:00

Added null protection to addHideoutEliteSlots() when profile lacks a generator

This commit is contained in:
Chomp 2024-12-07 11:41:51 +00:00
parent a431a3454b
commit fe482127ab

View File

@ -345,12 +345,11 @@ export class ProfileFixerService {
/**
* Initial release of SPT 3.10 used an incorrect favorites structure, reformat
* the structure to the correct MongoID array structure
* @param pmcProfile
* @param pmcProfile
*/
protected fixFavorites(pmcProfile: IPmcData): void {
const favoritesAsAny = pmcProfile.Inventory?.favoriteItems as any;
if (favoritesAsAny)
{
if (favoritesAsAny) {
const correctedFavorites = favoritesAsAny.map((favorite) => {
return favorite._id ?? favorite;
});
@ -367,12 +366,15 @@ export class ProfileFixerService {
protected addHideoutEliteSlots(pmcProfile: IPmcData): void {
const globals = this.databaseService.getGlobals();
const genSlots = pmcProfile.Hideout.Areas.find((x) => x.type === HideoutAreas.GENERATOR).slots.length;
const extraGenSlots = globals.config.SkillsSettings.HideoutManagement.EliteSlots.Generator.Slots;
const generator = pmcProfile.Hideout.Areas.find((area) => area.type === HideoutAreas.GENERATOR);
if (generator) {
const genSlots = generator.slots.length;
const extraGenSlots = globals.config.SkillsSettings.HideoutManagement.EliteSlots.Generator.Slots;
if (genSlots < 6 + extraGenSlots) {
this.logger.debug("Updating generator area slots to a size of 6 + hideout management skill");
this.addEmptyObjectsToHideoutAreaSlots(HideoutAreas.GENERATOR, 6 + extraGenSlots, pmcProfile);
if (genSlots < 6 + extraGenSlots) {
this.logger.debug("Updating generator area slots to a size of 6 + hideout management skill");
this.addEmptyObjectsToHideoutAreaSlots(HideoutAreas.GENERATOR, 6 + extraGenSlots, pmcProfile);
}
}
const waterCollSlots = pmcProfile.Hideout.Areas.find((x) => x.type === HideoutAreas.WATER_COLLECTOR).slots