Skip to content

Commit

Permalink
Correct Persistent spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanaobrien committed Jan 17, 2025
1 parent b4d7242 commit f7ca73c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 16 deletions.
36 changes: 32 additions & 4 deletions emscripten/deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
var EmscriptenDeps = {
ExportPersistantData: () =>
ExportPersistentData: () =>
{
if (!window.JSZip)
{
Expand Down Expand Up @@ -40,7 +40,7 @@ var EmscriptenDeps = {
processFolder(folder);
return zip;
}
const zip = zipFolder("/persistant/");
const zip = zipFolder("/persistent/");
zip.generateAsync({type: "blob"}).then(blob => {
const a = document.createElement("a");

Expand All @@ -50,13 +50,41 @@ var EmscriptenDeps = {
setTimeout(() => URL.revokeObjectURL(a.href), 1000);
})
},
ImportPersistantData: () =>
ImportPersistentData: () =>
{
if (!window.JSZip)
{
alert("JSZip library not found. Aborting");
return;
}
const clearDatabase = async function(dir) => {
await new Promise(res => Module.FS.syncfs(false, res));
const processFolder = (path) => {
let contents;
try {
contents = Module.FS.readdir(path);
} catch(e) {
return;
}
contents.forEach((entry) => {
if ([".", ".."].includes(entry)) return;
try {
Module.FS.readFile(path + entry);
Module.FS.unlink(path + entry);
} catch(e) {
processFolder(path + entry + "/");
}
})
if (path === dir) return;
try {
Module.FS.rmdir(path, {recursive: true});
} catch(e) {
console.log("Could not remove:", path);
}
}
processFolder(dir);
await new Promise(res => Module.FS.syncfs(false, res));
};
if (!confirm("Are you sure? This will wipe all current data.")) return;
alert("Select a zip file");
const input = document.createElement("input");
Expand All @@ -69,7 +97,7 @@ var EmscriptenDeps = {
alert("Not a zip file!");
return;
}
await clearDatabase("/persistant/");
await clearDatabase("/persistent/");
for (const k in zip.files) {
const entry = zip.files[k];
if (entry.dir) {
Expand Down
16 changes: 8 additions & 8 deletions emscripten/static/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
}
});

Module.FS.mkdir("/persistant");
Module.FS.mount(Module.FS.filesystems.IDBFS, {autoPersist: true}, '/persistant');
Module.FS.mkdir("/persistent");
Module.FS.mount(Module.FS.filesystems.IDBFS, {autoPersist: true}, '/persistent');

Module.FS.mkdir("/RCT");
Module.FS.mount(Module.FS.filesystems.IDBFS, {autoPersist: true}, '/RCT');
Expand All @@ -53,10 +53,10 @@

await new Promise(res => Module.FS.syncfs(true, res));

let configExists = fileExists("/persistant/config.ini");
let configExists = fileExists("/persistent/config.ini");
if (!configExists)
{
Module.FS.writeFile("/persistant/config.ini", `
Module.FS.writeFile("/persistent/config.ini", `
[general]
game_path = "/RCT"
uncap_fps = true
Expand All @@ -69,11 +69,11 @@ window_scale = 1.750000
Module.FS.writeFile("/OpenRCT2/changelog.txt", `EMSCRIPTEN --- README
Since we're running in the web browser, we don't have direct access to the file system.
All save data is saved under the directory /persistant.
All save data is saved under the directory /persistent.
ALWAYS be sure to save to /persistant/saves when saving a game! Otherwise it will be wiped!
ALWAYS be sure to save to /persistent/saves when saving a game! Otherwise it will be wiped!
You can import/export the /persistant folder in the options menu.`);
You can import/export the /persistent folder in the options menu.`);
document.getElementById("loadingWebassembly").remove();

let filesFound = fileExists("/RCT/Data/ch.dat");
Expand Down Expand Up @@ -110,7 +110,7 @@ You can import/export the /persistant folder in the options menu.`);
});
}
Module.canvas.style.display = "";
Module.callMain(["--user-data-path=/persistant/", "--openrct2-data-path=/OpenRCT2/"]);
Module.callMain(["--user-data-path=/persistent/", "--openrct2-data-path=/OpenRCT2/"]);
})();

async function updateAssets() {
Expand Down
8 changes: 4 additions & 4 deletions src/openrct2-ui/windows/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
extern "C" {
extern void ExportPersistantData();
extern void ImportPersistantData();
extern void ExportPersistentData();
extern void ImportPersistentData();
}
#endif

Expand Down Expand Up @@ -1991,10 +1991,10 @@ namespace OpenRCT2::Ui::Windows
break;
#ifdef __EMSCRIPTEN__
case WIDX_EXPORT_EMSCRIPTEN_DATA:
ExportPersistantData();
ExportPersistentData();
break;
case WIDX_IMPORT_EMSCRIPTEN_DATA:
ImportPersistantData();
ImportPersistentData();
break;
#endif
}
Expand Down

0 comments on commit f7ca73c

Please sign in to comment.