Fix up save state interval logic

This commit is contained in:
Ethan O'Brien 2025-04-05 21:50:46 -05:00
parent 0ee5cc9f06
commit 8df1acf446
No known key found for this signature in database
GPG Key ID: 7A6E7CCD3BD93AB1

View File

@ -3926,14 +3926,17 @@ class EmulatorJS {
}
} else if (option === "save-save-interval") {
value = parseInt(value);
if (this.saveSaveInterval !== null) {
if (this.saveSaveInterval && this.saveSaveInterval !== null) {
clearInterval(this.saveSaveInterval);
this.saveSaveInterval = null;
}
// Disabled
if (value === 0 || isNaN(value)) return;
this.gameManager.saveSaveFiles();
if (this.started) this.gameManager.saveSaveFiles();
if (this.debug) console.log("Saving every", value * 1000, "miliseconds");
setInterval(() => this.gameManager.saveSaveFiles(), value * 1000);
this.saveSaveInterval = setInterval(() => {
if (this.started) this.gameManager.saveSaveFiles();
}, value * 1000);
}
}
menuOptionChanged(option, value) {