mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-22 23:33:04 +01:00
Use named casts instead of old-style casts
Change prepared with clang-tidy and google-readability-casting check
This commit is contained in:
committed by
GitHub
parent
cfd94d4fa5
commit
2323cc1596
@@ -162,7 +162,7 @@ void window_update_all()
|
||||
static void window_close_surplus(int32_t cap, int8_t avoid_classification)
|
||||
{
|
||||
// find the amount of windows that are currently open
|
||||
auto count = (int32_t)g_window_list.size();
|
||||
auto count = static_cast<int32_t>(g_window_list.size());
|
||||
// difference between amount open and cap = amount to close
|
||||
auto diff = count - WINDOW_LIMIT_RESERVED - cap;
|
||||
for (auto i = 0; i < diff; i++)
|
||||
@@ -846,8 +846,8 @@ void window_scroll_to_location(rct_window* w, int32_t x, int32_t y, int32_t z)
|
||||
bool found = false;
|
||||
while (!found)
|
||||
{
|
||||
int16_t x2 = w->viewport->pos.x + (int16_t)(w->viewport->width * window_scroll_locations[i][0]);
|
||||
int16_t y2 = w->viewport->pos.y + (int16_t)(w->viewport->height * window_scroll_locations[i][1]);
|
||||
int16_t x2 = w->viewport->pos.x + static_cast<int16_t>(w->viewport->width * window_scroll_locations[i][0]);
|
||||
int16_t y2 = w->viewport->pos.y + static_cast<int16_t>(w->viewport->height * window_scroll_locations[i][1]);
|
||||
|
||||
auto it = window_get_iterator(w);
|
||||
for (; it != g_window_list.end(); it++)
|
||||
@@ -870,7 +870,7 @@ void window_scroll_to_location(rct_window* w, int32_t x, int32_t y, int32_t z)
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
if (i >= (int32_t)std::size(window_scroll_locations))
|
||||
if (i >= static_cast<int32_t>(std::size(window_scroll_locations)))
|
||||
{
|
||||
i = 0;
|
||||
found = true;
|
||||
@@ -883,8 +883,8 @@ void window_scroll_to_location(rct_window* w, int32_t x, int32_t y, int32_t z)
|
||||
if (!(w->flags & WF_NO_SCROLLING))
|
||||
{
|
||||
w->savedViewPos = screenCoords
|
||||
- ScreenCoordsXY{ (int16_t)(w->viewport->view_width * window_scroll_locations[i][0]),
|
||||
(int16_t)(w->viewport->view_height * window_scroll_locations[i][1]) };
|
||||
- ScreenCoordsXY{ static_cast<int16_t>(w->viewport->view_width * window_scroll_locations[i][0]),
|
||||
static_cast<int16_t>(w->viewport->view_height * window_scroll_locations[i][1]) };
|
||||
w->flags |= WF_SCROLLING_TO_LOCATION;
|
||||
}
|
||||
}
|
||||
@@ -2082,7 +2082,7 @@ void window_follow_sprite(rct_window* w, size_t spriteIndex)
|
||||
{
|
||||
if (spriteIndex < MAX_SPRITES || spriteIndex == SPRITE_INDEX_NULL)
|
||||
{
|
||||
w->viewport_smart_follow_sprite = (uint16_t)spriteIndex;
|
||||
w->viewport_smart_follow_sprite = static_cast<uint16_t>(spriteIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2157,8 +2157,8 @@ void widget_scroll_update_thumbs(rct_window* w, rct_widgetindex widget_index)
|
||||
{
|
||||
double barPosition = (scroll->h_thumb_right * 1.0) / view_size;
|
||||
|
||||
scroll->h_thumb_left = (uint16_t)std::lround(scroll->h_thumb_left - (20 * barPosition));
|
||||
scroll->h_thumb_right = (uint16_t)std::lround(scroll->h_thumb_right + (20 * (1 - barPosition)));
|
||||
scroll->h_thumb_left = static_cast<uint16_t>(std::lround(scroll->h_thumb_left - (20 * barPosition)));
|
||||
scroll->h_thumb_right = static_cast<uint16_t>(std::lround(scroll->h_thumb_right + (20 * (1 - barPosition))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2186,8 +2186,8 @@ void widget_scroll_update_thumbs(rct_window* w, rct_widgetindex widget_index)
|
||||
{
|
||||
double barPosition = (scroll->v_thumb_bottom * 1.0) / view_size;
|
||||
|
||||
scroll->v_thumb_top = (uint16_t)std::lround(scroll->v_thumb_top - (20 * barPosition));
|
||||
scroll->v_thumb_bottom = (uint16_t)std::lround(scroll->v_thumb_bottom + (20 * (1 - barPosition)));
|
||||
scroll->v_thumb_top = static_cast<uint16_t>(std::lround(scroll->v_thumb_top - (20 * barPosition)));
|
||||
scroll->v_thumb_bottom = static_cast<uint16_t>(std::lround(scroll->v_thumb_bottom + (20 * (1 - barPosition))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user