Merge pull request #8339 from ZehMatt/realtime-ticks

Use real time ticks for UI effects.
This commit is contained in:
Michael Steenbeek authored and GitHub committed 2018-12-15 21:00:44 +01:00
commit 6d0f0334d7
12 files changed
+28 -18

No files matched your search

+3 -3
View File
@@ -259,7 +259,7 @@ static void input_scroll_right(int32_t x, int32_t y, int32_t state)
switch (state)
{
case MOUSE_STATE_RELEASED:
_ticksSinceDragStart += gTicksSinceLastUpdate;
_ticksSinceDragStart += gCurrentDeltaTime;
if (x != 0 || y != 0)
{
_ticksSinceDragStart = 1000;
@@ -552,7 +552,7 @@ static void input_viewport_drag_continue()
}
viewport = w->viewport;
_ticksSinceDragStart += gTicksSinceLastUpdate;
_ticksSinceDragStart += gCurrentDeltaTime;
if (viewport == nullptr)
{
context_show_cursor();
@@ -1479,7 +1479,7 @@ static void input_update_tooltip(rct_window* w, rct_widgetindex widgetIndex, int
window_tooltip_close();
}
gTooltipTimeout += gTicksSinceLastUpdate;
gTooltipTimeout += gCurrentDeltaTime;
if (gTooltipTimeout >= 8000)
{
window_close_by_class(WC_TOOLTIP);
@@ -486,7 +486,7 @@ static void window_game_bottom_toolbar_draw_park_rating(
bar_width = (factor * 114) / 255;
gfx_fill_rect_inset(dpi, x + 1, y + 1, x + 114, y + 9, w->colours[1], INSET_RECT_F_30);
if (!(colour & IMAGE_TYPE_REMAP_2_PLUS) || game_is_paused() || (gCurrentTicks & 8))
if (!(colour & IMAGE_TYPE_REMAP_2_PLUS) || game_is_paused() || (gCurrentRealTimeTicks & 8))
{
if (bar_width > 2)
gfx_fill_rect_inset(dpi, x + 2, y + 2, x + bar_width - 1, y + 8, colour & 0x7FFFFFFF, 0);
+1 -1
View File
@@ -1378,7 +1378,7 @@ static void window_guest_stats_bars_paint(
int32_t blink_flag = colour & BAR_BLINK;
colour &= ~BAR_BLINK;
if (!blink_flag || game_is_paused() || (gCurrentTicks & 8) == 0)
if (!blink_flag || game_is_paused() || (gCurrentRealTimeTicks & 8) == 0)
{
value *= 118;
value >>= 8;
+1 -1
View File
@@ -3793,7 +3793,7 @@ static void window_ride_maintenance_draw_bar(
if (colour & BAR_BLINK)
{
colour &= ~BAR_BLINK;
if (game_is_not_paused() && (gCurrentTicks & 8))
if (game_is_not_paused() && (gCurrentRealTimeTicks & 8))
return;
}
+1 -1
View File
@@ -302,7 +302,7 @@ static void window_ride_list_resize(rct_window* w)
// Refreshing the list can be a very intensive operation
// owing to its use of ride_has_any_track_elements().
// This makes sure it's only refreshed every 64 ticks.
if (!(gCurrentTicks & 0x3f))
if (!(gCurrentRealTimeTicks & 0x3f))
{
window_ride_list_refresh_list(w);
}
+6 -5
View File
@@ -110,7 +110,7 @@ namespace OpenRCT2
bool _isWindowMinimised = false;
uint32_t _lastTick = 0;
uint32_t _accumulator = 0;
uint32_t _lastUpdateTick = 0;
uint32_t _lastUpdateTime = 0;
bool _variableFrame = false;
// If set, will end the OpenRCT2 game loop. Intentially private to this module so that the flag can not be set back to
@@ -921,13 +921,14 @@ namespace OpenRCT2
void Update()
{
uint32_t currentUpdateTick = platform_get_ticks();
gTicksSinceLastUpdate = std::min<uint32_t>(currentUpdateTick - _lastUpdateTick, 500);
_lastUpdateTick = currentUpdateTick;
uint32_t currentUpdateTime = platform_get_ticks();
gCurrentDeltaTime = std::min<uint32_t>(currentUpdateTime - _lastUpdateTime, 500);
_lastUpdateTime = currentUpdateTime;
if (game_is_not_paused())
{
gPaletteEffectFrame += gTicksSinceLastUpdate;
gPaletteEffectFrame += gCurrentDeltaTime;
}
date_update_real_time_of_day();
+2 -1
View File
@@ -65,7 +65,7 @@
#define NUMBER_OF_AUTOSAVES_TO_KEEP 9
uint16_t gTicksSinceLastUpdate;
uint16_t gCurrentDeltaTime;
uint8_t gGamePaused = 0;
int32_t gGameSpeed = 1;
bool gDoSingleUpdate = false;
@@ -82,6 +82,7 @@ uint8_t gUnk13CA740;
uint8_t gUnk141F568;
uint32_t gCurrentTicks;
uint32_t gCurrentRealTimeTicks;
// clang-format off
GAME_COMMAND_CALLBACK_POINTER * game_command_callback = nullptr;
+2 -1
View File
@@ -138,8 +138,9 @@ extern rct_string_id gErrorStringId;
extern GAME_COMMAND_POINTER* new_game_command_table[GAME_COMMAND_COUNT];
extern uint32_t gCurrentTicks;
extern uint32_t gCurrentRealTimeTicks;
extern uint16_t gTicksSinceLastUpdate;
extern uint16_t gCurrentDeltaTime;
extern uint8_t gGamePaused;
extern int32_t gGameSpeed;
extern bool gDoSingleUpdate;
+8 -3
View File
@@ -91,6 +91,12 @@ void GameState::Update()
}
}
uint32_t realtimeTicksElapsed = gCurrentDeltaTime / GAME_UPDATE_TIME_MS;
realtimeTicksElapsed = std::clamp<uint32_t>(realtimeTicksElapsed, 1, GAME_MAX_UPDATES);
// We use this variable to always advance ticks in normal speed.
gCurrentRealTimeTicks += realtimeTicksElapsed;
// Determine how many times we need to update the game
if (gGameSpeed > 1)
{
@@ -98,8 +104,7 @@ void GameState::Update()
}
else
{
numUpdates = gTicksSinceLastUpdate / GAME_UPDATE_TIME_MS;
numUpdates = std::clamp<uint32_t>(numUpdates, 1, GAME_MAX_UPDATES);
numUpdates = realtimeTicksElapsed;
}
if (network_get_mode() == NETWORK_MODE_CLIENT && network_get_status() == NETWORK_STATUS_CONNECTED
@@ -163,7 +168,7 @@ void GameState::Update()
// the flickering frequency is reduced by 4, compared to the original
// it was done due to inability to reproduce original frequency
// and decision that the original one looks too fast
if (gCurrentTicks % 4 == 0)
if (gCurrentRealTimeTicks % 4 == 0)
gWindowMapFlashingFlags ^= (1 << 15);
// Handle guest map flashing
+1 -1
View File
@@ -133,7 +133,7 @@ void window_update_all()
// gfx_draw_all_dirty_blocks();
// 1000 tick update
gWindowUpdateTicks += gTicksSinceLastUpdate;
gWindowUpdateTicks += gCurrentDeltaTime;
if (gWindowUpdateTicks >= 1000)
{
gWindowUpdateTicks = 0;
@@ -62,6 +62,7 @@ void date_reset()
gDateMonthsElapsed = 0;
gDateMonthTicks = 0;
gCurrentTicks = 0;
gCurrentRealTimeTicks = 0;
}
void date_set(int32_t year, int32_t month, int32_t day)
+1
View File
@@ -384,6 +384,7 @@ public:
user_string_clear_all();
memcpy(gUserStrings, _s6.custom_strings, sizeof(_s6.custom_strings));
gCurrentTicks = _s6.game_ticks_1;
gCurrentRealTimeTicks = 0;
ImportRides();