0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 09:50:43 -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

@ -349,8 +349,7 @@ export class ProfileFixerService {
*/ */
protected fixFavorites(pmcProfile: IPmcData): void { protected fixFavorites(pmcProfile: IPmcData): void {
const favoritesAsAny = pmcProfile.Inventory?.favoriteItems as any; const favoritesAsAny = pmcProfile.Inventory?.favoriteItems as any;
if (favoritesAsAny) if (favoritesAsAny) {
{
const correctedFavorites = favoritesAsAny.map((favorite) => { const correctedFavorites = favoritesAsAny.map((favorite) => {
return favorite._id ?? favorite; return favorite._id ?? favorite;
}); });
@ -367,13 +366,16 @@ export class ProfileFixerService {
protected addHideoutEliteSlots(pmcProfile: IPmcData): void { protected addHideoutEliteSlots(pmcProfile: IPmcData): void {
const globals = this.databaseService.getGlobals(); const globals = this.databaseService.getGlobals();
const genSlots = pmcProfile.Hideout.Areas.find((x) => x.type === HideoutAreas.GENERATOR).slots.length; 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; const extraGenSlots = globals.config.SkillsSettings.HideoutManagement.EliteSlots.Generator.Slots;
if (genSlots < 6 + extraGenSlots) { if (genSlots < 6 + extraGenSlots) {
this.logger.debug("Updating generator area slots to a size of 6 + hideout management skill"); this.logger.debug("Updating generator area slots to a size of 6 + hideout management skill");
this.addEmptyObjectsToHideoutAreaSlots(HideoutAreas.GENERATOR, 6 + extraGenSlots, pmcProfile); this.addEmptyObjectsToHideoutAreaSlots(HideoutAreas.GENERATOR, 6 + extraGenSlots, pmcProfile);
} }
}
const waterCollSlots = pmcProfile.Hideout.Areas.find((x) => x.type === HideoutAreas.WATER_COLLECTOR).slots const waterCollSlots = pmcProfile.Hideout.Areas.find((x) => x.type === HideoutAreas.WATER_COLLECTOR).slots
.length; .length;