Insurance Package Removal Issue

Resolved an issue that caused insurance packages that were created/lost in the same raid with different traders to be removed all at once instead of one-by-one after they were processed. This shouldn't have been causing any notable issues as the packages were already cached/queued up for processing elsewhere in the code, but it was never the original intent to have them removed before they were processed. The fix was simply to also match the trader ID when the package removal takes place.

Possibly related to #401 #425
This commit is contained in:
Refringe 2024-02-06 20:08:14 -05:00
parent 6714d2d172
commit 2aa0054833
No known key found for this signature in database
GPG Key ID: 64E03E5F892C6F9E

View File

@ -10,7 +10,7 @@ import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGet
import { IGetInsuranceCostResponseData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostResponseData"; import { IGetInsuranceCostResponseData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostResponseData";
import { IInsureRequestData } from "@spt-aki/models/eft/insurance/IInsureRequestData"; import { IInsureRequestData } from "@spt-aki/models/eft/insurance/IInsureRequestData";
import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse"; import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse";
import { ISystemData, Insurance } from "@spt-aki/models/eft/profile/IAkiProfile"; import { Insurance } from "@spt-aki/models/eft/profile/IAkiProfile";
import { IProcessBuyTradeRequestData } from "@spt-aki/models/eft/trade/IProcessBuyTradeRequestData"; import { IProcessBuyTradeRequestData } from "@spt-aki/models/eft/trade/IProcessBuyTradeRequestData";
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
import { SkillTypes } from "@spt-aki/models/enums/SkillTypes"; import { SkillTypes } from "@spt-aki/models/enums/SkillTypes";
@ -136,7 +136,7 @@ export class InsuranceController
this.sendMail(sessionID, insured); this.sendMail(sessionID, insured);
// Remove the fully processed insurance package from the profile. // Remove the fully processed insurance package from the profile.
this.removeInsurancePackageFromProfile(sessionID, insured.systemData); this.removeInsurancePackageFromProfile(sessionID, insured);
} }
} }
@ -157,18 +157,17 @@ export class InsuranceController
* @param index The array index of the insurance package to remove. * @param index The array index of the insurance package to remove.
* @returns void * @returns void
*/ */
protected removeInsurancePackageFromProfile(sessionID: string, packageInfo: ISystemData): void protected removeInsurancePackageFromProfile(sessionID: string, insPackage: Insurance): void
{ {
const profile = this.saveServer.getProfile(sessionID); const profile = this.saveServer.getProfile(sessionID);
profile.insurance = profile.insurance.filter((insurance) => profile.insurance = profile.insurance.filter((insurance) =>
insurance.systemData.date !== packageInfo.date insurance.traderId !== insPackage.traderId
|| insurance.systemData.time !== packageInfo.time || insurance.systemData.date !== insPackage.systemData.date
|| insurance.systemData.location !== packageInfo.location || insurance.systemData.time !== insPackage.systemData.time
|| insurance.systemData.location !== insPackage.systemData.location
); );
this.logger.debug( this.logger.debug(`Removed processed insurance package. Remaining packages: ${profile.insurance.length}`);
`Removed insurance package with date: ${packageInfo.date}, time: ${packageInfo.time}, and location: ${packageInfo.location} from profile ${sessionID}. Remaining packages: ${profile.insurance.length}`,
);
} }
/** /**