From 7a1e00b2e8ac4172779b3dde701aaf1128766b58 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sat, 3 Dec 2022 12:25:58 -0600 Subject: [PATCH] Fixed offline time not being capped --- src/util/save.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/util/save.ts b/src/util/save.ts index 4138e17..005e4e4 100644 --- a/src/util/save.ts +++ b/src/util/save.ts @@ -102,9 +102,12 @@ export async function loadSave(playerObj: Partial): Promise { getInitialLayers(playerObj).forEach(layer => addLayer(layer, playerObj)); playerObj = setupInitialStore(playerObj); - if (playerObj.offlineProd && playerObj.time) { + if (playerObj.offlineProd && playerObj.time && playerObj.devSpeed !== 0) { if (playerObj.offlineTime == undefined) playerObj.offlineTime = 0; - playerObj.offlineTime += (Date.now() - playerObj.time) / 1000; + playerObj.offlineTime += Math.min( + playerObj.offlineTime + (Date.now() - playerObj.time) / 1000, + projInfo.offlineLimit * 3600 + ); } playerObj.time = Date.now(); if (playerObj.modVersion !== projInfo.versionNumber) {