Nullguard against missing data from client

This commit is contained in:
Dev 2023-08-07 19:42:23 +01:00
parent 7e75f867a0
commit dd26a94ede
2 changed files with 8 additions and 2 deletions

View File

@ -141,6 +141,11 @@ export class InRaidHelper
for (const backendCounterKey in saveProgressRequest.profile.BackendCounters)
{
if (!saveProgressRequest.profile.BackendCounters[backendCounterKey].id)
{
continue;
}
const matchingPreRaidCounter = profileData.BackendCounters[backendCounterKey];
if (!matchingPreRaidCounter)
{
@ -148,6 +153,7 @@ export class InRaidHelper
continue;
}
if (matchingPreRaidCounter.value !== saveProgressRequest.profile.BackendCounters[backendCounterKey].value)
{
this.logger.error(`Backendcounter: ${backendCounterKey} value is different post raid, old: ${matchingPreRaidCounter.value} new: saveProgressRequest.profile.BackendCounters[backendCounterKey].value`);

View File

@ -244,7 +244,7 @@ export class InsuranceService
{
equipmentToSendToPlayer.push({
pmcData: pmcData,
itemToReturnToPlayer: this.getInsuredItemDetails(pmcData, preRaidItem, offraidData.insurance.find(x => x.id === insuredItem.itemId)),
itemToReturnToPlayer: this.getInsuredItemDetails(pmcData, preRaidItem, offraidData.insurance?.find(x => x.id === insuredItem.itemId)),
traderId: insuredItem.tid,
sessionID: sessionID
});
@ -293,7 +293,7 @@ export class InsuranceService
}
// Client item has durability values, Ensure values persist into server data
if (insuredItemFromClient.durability)
if (insuredItemFromClient?.durability)
{
// Item didnt have Repairable object pre-raid, add it
if (!itemToReturn.upd.Repairable)