mirror of
https://github.com/IvarK/AntimatterDimensionsSourceCode.git
synced 2025-02-18 08:30:13 +00:00
Fix real time and game time desync
This commit is contained in:
parent
afe9e65771
commit
28f9053dd6
@ -483,7 +483,9 @@ function getGameSpeedupForDisplay() {
|
||||
|
||||
let autobuyerOnGameLoop = true;
|
||||
|
||||
// "diff" is in ms. When unspecified, it just uses the game update rate.
|
||||
// "diff" is in ms. It is only unspecified when it's being called normally and not due to simulating time, in which
|
||||
// case it uses the gap between now and the last time the function was called. This is on average equal to the update
|
||||
// rate.
|
||||
function gameLoop(diff, options = {}) {
|
||||
PerformanceStats.start("Frame Time");
|
||||
PerformanceStats.start("Game Update");
|
||||
@ -493,17 +495,16 @@ function gameLoop(diff, options = {}) {
|
||||
? Math.clamp(thisUpdate - player.lastUpdate, 1, 21600000)
|
||||
: diff;
|
||||
|
||||
player.realTimePlayed += realDiff;
|
||||
player.thisInfinityRealTime += realDiff;
|
||||
player.thisEternityRealTime += realDiff;
|
||||
player.thisRealityRealTime += realDiff;
|
||||
|
||||
// Matter dimensions bypass any kind of stored time mechanics
|
||||
Laitela.handleMatterDimensionUnlocks();
|
||||
matterDimensionLoop(realDiff);
|
||||
|
||||
// When storing real time, skip everything else having to do with production once stats are updated
|
||||
if (Enslaved.isStoringRealTime) {
|
||||
player.realTimePlayed += realDiff;
|
||||
player.thisInfinityRealTime += realDiff;
|
||||
player.thisEternityRealTime += realDiff;
|
||||
player.thisRealityRealTime += realDiff;
|
||||
Enslaved.storeRealTime();
|
||||
GameUI.update();
|
||||
return;
|
||||
@ -518,7 +519,7 @@ function gameLoop(diff, options = {}) {
|
||||
Enslaved.useStoredTime(true);
|
||||
Enslaved.isReleaseTick = true;
|
||||
} else if (!Enslaved.isReleaseTick) {
|
||||
Enslaved.nextTickDiff = player.options.updateRate;
|
||||
Enslaved.nextTickDiff = realDiff;
|
||||
}
|
||||
if (diff === undefined) {
|
||||
diff = Enslaved.nextTickDiff;
|
||||
@ -565,6 +566,18 @@ function gameLoop(diff, options = {}) {
|
||||
}
|
||||
player.celestials.ra.peakGamespeed = Math.max(player.celestials.ra.peakGamespeed, getGameSpeedupFactor());
|
||||
Enslaved.isReleaseTick = false;
|
||||
|
||||
// These need to all be done consecutively in order to minimize the chance of a reset occurring between real time
|
||||
// updating and game time updating. This is only particularly noticeable when game speed is 1 and the player
|
||||
// expects to see identical numbers.
|
||||
player.realTimePlayed += realDiff;
|
||||
player.totalTimePlayed += diff;
|
||||
player.thisInfinityRealTime += realDiff;
|
||||
player.thisInfinityTime += diff;
|
||||
player.thisEternityRealTime += realDiff;
|
||||
player.thisEternity += diff;
|
||||
player.thisRealityRealTime += realDiff;
|
||||
player.thisReality += diff;
|
||||
|
||||
DeltaTimeState.update(realDiff, diff);
|
||||
|
||||
@ -653,10 +666,6 @@ function gameLoop(diff, options = {}) {
|
||||
}
|
||||
|
||||
if (Perk.autocompleteEC1.isBought && player.reality.autoEC) player.reality.lastAutoEC += realDiff;
|
||||
player.totalTimePlayed += diff;
|
||||
player.thisInfinityTime += diff;
|
||||
player.thisEternity += diff;
|
||||
player.thisReality += diff;
|
||||
|
||||
EternityChallenge(12).tryFail();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user