Skip to content

Commit

Permalink
Pull asset version from the game
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanaobrien committed Jan 10, 2025
1 parent 7d25483 commit f5eb4d0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
14 changes: 8 additions & 6 deletions emscripten/static/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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");
};

const assets_version = Module.ccall("GetVersion", "string");

if (currentVersion !== assets_version || assets_version === "DEV")
//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...";
Expand Down
10 changes: 10 additions & 0 deletions src/openrct2/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f5eb4d0

Please sign in to comment.