diff --git a/src/openrct2-ui/CursorRepository.cpp b/src/openrct2-ui/CursorRepository.cpp index d8070612bd..11657339c2 100644 --- a/src/openrct2-ui/CursorRepository.cpp +++ b/src/openrct2-ui/CursorRepository.cpp @@ -92,7 +92,7 @@ SDL_Cursor* CursorRepository::Create(const CursorData* cursorInfo, uint8_t scale { SDL_Cursor* cursor; - auto integer_scale = (int)round(scale); + auto integer_scale = static_cast(round(scale)); auto data = scaleDataArray(cursorInfo->Data, CURSOR_BIT_WIDTH, CURSOR_HEIGHT, static_cast(integer_scale)); auto mask = scaleDataArray(cursorInfo->Mask, CURSOR_BIT_WIDTH, CURSOR_HEIGHT, static_cast(integer_scale)); diff --git a/src/openrct2-ui/UiContext.Linux.cpp b/src/openrct2-ui/UiContext.Linux.cpp index f2b1f21e52..88a1e465f1 100644 --- a/src/openrct2-ui/UiContext.Linux.cpp +++ b/src/openrct2-ui/UiContext.Linux.cpp @@ -65,8 +65,8 @@ namespace OpenRCT2::Ui void* processHandle = dlopen(nullptr, RTLD_NOW); if (processHandle != nullptr) { - dummy* p = ((dummy*)processHandle)->ptr; - lmap* pl = (lmap*)p->ptr; + dummy* p = (static_cast(processHandle))->ptr; + lmap* pl = reinterpret_cast(p->ptr); while (pl != nullptr) { if (strstr(pl->path, "gameoverlayrenderer.so") != nullptr) @@ -357,7 +357,7 @@ namespace OpenRCT2::Ui } else if (isalpha(c)) { - filtersb << '[' << (char)tolower(c) << (char)toupper(c) << ']'; + filtersb << '[' << static_cast(tolower(c)) << static_cast(toupper(c)) << ']'; } else { diff --git a/src/openrct2-ui/UiContext.Win32.cpp b/src/openrct2-ui/UiContext.Win32.cpp index b4ed7e58d0..85c5189156 100644 --- a/src/openrct2-ui/UiContext.Win32.cpp +++ b/src/openrct2-ui/UiContext.Win32.cpp @@ -73,7 +73,7 @@ namespace OpenRCT2::Ui HWND hwnd = GetHWND(window); if (hwnd != nullptr) { - SendMessageA(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)icon); + SendMessageA(hwnd, WM_SETICON, ICON_SMALL, reinterpret_cast(icon)); } } } @@ -113,7 +113,7 @@ namespace OpenRCT2::Ui openFileName.lpstrInitialDir = wcInitialDirectory.c_str(); openFileName.lpstrFilter = wcFilters.c_str(); openFileName.lpstrFile = &wcFilename[0]; - openFileName.nMaxFile = (DWORD)wcFilename.size(); + openFileName.nMaxFile = static_cast(wcFilename.size()); // Open dialog BOOL dialogResult = FALSE; @@ -141,7 +141,7 @@ namespace OpenRCT2::Ui int32_t filterIndex = openFileName.nFilterIndex - 1; assert(filterIndex >= 0); - assert(filterIndex < (int32_t)desc.Filters.size()); + assert(filterIndex < static_cast(desc.Filters.size())); std::string pattern = desc.Filters[filterIndex].Pattern; std::string patternExtension = Path::GetExtension(pattern); diff --git a/src/openrct2-ui/UiContext.cpp b/src/openrct2-ui/UiContext.cpp index 63723a3772..88c15d495d 100644 --- a/src/openrct2-ui/UiContext.cpp +++ b/src/openrct2-ui/UiContext.cpp @@ -151,7 +151,7 @@ public: void SetFullscreenMode(FULLSCREEN_MODE mode) override { static constexpr const int32_t SDLFSFlags[] = { 0, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN_DESKTOP }; - uint32_t windowFlags = SDLFSFlags[(int32_t)mode]; + uint32_t windowFlags = SDLFSFlags[static_cast(mode)]; // HACK Changing window size when in fullscreen usually has no effect if (mode == FULLSCREEN_MODE::FULLSCREEN) @@ -499,7 +499,7 @@ public: // Zoom gesture constexpr int32_t tolerance = 128; - int32_t gesturePixels = (int32_t)(_gestureRadius * _width); + int32_t gesturePixels = static_cast(_gestureRadius * _width); if (abs(gesturePixels) > tolerance) { _gestureRadius = 0; @@ -661,7 +661,7 @@ private: OnResize(width, height); UpdateFullscreenResolutions(); - SetFullscreenMode((FULLSCREEN_MODE)gConfigGeneral.fullscreen_mode); + SetFullscreenMode(static_cast(gConfigGeneral.fullscreen_mode)); TriggerResize(); } @@ -669,8 +669,8 @@ private: void OnResize(int32_t width, int32_t height) { // Scale the native window size to the game's canvas size - _width = (int32_t)(width / gConfigGeneral.window_scale); - _height = (int32_t)(height / gConfigGeneral.window_scale); + _width = static_cast(width / gConfigGeneral.window_scale); + _height = static_cast(height / gConfigGeneral.window_scale); drawing_engine_resize(); @@ -713,13 +713,13 @@ private: // Get resolutions auto resolutions = std::vector(); - float desktopAspectRatio = (float)mode.w / mode.h; + float desktopAspectRatio = static_cast(mode.w) / mode.h; for (int32_t i = 0; i < numDisplayModes; i++) { SDL_GetDisplayMode(displayIndex, i, &mode); if (mode.w > 0 && mode.h > 0) { - float aspectRatio = (float)mode.w / mode.h; + float aspectRatio = static_cast(mode.w) / mode.h; if (std::fabs(desktopAspectRatio - aspectRatio) < 0.1f) { resolutions.push_back({ mode.w, mode.h }); diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index bc4237ee14..6eb5a04f01 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -212,9 +212,9 @@ public: switch (intent->GetWindowClass()) { case WC_PEEP: - return window_guest_open((Peep*)intent->GetPointerExtra(INTENT_EXTRA_PEEP)); + return window_guest_open(static_cast(intent->GetPointerExtra(INTENT_EXTRA_PEEP))); case WC_FIRE_PROMPT: - return window_staff_fire_prompt_open((Peep*)intent->GetPointerExtra(INTENT_EXTRA_PEEP)); + return window_staff_fire_prompt_open(static_cast(intent->GetPointerExtra(INTENT_EXTRA_PEEP))); case WC_INSTALL_TRACK: return window_install_track_open(intent->GetStringExtra(INTENT_EXTRA_PATH).c_str()); case WC_GUEST_LIST: @@ -224,14 +224,16 @@ public: { uint32_t type = intent->GetUIntExtra(INTENT_EXTRA_LOADSAVE_TYPE); std::string defaultName = intent->GetStringExtra(INTENT_EXTRA_PATH); - loadsave_callback callback = (loadsave_callback)intent->GetPointerExtra(INTENT_EXTRA_CALLBACK); + loadsave_callback callback = reinterpret_cast( + intent->GetPointerExtra(INTENT_EXTRA_CALLBACK)); TrackDesign* trackDesign = static_cast(intent->GetPointerExtra(INTENT_EXTRA_TRACK_DESIGN)); rct_window* w = window_loadsave_open(type, defaultName.c_str(), callback, trackDesign); return w; } case WC_MANAGE_TRACK_DESIGN: - return window_track_manage_open((track_design_file_ref*)intent->GetPointerExtra(INTENT_EXTRA_TRACK_DESIGN)); + return window_track_manage_open( + static_cast(intent->GetPointerExtra(INTENT_EXTRA_TRACK_DESIGN))); case WC_NETWORK_STATUS: { std::string message = intent->GetStringExtra(INTENT_EXTRA_MESSAGE); @@ -241,7 +243,7 @@ public: case WC_OBJECT_LOAD_ERROR: { std::string path = intent->GetStringExtra(INTENT_EXTRA_PATH); - const rct_object_entry* objects = (rct_object_entry*)intent->GetPointerExtra(INTENT_EXTRA_LIST); + const rct_object_entry* objects = static_cast(intent->GetPointerExtra(INTENT_EXTRA_LIST)); size_t count = intent->GetUIntExtra(INTENT_EXTRA_LIST_COUNT); window_object_load_error_open(const_cast(path.c_str()), count, objects); @@ -253,7 +255,8 @@ public: return ride == nullptr ? nullptr : window_ride_main_open(ride); } case WC_TRACK_DESIGN_PLACE: - return window_track_place_open((track_design_file_ref*)intent->GetPointerExtra(INTENT_EXTRA_TRACK_DESIGN)); + return window_track_place_open( + static_cast(intent->GetPointerExtra(INTENT_EXTRA_TRACK_DESIGN))); case WC_TRACK_DESIGN_LIST: { ride_list_item rideItem; @@ -263,11 +266,11 @@ public: } case WC_SCENARIO_SELECT: return window_scenarioselect_open( - (scenarioselect_callback)intent->GetPointerExtra(INTENT_EXTRA_CALLBACK), false); + reinterpret_cast(intent->GetPointerExtra(INTENT_EXTRA_CALLBACK)), false); case WD_VEHICLE: - return window_ride_open_vehicle((Vehicle*)intent->GetPointerExtra(INTENT_EXTRA_VEHICLE)); + return window_ride_open_vehicle(static_cast(intent->GetPointerExtra(INTENT_EXTRA_VEHICLE))); case WD_TRACK: - return window_ride_open_track((TileElement*)intent->GetPointerExtra(INTENT_EXTRA_TILE_ELEMENT)); + return window_ride_open_track(static_cast(intent->GetPointerExtra(INTENT_EXTRA_TILE_ELEMENT))); case INTENT_ACTION_NEW_RIDE_OF_TYPE: { // Open ride list window