diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index 813806aa18..fdc312becc 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -342,7 +342,7 @@ public: { window_close_construction_windows(); _currentRideIndex = static_cast(rideIndex); - w = OpenWindow(WC_RIDE_CONSTRUCTION); + OpenWindow(WC_RIDE_CONSTRUCTION); } else { diff --git a/src/openrct2-ui/interface/Widget.cpp b/src/openrct2-ui/interface/Widget.cpp index 4c883a04c7..db8904b694 100644 --- a/src/openrct2-ui/interface/Widget.cpp +++ b/src/openrct2-ui/interface/Widget.cpp @@ -465,11 +465,9 @@ static void WidgetGroupboxDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widget rct_widget* widget = &w->widgets[widgetIndex]; // Resolve the absolute ltrb - int32_t l = w->windowPos.x + widget->left + 5; - int32_t t = w->windowPos.y + widget->top; - int32_t r = w->windowPos.x + widget->right; - int32_t b = w->windowPos.y + widget->bottom; - int32_t textRight = l; + auto l = w->windowPos.x + widget->left + 5; + auto t = w->windowPos.y + widget->top; + auto textRight = l; // Text auto [stringId, formatArgs] = widget_get_stringid_and_args(widget); @@ -491,8 +489,8 @@ static void WidgetGroupboxDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widget // Resolve the absolute ltrb l = w->windowPos.x + widget->left; t = w->windowPos.y + widget->top + 4; - r = w->windowPos.x + widget->right; - b = w->windowPos.y + widget->bottom; + const auto r = w->windowPos.x + widget->right; + const auto b = w->windowPos.y + widget->bottom; // Get the colour uint8_t colour = w->colours[widget->colour] & 0x7F; diff --git a/src/openrct2-ui/windows/Options.cpp b/src/openrct2-ui/windows/Options.cpp index 58ddd2034b..51f7972ff2 100644 --- a/src/openrct2-ui/windows/Options.cpp +++ b/src/openrct2-ui/windows/Options.cpp @@ -1005,8 +1005,6 @@ static void window_options_rendering_mouseup(rct_window* w, rct_widgetindex widg static void window_options_rendering_mousedown(rct_window* w, rct_widgetindex widgetIndex, rct_widget* widget) { - widget = &w->widgets[widgetIndex - 1]; - switch (widgetIndex) { case WIDX_VIRTUAL_FLOOR_DROPDOWN: @@ -1258,7 +1256,6 @@ static void window_options_culture_dropdown(rct_window* w, rct_widgetindex widge } // report error to console regardless log_error("Failed to open language file."); - dropdownIndex = fallbackLanguage - 1; } else { diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index f23755bae5..15de24f541 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -3521,7 +3521,6 @@ void ride_construction_toolupdate_construct(const ScreenCoordsXY& screenCoords) &trackType, &trackDirection, &rideIndex, &liftHillAndAlternativeState, &trackPos, nullptr); _currentTrackPrice = place_provisional_track_piece( rideIndex, trackType, trackDirection, liftHillAndAlternativeState, trackPos); - z = trackPos.z; if (_currentTrackPrice != MONEY32_UNDEFINED) break; diff --git a/src/openrct2-ui/windows/ViewClipping.cpp b/src/openrct2-ui/windows/ViewClipping.cpp index 59a42072c4..e4c897d335 100644 --- a/src/openrct2-ui/windows/ViewClipping.cpp +++ b/src/openrct2-ui/windows/ViewClipping.cpp @@ -250,14 +250,12 @@ static void window_view_clipping_mousedown(rct_window* w, rct_widgetindex widget case WIDX_CLIP_HEIGHT_INCREASE: if (gClipHeight < 255) window_view_clipping_set_clipheight(w, gClipHeight + 1); - mainWindow = window_get_main(); if (mainWindow != nullptr) mainWindow->Invalidate(); break; case WIDX_CLIP_HEIGHT_DECREASE: if (gClipHeight > 0) window_view_clipping_set_clipheight(w, gClipHeight - 1); - mainWindow = window_get_main(); if (mainWindow != nullptr) mainWindow->Invalidate(); break; diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 50c8afb43f..4ee5331374 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -519,8 +519,6 @@ void game_fix_save_vars() void game_load_init() { - rct_window* mainWindow; - IGameStateSnapshots* snapshots = GetContext()->GetGameStateSnapshots(); snapshots->Reset(); @@ -530,11 +528,10 @@ void game_load_init() { viewport_init_all(); game_create_windows(); - mainWindow = window_get_main(); } else { - mainWindow = window_get_main(); + const auto mainWindow = window_get_main(); window_unfollow_sprite(mainWindow); } diff --git a/src/openrct2/actions/LandSmoothAction.cpp b/src/openrct2/actions/LandSmoothAction.cpp index 656949a681..0bee3b6253 100644 --- a/src/openrct2/actions/LandSmoothAction.cpp +++ b/src/openrct2/actions/LandSmoothAction.cpp @@ -542,17 +542,9 @@ GameActions::Result::Ptr LandSmoothAction::SmoothLand(bool isExecuting) const break; uint8_t newBaseZ = surfaceElement->base_height; uint8_t oldSlope = surfaceElement->GetSlope(); - uint8_t newSlope = oldSlope; int32_t rowIndex = selectionType - (MAP_SELECT_TYPE_EDGE_0 - MAP_SELECT_TYPE_FULL - 1); - - if (raiseLand) - { - newSlope = tile_element_raise_styles[rowIndex][oldSlope]; - } - else - { - newSlope = tile_element_lower_styles[rowIndex][oldSlope]; - } + uint8_t newSlope = raiseLand ? tile_element_raise_styles[rowIndex][oldSlope] + : tile_element_lower_styles[rowIndex][oldSlope]; const bool changeBaseHeight = newSlope & SURFACE_STYLE_FLAG_RAISE_OR_LOWER_BASE_HEIGHT; if (changeBaseHeight) diff --git a/src/openrct2/drawing/Drawing.String.cpp b/src/openrct2/drawing/Drawing.String.cpp index 421485132d..e6f1df2dde 100644 --- a/src/openrct2/drawing/Drawing.String.cpp +++ b/src/openrct2/drawing/Drawing.String.cpp @@ -958,7 +958,6 @@ static void ttf_process_initial_colour(int32_t colour, text_draw_info* info) info->palette[2] = (eax >> 8) & 0xFF; info->palette[3] = (eax >> 16) & 0xFF; info->palette[4] = (eax >> 24) & 0xFF; - eax = 0; } } } diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index a3d53b70d7..d301420a88 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -958,8 +958,6 @@ void viewport_paint( height &= bitmask; left &= bitmask; top &= bitmask; - right = left + width; - bottom = top + height; auto x = left - static_cast(viewport->viewPos.x & bitmask); x = x / viewport->zoom; diff --git a/src/openrct2/paint/tile_element/Paint.TileElement.cpp b/src/openrct2/paint/tile_element/Paint.TileElement.cpp index c6fa7c74e9..19c93a786c 100644 --- a/src/openrct2/paint/tile_element/Paint.TileElement.cpp +++ b/src/openrct2/paint/tile_element/Paint.TileElement.cpp @@ -211,8 +211,6 @@ static void sub_68B3FB(paint_session* session, int32_t x, int32_t y) #endif // __TESTPAINT__ dx -= max_height + 32; - - element = tile_element; // pop tile_element dx -= dpi->height; if (dx >= dpi->y) return; diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index 33cea3719d..f37e29329d 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -4731,7 +4731,7 @@ void Guest::UpdateRideLeaveSpiralSlide() SetDestination(targetLoc); return; } - waypoint = 3; + // Actually force the final waypoint Var37 |= 3; diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index df1247b4f8..691bdf8e88 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -3416,7 +3416,6 @@ bool Ride::CreateVehicles(const CoordsXYE& element, bool isApplying) trackElement = map_get_track_element_at(vehiclePos); vehiclePos.z = trackElement->GetBaseZ(); - direction = trackElement->GetDirection(); } if (!vehicle_create_trains(id, vehiclePos, trackElement)) diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 1dca09c289..4af87d4f7c 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -247,7 +247,6 @@ rct_string_id TrackDesign::CreateTrackDesignTrack(const Ride& ride) } trackElement.x = newCoords->x; trackElement.y = newCoords->y; - z = newCoords->z; if (track_elements.size() > TD6MaxTrackElements) { diff --git a/src/openrct2/scripting/bindings/world/ScTileElement.cpp b/src/openrct2/scripting/bindings/world/ScTileElement.cpp index 18f644c1f9..c582c6dd81 100644 --- a/src/openrct2/scripting/bindings/world/ScTileElement.cpp +++ b/src/openrct2/scripting/bindings/world/ScTileElement.cpp @@ -63,23 +63,22 @@ namespace OpenRCT2::Scripting void ScTileElement::type_set(std::string value) { - auto type = _element->type; if (value == "surface") - type = TILE_ELEMENT_TYPE_SURFACE; + _element->type = TILE_ELEMENT_TYPE_SURFACE; else if (value == "footpath") - type = TILE_ELEMENT_TYPE_PATH; + _element->type = TILE_ELEMENT_TYPE_PATH; else if (value == "track") - type = TILE_ELEMENT_TYPE_TRACK; + _element->type = TILE_ELEMENT_TYPE_TRACK; else if (value == "small_scenery") - type = TILE_ELEMENT_TYPE_SMALL_SCENERY; + _element->type = TILE_ELEMENT_TYPE_SMALL_SCENERY; else if (value == "entrance") - type = TILE_ELEMENT_TYPE_ENTRANCE; + _element->type = TILE_ELEMENT_TYPE_ENTRANCE; else if (value == "wall") - type = TILE_ELEMENT_TYPE_WALL; + _element->type = TILE_ELEMENT_TYPE_WALL; else if (value == "large_scenery") - type = TILE_ELEMENT_TYPE_LARGE_SCENERY; + _element->type = TILE_ELEMENT_TYPE_LARGE_SCENERY; else if (value == "banner") - type = TILE_ELEMENT_TYPE_BANNER; + _element->type = TILE_ELEMENT_TYPE_BANNER; else { if (value == "openrct2_corrupt_deprecated") @@ -88,7 +87,6 @@ namespace OpenRCT2::Scripting return; } - _element->type = type; Invalidate(); } diff --git a/src/openrct2/util/Util.cpp b/src/openrct2/util/Util.cpp index 67e08c80d7..387e890d04 100644 --- a/src/openrct2/util/Util.cpp +++ b/src/openrct2/util/Util.cpp @@ -387,8 +387,7 @@ utf8* safe_strtrunc(utf8* text, size_t size) const char* sourceLimit = text + size - 1; char* ch = text; char* last = text; - uint32_t codepoint; - while ((codepoint = utf8_get_next(ch, const_cast(&ch))) != 0) + while (utf8_get_next(ch, const_cast(&ch)) != 0) { if (ch <= sourceLimit) {