From 7ac6bf8cd4f7a15f5fda9041699a673e6f1dd7c0 Mon Sep 17 00:00:00 2001 From: Aarex Tiaokhiao Date: Tue, 15 Sep 2020 10:38:47 -0400 Subject: [PATCH] Pre-Release 3 Patch 2 --- js/game.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/js/game.js b/js/game.js index 5731b53..1dd8a36 100644 --- a/js/game.js +++ b/js/game.js @@ -3851,6 +3851,12 @@ function keepGoing() { showTab("tree") } +function toNumber(x) { + if (x.mag !== undefined) return x.toNumber() + if (x + 0 !== x) return parseFloat(x) + return x +} + function addTime(diff, layer) { let data = player let time = data.timePlayed @@ -3862,15 +3868,14 @@ function addTime(diff, layer) { //I am not that good to perfectly fix that leak. ~ DB Aarex if (time + 0 !== time) { console.log("Memory leak detected. Trying to fix...") - if (time.mag !== undefined) time = time.toNumber() - else time = parseFloat(time) + time = toNumber(time) if (isNaN(time) || time == 0) { console.log("Couldn't fix! Resetting...") time = layer ? player.timePlayed : 0 if (!layer) player.timePlayedReset = true } } - time += diff + time += toNumber(diff) if (layer) data.time = time else data.timePlayed = time