diff --git a/src/openrct2-ui/UiContext.cpp b/src/openrct2-ui/UiContext.cpp index 305203a4a2..3190f3169d 100644 --- a/src/openrct2-ui/UiContext.cpp +++ b/src/openrct2-ui/UiContext.cpp @@ -683,7 +683,6 @@ private: gfx_invalidate_screen(); // Check if the window has been resized in windowed mode and update the config file accordingly - // This is called in rct2_update and is only called after resizing a window has finished sint32 nonWindowFlags = #ifndef __MACOSX__ SDL_WINDOW_MAXIMIZED | diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index c3c9687f6e..b92b9ac98d 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -48,11 +48,13 @@ extern "C" #include "editor.h" #include "game.h" #include "interface/chat.h" + #include "interface/console.h" #include "interface/themes.h" #include "intro.h" #include "localisation/localisation.h" #include "network/http.h" #include "network/network.h" + #include "network/twitch.h" #include "object_list.h" #include "platform/platform.h" #include "rct1.h" @@ -80,9 +82,10 @@ namespace OpenRCT2 ITrackDesignRepository * _trackDesignRepository = nullptr; IScenarioRepository * _scenarioRepository = nullptr; - bool _isWindowMinimised = false; - uint32 _lastTick = 0; - uint32 _accumulator = 0; + bool _isWindowMinimised = false; + uint32 _lastTick = 0; + uint32 _accumulator = 0; + uint32 _lastUpdateTick = 0; /** If set, will end the OpenRCT2 game loop. Intentially private to this module so that the flag can not be set back to false. */ bool _finished = false; @@ -178,7 +181,7 @@ namespace OpenRCT2 if (!gOpenRCT2Headless) { - GetContext()->GetUiContext()->CreateWindow(); + _uiContext->CreateWindow(); } // TODO add configuration option to allow multiple instances @@ -404,7 +407,7 @@ namespace OpenRCT2 _lastTick = currentTick; _accumulator += elapsed; - GetContext()->GetUiContext()->ProcessMessages(); + _uiContext->ProcessMessages(); if (_accumulator < UPDATE_TIME_MS) { @@ -414,7 +417,7 @@ namespace OpenRCT2 _accumulator -= UPDATE_TIME_MS; - rct2_update(); + Update(); if (!_isWindowMinimised && !gOpenRCT2Headless) { platform_draw(); @@ -442,7 +445,7 @@ namespace OpenRCT2 _lastTick = currentTick; _accumulator += elapsed; - GetContext()->GetUiContext()->ProcessMessages(); + _uiContext->ProcessMessages(); while (_accumulator >= UPDATE_TIME_MS) { @@ -450,7 +453,7 @@ namespace OpenRCT2 if(draw) sprite_position_tween_store_a(); - rct2_update(); + Update(); _accumulator -= UPDATE_TIME_MS; @@ -470,6 +473,37 @@ namespace OpenRCT2 } } + void Update() + { + uint32 currentUpdateTick = platform_get_ticks(); + gTicksSinceLastUpdate = std::min(currentUpdateTick - _lastUpdateTick, 500); + _lastUpdateTick = currentUpdateTick; + + if (game_is_not_paused()) + { + gPaletteEffectFrame += gTicksSinceLastUpdate; + } + + date_update_real_time_of_day(); + + if (gIntroState != INTRO_STATE_NONE) + { + intro_update(); + } + else if ((gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) && !gOpenRCT2Headless) + { + title_update(); + } + else + { + game_update(); + } + + twitch_update(); + chat_update(); + console_update(); + } + bool OpenParkAutoDetectFormat(IStream * stream) { ClassifiedFile info; diff --git a/src/openrct2/game.c b/src/openrct2/game.c index f15ddec696..6022094c00 100644 --- a/src/openrct2/game.c +++ b/src/openrct2/game.c @@ -63,7 +63,6 @@ #define NUMBER_OF_AUTOSAVES_TO_KEEP 9 uint16 gTicksSinceLastUpdate; -uint32 gLastTickCount; uint8 gGamePaused = 0; sint32 gGameSpeed = 1; float gDayNightCycle = 0; diff --git a/src/openrct2/game.h b/src/openrct2/game.h index 5b5b533bd9..c042426477 100644 --- a/src/openrct2/game.h +++ b/src/openrct2/game.h @@ -143,7 +143,6 @@ extern uint32 gCurrentTicks; #endif extern uint16 gTicksSinceLastUpdate; -extern uint32 gLastTickCount; extern uint8 gGamePaused; extern sint32 gGameSpeed; extern float gDayNightCycle; diff --git a/src/openrct2/rct2.c b/src/openrct2/rct2.c index 79d02b3ab7..adb2073a0d 100644 --- a/src/openrct2/rct2.c +++ b/src/openrct2/rct2.c @@ -411,38 +411,6 @@ sint32 check_file_paths() return 1; } -void rct2_update() -{ - sint32 tickCount = platform_get_ticks(); - gTicksSinceLastUpdate = min(tickCount - gLastTickCount, 500); - gLastTickCount = tickCount; - if (game_is_not_paused()) { - gPaletteEffectFrame += gTicksSinceLastUpdate; - } - - date_update_real_time_of_day(); - - // TODO: screenshot countdown process - - // network_update() is called in game_update - - // check_cmdline_arg(); - // Screens - if (gIntroState != INTRO_STATE_NONE) { - intro_update(); - } else if ((gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) && !gOpenRCT2Headless) { - title_update(); - } else { - game_update(); - } - - //stop_completed_sounds(); // removes other sounds that are no longer playing in directsound - - twitch_update(); - chat_update(); - console_update(); -} - /** * * rct2: 0x00674E6C diff --git a/src/openrct2/rct2.h b/src/openrct2/rct2.h index 7c486bce93..487d7b72df 100644 --- a/src/openrct2/rct2.h +++ b/src/openrct2/rct2.h @@ -173,7 +173,6 @@ bool rct2_init(); sint32 rct2_init_directories(); sint32 rct2_startup_checks(); void rct2_dispose(); -void rct2_update(); void substitute_path(char *dest, size_t size, const char *path, const char *filename); sint32 check_mutex(); sint32 check_file_paths();