mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 09:50:43 -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:
parent
387e924fb4
commit
798dcfffaa
@ -147,7 +147,7 @@ export class BuildController
|
|||||||
this.removePlayerBuild(request.id, sessionID);
|
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 profile = this.saveServer.getProfile(sessionID);
|
||||||
const weaponBuilds = profile.userbuilds.weaponBuilds;
|
const weaponBuilds = profile.userbuilds.weaponBuilds;
|
||||||
@ -155,7 +155,7 @@ export class BuildController
|
|||||||
const magazineBuilds = profile.userbuilds.magazineBuilds;
|
const magazineBuilds = profile.userbuilds.magazineBuilds;
|
||||||
|
|
||||||
// Check for id in weapon array first
|
// 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)
|
if (matchingWeaponBuild)
|
||||||
{
|
{
|
||||||
weaponBuilds.splice(weaponBuilds.indexOf(matchingWeaponBuild), 1);
|
weaponBuilds.splice(weaponBuilds.indexOf(matchingWeaponBuild), 1);
|
||||||
@ -164,7 +164,7 @@ export class BuildController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Id not found in weapons, try equipment
|
// 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)
|
if (matchingEquipmentBuild)
|
||||||
{
|
{
|
||||||
equipmentBuilds.splice(equipmentBuilds.indexOf(matchingEquipmentBuild), 1);
|
equipmentBuilds.splice(equipmentBuilds.indexOf(matchingEquipmentBuild), 1);
|
||||||
@ -173,7 +173,7 @@ export class BuildController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Id not found in weapons/equipment, try mags
|
// 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)
|
if (matchingMagazineBuild)
|
||||||
{
|
{
|
||||||
magazineBuilds.splice(magazineBuilds.indexOf(matchingMagazineBuild), 1);
|
magazineBuilds.splice(magazineBuilds.indexOf(matchingMagazineBuild), 1);
|
||||||
@ -182,7 +182,9 @@ export class BuildController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Not found in weapons,equipment or magazines, not good
|
// 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`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -282,7 +282,11 @@ export class ProfileFixerService
|
|||||||
}
|
}
|
||||||
|
|
||||||
const db = this.databaseServer.getTables();
|
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 stageCurrentlyAt = placeOfFameAreaDb.stages[placeOfFameArea.level];
|
||||||
const placeOfFameStashId = pmcProfile.Inventory.hideoutAreaStashes[HideoutAreas.PLACE_OF_FAME];
|
const placeOfFameStashId = pmcProfile.Inventory.hideoutAreaStashes[HideoutAreas.PLACE_OF_FAME];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user