Saving, technically done
This commit is contained in:
@ -63,7 +63,6 @@ class HomeplayEmulator {
|
||||
try {
|
||||
this.saveUpdates = await this.hasSaveUpdates();
|
||||
if(this.saveUpdates) {
|
||||
console.log('Saving');
|
||||
await this.save();
|
||||
}
|
||||
} catch(e) {
|
||||
@ -111,7 +110,9 @@ class HomeplayEmulator {
|
||||
|
||||
setTimeout(() => {
|
||||
window.EJS_emulator.gameManager.saveSaveFiles();
|
||||
this.gameStarted = true;
|
||||
setTimeout(() => {
|
||||
this.gameStarted = true;
|
||||
}, 1000);
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
@ -145,12 +146,8 @@ class HomeplayEmulator {
|
||||
window.EJS_volume = data.volume;
|
||||
break;
|
||||
|
||||
case 'save':
|
||||
window.EJS_emulator.saveSaveFiles();
|
||||
break;
|
||||
|
||||
default:
|
||||
console.error('Unknown message', message);
|
||||
console.error('Website sent invalid message', data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,19 +181,21 @@ class HomeplayEmulator {
|
||||
}
|
||||
|
||||
getSaveFiles = () => {
|
||||
return [ 'rom.srm' ];
|
||||
return [ 'rom.srm', 'rom.rtc' ];
|
||||
}
|
||||
|
||||
hasSaveUpdates = async () => {
|
||||
if(!window.EJS_emulator) return false;
|
||||
if(!window.EJS_emulator.gameManager) return false;
|
||||
if(!this.gameStarted) return false;
|
||||
// At least 20 seconds must've passed.
|
||||
if(window.EJS_emulator.gameManager.getFrameNum() < 20 * 60) return false;
|
||||
|
||||
const saveFiles = this.getSaveFiles();
|
||||
const hashes = await Promise.all(saveFiles.map(f => this.getFileMD5(`/homeplay/saves/${f}`)));
|
||||
|
||||
window.EJS_emulator.gameManager.saveSaveFiles();
|
||||
|
||||
|
||||
const newHashes = await Promise.all(saveFiles.map(f => this.getFileMD5(`/homeplay/saves/${f}`)));
|
||||
const changedFiles = saveFiles.filter((f, i) => hashes[i] !== newHashes[i]);
|
||||
|
||||
|
Reference in New Issue
Block a user