mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-22 10:21:57 -05:00
Emscripten: handle missing assets
This commit is contained in:
parent
b576d896c6
commit
0eca0198dd
1 changed files with 21 additions and 3 deletions
|
@ -64,7 +64,11 @@ window_scale = 1.750000
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await updateAssets();
|
const assetsOK = await updateAssets();
|
||||||
|
if (!assetsOK)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
Module.FS.writeFile("/OpenRCT2/changelog.txt", `EMSCRIPTEN --- README
|
Module.FS.writeFile("/OpenRCT2/changelog.txt", `EMSCRIPTEN --- README
|
||||||
|
|
||||||
|
@ -134,12 +138,26 @@ async function updateAssets() {
|
||||||
console.log("Updating assets to", assetsVersion);
|
console.log("Updating assets to", assetsVersion);
|
||||||
document.getElementById("loadingWebassembly").innerText = "Asset update found. Downloading...";
|
document.getElementById("loadingWebassembly").innerText = "Asset update found. Downloading...";
|
||||||
await clearDatabase("/OpenRCT2/");
|
await clearDatabase("/OpenRCT2/");
|
||||||
await extractZip(await (await fetch("assets.zip")).blob(), () =>
|
|
||||||
{
|
// Fetch the assets.zip file
|
||||||
|
const response = await fetch("assets.zip");
|
||||||
|
if (!response.ok) {
|
||||||
|
if (response.status === 404) {
|
||||||
|
document.getElementById("loadingWebassembly").innerText = "Error! Assets file not found (404).";
|
||||||
|
} else {
|
||||||
|
document.getElementById("loadingWebassembly").innerText = `Error! Failed to download assets (status: ${response.status}).`;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
document.getElementById("loadingWebassembly").innerText = "Downloaded assets.zip";
|
||||||
|
}
|
||||||
|
|
||||||
|
await extractZip(await response.blob(), () => {
|
||||||
return "/OpenRCT2/";
|
return "/OpenRCT2/";
|
||||||
});
|
});
|
||||||
Module.FS.writeFile("/OpenRCT2/version", assetsVersion.toString());
|
Module.FS.writeFile("/OpenRCT2/version", assetsVersion.toString());
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function extractZip(data, checkZip) {
|
async function extractZip(data, checkZip) {
|
||||||
|
|
Loading…
Reference in a new issue