diff --git a/emscripten/static/index.js b/emscripten/static/index.js index 55fe0905ea..30dae52aba 100644 --- a/emscripten/static/index.js +++ b/emscripten/static/index.js @@ -6,9 +6,6 @@ * * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ - -// assets_version should be updated when assets need to be re-downloaded on the client -const assets_version = "0.4.17-1"; (async () => { await new Promise(res => window.addEventListener("DOMContentLoaded", res)); @@ -159,10 +156,15 @@ async function updateAssets() { let currentVersion = ""; try { currentVersion = Module.FS.readFile("/OpenRCT2/version", {encoding: "utf8"}); - } catch(e) {}; - console.log("Found asset version", currentVersion); + console.log("Found asset version", currentVersion); + } catch(e) { + console.log("No asset version found"); + }; - if (currentVersion !== assets_version || assets_version === "DEV") + const assets_version = Module.ccall("GetVersion", "string"); + + //Always pull assets on a debug build + if (currentVersion !== assets_version || assets_version.includes("DEBUG")) { console.log("Updating assets to", assets_version); document.getElementById("loadingWebassembly").innerText = "Asset update found. Downloading..."; diff --git a/src/openrct2/Version.cpp b/src/openrct2/Version.cpp index 919f620413..9a0dd0e0c7 100644 --- a/src/openrct2/Version.cpp +++ b/src/openrct2/Version.cpp @@ -55,6 +55,16 @@ const char gVersionInfoFull[] = OPENRCT2_NAME ", " #endif ; +#ifdef __EMSCRIPTEN__ +// This must be wrapped in extern "C", according to the emscripten docs, "to prevent C++ name mangling" +extern "C" { +const char* GetVersion() +{ + return gVersionInfoFull; +} +} +#endif + NewVersionInfo GetLatestVersion() { // If the check doesn't succeed, provide current version so we don't bother user