Move setting of the generated bools to inside the cache methods (!298)

Also make `generateDynamicPrices` public to match the static method, and allow mods to refresh the cache

Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/298
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
This commit is contained in:
DrakiaXYZ 2024-04-18 07:55:39 +00:00 committed by chomp
parent 820a5caccb
commit 0d553e8ea6

View File

@ -56,13 +56,11 @@ export class RagfairPriceService implements OnLoad
if (!this.generatedStaticPrices) if (!this.generatedStaticPrices)
{ {
this.generateStaticPrices(); this.generateStaticPrices();
this.generatedStaticPrices = true;
} }
if (!this.generatedDynamicPrices) if (!this.generatedDynamicPrices)
{ {
this.generateDynamicPrices(); this.generateDynamicPrices();
this.generatedDynamicPrices = true;
} }
} }
@ -84,14 +82,18 @@ export class RagfairPriceService implements OnLoad
{ {
this.prices.static[item._id] = Math.round(this.handbookHelper.getTemplatePrice(item._id)); this.prices.static[item._id] = Math.round(this.handbookHelper.getTemplatePrice(item._id));
} }
this.generatedStaticPrices = true;
} }
/** /**
* Create a dictionary and store prices from prices.json in it * Create a dictionary and store prices from prices.json in it
*/ */
protected generateDynamicPrices(): void public generateDynamicPrices(): void
{ {
Object.assign(this.prices.dynamic, this.databaseServer.getTables().templates.prices); Object.assign(this.prices.dynamic, this.databaseServer.getTables().templates.prices);
this.generatedDynamicPrices = true;
} }
/** /**