1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-24 07:14:31 +01:00

Fix emscripten support

This commit is contained in:
Ethan O'Brien
2024-12-31 09:31:33 -06:00
parent 752f169acf
commit 63b0106de8
28 changed files with 769 additions and 25 deletions

View File

@@ -1201,9 +1201,21 @@ namespace OpenRCT2
{
SwitchToStartUpScene();
}
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop_arg(
[](void* vctx) {
auto ctx = reinterpret_cast<Context*>(vctx);
if (ctx->_finished)
{
emscripten_cancel_main_loop();
}
ctx->RunFrame();
},
this, 0, 1);
#else
_stdInOutConsole.Start();
RunGameLoop();
#endif
}
bool ShouldDraw()
@@ -1229,6 +1241,7 @@ namespace OpenRCT2
/**
* Run the main game loop until the finished flag is set.
*/
#ifndef __EMSCRIPTEN__
void RunGameLoop()
{
PROFILED_FUNCTION();
@@ -1236,22 +1249,14 @@ namespace OpenRCT2
LOG_VERBOSE("begin openrct2 loop");
_finished = false;
#ifndef __EMSCRIPTEN__
_variableFrame = ShouldRunVariableFrame();
do
{
RunFrame();
} while (!_finished);
#else
emscripten_set_main_loop_arg(
[](void* vctx) -> {
auto ctx = reinterpret_cast<Context*>(vctx);
ctx->RunFrame();
},
this, 0, 1);
#endif // __EMSCRIPTEN__
LOG_VERBOSE("finish openrct2 loop");
}
#endif // __EMSCRIPTEN__
void RunFrame()
{