diff --git a/src/3rdparty/squirrel/squirrel/sqobject.cpp b/src/3rdparty/squirrel/squirrel/sqobject.cpp --- a/src/3rdparty/squirrel/squirrel/sqobject.cpp +++ b/src/3rdparty/squirrel/squirrel/sqobject.cpp @@ -446,11 +446,11 @@ bool SQFunctionProto::Load(SQVM *v,SQUse for(i = 0; i < noutervalues; i++){ SQUnsignedInteger type; - SQObjectPtr name; + SQObjectPtr value_name; _CHECK_IO(SafeRead(v,read,up, &type, sizeof(SQUnsignedInteger))); _CHECK_IO(ReadObject(v, up, read, o)); - _CHECK_IO(ReadObject(v, up, read, name)); - f->_outervalues[i] = SQOuterVar(name,o, (SQOuterType)type); + _CHECK_IO(ReadObject(v, up, read, value_name)); + f->_outervalues[i] = SQOuterVar(value_name,o, (SQOuterType)type); } _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART)); diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -781,7 +781,6 @@ CommandCost CmdAutoreplaceVehicle(DoComm RestoreRandomSeeds(saved_seeds); if (cost.Succeeded() && (flags & DC_EXEC) != 0) { - CommandCost ret; if (free_wagon) { ret = ReplaceFreeUnit(&v, flags, ¬hing_to_do); } else { diff --git a/src/base_media_func.h b/src/base_media_func.h --- a/src/base_media_func.h +++ b/src/base_media_func.h @@ -48,7 +48,7 @@ bool BaseSetdescription[std::string{}] = *item->value; /* Add the translations of the descriptions too. */ - for (const IniItem *item = metadata->item; item != nullptr; item = item->next) { + for (item = metadata->item; item != nullptr; item = item->next) { if (item->name.compare(0, 12, "description.") != 0) continue; this->description[item->name.substr(12)] = item->value.value_or(""); diff --git a/src/company_gui.cpp b/src/company_gui.cpp --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -633,7 +633,6 @@ private: void ShowColourDropDownMenu(uint32 widget) { uint32 used_colours = 0; - const Company *c; const Livery *livery, *default_livery = nullptr; bool primary = widget == WID_SCL_PRI_COL_DROPDOWN; byte default_col = 0; @@ -645,7 +644,7 @@ private: } } - c = Company::Get((CompanyID)this->window_number); + const Company *c = Company::Get((CompanyID)this->window_number); if (this->livery_class < LC_GROUP_RAIL) { /* Get the first selected livery to use as the default dropdown item */ diff --git a/src/gfx.cpp b/src/gfx.cpp --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -1327,7 +1327,6 @@ void DoPaletteAnimations() const ExtraPaletteValues *ev = &_extra_palette_values; Colour old_val[PALETTE_ANIM_SIZE]; const uint old_tc = palette_animation_counter; - uint i; uint j; if (blitter != nullptr && blitter->UsePaletteAnimation() == Blitter::PALETTE_ANIMATION_NONE) { @@ -1342,7 +1341,7 @@ void DoPaletteAnimations() /* Fizzy Drink bubbles animation */ s = ev->fizzy_drink; j = EXTR2(512, EPV_CYCLES_FIZZY_DRINK); - for (i = 0; i != EPV_CYCLES_FIZZY_DRINK; i++) { + for (uint i = 0; i != EPV_CYCLES_FIZZY_DRINK; i++) { *palette_pos++ = s[j]; j++; if (j == EPV_CYCLES_FIZZY_DRINK) j = 0; @@ -1351,7 +1350,7 @@ void DoPaletteAnimations() /* Oil refinery fire animation */ s = ev->oil_refinery; j = EXTR2(512, EPV_CYCLES_OIL_REFINERY); - for (i = 0; i != EPV_CYCLES_OIL_REFINERY; i++) { + for (uint i = 0; i != EPV_CYCLES_OIL_REFINERY; i++) { *palette_pos++ = s[j]; j++; if (j == EPV_CYCLES_OIL_REFINERY) j = 0; @@ -1391,7 +1390,7 @@ void DoPaletteAnimations() /* Handle lighthouse and stadium animation */ s = ev->lighthouse; j = EXTR(256, EPV_CYCLES_LIGHTHOUSE); - for (i = 0; i != EPV_CYCLES_LIGHTHOUSE; i++) { + for (uint i = 0; i != EPV_CYCLES_LIGHTHOUSE; i++) { *palette_pos++ = s[j]; j++; if (j == EPV_CYCLES_LIGHTHOUSE) j = 0; @@ -1400,7 +1399,7 @@ void DoPaletteAnimations() /* Dark blue water */ s = (_settings_game.game_creation.landscape == LT_TOYLAND) ? ev->dark_water_toyland : ev->dark_water; j = EXTR(320, EPV_CYCLES_DARK_WATER); - for (i = 0; i != EPV_CYCLES_DARK_WATER; i++) { + for (uint i = 0; i != EPV_CYCLES_DARK_WATER; i++) { *palette_pos++ = s[j]; j++; if (j == EPV_CYCLES_DARK_WATER) j = 0; @@ -1409,7 +1408,7 @@ void DoPaletteAnimations() /* Glittery water */ s = (_settings_game.game_creation.landscape == LT_TOYLAND) ? ev->glitter_water_toyland : ev->glitter_water; j = EXTR(128, EPV_CYCLES_GLITTER_WATER); - for (i = 0; i != EPV_CYCLES_GLITTER_WATER / 3; i++) { + for (uint i = 0; i != EPV_CYCLES_GLITTER_WATER / 3; i++) { *palette_pos++ = s[j]; j += 3; if (j >= EPV_CYCLES_GLITTER_WATER) j -= EPV_CYCLES_GLITTER_WATER; @@ -1669,23 +1668,23 @@ void DrawDirtyBlocks() while (right != w) { byte *p2 = ++p; - int h = h2; + int i = h2; /* Check if a full line of dirty flags is set. */ do { if (!*p2) goto no_more_coalesc; p2 += _dirty_bytes_per_line; - } while (--h != 0); + } while (--i != 0); /* Wohoo, can combine it one step to the right! * Do that, and clear the bits. */ right += DIRTY_BLOCK_WIDTH; - h = h2; + i = h2; p2 = p; do { *p2 = 0; p2 += _dirty_bytes_per_line; - } while (--h != 0); + } while (--i != 0); } no_more_coalesc: diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -662,8 +662,6 @@ static void AnimateTile_Industry(TileInd case GFX_PLASTIC_FOUNTAIN_ANIMATED_5: case GFX_PLASTIC_FOUNTAIN_ANIMATED_6: case GFX_PLASTIC_FOUNTAIN_ANIMATED_7: case GFX_PLASTIC_FOUNTAIN_ANIMATED_8: if ((_tick_counter & 3) == 0) { - IndustryGfx gfx = GetIndustryGfx(tile); - gfx = (gfx < 155) ? gfx + 1 : 148; SetIndustryGfx(tile, gfx); MarkTileDirtyByTile(tile); @@ -675,8 +673,6 @@ static void AnimateTile_Industry(TileInd case GFX_OILWELL_ANIMATED_3: if ((_tick_counter & 7) == 0) { bool b = Chance16(1, 7); - IndustryGfx gfx = GetIndustryGfx(tile); - byte m = GetAnimationFrame(tile) + 1; if (m == 4 && (m = 0, ++gfx) == GFX_OILWELL_ANIMATED_3 + 1 && (gfx = GFX_OILWELL_ANIMATED_1, b)) { SetIndustryGfx(tile, GFX_OILWELL_NOT_ANIMATED); @@ -1467,13 +1463,13 @@ static CommandCost CheckIfIndustryTilesA /* Clear the tiles as OWNER_TOWN to not affect town rating, and to not clear protected buildings */ Backup cur_company(_current_company, OWNER_TOWN, FILE_LINE); - CommandCost ret = Command::Do(DC_NONE, cur_tile); + ret = Command::Do(DC_NONE, cur_tile); cur_company.Restore(); if (ret.Failed()) return ret; } else { /* Clear the tiles, but do not affect town ratings */ - CommandCost ret = Command::Do(DC_AUTO | DC_NO_TEST_TOWN_RATING | DC_NO_MODIFY_TOWN_RATING, cur_tile); + ret = Command::Do(DC_AUTO | DC_NO_TEST_TOWN_RATING | DC_NO_MODIFY_TOWN_RATING, cur_tile); if (ret.Failed()) return ret; } } diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -2775,7 +2775,7 @@ struct IndustryCargoesWindow : public Wi int num_cust = CountMatchingAcceptingIndustries(central_sp->produced_cargo, lengthof(central_sp->produced_cargo)) + houses_accept; int num_indrows = std::max(3, std::max(num_supp, num_cust)); // One is needed for the 'it' industry, and 2 for the cargo labels. for (int i = 0; i < num_indrows; i++) { - CargoesRow &row = this->fields.emplace_back(); + row = this->fields.emplace_back(); row.columns[0].MakeEmpty(CFT_EMPTY); row.columns[1].MakeCargo(central_sp->accepts_cargo, lengthof(central_sp->accepts_cargo)); row.columns[2].MakeEmpty(CFT_EMPTY); @@ -2850,7 +2850,7 @@ struct IndustryCargoesWindow : public Wi int num_cust = CountMatchingAcceptingIndustries(&cid, 1) + houses_accept; int num_indrows = std::max(num_supp, num_cust); for (int i = 0; i < num_indrows; i++) { - CargoesRow &row = this->fields.emplace_back(); + row = this->fields.emplace_back(); row.columns[0].MakeEmpty(CFT_EMPTY); row.columns[1].MakeCargo(&cid, 1); row.columns[2].MakeEmpty(CFT_EMPTY); diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -1054,11 +1054,11 @@ void ClientNetworkContentSocketHandler:: * After that's done run over them once again to test their children * to unselect. Don't do it immediately because it'll do exactly what * we're doing now. */ - for (const ContentInfo *c : parents) { - if (c->state == ContentInfo::AUTOSELECTED) this->Unselect(c->id); + for (const ContentInfo *parent : parents) { + if (parent->state == ContentInfo::AUTOSELECTED) this->Unselect(parent->id); } - for (const ContentInfo *c : parents) { - this->CheckDependencyState(this->GetContent(c->id)); + for (const ContentInfo *parent : parents) { + this->CheckDependencyState(this->GetContent(parent->id)); } } } diff --git a/src/newgrf.cpp b/src/newgrf.cpp --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -4270,13 +4270,13 @@ static ChangeInfoResult RailTypeChangeIn int n = buf->ReadByte(); for (int j = 0; j != n; j++) { RailTypeLabel label = buf->ReadDWord(); - RailType rt = GetRailTypeByLabel(BSWAP32(label), false); - if (rt != INVALID_RAILTYPE) { + RailType resolved_rt = GetRailTypeByLabel(BSWAP32(label), false); + if (resolved_rt != INVALID_RAILTYPE) { switch (prop) { - case 0x0F: SetBit(rti->powered_railtypes, rt); FALLTHROUGH; // Powered implies compatible. - case 0x0E: SetBit(rti->compatible_railtypes, rt); break; - case 0x18: SetBit(rti->introduction_required_railtypes, rt); break; - case 0x19: SetBit(rti->introduces_railtypes, rt); break; + case 0x0F: SetBit(rti->powered_railtypes, resolved_rt); FALLTHROUGH; // Powered implies compatible. + case 0x0E: SetBit(rti->compatible_railtypes, resolved_rt); break; + case 0x18: SetBit(rti->introduction_required_railtypes, resolved_rt); break; + case 0x19: SetBit(rti->introduces_railtypes, resolved_rt); break; } } } @@ -4484,12 +4484,12 @@ static ChangeInfoResult RoadTypeChangeIn int n = buf->ReadByte(); for (int j = 0; j != n; j++) { RoadTypeLabel label = buf->ReadDWord(); - RoadType rt = GetRoadTypeByLabel(BSWAP32(label), false); - if (rt != INVALID_ROADTYPE) { + RoadType resolved_rt = GetRoadTypeByLabel(BSWAP32(label), false); + if (resolved_rt != INVALID_ROADTYPE) { switch (prop) { - case 0x0F: SetBit(rti->powered_roadtypes, rt); break; - case 0x18: SetBit(rti->introduction_required_roadtypes, rt); break; - case 0x19: SetBit(rti->introduces_roadtypes, rt); break; + case 0x0F: SetBit(rti->powered_roadtypes, resolved_rt); break; + case 0x18: SetBit(rti->introduction_required_roadtypes, resolved_rt); break; + case 0x19: SetBit(rti->introduces_roadtypes, resolved_rt); break; } } } diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -1285,16 +1285,16 @@ struct NewGRFWindow : public Window, New WIDGET_LIST_END ); - const GRFConfig *c = (this->avail_sel == nullptr) ? this->active_sel : this->avail_sel; + const GRFConfig *selected_config = (this->avail_sel == nullptr) ? this->active_sel : this->avail_sel; for (TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) { - this->SetWidgetDisabledState(WID_NS_NEWGRF_TEXTFILE + tft, c == nullptr || c->GetTextfile(tft) == nullptr); + this->SetWidgetDisabledState(WID_NS_NEWGRF_TEXTFILE + tft, selected_config == nullptr || selected_config->GetTextfile(tft) == nullptr); } - this->SetWidgetDisabledState(WID_NS_OPEN_URL, c == nullptr || StrEmpty(c->GetURL())); + this->SetWidgetDisabledState(WID_NS_OPEN_URL, selected_config == nullptr || StrEmpty(selected_config->GetURL())); this->SetWidgetDisabledState(WID_NS_SET_PARAMETERS, !this->show_params || this->active_sel == nullptr || this->active_sel->num_valid_params == 0); this->SetWidgetDisabledState(WID_NS_VIEW_PARAMETERS, !this->show_params || this->active_sel == nullptr || this->active_sel->num_valid_params == 0); this->SetWidgetDisabledState(WID_NS_TOGGLE_PALETTE, disable_all || - (!(_settings_client.gui.newgrf_developer_tools || _settings_client.gui.scenario_developer) && ((c->palette & GRFP_GRF_MASK) != GRFP_GRF_UNSET))); + (!(_settings_client.gui.newgrf_developer_tools || _settings_client.gui.scenario_developer) && ((selected_config->palette & GRFP_GRF_MASK) != GRFP_GRF_UNSET))); if (!disable_all) { /* All widgets are now enabled, so disable widgets we can't use */ diff --git a/src/openttd.cpp b/src/openttd.cpp --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1403,7 +1403,7 @@ void StateGameLoop() #ifndef DEBUG_DUMP_COMMANDS { - PerformanceMeasurer framerate(PFE_ALLSCRIPTS); + PerformanceMeasurer script_framerate(PFE_ALLSCRIPTS); AI::GameLoop(); Game::GameLoop(); } diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -754,7 +754,7 @@ CommandCost CmdInsertOrder(DoCommandFlag if (st == nullptr) return CMD_ERROR; if (st->owner != OWNER_NONE) { - CommandCost ret = CheckOwnership(st->owner); + ret = CheckOwnership(st->owner); if (ret.Failed()) return ret; } @@ -800,7 +800,7 @@ CommandCost CmdInsertOrder(DoCommandFlag if (st == nullptr) return CMD_ERROR; - CommandCost ret = CheckOwnership(st->owner); + ret = CheckOwnership(st->owner); if (ret.Failed()) return ret; if (!CanVehicleUseStation(v, st) || !st->airport.HasHangar()) { @@ -811,7 +811,7 @@ CommandCost CmdInsertOrder(DoCommandFlag if (dp == nullptr) return CMD_ERROR; - CommandCost ret = CheckOwnership(GetTileOwner(dp->xy)); + ret = CheckOwnership(GetTileOwner(dp->xy)); if (ret.Failed()) return ret; switch (v->type) { @@ -849,7 +849,7 @@ CommandCost CmdInsertOrder(DoCommandFlag case VEH_TRAIN: { if (!(wp->facilities & FACIL_TRAIN)) return_cmd_error(STR_ERROR_CAN_T_ADD_ORDER); - CommandCost ret = CheckOwnership(wp->owner); + ret = CheckOwnership(wp->owner); if (ret.Failed()) return ret; break; } @@ -857,7 +857,7 @@ CommandCost CmdInsertOrder(DoCommandFlag case VEH_SHIP: if (!(wp->facilities & FACIL_DOCK)) return_cmd_error(STR_ERROR_CAN_T_ADD_ORDER); if (wp->owner != OWNER_NONE) { - CommandCost ret = CheckOwnership(wp->owner); + ret = CheckOwnership(wp->owner); if (ret.Failed()) return ret; } break; @@ -1514,7 +1514,7 @@ CommandCost CmdCloneOrder(DoCommandFlag /* Sanity checks */ if (src == nullptr || !src->IsPrimaryVehicle() || dst->type != src->type || dst == src) return CMD_ERROR; - CommandCost ret = CheckOwnership(src->owner); + ret = CheckOwnership(src->owner); if (ret.Failed()) return ret; /* Trucks can't share orders with busses (and visa versa) */ @@ -1571,7 +1571,7 @@ CommandCost CmdCloneOrder(DoCommandFlag /* Sanity checks */ if (src == nullptr || !src->IsPrimaryVehicle() || dst->type != src->type || dst == src) return CMD_ERROR; - CommandCost ret = CheckOwnership(src->owner); + ret = CheckOwnership(src->owner); if (ret.Failed()) return ret; /* Trucks can't copy all the orders from busses (and visa versa), @@ -1771,12 +1771,9 @@ void RemoveOrderFromAllVehicles(OrderTyp /* Go through all vehicles */ for (Vehicle *v : Vehicle::Iterate()) { - Order *order; - - order = &v->current_order; - if ((v->type == VEH_AIRCRAFT && order->IsType(OT_GOTO_DEPOT) && !hangar ? OT_GOTO_STATION : order->GetType()) == type && + if ((v->type == VEH_AIRCRAFT && v->current_order.IsType(OT_GOTO_DEPOT) && !hangar ? OT_GOTO_STATION : v->current_order.GetType()) == type && (!hangar || v->type == VEH_AIRCRAFT) && v->current_order.GetDestination() == destination) { - order->MakeDummy(); + v->current_order.MakeDummy(); SetWindowDirty(WC_VEHICLE_VIEW, v->index); } diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -531,7 +531,7 @@ CommandCost CmdBuildSingleRail(DoCommand /* Disallow breaking end-of-line of someone else * so trams can still reverse on this tile. */ if (Company::IsValidID(tram_owner) && HasExactlyOneBit(tram)) { - CommandCost ret = CheckOwnership(tram_owner); + ret = CheckOwnership(tram_owner); if (ret.Failed()) return ret; } @@ -893,7 +893,7 @@ static CommandCost CmdRailTrackHelper(Do bool had_success = false; CommandCost last_error = CMD_ERROR; for (;;) { - CommandCost ret = remove ? Command::Do(flags, tile, TrackdirToTrack(trackdir)) : Command::Do(flags, tile, railtype, TrackdirToTrack(trackdir), auto_remove_signals); + ret = remove ? Command::Do(flags, tile, TrackdirToTrack(trackdir)) : Command::Do(flags, tile, railtype, TrackdirToTrack(trackdir), auto_remove_signals); if (ret.Failed()) { last_error = ret; @@ -1591,7 +1591,7 @@ CommandCost CmdConvertRail(DoCommandFlag * Tunnels and bridges have special check later */ if (tt != MP_TUNNELBRIDGE) { if (!IsCompatibleRail(type, totype)) { - CommandCost ret = IsPlainRailTile(tile) ? EnsureNoTrainOnTrackBits(tile, GetTrackBits(tile)) : EnsureNoVehicleOnGround(tile); + ret = IsPlainRailTile(tile) ? EnsureNoTrainOnTrackBits(tile, GetTrackBits(tile)) : EnsureNoVehicleOnGround(tile); if (ret.Failed()) { error = ret; continue; @@ -1675,7 +1675,7 @@ CommandCost CmdConvertRail(DoCommandFlag /* When not converting rail <-> el. rail, any vehicle cannot be in tunnel/bridge */ if (!IsCompatibleRail(GetRailType(tile), totype)) { - CommandCost ret = TunnelBridgeIsFree(tile, endtile); + ret = TunnelBridgeIsFree(tile, endtile); if (ret.Failed()) { error = ret; continue; diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -865,7 +865,7 @@ do_clear:; if (HasPowerOnRoad(rt, existing_rt)) { rt = existing_rt; } else if (HasPowerOnRoad(existing_rt, rt)) { - CommandCost ret = Command::Do(flags, tile, tile, rt); + ret = Command::Do(flags, tile, tile, rt); if (ret.Failed()) return ret; cost.AddCost(ret); } else { @@ -1715,7 +1715,7 @@ static void DrawTile_Road(TileInfo *ti) /* Draw rail/PBS overlay */ bool draw_pbs = _game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasCrossingReservation(ti->tile); if (rti->UsesOverlay()) { - PaletteID pal = draw_pbs ? PALETTE_CRASH : PAL_NONE; + pal = draw_pbs ? PALETTE_CRASH : PAL_NONE; SpriteID rail = GetCustomRailSprite(rti, ti->tile, RTSG_CROSSING) + axis; DrawGroundSprite(rail, pal); @@ -1757,7 +1757,7 @@ static void DrawTile_Road(TileInfo *ti) } } else if (draw_pbs || tram_rti != nullptr || road_rti->UsesOverlay()) { /* Add another rail overlay, unless there is only the base road sprite. */ - PaletteID pal = draw_pbs ? PALETTE_CRASH : PAL_NONE; + pal = draw_pbs ? PALETTE_CRASH : PAL_NONE; SpriteID rail = GetCrossingRoadAxis(ti->tile) == AXIS_Y ? GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.single_x : GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.single_y; DrawGroundSprite(rail, pal); } diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp --- a/src/saveload/oldloader_sl.cpp +++ b/src/saveload/oldloader_sl.cpp @@ -384,11 +384,13 @@ static bool FixTTOEngines() } /* Load the default engine set. Many of them will be overridden later */ - uint j = 0; - for (uint i = 0; i < lengthof(_orig_rail_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_TRAIN, i); - for (uint i = 0; i < lengthof(_orig_road_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_ROAD, i); - for (uint i = 0; i < lengthof(_orig_ship_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_SHIP, i); - for (uint i = 0; i < lengthof(_orig_aircraft_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_AIRCRAFT, i); + { + uint j = 0; + for (uint i = 0; i < lengthof(_orig_rail_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_TRAIN, i); + for (uint i = 0; i < lengthof(_orig_road_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_ROAD, i); + for (uint i = 0; i < lengthof(_orig_ship_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_SHIP, i); + for (uint i = 0; i < lengthof(_orig_aircraft_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_AIRCRAFT, i); + } Date aging_date = std::min(_date + DAYS_TILL_ORIGINAL_BASE_YEAR, ConvertYMDToDate(2050, 0, 1)); diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -931,7 +931,7 @@ static CommandCost CheckFlatLandRailStat affected_vehicles.push_back(v); } } - CommandCost ret = Command::Do(flags, tile_cur, track); + ret = Command::Do(flags, tile_cur, track); if (ret.Failed()) return ret; cost.AddCost(ret); /* With flags & ~DC_EXEC CmdLandscapeClear would fail since the rail still exists */ @@ -1018,7 +1018,7 @@ static CommandCost CheckFlatLandRoadStop if (road_owner == OWNER_TOWN) { if (!_settings_game.construction.road_stop_on_town_road) return_cmd_error(STR_ERROR_DRIVE_THROUGH_ON_TOWN_ROAD); } else if (!_settings_game.construction.road_stop_on_competitor_road && road_owner != OWNER_NONE) { - CommandCost ret = CheckOwnership(road_owner); + ret = CheckOwnership(road_owner); if (ret.Failed()) return ret; } uint num_pieces = CountBits(GetRoadBits(cur_tile, RTT_ROAD)); @@ -1026,7 +1026,7 @@ static CommandCost CheckFlatLandRoadStop if (RoadTypeIsRoad(rt) && !HasPowerOnRoad(rt, road_rt)) return_cmd_error(STR_ERROR_NO_SUITABLE_ROAD); if (GetDisallowedRoadDirections(cur_tile) != DRD_NONE && road_owner != OWNER_TOWN) { - CommandCost ret = CheckOwnership(road_owner); + ret = CheckOwnership(road_owner); if (ret.Failed()) return ret; } @@ -1044,7 +1044,7 @@ static CommandCost CheckFlatLandRoadStop /* Disallow breaking end-of-line of someone else * so trams can still reverse on this tile. */ HasExactlyOneBit(GetRoadBits(cur_tile, RTT_TRAM)))) { - CommandCost ret = CheckOwnership(tram_owner); + ret = CheckOwnership(tram_owner); if (ret.Failed()) return ret; } uint num_pieces = CountBits(GetRoadBits(cur_tile, RTT_TRAM)); @@ -1308,7 +1308,7 @@ CommandCost CmdBuildRailStation(DoComman if (ret.Failed()) return ret; if (st != nullptr && st->train_station.tile != INVALID_TILE) { - CommandCost ret = CanExpandRailStation(st, new_location, axis); + ret = CanExpandRailStation(st, new_location, axis); if (ret.Failed()) return ret; } @@ -1573,7 +1573,7 @@ CommandCost RemoveFromRailBaseStation(Ti if (st == nullptr) continue; if (_current_company != OWNER_WATER) { - CommandCost ret = CheckOwnership(st->owner); + ret = CheckOwnership(st->owner); error.AddCost(ret); if (ret.Failed()) continue; } @@ -2236,13 +2236,13 @@ CommandCost CmdBuildAirport(DoCommandFla return_cmd_error(STR_ERROR_STATION_TOO_SPREAD_OUT); } - AirportTileTableIterator iter(as->table[layout], tile); - CommandCost cost = CheckFlatLandAirport(iter, flags); + AirportTileTableIterator tile_iter(as->table[layout], tile); + CommandCost cost = CheckFlatLandAirport(tile_iter, flags); if (cost.Failed()) return cost; /* The noise level is the noise from the airport and reduce it to account for the distance to the town center. */ uint dist; - Town *nearest = AirportGetNearestTown(as, iter, dist); + Town *nearest = AirportGetNearestTown(as, tile_iter, dist); uint newnoise_level = GetAirportNoiseLevelForDistance(as, dist); /* Check if local auth would allow a new airport */ @@ -2986,7 +2986,6 @@ draw_default_foundation: /* PBS debugging, draw reserved tracks darker */ if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasStationRail(ti->tile) && HasStationReservation(ti->tile)) { - const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile)); DrawGroundSprite(GetRailStationAxis(ti->tile) == AXIS_X ? rti->base_sprites.single_x : rti->base_sprites.single_y, PALETTE_CRASH); } } @@ -3033,17 +3032,17 @@ void StationPickerDrawSprite(int x, int int32 total_offset = 0; PaletteID pal = COMPANY_SPRITE_COLOUR(_local_company); const DrawTileSprites *t = GetStationTileLayout(st, image); - const RailtypeInfo *rti = nullptr; + const RailtypeInfo *railtype_info = nullptr; if (railtype != INVALID_RAILTYPE) { - rti = GetRailTypeInfo(railtype); - total_offset = rti->GetRailtypeSpriteOffset(); + railtype_info = GetRailTypeInfo(railtype); + total_offset = railtype_info->GetRailtypeSpriteOffset(); } SpriteID img = t->ground.sprite; RailTrackOffset overlay_offset; - if (rti != nullptr && rti->UsesOverlay() && SplitGroundSpriteForOverlay(nullptr, &img, &overlay_offset)) { - SpriteID ground = GetCustomRailSprite(rti, INVALID_TILE, RTSG_GROUND); + if (railtype_info != nullptr && railtype_info->UsesOverlay() && SplitGroundSpriteForOverlay(nullptr, &img, &overlay_offset)) { + SpriteID ground = GetCustomRailSprite(railtype_info, INVALID_TILE, RTSG_GROUND); DrawSprite(img, PAL_NONE, x, y); DrawSprite(ground + overlay_offset, PAL_NONE, x, y); } else { @@ -3051,25 +3050,25 @@ void StationPickerDrawSprite(int x, int } if (roadtype != INVALID_ROADTYPE) { - const RoadTypeInfo* rti = GetRoadTypeInfo(roadtype); + const RoadTypeInfo *roadtype_info = GetRoadTypeInfo(roadtype); if (image >= 4) { /* Drive-through stop */ uint sprite_offset = 5 - image; /* Road underlay takes precedence over tram */ - if (rti->UsesOverlay()) { - SpriteID ground = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_GROUND); + if (roadtype_info->UsesOverlay()) { + SpriteID ground = GetCustomRoadSprite(roadtype_info, INVALID_TILE, ROTSG_GROUND); DrawSprite(ground + sprite_offset, PAL_NONE, x, y); - SpriteID overlay = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_OVERLAY); + SpriteID overlay = GetCustomRoadSprite(roadtype_info, INVALID_TILE, ROTSG_OVERLAY); if (overlay) DrawSprite(overlay + sprite_offset, PAL_NONE, x, y); } else if (RoadTypeIsTram(roadtype)) { DrawSprite(SPR_TRAMWAY_TRAM + sprite_offset, PAL_NONE, x, y); } } else { /* Drive-in stop */ - if (RoadTypeIsRoad(roadtype) && rti->UsesOverlay()) { - SpriteID ground = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_ROADSTOP); + if (RoadTypeIsRoad(roadtype) && roadtype_info->UsesOverlay()) { + SpriteID ground = GetCustomRoadSprite(roadtype_info, INVALID_TILE, ROTSG_ROADSTOP); DrawSprite(ground + image, PAL_NONE, x, y); } } diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp --- a/src/strgen/strgen.cpp +++ b/src/strgen/strgen.cpp @@ -472,9 +472,9 @@ int CDECL main(int argc, char *argv[]) case 'P': printf("name\tflags\tdefault\tdescription\n"); - for (size_t i = 0; i < lengthof(_pragmas); i++) { + for (size_t j = 0; j < lengthof(_pragmas); j++) { printf("\"%s\"\t%s\t\"%s\"\t\"%s\"\n", - _pragmas[i][0], _pragmas[i][1], _pragmas[i][2], _pragmas[i][3]); + _pragmas[j][0], _pragmas[j][1], _pragmas[j][2], _pragmas[j][3]); } return 0; diff --git a/src/strgen/strgen_base.cpp b/src/strgen/strgen_base.cpp --- a/src/strgen/strgen_base.cpp +++ b/src/strgen/strgen_base.cpp @@ -877,7 +877,7 @@ static int TranslateArgumentIdx(int argi } for (int i = sum = 0; i < argidx; i++) { - const CmdStruct *cs = _cur_pcs.cmd[i]; + cs = _cur_pcs.cmd[i]; sum += (cs != nullptr) ? cs->consumes : 1; } diff --git a/src/strings.cpp b/src/strings.cpp --- a/src/strings.cpp +++ b/src/strings.cpp @@ -938,7 +938,7 @@ static char *FormatString(char *buff, co buff = GetStringWithArgs(buff, MakeStringID(TEXT_TAB_GAMESCRIPT_START, stringid), &sub_args, last, true); } - for (int i = 0; i < 20; i++) { + for (i = 0; i < 20; i++) { if (sub_args_need_free[i]) free((void *)sub_args.GetParam(i)); } break; @@ -1044,19 +1044,19 @@ static char *FormatString(char *buff, co case SCC_RAW_STRING_POINTER: { // {RAW_STRING} if (game_script) break; - const char *str = (const char *)(size_t)args->GetInt64(SCC_RAW_STRING_POINTER); - buff = FormatString(buff, str, args, last); + const char *raw_string = (const char *)(size_t)args->GetInt64(SCC_RAW_STRING_POINTER); + buff = FormatString(buff, raw_string, args, last); break; } case SCC_STRING: {// {STRING} - StringID str = args->GetInt32(SCC_STRING); - if (game_script && GetStringTab(str) != TEXT_TAB_GAMESCRIPT_START) break; + StringID string_id = args->GetInt32(SCC_STRING); + if (game_script && GetStringTab(string_id) != TEXT_TAB_GAMESCRIPT_START) break; /* WARNING. It's prohibited for the included string to consume any arguments. * For included strings that consume argument, you should use STRING1, STRING2 etc. * To debug stuff you can set argv to nullptr and it will tell you */ StringParameters tmp_params(args->GetDataPointer(), args->GetDataLeft(), nullptr); - buff = GetStringWithArgs(buff, str, &tmp_params, last, next_substr_case_index, game_script); + buff = GetStringWithArgs(buff, string_id, &tmp_params, last, next_substr_case_index, game_script); next_substr_case_index = 0; break; } @@ -1069,14 +1069,14 @@ static char *FormatString(char *buff, co case SCC_STRING6: case SCC_STRING7: { // {STRING1..7} /* Strings that consume arguments */ - StringID str = args->GetInt32(b); - if (game_script && GetStringTab(str) != TEXT_TAB_GAMESCRIPT_START) break; + StringID string_id = args->GetInt32(b); + if (game_script && GetStringTab(string_id) != TEXT_TAB_GAMESCRIPT_START) break; uint size = b - SCC_STRING1 + 1; if (game_script && size > args->GetDataLeft()) { buff = strecat(buff, "(too many parameters)", last); } else { StringParameters sub_args(*args, size); - buff = GetStringWithArgs(buff, str, &sub_args, last, next_substr_case_index, game_script); + buff = GetStringWithArgs(buff, string_id, &sub_args, last, next_substr_case_index, game_script); } next_substr_case_index = 0; break; @@ -1456,7 +1456,7 @@ static char *FormatString(char *buff, co StringParameters tmp_params(args_array); buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last); } else { - StringID str = st->string_id; + StringID string_id = st->string_id; if (st->indtype != IT_INVALID) { /* Special case where the industry provides the name for the station */ const IndustrySpec *indsp = GetIndustrySpec(st->indtype); @@ -1465,14 +1465,14 @@ static char *FormatString(char *buff, co * thus cause very strange things. Here we check for that before we * actually set the station name. */ if (indsp->station_name != STR_NULL && indsp->station_name != STR_UNDEFINED) { - str = indsp->station_name; + string_id = indsp->station_name; } } uint64 args_array[] = {STR_TOWN_NAME, st->town->index, st->index}; WChar types_array[] = {0, SCC_TOWN_NAME, SCC_NUM}; StringParameters tmp_params(args_array, 3, types_array); - buff = GetStringWithArgs(buff, str, &tmp_params, last); + buff = GetStringWithArgs(buff, string_id, &tmp_params, last); } break; } @@ -1502,9 +1502,9 @@ static char *FormatString(char *buff, co } else { int64 args_array[] = {wp->town->index, wp->town_cn + 1}; StringParameters tmp_params(args_array); - StringID str = ((wp->string_id == STR_SV_STNAME_BUOY) ? STR_FORMAT_BUOY_NAME : STR_FORMAT_WAYPOINT_NAME); - if (wp->town_cn != 0) str++; - buff = GetStringWithArgs(buff, str, &tmp_params, last); + StringID string_id = ((wp->string_id == STR_SV_STNAME_BUOY) ? STR_FORMAT_BUOY_NAME : STR_FORMAT_WAYPOINT_NAME); + if (wp->town_cn != 0) string_id++; + buff = GetStringWithArgs(buff, string_id, &tmp_params, last); } break; } @@ -1526,16 +1526,16 @@ static char *FormatString(char *buff, co int64 args_array[] = {v->unitnumber}; StringParameters tmp_params(args_array); - StringID str; + StringID string_id; switch (v->type) { - default: str = STR_INVALID_VEHICLE; break; - case VEH_TRAIN: str = STR_SV_TRAIN_NAME; break; - case VEH_ROAD: str = STR_SV_ROAD_VEHICLE_NAME; break; - case VEH_SHIP: str = STR_SV_SHIP_NAME; break; - case VEH_AIRCRAFT: str = STR_SV_AIRCRAFT_NAME; break; + default: string_id = STR_INVALID_VEHICLE; break; + case VEH_TRAIN: string_id = STR_SV_TRAIN_NAME; break; + case VEH_ROAD: string_id = STR_SV_ROAD_VEHICLE_NAME; break; + case VEH_SHIP: string_id = STR_SV_SHIP_NAME; break; + case VEH_AIRCRAFT: string_id = STR_SV_AIRCRAFT_NAME; break; } - buff = GetStringWithArgs(buff, str, &tmp_params, last); + buff = GetStringWithArgs(buff, string_id, &tmp_params, last); } break; } diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -91,15 +91,15 @@ static void FillTimetableArrivalDepartur assert(v->GetNumOrders() >= 2); assert(start < v->GetNumOrders()); - Ticks sum = offset; - VehicleOrderID i = start; - const Order *order = v->GetOrder(i); - /* Pre-initialize with unknown time */ for (int i = 0; i < v->GetNumOrders(); ++i) { table[i].arrival = table[i].departure = INVALID_TICKS; } + Ticks sum = offset; + VehicleOrderID i = start; + const Order *order = v->GetOrder(i); + /* Cyclically loop over all orders until we reach the current one again. * As we may start at the current order, do a post-checking loop */ do { diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -93,7 +93,7 @@ static bool TestTownOwnsBridge(TileIndex if (!town_owned) { /* Or other adjacent road */ - TileIndex adjacent = tile + TileOffsByDiagDir(ReverseDiagDir(GetTunnelBridgeDirection(GetOtherTunnelBridgeEnd(tile)))); + adjacent = tile + TileOffsByDiagDir(ReverseDiagDir(GetTunnelBridgeDirection(GetOtherTunnelBridgeEnd(tile)))); town_owned = IsTileType(adjacent, MP_ROAD) && IsTileOwner(adjacent, OWNER_TOWN) && GetTownIndex(adjacent) == t->index; } @@ -2656,15 +2656,15 @@ static bool BuildTownHouse(Town *t, Tile byte construction_stage = 0; if (_generating_world || _game_mode == GM_EDITOR) { - uint32 r = Random(); + uint32 construction_random = Random(); construction_stage = TOWN_HOUSE_COMPLETED; - if (Chance16(1, 7)) construction_stage = GB(r, 0, 2); + if (Chance16(1, 7)) construction_stage = GB(construction_random, 0, 2); if (construction_stage == TOWN_HOUSE_COMPLETED) { ChangePopulation(t, hs->population); } else { - construction_counter = GB(r, 2, 2); + construction_counter = GB(construction_random, 2, 2); } } diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1202,7 +1202,7 @@ CommandCost CmdMoveRailVehicle(DoCommand dst = Train::GetIfValid(dest_veh); if (dst == nullptr) return CMD_ERROR; - CommandCost ret = CheckOwnership(dst->owner); + ret = CheckOwnership(dst->owner); if (ret.Failed()) return ret; /* Do not allow appending to crashed vehicles, too */ @@ -1271,7 +1271,7 @@ CommandCost CmdMoveRailVehicle(DoCommand /* If the autoreplace flag is set we do not need to test for the validity * because we are going to revert the train to its original state. As we * assume the original state was correct autoreplace can skip this. */ - CommandCost ret = ValidateTrains(original_dst_head, dst_head, original_src_head, src_head, true); + ret = ValidateTrains(original_dst_head, dst_head, original_src_head, src_head, true); if (ret.Failed()) { /* Restore the train we had. */ RestoreTrainBackup(original_src); diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -862,7 +862,7 @@ static CommandCost DoClearTunnel(TileInd /* Check if you are allowed to remove the tunnel owned by a town * Removal depends on difficulty settings */ - CommandCost ret = CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE); + ret = CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE); if (ret.Failed()) return ret; } @@ -943,7 +943,7 @@ static CommandCost DoClearBridge(TileInd /* Check if you are allowed to remove the bridge owned by a town * Removal depends on difficulty settings */ - CommandCost ret = CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE); + ret = CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE); if (ret.Failed()) return ret; } diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -3226,8 +3226,8 @@ public: } /* The same system applies to widget WID_VV_REFIT_VEH and VVW_WIDGET_TURN_AROUND.*/ if (v->IsGroundVehicle()) { - PlaneSelections plane = veh_stopped ? SEL_RT_REFIT : SEL_RT_TURN_AROUND; - NWidgetStacked *nwi = this->GetWidget(WID_VV_SELECT_REFIT_TURN); + plane = veh_stopped ? SEL_RT_REFIT : SEL_RT_TURN_AROUND; + nwi = this->GetWidget(WID_VV_SELECT_REFIT_TURN); if (nwi->shown_plane + SEL_RT_BASEPLANE != plane) { this->SelectPlane(plane); this->SetWidgetDirty(WID_VV_SELECT_REFIT_TURN); diff --git a/src/video/opengl.cpp b/src/video/opengl.cpp --- a/src/video/opengl.cpp +++ b/src/video/opengl.cpp @@ -1120,8 +1120,8 @@ void OpenGLBackend::PopulateCursorCache( if (!this->cursor_cache.Contains(sprite)) { Sprite *old = this->cursor_cache.Insert(sprite, (Sprite *)GetRawSprite(sprite, ST_NORMAL, &SimpleSpriteAlloc, this)); if (old != nullptr) { - OpenGLSprite *sprite = (OpenGLSprite *)old->data; - sprite->~OpenGLSprite(); + OpenGLSprite *gl_sprite = (OpenGLSprite *)old->data; + gl_sprite->~OpenGLSprite(); free(old); } } diff --git a/src/viewport.cpp b/src/viewport.cpp --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1356,9 +1356,6 @@ static void ViewportAddKdtreeSigns(DrawP bool show_signs = HasBit(_display_opt, DO_SHOW_SIGNS) && !IsInvisibilitySet(TO_SIGNS); bool show_competitors = HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS); - const BaseStation *st; - const Sign *si; - /* Collect all the items first and draw afterwards, to ensure layering */ std::vector stations; std::vector towns; @@ -1366,34 +1363,36 @@ static void ViewportAddKdtreeSigns(DrawP _viewport_sign_kdtree.FindContained(search_rect.left, search_rect.top, search_rect.right, search_rect.bottom, [&](const ViewportSignKdtreeItem & item) { switch (item.type) { - case ViewportSignKdtreeItem::VKI_STATION: + case ViewportSignKdtreeItem::VKI_STATION: { if (!show_stations) break; - st = BaseStation::Get(item.id.station); + const BaseStation *st = BaseStation::Get(item.id.station); /* Don't draw if station is owned by another company and competitor station names are hidden. Stations owned by none are never ignored. */ if (!show_competitors && _local_company != st->owner && st->owner != OWNER_NONE) break; stations.push_back(st); break; - - case ViewportSignKdtreeItem::VKI_WAYPOINT: + } + + case ViewportSignKdtreeItem::VKI_WAYPOINT: { if (!show_waypoints) break; - st = BaseStation::Get(item.id.station); + const BaseStation *st = BaseStation::Get(item.id.station); /* Don't draw if station is owned by another company and competitor station names are hidden. Stations owned by none are never ignored. */ if (!show_competitors && _local_company != st->owner && st->owner != OWNER_NONE) break; stations.push_back(st); break; + } case ViewportSignKdtreeItem::VKI_TOWN: if (!show_towns) break; towns.push_back(Town::Get(item.id.town)); break; - case ViewportSignKdtreeItem::VKI_SIGN: + case ViewportSignKdtreeItem::VKI_SIGN: { if (!show_signs) break; - si = Sign::Get(item.id.sign); + const Sign *si = Sign::Get(item.id.sign); /* Don't draw if sign is owned by another company and competitor signs should be hidden. * Note: It is intentional that also signs owned by OWNER_NONE are hidden. Bankrupt @@ -1402,6 +1401,7 @@ static void ViewportAddKdtreeSigns(DrawP signs.push_back(si); break; + } default: NOT_REACHED(); diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -264,7 +264,7 @@ static CommandCost RemoveShipDepot(TileI /* do not check for ship on tile when company goes bankrupt */ if (!(flags & DC_BANKRUPT)) { - CommandCost ret = EnsureNoVehicleOnGround(tile); + ret = EnsureNoVehicleOnGround(tile); if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile2); if (ret.Failed()) return ret; } @@ -539,7 +539,7 @@ static CommandCost ClearTile_Water(TileI Owner owner = GetTileOwner(tile); if (owner != OWNER_WATER && owner != OWNER_NONE) { - CommandCost ret = CheckTileOwnership(tile); + ret = CheckTileOwnership(tile); if (ret.Failed()) return ret; } diff --git a/src/waypoint_cmd.cpp b/src/waypoint_cmd.cpp --- a/src/waypoint_cmd.cpp +++ b/src/waypoint_cmd.cpp @@ -217,11 +217,11 @@ CommandCost CmdBuildRailWaypoint(DoComma /* check if we want to expand an already existing waypoint? */ if (wp->train_station.tile != INVALID_TILE) { - CommandCost ret = CanExpandRailStation(wp, new_location, axis); + ret = CanExpandRailStation(wp, new_location, axis); if (ret.Failed()) return ret; } - CommandCost ret = wp->rect.BeforeAddRect(start_tile, width, height, StationRect::ADD_TEST); + ret = wp->rect.BeforeAddRect(start_tile, width, height, StationRect::ADD_TEST); if (ret.Failed()) return ret; } else { /* allocate and initialize new waypoint */ diff --git a/src/widget.cpp b/src/widget.cpp --- a/src/widget.cpp +++ b/src/widget.cpp @@ -3209,7 +3209,7 @@ static int MakeWidgetTree(const NWidgetP if (fill_sub && (tp == NWID_HORIZONTAL || tp == NWID_HORIZONTAL_LTR || tp == NWID_VERTICAL || tp == NWID_MATRIX || tp == WWT_PANEL || tp == WWT_FRAME || tp == WWT_INSET || tp == NWID_SELECTION)) { NWidgetBase *sub_ptr = sub_widget; - int num_used = MakeWidgetTree(parts, count - total_used, &sub_ptr, biggest_index); + num_used = MakeWidgetTree(parts, count - total_used, &sub_ptr, biggest_index); parts += num_used; total_used += num_used; } diff --git a/src/window.cpp b/src/window.cpp --- a/src/window.cpp +++ b/src/window.cpp @@ -257,7 +257,7 @@ void Window::SetWidgetHighlight(byte wid /* If we disable a highlight, check all widgets if anyone still has a highlight */ bool valid = false; for (uint i = 0; i < this->nested_array_size; i++) { - NWidgetBase *nwid = this->GetWidget(i); + nwid = this->GetWidget(i); if (nwid == nullptr) continue; if (!nwid->IsHighlighted()) continue;