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

Prevent nullref when profile is missing the Place of Fame area on game start

variable cleanup in build controller
This commit is contained in:
Dev 2024-04-05 18:42:09 +01:00 committed by Refringe
parent 387e924fb4
commit 798dcfffaa
Signed by: Refringe
GPG Key ID: 7715B85B4A6306ED
2 changed files with 12 additions and 6 deletions

View File

@ -147,7 +147,7 @@ export class BuildController
this.removePlayerBuild(request.id, sessionID);
}
protected removePlayerBuild(id: string, sessionID: string): void
protected removePlayerBuild(idToRemove: string, sessionID: string): void
{
const profile = this.saveServer.getProfile(sessionID);
const weaponBuilds = profile.userbuilds.weaponBuilds;
@ -155,7 +155,7 @@ export class BuildController
const magazineBuilds = profile.userbuilds.magazineBuilds;
// Check for id in weapon array first
const matchingWeaponBuild = weaponBuilds.find((x) => x.Id === id);
const matchingWeaponBuild = weaponBuilds.find((weaponBuild) => weaponBuild.Id === idToRemove);
if (matchingWeaponBuild)
{
weaponBuilds.splice(weaponBuilds.indexOf(matchingWeaponBuild), 1);
@ -164,7 +164,7 @@ export class BuildController
}
// Id not found in weapons, try equipment
const matchingEquipmentBuild = equipmentBuilds.find((x) => x.Id === id);
const matchingEquipmentBuild = equipmentBuilds.find((equipmentBuild) => equipmentBuild.Id === idToRemove);
if (matchingEquipmentBuild)
{
equipmentBuilds.splice(equipmentBuilds.indexOf(matchingEquipmentBuild), 1);
@ -173,7 +173,7 @@ export class BuildController
}
// Id not found in weapons/equipment, try mags
const matchingMagazineBuild = magazineBuilds.find((x) => x.Id === id);
const matchingMagazineBuild = magazineBuilds.find((magBuild) => magBuild.Id === idToRemove);
if (matchingMagazineBuild)
{
magazineBuilds.splice(magazineBuilds.indexOf(matchingMagazineBuild), 1);
@ -182,7 +182,9 @@ export class BuildController
}
// Not found in weapons,equipment or magazines, not good
this.logger.error(`Unable to delete preset, cannot find ${id} in weapon, equipment or magazine presets`);
this.logger.error(
`Unable to delete preset, cannot find ${idToRemove} in weapon, equipment or magazine presets`,
);
}
/**

View File

@ -282,7 +282,11 @@ export class ProfileFixerService
}
const db = this.databaseServer.getTables();
const placeOfFameAreaDb = db.hideout.areas.find((x) => x.type === HideoutAreas.PLACE_OF_FAME);
const placeOfFameAreaDb = db.hideout.areas.find((area) => area.type === HideoutAreas.PLACE_OF_FAME);
if (!placeOfFameAreaDb)
{
return;
}
const stageCurrentlyAt = placeOfFameAreaDb.stages[placeOfFameArea.level];
const placeOfFameStashId = pmcProfile.Inventory.hideoutAreaStashes[HideoutAreas.PLACE_OF_FAME];