Remove some dead code

Reported by clang
clang-analyzer-deadcode.DeadStores
This commit is contained in:
Hielke Morsink 2021-09-24 23:21:35 +02:00
parent ba74393a43
commit 94144bcd89
No known key found for this signature in database
GPG Key ID: FE0B343DF883E7F2
15 changed files with 19 additions and 48 deletions

View File

@ -342,7 +342,7 @@ public:
{
window_close_construction_windows();
_currentRideIndex = static_cast<ride_id_t>(rideIndex);
w = OpenWindow(WC_RIDE_CONSTRUCTION);
OpenWindow(WC_RIDE_CONSTRUCTION);
}
else
{

View File

@ -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;

View File

@ -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
{

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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)

View File

@ -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;
}
}
}

View File

@ -958,8 +958,6 @@ void viewport_paint(
height &= bitmask;
left &= bitmask;
top &= bitmask;
right = left + width;
bottom = top + height;
auto x = left - static_cast<int32_t>(viewport->viewPos.x & bitmask);
x = x / viewport->zoom;

View File

@ -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;

View File

@ -4731,7 +4731,7 @@ void Guest::UpdateRideLeaveSpiralSlide()
SetDestination(targetLoc);
return;
}
waypoint = 3;
// Actually force the final waypoint
Var37 |= 3;

View File

@ -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))

View File

@ -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)
{

View File

@ -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();
}

View File

@ -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<const utf8**>(&ch))) != 0)
while (utf8_get_next(ch, const_cast<const utf8**>(&ch)) != 0)
{
if (ch <= sourceLimit)
{