From f52c42e8b769cb179a7d6d5b71fec65e5af76cb6 Mon Sep 17 00:00:00 2001 From: Dev Date: Sun, 23 Apr 2023 19:24:00 +0100 Subject: [PATCH] Fixed bug when enabling generator for long-running generator-off crafts gaining a burst of progress as if generator was on the whole time Refactor updateProductionProgress() to get seconds between `sptUpdateLastRunTimestamp` and now instead of crafts `StartTimestamp` and now Store hideout craft progress as decimal for better accuracy when crafting without generator Added code to EventOutputHolder to ensure we continue to return progress as an int --- project/src/helpers/HideoutHelper.ts | 6 +++--- project/src/routers/EventOutputHolder.ts | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/project/src/helpers/HideoutHelper.ts b/project/src/helpers/HideoutHelper.ts index 8cea5c93..d24e50c0 100644 --- a/project/src/helpers/HideoutHelper.ts +++ b/project/src/helpers/HideoutHelper.ts @@ -289,12 +289,12 @@ export class HideoutHelper return; } - // Get seconds since production started + now - let timeElapsed = (this.timeUtil.getTimestamp() - pmcData.Hideout.Production[prodId].StartTimestamp) - pmcData.Hideout.Production[prodId].Progress; + // Get seconds since last hideout update + now + let timeElapsed = this.timeUtil.getTimestamp() - pmcData.Hideout.sptUpdateLastRunTimestamp; if (!hideoutProperties.isGeneratorOn) { // Adjust for running without fuel - timeElapsed = Math.floor(timeElapsed * this.databaseServer.getTables().hideout.settings.generatorSpeedWithoutFuel); + timeElapsed *= this.databaseServer.getTables().hideout.settings.generatorSpeedWithoutFuel; } // Increment progress by time passed diff --git a/project/src/routers/EventOutputHolder.ts b/project/src/routers/EventOutputHolder.ts index 5bd3ec1c..620c8f83 100644 --- a/project/src/routers/EventOutputHolder.ts +++ b/project/src/routers/EventOutputHolder.ts @@ -146,6 +146,12 @@ export class EventOutputHolder { this.clientActiveSessionStorage[productionKey] = {clientInformed: true}; } + + // Only return integer for progress, ignore the decimal progress gained when generator is off + if (production.Progress > 0) + { + Math.round(production.Progress); + } } return productions;