diff options
author | rubidium42 <rubidium@openttd.org> | 2021-05-26 20:51:17 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-05-27 18:30:56 +0200 |
commit | b791ffc6de6dcc33739bb36bec4824dc44417961 (patch) | |
tree | 0f3c42eee61630369a59623b36e0920fcecb9235 | |
parent | eaa3df1e8e3c9c6f6a22e95d0d4ed8ff251d4af9 (diff) | |
download | openttd-b791ffc6de6dcc33739bb36bec4824dc44417961.tar.xz |
Fix: do not hide parameter by local variable with the same name
-rw-r--r-- | src/blitter/common.hpp | 56 | ||||
-rw-r--r-- | src/company_gui.cpp | 6 | ||||
-rw-r--r-- | src/industry_gui.cpp | 12 | ||||
-rw-r--r-- | src/network/network_content.cpp | 10 | ||||
-rw-r--r-- | src/newgrf_station.cpp | 20 | ||||
-rw-r--r-- | src/rail_cmd.cpp | 12 | ||||
-rw-r--r-- | src/smallmap_gui.cpp | 4 | ||||
-rw-r--r-- | src/station_cmd.cpp | 12 | ||||
-rw-r--r-- | src/terraform_cmd.cpp | 40 | ||||
-rw-r--r-- | src/town_cmd.cpp | 20 | ||||
-rw-r--r-- | src/train_cmd.cpp | 2 | ||||
-rw-r--r-- | src/tree_cmd.cpp | 32 | ||||
-rw-r--r-- | src/viewport.cpp | 4 | ||||
-rw-r--r-- | src/water_cmd.cpp | 30 |
14 files changed, 130 insertions, 130 deletions
diff --git a/src/blitter/common.hpp b/src/blitter/common.hpp index aaf63cd6a..cd3b6276a 100644 --- a/src/blitter/common.hpp +++ b/src/blitter/common.hpp @@ -16,14 +16,14 @@ #include <utility> template <typename SetPixelT> -void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, int screen_height, int width, int dash, SetPixelT set_pixel) +void Blitter::DrawLineGeneric(int x1, int y1, int x2, int y2, int screen_width, int screen_height, int width, int dash, SetPixelT set_pixel) { int dy; int dx; int stepx; int stepy; - dy = (y2 - y) * 2; + dy = (y2 - y1) * 2; if (dy < 0) { dy = -dy; stepy = -1; @@ -31,7 +31,7 @@ void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, in stepy = 1; } - dx = (x2 - x) * 2; + dx = (x2 - x1) * 2; if (dx < 0) { dx = -dx; stepx = -1; @@ -41,7 +41,7 @@ void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, in if (dx == 0 && dy == 0) { /* The algorithm below cannot handle this special case; make it work at least for line width 1 */ - if (x >= 0 && x < screen_width && y >= 0 && y < screen_height) set_pixel(x, y); + if (x1 >= 0 && x1 < screen_width && y1 >= 0 && y1 < screen_height) set_pixel(x1, y1); return; } @@ -67,14 +67,14 @@ void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, in int dash_count = 0; if (dx > dy) { if (stepx < 0) { - std::swap(x, x2); - std::swap(y, y2); + std::swap(x1, x2); + std::swap(y1, y2); stepy = -stepy; } - if (x2 < 0 || x >= screen_width) return; + if (x2 < 0 || x1 >= screen_width) return; - int y_low = y; - int y_high = y; + int y_low = y1; + int y_high = y1; int frac_low = dy - frac_diff / 2; int frac_high = dy + frac_diff / 2; @@ -87,10 +87,10 @@ void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, in y_high += stepy; } - if (x < 0) { - dash_count = (-x) % (dash + gap); + if (x1 < 0) { + dash_count = (-x1) % (dash + gap); auto adjust_frac = [&](int64 frac, int &y_bound) -> int { - frac -= ((int64) dy) * ((int64) x); + frac -= ((int64) dy) * ((int64) x1); if (frac >= 0) { int quotient = frac / dx; int remainder = frac % dx; @@ -101,17 +101,17 @@ void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, in }; frac_low = adjust_frac(frac_low, y_low); frac_high = adjust_frac(frac_high, y_high); - x = 0; + x1 = 0; } x2++; if (x2 > screen_width) { x2 = screen_width; } - while (x != x2) { + while (x1 != x2) { if (dash_count < dash) { for (int y = y_low; y != y_high; y += stepy) { - if (y >= 0 && y < screen_height) set_pixel(x, y); + if (y >= 0 && y < screen_height) set_pixel(x1, y); } } if (frac_low >= 0) { @@ -122,21 +122,21 @@ void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, in y_high += stepy; frac_high -= dx; } - x++; + x1++; frac_low += dy; frac_high += dy; if (++dash_count >= dash + gap) dash_count = 0; } } else { if (stepy < 0) { - std::swap(x, x2); - std::swap(y, y2); + std::swap(x1, x2); + std::swap(y1, y2); stepx = -stepx; } - if (y2 < 0 || y >= screen_height) return; + if (y2 < 0 || y1 >= screen_height) return; - int x_low = x; - int x_high = x; + int x_low = x1; + int x_high = x1; int frac_low = dx - frac_diff / 2; int frac_high = dx + frac_diff / 2; @@ -149,10 +149,10 @@ void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, in x_high += stepx; } - if (y < 0) { - dash_count = (-y) % (dash + gap); + if (y1 < 0) { + dash_count = (-y1) % (dash + gap); auto adjust_frac = [&](int64 frac, int &x_bound) -> int { - frac -= ((int64) dx) * ((int64) y); + frac -= ((int64) dx) * ((int64) y1); if (frac >= 0) { int quotient = frac / dy; int remainder = frac % dy; @@ -163,17 +163,17 @@ void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, in }; frac_low = adjust_frac(frac_low, x_low); frac_high = adjust_frac(frac_high, x_high); - y = 0; + y1 = 0; } y2++; if (y2 > screen_height) { y2 = screen_height; } - while (y != y2) { + while (y1 != y2) { if (dash_count < dash) { for (int x = x_low; x != x_high; x += stepx) { - if (x >= 0 && x < screen_width) set_pixel(x, y); + if (x >= 0 && x < screen_width) set_pixel(x, y1); } } if (frac_low >= 0) { @@ -184,7 +184,7 @@ void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, in x_high += stepx; frac_high -= dy; } - y++; + y1++; frac_low += dx; frac_high += dx; if (++dash_count >= dash + gap) dash_count = 0; diff --git a/src/company_gui.cpp b/src/company_gui.cpp index f9eceba17..a23bda7bd 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -776,11 +776,11 @@ public: case WID_SCL_PRI_COL_DROPDOWN: { this->square = GetSpriteSize(SPR_SQUARE); - int padding = this->square.width + NWidgetScrollbar::GetVerticalDimension().width + 10; + int string_padding = this->square.width + NWidgetScrollbar::GetVerticalDimension().width + 10; for (const StringID *id = _colour_dropdown; id != endof(_colour_dropdown); id++) { - size->width = std::max(size->width, GetStringBoundingBox(*id).width + padding); + size->width = std::max(size->width, GetStringBoundingBox(*id).width + string_padding); } - size->width = std::max(size->width, GetStringBoundingBox(STR_COLOUR_DEFAULT).width + padding); + size->width = std::max(size->width, GetStringBoundingBox(STR_COLOUR_DEFAULT).width + string_padding); break; } } diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index b1768af1f..fd5f5d487 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -2700,14 +2700,14 @@ struct IndustryCargoesWindow : public Window { /** * Compute what and where to display for industry type \a it. - * @param it Industry type to display. + * @param displayed_it Industry type to display. */ - void ComputeIndustryDisplay(IndustryType it) + void ComputeIndustryDisplay(IndustryType displayed_it) { this->GetWidget<NWidgetCore>(WID_IC_CAPTION)->widget_data = STR_INDUSTRY_CARGOES_INDUSTRY_CAPTION; - this->ind_cargo = it; + this->ind_cargo = displayed_it; _displayed_industries.reset(); - _displayed_industries.set(it); + _displayed_industries.set(displayed_it); this->fields.clear(); CargoesRow &row = this->fields.emplace_back(); @@ -2717,7 +2717,7 @@ struct IndustryCargoesWindow : public Window { row.columns[3].MakeEmpty(CFT_SMALL_EMPTY); row.columns[4].MakeHeader(STR_INDUSTRY_CARGOES_CUSTOMERS); - const IndustrySpec *central_sp = GetIndustrySpec(it); + const IndustrySpec *central_sp = GetIndustrySpec(displayed_it); bool houses_supply = HousesCanSupply(central_sp->accepts_cargo, lengthof(central_sp->accepts_cargo)); bool houses_accept = HousesCanAccept(central_sp->produced_cargo, lengthof(central_sp->produced_cargo)); /* Make a field consisting of two cargo columns. */ @@ -2734,7 +2734,7 @@ struct IndustryCargoesWindow : public Window { } /* Add central industry. */ int central_row = 1 + num_indrows / 2; - this->fields[central_row].columns[2].MakeIndustry(it); + this->fields[central_row].columns[2].MakeIndustry(displayed_it); this->fields[central_row].ConnectIndustryProduced(2); this->fields[central_row].ConnectIndustryAccepted(2); diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index 2b90cf415..e09b05ec7 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -1010,9 +1010,9 @@ void ClientNetworkContentSocketHandler::CheckDependencyState(ContentInfo *ci) /* First check whether anything depends on us */ int sel_count = 0; bool force_selection = false; - for (const ContentInfo *ci : parents) { - if (ci->IsSelected()) sel_count++; - if (ci->state == ContentInfo::SELECTED) force_selection = true; + for (const ContentInfo *parent_ci : parents) { + if (parent_ci->IsSelected()) sel_count++; + if (parent_ci->state == ContentInfo::SELECTED) force_selection = true; } if (sel_count == 0) { /* Nothing depends on us */ @@ -1027,8 +1027,8 @@ void ClientNetworkContentSocketHandler::CheckDependencyState(ContentInfo *ci) this->ReverseLookupTreeDependency(parents, c); /* Is there anything that is "force" selected?, if so... we're done. */ - for (const ContentInfo *ci : parents) { - if (ci->state != ContentInfo::SELECTED) continue; + for (const ContentInfo *parent_ci : parents) { + if (parent_ci->state != ContentInfo::SELECTED) continue; force_selection = true; break; diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index fbc6f5c60..c66b53d3f 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -550,16 +550,16 @@ uint32 StationResolverObject::GetDebugID() const /** * Resolver for stations. * @param statspec Station (type) specification. - * @param st Instance of the station. + * @param base_station Instance of the station. * @param tile %Tile of the station. * @param callback Callback ID. * @param callback_param1 First parameter (var 10) of the callback. * @param callback_param2 Second parameter (var 18) of the callback. */ -StationResolverObject::StationResolverObject(const StationSpec *statspec, BaseStation *st, TileIndex tile, +StationResolverObject::StationResolverObject(const StationSpec *statspec, BaseStation *base_station, TileIndex tile, CallbackID callback, uint32 callback_param1, uint32 callback_param2) : ResolverObject(statspec->grf_prop.grffile, callback, callback_param1, callback_param2), - station_scope(*this, statspec, st, tile), town_scope(nullptr) + station_scope(*this, statspec, base_station, tile), town_scope(nullptr) { /* Invalidate all cached vars */ _svc.valid = 0; @@ -921,7 +921,7 @@ void AnimateStationTile(TileIndex tile) StationAnimationBase::AnimateTile(ss, BaseStation::GetByTile(tile), tile, HasBit(ss->flags, SSF_CB141_RANDOM_BITS)); } -void TriggerStationAnimation(BaseStation *st, TileIndex tile, StationAnimationTrigger trigger, CargoID cargo_type) +void TriggerStationAnimation(BaseStation *st, TileIndex trigger_tile, StationAnimationTrigger trigger, CargoID cargo_type) { /* List of coverage areas for each animation trigger */ static const TriggerArea tas[] = { @@ -929,14 +929,14 @@ void TriggerStationAnimation(BaseStation *st, TileIndex tile, StationAnimationTr }; /* Get Station if it wasn't supplied */ - if (st == nullptr) st = BaseStation::GetByTile(tile); + if (st == nullptr) st = BaseStation::GetByTile(trigger_tile); /* Check the cached animation trigger bitmask to see if we need * to bother with any further processing. */ if (!HasBit(st->cached_anim_triggers, trigger)) return; uint16 random_bits = Random(); - ETileArea area = ETileArea(st, tile, tas[trigger]); + ETileArea area = ETileArea(st, trigger_tile, tas[trigger]); /* Check all tiles over the station to check if the specindex is still in use */ for (TileIndex tile : area) { @@ -958,11 +958,11 @@ void TriggerStationAnimation(BaseStation *st, TileIndex tile, StationAnimationTr /** * Trigger station randomisation * @param st station being triggered - * @param tile specific tile of platform to trigger + * @param trigger_tile specific tile of platform to trigger * @param trigger trigger type * @param cargo_type cargo type causing trigger */ -void TriggerStationRandomisation(Station *st, TileIndex tile, StationRandomTrigger trigger, CargoID cargo_type) +void TriggerStationRandomisation(Station *st, TileIndex trigger_tile, StationRandomTrigger trigger, CargoID cargo_type) { /* List of coverage areas for each animation trigger */ static const TriggerArea tas[] = { @@ -970,7 +970,7 @@ void TriggerStationRandomisation(Station *st, TileIndex tile, StationRandomTrigg }; /* Get Station if it wasn't supplied */ - if (st == nullptr) st = Station::GetByTile(tile); + if (st == nullptr) st = Station::GetByTile(trigger_tile); /* Check the cached cargo trigger bitmask to see if we need * to bother with any further processing. */ @@ -978,7 +978,7 @@ void TriggerStationRandomisation(Station *st, TileIndex tile, StationRandomTrigg if (cargo_type != CT_INVALID && !HasBit(st->cached_cargo_triggers, cargo_type)) return; uint32 whole_reseed = 0; - ETileArea area = ETileArea(st, tile, tas[trigger]); + ETileArea area = ETileArea(st, trigger_tile, tas[trigger]); CargoTypes empty_mask = 0; if (trigger == SRT_CARGO_TAKEN) { diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 888b98e94..72ae0724c 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1359,11 +1359,11 @@ static CommandCost CmdSignalTrackHelper(TileIndex tile, DoCommandFlag flags, uin for (;;) { /* only build/remove signals with the specified density */ if (remove || minimise_gaps || signal_ctr % signal_density == 0) { - uint32 p1 = GB(TrackdirToTrack(trackdir), 0, 3); - SB(p1, 3, 1, mode); - SB(p1, 4, 1, semaphores); - SB(p1, 5, 3, sigtype); - if (!remove && signal_ctr == 0) SetBit(p1, 17); + uint32 param1 = GB(TrackdirToTrack(trackdir), 0, 3); + SB(param1, 3, 1, mode); + SB(param1, 4, 1, semaphores); + SB(param1, 5, 3, sigtype); + if (!remove && signal_ctr == 0) SetBit(param1, 17); /* Pick the correct orientation for the track direction */ signals = 0; @@ -1372,7 +1372,7 @@ static CommandCost CmdSignalTrackHelper(TileIndex tile, DoCommandFlag flags, uin /* Test tiles in between for suitability as well if minimising gaps. */ bool test_only = !remove && minimise_gaps && signal_ctr < (last_used_ctr + signal_density); - CommandCost ret = DoCommand(tile, p1, signals, test_only ? flags & ~DC_EXEC : flags, remove ? CMD_REMOVE_SIGNALS : CMD_BUILD_SIGNALS); + CommandCost ret = DoCommand(tile, param1, signals, test_only ? flags & ~DC_EXEC : flags, remove ? CMD_REMOVE_SIGNALS : CMD_BUILD_SIGNALS); if (ret.Succeeded()) { /* Remember last track piece where we can place a signal. */ diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 17d1d25cb..bc0a7b447 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1436,8 +1436,8 @@ int SmallMapWindow::GetPositionOnLegend(Point pt) case WID_SM_ZOOM_IN: case WID_SM_ZOOM_OUT: { const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_SM_MAP); - Point pt = { (int)wid->current_x / 2, (int)wid->current_y / 2}; - this->SetZoomLevel((widget == WID_SM_ZOOM_IN) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &pt); + Point zoom_pt = { (int)wid->current_x / 2, (int)wid->current_y / 2}; + this->SetZoomLevel((widget == WID_SM_ZOOM_IN) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &zoom_pt); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); break; } diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index d1e12604c..d9529da11 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -498,16 +498,16 @@ static void ShowRejectOrAcceptNews(const Station *st, uint num_items, CargoID *c /** * Get the cargo types being produced around the tile (in a rectangle). - * @param tile Northtile of area + * @param north_tile Northern most tile of area * @param w X extent of the area * @param h Y extent of the area * @param rad Search radius in addition to the given area */ -CargoArray GetProductionAroundTiles(TileIndex tile, int w, int h, int rad) +CargoArray GetProductionAroundTiles(TileIndex north_tile, int w, int h, int rad) { CargoArray produced; std::set<IndustryID> industries; - TileArea ta = TileArea(tile, w, h).Expand(rad); + TileArea ta = TileArea(north_tile, w, h).Expand(rad); /* Loop over all tiles to get the produced cargo of * everything except industries */ @@ -535,19 +535,19 @@ CargoArray GetProductionAroundTiles(TileIndex tile, int w, int h, int rad) /** * Get the acceptance of cargoes around the tile in 1/8. - * @param tile Center of the search area + * @param center_tile Center of the search area * @param w X extent of area * @param h Y extent of area * @param rad Search radius in addition to given area * @param always_accepted bitmask of cargo accepted by houses and headquarters; can be nullptr * @param ind Industry associated with neutral station (e.g. oil rig) or nullptr */ -CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad, CargoTypes *always_accepted) +CargoArray GetAcceptanceAroundTiles(TileIndex center_tile, int w, int h, int rad, CargoTypes *always_accepted) { CargoArray acceptance; if (always_accepted != nullptr) *always_accepted = 0; - TileArea ta = TileArea(tile, w, h).Expand(rad); + TileArea ta = TileArea(center_tile, w, h).Expand(rad); for (TileIndex tile : ta) { /* Ignore industry if it has a neutral station. */ diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp index bc4df173d..a23e02ab9 100644 --- a/src/terraform_cmd.cpp +++ b/src/terraform_cmd.cpp @@ -226,18 +226,18 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin * Pass == 1: Collect the actual cost. */ for (int pass = 0; pass < 2; pass++) { for (TileIndexSet::const_iterator it = ts.dirty_tiles.begin(); it != ts.dirty_tiles.end(); it++) { - TileIndex tile = *it; + TileIndex t = *it; - assert(tile < MapSize()); + assert(t < MapSize()); /* MP_VOID tiles can be terraformed but as tunnels and bridges * cannot go under / over these tiles they don't need checking. */ - if (IsTileType(tile, MP_VOID)) continue; + if (IsTileType(t, MP_VOID)) continue; /* Find new heights of tile corners */ - int z_N = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0)); - int z_W = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0)); - int z_S = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1)); - int z_E = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1)); + int z_N = TerraformGetHeightOfTile(&ts, t + TileDiffXY(0, 0)); + int z_W = TerraformGetHeightOfTile(&ts, t + TileDiffXY(1, 0)); + int z_S = TerraformGetHeightOfTile(&ts, t + TileDiffXY(1, 1)); + int z_E = TerraformGetHeightOfTile(&ts, t + TileDiffXY(0, 1)); /* Find min and max height of tile */ int z_min = std::min({z_N, z_W, z_S, z_E}); @@ -252,31 +252,31 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin if (pass == 0) { /* Check if bridge would take damage */ - if (IsBridgeAbove(tile)) { - int bridge_height = GetBridgeHeight(GetSouthernBridgeEnd(tile)); + if (IsBridgeAbove(t)) { + int bridge_height = GetBridgeHeight(GetSouthernBridgeEnd(t)); /* Check if bridge would take damage. */ if (direction == 1 && bridge_height <= z_max) { - _terraform_err_tile = tile; // highlight the tile under the bridge + _terraform_err_tile = t; // highlight the tile under the bridge return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); } /* Is the bridge above not too high afterwards? */ if (direction == -1 && bridge_height > (z_min + _settings_game.construction.max_bridge_height)) { - _terraform_err_tile = tile; + _terraform_err_tile = t; return_cmd_error(STR_ERROR_BRIDGE_TOO_HIGH_AFTER_LOWER_LAND); } } /* Check if tunnel would take damage */ - if (direction == -1 && IsTunnelInWay(tile, z_min)) { - _terraform_err_tile = tile; // highlight the tile above the tunnel + if (direction == -1 && IsTunnelInWay(t, z_min)) { + _terraform_err_tile = t; // highlight the tile above the tunnel return_cmd_error(STR_ERROR_EXCAVATION_WOULD_DAMAGE); } } /* Is the tile already cleared? */ - const ClearedObjectArea *coa = FindClearedObject(tile); - bool indirectly_cleared = coa != nullptr && coa->first_tile != tile; + const ClearedObjectArea *coa = FindClearedObject(t); + bool indirectly_cleared = coa != nullptr && coa->first_tile != t; /* Check tiletype-specific things, and add extra-cost */ const bool curr_gen = _generating_world; @@ -288,13 +288,13 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin } CommandCost cost; if (indirectly_cleared) { - cost = DoCommand(tile, 0, 0, tile_flags, CMD_LANDSCAPE_CLEAR); + cost = DoCommand(t, 0, 0, tile_flags, CMD_LANDSCAPE_CLEAR); } else { - cost = _tile_type_procs[GetTileType(tile)]->terraform_tile_proc(tile, tile_flags, z_min, tileh); + cost = _tile_type_procs[GetTileType(t)]->terraform_tile_proc(t, tile_flags, z_min, tileh); } _generating_world = curr_gen; if (cost.Failed()) { - _terraform_err_tile = tile; + _terraform_err_tile = t; return cost; } if (pass == 1) total_cost.AddCost(cost); @@ -318,10 +318,10 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin /* change the height */ for (TileIndexToHeightMap::const_iterator it = ts.tile_to_new_height.begin(); it != ts.tile_to_new_height.end(); it++) { - TileIndex tile = it->first; + TileIndex t = it->first; int height = it->second; - SetTileHeight(tile, (uint)height); + SetTileHeight(t, (uint)height); } if (c != nullptr) c->terraform_limit -= (uint32)ts.tile_to_new_height.size() << 16; diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 033d04248..177b507e4 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2988,27 +2988,27 @@ CommandCost CmdDeleteTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 * these do not directly have an owner so we need to check adjacent * tiles. This won't work correctly in the same loop if the adjacent * tile was already deleted earlier in the loop. */ - for (TileIndex tile = 0; tile < MapSize(); ++tile) { - if (IsTileType(tile, MP_TUNNELBRIDGE) && TestTownOwnsBridge(tile, t)) { - CommandCost ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); + for (TileIndex current_tile = 0; current_tile < MapSize(); ++current_tile) { + if (IsTileType(current_tile, MP_TUNNELBRIDGE) && TestTownOwnsBridge(current_tile, t)) { + CommandCost ret = DoCommand(current_tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); if (ret.Failed()) return ret; } } /* Check all remaining tiles for town ownership. */ - for (TileIndex tile = 0; tile < MapSize(); ++tile) { + for (TileIndex current_tile = 0; current_tile < MapSize(); ++current_tile) { bool try_clear = false; - switch (GetTileType(tile)) { + switch (GetTileType(current_tile)) { case MP_ROAD: - try_clear = HasTownOwnedRoad(tile) && GetTownIndex(tile) == t->index; + try_clear = HasTownOwnedRoad(current_tile) && GetTownIndex(current_tile) == t->index; break; case MP_HOUSE: - try_clear = GetTownIndex(tile) == t->index; + try_clear = GetTownIndex(current_tile) == t->index; break; case MP_INDUSTRY: - try_clear = Industry::GetByTile(tile)->town == t; + try_clear = Industry::GetByTile(current_tile)->town == t; break; case MP_OBJECT: @@ -3016,7 +3016,7 @@ CommandCost CmdDeleteTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 /* No towns will be left, remove it! */ try_clear = true; } else { - Object *o = Object::GetByTile(tile); + Object *o = Object::GetByTile(current_tile); if (o->town == t) { if (o->type == OBJECT_STATUE) { /* Statue... always remove. */ @@ -3033,7 +3033,7 @@ CommandCost CmdDeleteTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 break; } if (try_clear) { - CommandCost ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); + CommandCost ret = DoCommand(current_tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); if (ret.Failed()) return ret; } } diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 3b1667094..0a3a5db9e 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1391,7 +1391,7 @@ CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, uint16 data, uint3 } CommandCost cost(EXPENSES_NEW_VEHICLES); - for (Train *t = sell_head; t != nullptr; t = t->Next()) cost.AddCost(-t->value); + for (Train *part = sell_head; part != nullptr; part = part->Next()) cost.AddCost(-part->value); /* do it? */ if (flags & DC_EXEC) { diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index 9798c2bb5..baf149f5f 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -392,11 +392,11 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 int limit = (c == nullptr ? INT32_MAX : GB(c->tree_limit, 16, 16)); TileArea ta(tile, p2); - for (TileIndex tile : ta) { - switch (GetTileType(tile)) { + for (TileIndex current_tile : ta) { + switch (GetTileType(current_tile)) { case MP_TREES: /* no more space for trees? */ - if (GetTreeCount(tile) == 4) { + if (GetTreeCount(current_tile) == 4) { msg = STR_ERROR_TREE_ALREADY_HERE; continue; } @@ -408,8 +408,8 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 } if (flags & DC_EXEC) { - AddTreeCount(tile, 1); - MarkTileDirtyByTile(tile); + AddTreeCount(current_tile, 1); + MarkTileDirtyByTile(current_tile); if (c != nullptr) c->tree_limit -= 1 << 16; } /* 2x as expensive to add more trees to an existing tile */ @@ -417,14 +417,14 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 break; case MP_WATER: - if (!IsCoast(tile) || IsSlopeWithOneCornerRaised(GetTileSlope(tile))) { + if (!IsCoast(current_tile) || IsSlopeWithOneCornerRaised(GetTileSlope(current_tile))) { msg = STR_ERROR_CAN_T_BUILD_ON_WATER; continue; } FALLTHROUGH; case MP_CLEAR: { - if (IsBridgeAbove(tile)) { + if (IsBridgeAbove(current_tile)) { msg = STR_ERROR_SITE_UNSUITABLE; continue; } @@ -433,11 +433,11 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 /* Be a bit picky about which trees go where. */ if (_settings_game.game_creation.landscape == LT_TROPIC && treetype != TREE_INVALID && ( /* No cacti outside the desert */ - (treetype == TREE_CACTUS && GetTropicZone(tile) != TROPICZONE_DESERT) || + (treetype == TREE_CACTUS && GetTropicZone(current_tile) != TROPICZONE_DESERT) || /* No rain forest trees outside the rain forest, except in the editor mode where it makes those tiles rain forest tile */ - (IsInsideMM(treetype, TREE_RAINFOREST, TREE_CACTUS) && GetTropicZone(tile) != TROPICZONE_RAINFOREST && _game_mode != GM_EDITOR) || + (IsInsideMM(treetype, TREE_RAINFOREST, TREE_CACTUS) && GetTropicZone(current_tile) != TROPICZONE_RAINFOREST && _game_mode != GM_EDITOR) || /* And no subtropical trees in the desert/rain forest */ - (IsInsideMM(treetype, TREE_SUB_TROPICAL, TREE_TOYLAND) && GetTropicZone(tile) != TROPICZONE_NORMAL))) { + (IsInsideMM(treetype, TREE_SUB_TROPICAL, TREE_TOYLAND) && GetTropicZone(current_tile) != TROPICZONE_NORMAL))) { msg = STR_ERROR_TREE_WRONG_TERRAIN_FOR_TREE_TYPE; continue; } @@ -453,7 +453,7 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 switch (GetRawClearGround(tile)) { case CLEAR_FIELDS: case CLEAR_ROCKS: { - CommandCost ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); + CommandCost ret = DoCommand(current_tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); if (ret.Failed()) return ret; cost.AddCost(ret); break; @@ -464,24 +464,24 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 } if (_game_mode != GM_EDITOR && Company::IsValidID(_current_company)) { - Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority); + Town *t = ClosestTownFromTile(current_tile, _settings_game.economy.dist_local_authority); if (t != nullptr) ChangeTownRating(t, RATING_TREE_UP_STEP, RATING_TREE_MAXIMUM, flags); } if (flags & DC_EXEC) { if (treetype == TREE_INVALID) { - treetype = GetRandomTreeType(tile, GB(Random(), 24, 8)); + treetype = GetRandomTreeType(current_tile, GB(Random(), 24, 8)); if (treetype == TREE_INVALID) treetype = TREE_CACTUS; } /* Plant full grown trees in scenario editor */ - PlantTreesOnTile(tile, treetype, 0, _game_mode == GM_EDITOR ? 3 : 0); - MarkTileDirtyByTile(tile); + PlantTreesOnTile(current_tile, treetype, 0, _game_mode == GM_EDITOR ? 3 : 0); + MarkTileDirtyByTile(current_tile); if (c != nullptr) c->tree_limit -= 1 << 16; /* When planting rainforest-trees, set tropiczone to rainforest in editor. */ if (_game_mode == GM_EDITOR && IsInsideMM(treetype, TREE_RAINFOREST, TREE_CACTUS)) { - SetTropicZone(tile, TROPICZONE_RAINFOREST); + SetTropicZone(current_tile, TROPICZONE_RAINFOREST); } } cost.AddCost(_price[PR_BUILD_TREES]); diff --git a/src/viewport.cpp b/src/viewport.cpp index 4344eac2a..7217cbc45 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -245,8 +245,8 @@ void InitializeWindowViewport(Window *w, int x, int y, veh = Vehicle::Get(vp->follow_vehicle); pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos); } else { - uint x = TileX(follow_flags) * TILE_SIZE; - uint y = TileY(follow_flags) * TILE_SIZE; + x = TileX(follow_flags) * TILE_SIZE; + y = TileY(follow_flags) * TILE_SIZE; vp->follow_vehicle = INVALID_VEHICLE; pt = MapXYZToViewport(vp, x, y, GetSlopePixelZ(x, y)); diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 8c8a438a5..dfbed6012 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -467,19 +467,19 @@ CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 } for (; *iter != INVALID_TILE; ++(*iter)) { - TileIndex tile = *iter; + TileIndex current_tile = *iter; CommandCost ret; - Slope slope = GetTileSlope(tile); + Slope slope = GetTileSlope(current_tile); if (slope != SLOPE_FLAT && (wc != WATER_CLASS_RIVER || !IsInclinedSlope(slope))) { return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED); } /* can't make water of water! */ - if (IsTileType(tile, MP_WATER) && (!IsTileOwner(tile, OWNER_WATER) || wc == WATER_CLASS_SEA)) continue; + if (IsTileType(current_tile, MP_WATER) && (!IsTileOwner(current_tile, OWNER_WATER) || wc == WATER_CLASS_SEA)) continue; - bool water = IsWaterTile(tile); - ret = DoCommand(tile, 0, 0, flags | DC_FORCE_CLEAR_TILE, CMD_LANDSCAPE_CLEAR); + bool water = IsWaterTile(current_tile); + ret = DoCommand(current_tile, 0, 0, flags | DC_FORCE_CLEAR_TILE, CMD_LANDSCAPE_CLEAR); if (ret.Failed()) return ret; if (!water) cost.AddCost(ret); @@ -487,31 +487,31 @@ CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 if (flags & DC_EXEC) { switch (wc) { case WATER_CLASS_RIVER: - MakeRiver(tile, Random()); + MakeRiver(current_tile, Random()); if (_game_mode == GM_EDITOR) { - TileIndex tile2 = tile; + TileIndex tile2 = current_tile; CircularTileSearch(&tile2, RIVER_OFFSET_DESERT_DISTANCE, RiverModifyDesertZone, nullptr); } break; case WATER_CLASS_SEA: - if (TileHeight(tile) == 0) { - MakeSea(tile); + if (TileHeight(current_tile) == 0) { + MakeSea(current_tile); break; } FALLTHROUGH; default: - MakeCanal(tile, _current_company, Random()); + MakeCanal(current_tile, _current_company, Random()); if (Company::IsValidID(_current_company)) { Company::Get(_current_company)->infrastructure.water++; DirtyCompanyInfrastructureWindows(_current_company); } break; } - MarkTileDirtyByTile(tile); - MarkCanalsAndRiversAroundDirty(tile); - CheckForDockingTile(tile); + MarkTileDirtyByTile(current_tile); + MarkCanalsAndRiversAroundDirty(current_tile); + CheckForDockingTile(current_tile); } cost.AddCost(_price[PR_BUILD_CANAL]); @@ -1044,8 +1044,8 @@ static void FloodVehicles(TileIndex tile) if (IsAirportTile(tile)) { const Station *st = Station::GetByTile(tile); - for (TileIndex tile : st->airport) { - if (st->TileBelongsToAirport(tile)) FindVehicleOnPos(tile, &z, &FloodVehicleProc); + for (TileIndex airport_tile : st->airport) { + if (st->TileBelongsToAirport(airport_tile)) FindVehicleOnPos(airport_tile, &z, &FloodVehicleProc); } /* No vehicle could be flooded on this airport anymore */ |