mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-31 10:45:16 +01:00
Reduce static access and call from anonymous function
This commit is contained in:
committed by
Michał Janiszewski
parent
100a63a743
commit
1eb3d07b3d
@@ -547,28 +547,6 @@ namespace OpenRCT2
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void RunGameTick(void * vctx)
|
||||
{
|
||||
Context * ctx = reinterpret_cast<Context *>(vctx);
|
||||
bool useVariableFrame = ctx->ShouldRunVariableFrame();
|
||||
// Make sure we catch the state change and reset it.
|
||||
if (ctx->_variableFrame != useVariableFrame)
|
||||
{
|
||||
ctx->_lastTick = 0;
|
||||
ctx->_variableFrame = useVariableFrame;
|
||||
}
|
||||
|
||||
if (useVariableFrame)
|
||||
{
|
||||
ctx->RunVariableFrame();
|
||||
}
|
||||
else
|
||||
{
|
||||
ctx->RunFixedFrame();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the main game loop until the finished flag is set.
|
||||
*/
|
||||
@@ -579,18 +557,41 @@ namespace OpenRCT2
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
_variableFrame = ShouldRunVariableFrame();
|
||||
|
||||
do
|
||||
{
|
||||
RunGameTick(this);
|
||||
|
||||
} while (!_finished);
|
||||
}
|
||||
while (!_finished);
|
||||
#else
|
||||
emscripten_set_main_loop_arg(RunGameTick, this, 0, 1);
|
||||
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");
|
||||
}
|
||||
|
||||
void RunFrame()
|
||||
{
|
||||
// Make sure we catch the state change and reset it.
|
||||
bool useVariableFrame = ShouldRunVariableFrame();
|
||||
if (_variableFrame != useVariableFrame)
|
||||
{
|
||||
_lastTick = 0;
|
||||
_variableFrame = useVariableFrame;
|
||||
}
|
||||
|
||||
if (useVariableFrame)
|
||||
{
|
||||
RunVariableFrame();
|
||||
}
|
||||
else
|
||||
{
|
||||
RunFixedFrame();
|
||||
}
|
||||
}
|
||||
|
||||
void RunFixedFrame()
|
||||
{
|
||||
uint32 currentTick = platform_get_ticks();
|
||||
|
||||
Reference in New Issue
Block a user