mirror of https://github.com/OpenTTD/OpenTTD
Codechange: [Emscripten] Improve syncfs synchronisation on exit/abort
parent
75d3dc0a19
commit
3d1c4a8589
|
@ -52,24 +52,26 @@ Module.preRun.push(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
window.openttd_syncfs_shown_warning = false;
|
window.openttd_syncfs_shown_warning = false;
|
||||||
window.openttd_syncfs = function() {
|
window.openttd_syncfs = function(callback) {
|
||||||
/* Copy the virtual FS to the persistent storage. */
|
/* Copy the virtual FS to the persistent storage. */
|
||||||
FS.syncfs(false, function (err) { });
|
FS.syncfs(false, function (err) {
|
||||||
|
/* On first time, warn the user about the volatile behaviour of
|
||||||
|
* persistent storage. */
|
||||||
|
if (!window.openttd_syncfs_shown_warning) {
|
||||||
|
window.openttd_syncfs_shown_warning = true;
|
||||||
|
Module.onWarningFs();
|
||||||
|
}
|
||||||
|
|
||||||
/* On first time, warn the user about the volatile behaviour of
|
if (callback) callback();
|
||||||
* persistent storage. */
|
});
|
||||||
if (!window.openttd_syncfs_shown_warning) {
|
|
||||||
window.openttd_syncfs_shown_warning = true;
|
|
||||||
Module.onWarningFs();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.openttd_exit = function() {
|
window.openttd_exit = function() {
|
||||||
Module.onExit();
|
window.openttd_syncfs(Module.onExit);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.openttd_abort = function() {
|
window.openttd_abort = function() {
|
||||||
Module.onAbort();
|
window.openttd_syncfs(Module.onAbort);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.openttd_server_list = function() {
|
window.openttd_server_list = function() {
|
||||||
|
|
|
@ -118,7 +118,6 @@ void UserErrorI(const std::string &str)
|
||||||
/* In effect, the game ends here. As emscripten_set_main_loop() caused
|
/* In effect, the game ends here. As emscripten_set_main_loop() caused
|
||||||
* the stack to be unwound, the code after MainLoop() in
|
* the stack to be unwound, the code after MainLoop() in
|
||||||
* openttd_main() is never executed. */
|
* openttd_main() is never executed. */
|
||||||
EM_ASM(if (window["openttd_syncfs"]) openttd_syncfs());
|
|
||||||
EM_ASM(if (window["openttd_abort"]) openttd_abort());
|
EM_ASM(if (window["openttd_abort"]) openttd_abort());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -615,7 +615,6 @@ void VideoDriver_SDL_Base::LoopOnce()
|
||||||
/* In effect, the game ends here. As emscripten_set_main_loop() caused
|
/* In effect, the game ends here. As emscripten_set_main_loop() caused
|
||||||
* the stack to be unwound, the code after MainLoop() in
|
* the stack to be unwound, the code after MainLoop() in
|
||||||
* openttd_main() is never executed. */
|
* openttd_main() is never executed. */
|
||||||
EM_ASM(if (window["openttd_syncfs"]) openttd_syncfs());
|
|
||||||
EM_ASM(if (window["openttd_exit"]) openttd_exit());
|
EM_ASM(if (window["openttd_exit"]) openttd_exit());
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue