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
This commit is contained in:
Dev 2023-04-23 19:24:00 +01:00
parent d411f5ce1d
commit f52c42e8b7
2 changed files with 9 additions and 3 deletions

View File

@ -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

View File

@ -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;