openrct2-ui cast fixes (#11348)

This commit is contained in:
Michał Janiszewski 2020-04-19 14:08:22 +02:00 committed by GitHub
parent d3a5446114
commit 5bfc41f49e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 26 additions and 26 deletions

View File

@ -83,7 +83,7 @@ std::string OpenGLShader::ReadSourceCode(const std::string& path)
throw IOException("Shader source too large.");
}
auto fileData = std::string((size_t)fileLength + 1, '\0');
auto fileData = std::string(static_cast<size_t>(fileLength) + 1, '\0');
fs.Read(static_cast<void*>(fileData.data()), fileLength);
return fileData;
}

View File

@ -277,7 +277,7 @@ AtlasTextureInfo TextureCache::AllocateImage(int32_t imageWidth, int32_t imageHe
}
auto atlasIndex = static_cast<int32_t>(_atlases.size());
int32_t atlasSize = powf(2, (float)Atlas::CalculateImageSizeOrder(imageWidth, imageHeight));
int32_t atlasSize = powf(2, static_cast<float>(Atlas::CalculateImageSizeOrder(imageWidth, imageHeight)));
# ifdef DEBUG
log_verbose("new texture atlas #%d (size %d) allocated", atlasIndex, atlasSize);

View File

@ -744,7 +744,7 @@ void theme_set_colour(rct_windowclass wc, uint8_t index, colour_t colour)
UIThemeWindowEntry entry{};
entry.WindowClass = wc;
auto currentEntry = (UIThemeWindowEntry*)ThemeManager::CurrentTheme->GetEntry(wc);
auto currentEntry = const_cast<UIThemeWindowEntry*>(ThemeManager::CurrentTheme->GetEntry(wc));
if (currentEntry != nullptr)
{
entry.Theme = currentEntry->Theme;

View File

@ -111,7 +111,7 @@ public:
}
// Check that position is valid
if (_position >= (int32_t)_sequence->NumCommands)
if (_position >= static_cast<int32_t>(_sequence->NumCommands))
{
_position = 0;
return false;
@ -173,7 +173,7 @@ public:
void Seek(int32_t targetPosition) override
{
if (targetPosition < 0 || targetPosition >= (int32_t)_sequence->NumCommands)
if (targetPosition < 0 || targetPosition >= static_cast<int32_t>(_sequence->NumCommands))
{
throw std::runtime_error("Invalid position.");
}

View File

@ -188,7 +188,7 @@ constexpr int32_t OPTW = 220; // Opti
constexpr int32_t OPTH = 10; // Option (checkbox) height (two columns)
constexpr int32_t GROUP_SPACE = 6;
#define YPL(ROW) (static_cast<int16_t>((YOS + ((BTNH + YSPA) * ROW))))
#define YPL(ROW) (static_cast<int16_t>((YOS + ((BTNH + YSPA) * ROW))))
#define HPL(ROW) (static_cast<int16_t>(YPL(ROW) + BTNH))
#define OHPL(ROW) (static_cast<int16_t>(YPL(ROW) + OPTH))
#define XPL(COL) (static_cast<int16_t>(XOS + ((BTNW + XSPA) * COL)))

View File

@ -169,7 +169,7 @@ void window_dropdown_show_text_custom_width(
{
rct_window* w;
input_set_flag((INPUT_FLAGS)(INPUT_FLAG_DROPDOWN_STAY_OPEN | INPUT_FLAG_DROPDOWN_MOUSE_UP), false);
input_set_flag(static_cast<INPUT_FLAGS>(INPUT_FLAG_DROPDOWN_STAY_OPEN | INPUT_FLAG_DROPDOWN_MOUSE_UP), false);
if (flags & DROPDOWN_FLAG_STAY_OPEN)
input_set_flag(INPUT_FLAG_DROPDOWN_STAY_OPEN, true);
@ -245,7 +245,7 @@ void window_dropdown_show_image(
int32_t width, height;
rct_window* w;
input_set_flag((INPUT_FLAGS)(INPUT_FLAG_DROPDOWN_STAY_OPEN | INPUT_FLAG_DROPDOWN_MOUSE_UP), false);
input_set_flag(static_cast<INPUT_FLAGS>(INPUT_FLAG_DROPDOWN_STAY_OPEN | INPUT_FLAG_DROPDOWN_MOUSE_UP), false);
if (flags & DROPDOWN_FLAG_STAY_OPEN)
input_set_flag(INPUT_FLAG_DROPDOWN_STAY_OPEN, true);

View File

@ -1028,7 +1028,7 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
if (widget->type != WWT_EMPTY)
{
stringId = _listSortType == RIDE_SORT_TYPE ? static_cast<rct_string_id>(_listSortDescending ? STR_DOWN : STR_UP)
: static_cast<rct_string_id>(STR_NONE);
: STR_NONE;
gfx_draw_string_left_clipped(
dpi, STR_OBJECTS_SORT_TYPE, &stringId, w->colours[1], w->windowPos.x + widget->left + 1,
w->windowPos.y + widget->top + 1, widget->right - widget->left);
@ -1037,7 +1037,7 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
if (widget->type != WWT_EMPTY)
{
stringId = _listSortType == RIDE_SORT_RIDE ? static_cast<rct_string_id>(_listSortDescending ? STR_DOWN : STR_UP)
: static_cast<rct_string_id>(STR_NONE);
: STR_NONE;
gfx_draw_string_left_clipped(
dpi, STR_OBJECTS_SORT_RIDE, &stringId, w->colours[1], w->windowPos.x + widget->left + 1,
w->windowPos.y + widget->top + 1, widget->right - widget->left);

View File

@ -906,7 +906,7 @@ static void window_mapgen_simplex_mouseup(rct_window* w, rct_widgetindex widgetI
mapgenSettings.simplex_low = _simplex_low;
mapgenSettings.simplex_high = _simplex_high;
mapgenSettings.simplex_base_freq = (static_cast<float>(_simplex_base_freq) / 100.00f);
mapgenSettings.simplex_base_freq = (static_cast<float>(_simplex_base_freq)) / 100.00f;
mapgenSettings.simplex_octaves = _simplex_octaves;
mapgen_generate(&mapgenSettings);

View File

@ -94,7 +94,7 @@ void window_map_tooltip_update_visibility()
if (_cursorHoldDuration < 25 || stringId == STR_NONE
|| input_test_place_object_modifier(
(PLACE_OBJECT_MODIFIER)(PLACE_OBJECT_MODIFIER_COPY_Z | PLACE_OBJECT_MODIFIER_SHIFT_Z))
static_cast<PLACE_OBJECT_MODIFIER>(PLACE_OBJECT_MODIFIER_COPY_Z | PLACE_OBJECT_MODIFIER_SHIFT_Z))
|| window_find_by_class(WC_ERROR) != nullptr)
{
window_close_by_class(WC_MAP_TOOLTIP);

View File

@ -1076,7 +1076,7 @@ static void window_options_mousedown(rct_window* w, rct_widgetindex widgetIndex,
if (resolution.Width == gConfigGeneral.fullscreen_width
&& resolution.Height == gConfigGeneral.fullscreen_height)
{
selectedResolution = (int32_t)i;
selectedResolution = static_cast<int32_t>(i);
}
}
@ -1255,7 +1255,7 @@ static void window_options_mousedown(rct_window* w, rct_widgetindex widgetIndex,
audio_populate_devices();
// populate the list with the sound devices
for (size_t i = 0; (int32_t)i < gAudioDeviceCount; i++)
for (size_t i = 0; static_cast<int32_t>(i) < gAudioDeviceCount; i++)
{
gDropdownItemsFormat[i] = STR_OPTIONS_DROPDOWN_ITEM;
gDropdownItemsArgs[i] = reinterpret_cast<uintptr_t>(gAudioDevices[i].name);
@ -1602,7 +1602,7 @@ static void window_options_dropdown(rct_window* w, rct_widgetindex widgetIndex,
switch (widgetIndex)
{
case WIDX_TITLE_SEQUENCE_DROPDOWN:
if (dropdownIndex != (int32_t)title_get_current_sequence())
if (dropdownIndex != static_cast<int32_t>(title_get_current_sequence()))
{
title_sequence_change_preset(static_cast<size_t>(dropdownIndex));
config_save_default();
@ -2077,7 +2077,7 @@ static void window_options_paint(rct_window* w, rct_drawpixelinfo* dpi)
dpi, STR_DRAWING_ENGINE, w, w->colours[1], w->windowPos.x + 10,
w->windowPos.y + window_options_display_widgets[WIDX_DRAWING_ENGINE].top + 1);
int32_t scale = static_cast<int32_t>((gConfigGeneral.window_scale * 100));
int32_t scale = static_cast<int32_t>(gConfigGeneral.window_scale * 100);
gfx_draw_string_left(
dpi, STR_WINDOW_OBJECTIVE_VALUE_RATING, &scale, w->colours[1], w->windowPos.x + w->widgets[WIDX_SCALE].left + 1,
w->windowPos.y + w->widgets[WIDX_SCALE].top + 1);
@ -2152,7 +2152,7 @@ static void window_options_paint(rct_window* w, rct_drawpixelinfo* dpi)
gfx_draw_string_left(
dpi, STR_AUTOSAVE_AMOUNT, w, w->colours[1], w->windowPos.x + 24,
w->windowPos.y + window_options_advanced_widgets[WIDX_AUTOSAVE_AMOUNT].top + 1);
int32_t autosavesToKeep = static_cast<int32_t>((gConfigGeneral.autosave_amount));
int32_t autosavesToKeep = static_cast<int32_t>(gConfigGeneral.autosave_amount);
gfx_draw_string_left(
dpi, STR_WINDOW_OBJECTIVE_VALUE_GUEST_COUNT, &autosavesToKeep, w->colours[1],
w->windowPos.x + w->widgets[WIDX_AUTOSAVE_AMOUNT].left + 1,

View File

@ -2487,7 +2487,7 @@ static void window_ride_main_dropdown(rct_window* w, rct_widgetindex widgetIndex
{
dropdownIndex = gDropdownHighlightedIndex;
}
if (dropdownIndex < (int32_t)std::size(gDropdownItemsArgs))
if (dropdownIndex < static_cast<int32_t>(std::size(gDropdownItemsArgs)))
{
switch (gDropdownItemsArgs[dropdownIndex])
{
@ -5338,7 +5338,7 @@ static void window_ride_music_paint(rct_window* w, rct_drawpixelinfo* dpi)
static rct_string_id get_rating_name(ride_rating rating)
{
int32_t index = std::clamp<int32_t>(rating >> 8, 0, (int32_t)std::size(RatingNames) - 1);
int32_t index = std::clamp<int32_t>(rating >> 8, 0, static_cast<int32_t>(std::size(RatingNames)) - 1);
return RatingNames[index];
}

View File

@ -686,7 +686,7 @@ static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi,
break;
case INFORMATION_TYPE_RUNNING_COST:
formatSecondary = STR_RIDE_LIST_RUNNING_COST_UNKNOWN;
if (ride->upkeep_cost != (money16)(uint16_t)0xFFFF)
if (ride->upkeep_cost != static_cast<money16>(0xFFFF))
{
formatSecondary = STR_RIDE_LIST_RUNNING_COST_LABEL;
set_format_arg(2, int32_t, ride->upkeep_cost * 16);
@ -784,7 +784,7 @@ void window_ride_list_refresh_list(rct_window* w)
for (auto& ridec : GetRideManager())
{
auto ride = &ridec;
if (ride->GetClassification() != (RideClassification)w->page
if (ride->GetClassification() != static_cast<RideClassification>(w->page)
|| (ride->status == RIDE_STATUS_CLOSED && !ride_has_any_track_elements(ride)))
continue;
@ -1010,7 +1010,7 @@ static void window_ride_list_close_all(rct_window* w)
{
for (auto& ride : GetRideManager())
{
if (ride.status != RIDE_STATUS_CLOSED && ride.GetClassification() == (RideClassification)w->page)
if (ride.status != RIDE_STATUS_CLOSED && ride.GetClassification() == static_cast<RideClassification>(w->page))
{
ride_set_status(&ride, RIDE_STATUS_CLOSED);
}
@ -1021,7 +1021,7 @@ static void window_ride_list_open_all(rct_window* w)
{
for (auto& ride : GetRideManager())
{
if (ride.status != RIDE_STATUS_OPEN && ride.GetClassification() == (RideClassification)w->page)
if (ride.status != RIDE_STATUS_OPEN && ride.GetClassification() == static_cast<RideClassification>(w->page))
{
ride_set_status(&ride, RIDE_STATUS_OPEN);
}

View File

@ -339,7 +339,7 @@ static void window_title_editor_mouseup(rct_window* w, rct_widgetindex widgetInd
if (w->selected_list_item != -1)
{
TitleSequenceRemovePark(_editingTitleSequence, w->selected_list_item);
if (w->selected_list_item >= (int16_t)_editingTitleSequence->NumSaves)
if (w->selected_list_item >= static_cast<int16_t>(_editingTitleSequence->NumSaves))
{
w->selected_list_item--;
}
@ -358,7 +358,7 @@ static void window_title_editor_mouseup(rct_window* w, rct_widgetindex widgetInd
}
break;
case WIDX_TITLE_EDITOR_LOAD_SAVE:
if (w->selected_list_item >= 0 && w->selected_list_item < (int16_t)_editingTitleSequence->NumSaves)
if (w->selected_list_item >= 0 && w->selected_list_item < static_cast<int16_t>(_editingTitleSequence->NumSaves))
{
auto handle = TitleSequenceGetParkHandle(_editingTitleSequence, w->selected_list_item);
auto stream = static_cast<IStream*>(handle->Stream);
@ -1032,7 +1032,7 @@ static void window_title_editor_scrollpaint_commands(rct_window* w, rct_drawpixe
else
{
format_string(buffer + 1, 255, commandName, gCommonFormatArgs);
buffer[0] = static_cast<utf8>((error) ? ((selected || hover) ? FORMAT_LIGHTPINK : FORMAT_RED) : FORMAT_BLACK);
buffer[0] = static_cast<utf8>(error ? ((selected || hover) ? FORMAT_LIGHTPINK : FORMAT_RED) : FORMAT_BLACK);
}
set_format_arg(0, uintptr_t, &buffer);
gfx_draw_string_left(dpi, STR_STRING, gCommonFormatArgs, w->colours[1], x + 5, y);