mirror of
https://github.com/OpenTTD/OpenTTD
synced 2025-12-10 06:52:05 +01:00
Codefix: shadowing variable, grouping loop increments
This commit is contained in:
@@ -233,16 +233,14 @@ CommandCost CmdBuildRailWaypoint(DoCommandFlags flags, TileIndex start_tile, Axi
|
||||
|
||||
const StationSpec *spec = StationClass::Get(spec_class)->GetSpec(spec_index);
|
||||
RailStationTileLayout stl{spec, count, 1};
|
||||
auto it = stl.begin();
|
||||
|
||||
/* Check whether the tiles we're building on are valid rail or not. */
|
||||
TileIndexDiff offset = TileOffsByAxis(OtherAxis(axis));
|
||||
for (int i = 0; i < count; i++) {
|
||||
TileIndex tile = start_tile + i * offset;
|
||||
for (auto [i, it, tile] = std::make_tuple(0, stl.begin(), start_tile); i < count; ++i, ++it, tile += offset) {
|
||||
CommandCost ret = IsValidTileForWaypoint(tile, axis, &est);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
ret = IsRailStationBridgeAboveOk(tile, spec, StationType::RailWaypoint, *it++ + axis);
|
||||
ret = IsRailStationBridgeAboveOk(tile, spec, StationType::RailWaypoint, *it + axis);
|
||||
if (ret.Failed()) return ret;
|
||||
}
|
||||
|
||||
@@ -297,17 +295,14 @@ CommandCost CmdBuildRailWaypoint(DoCommandFlags flags, TileIndex start_tile, Axi
|
||||
|
||||
wp->UpdateVirtCoord();
|
||||
|
||||
auto it = stl.begin();
|
||||
|
||||
Company *c = Company::Get(wp->owner);
|
||||
for (int i = 0; i < count; i++) {
|
||||
TileIndex tile = start_tile + i * offset;
|
||||
for (auto [i, it, tile] = std::make_tuple(0, stl.begin(), start_tile); i < count; ++i, ++it, tile += offset) {
|
||||
uint8_t old_specindex = HasStationTileRail(tile) ? GetCustomStationSpecIndex(tile) : 0;
|
||||
if (!HasStationTileRail(tile)) c->infrastructure.station++;
|
||||
bool reserved = IsTileType(tile, MP_RAILWAY) ?
|
||||
HasBit(GetRailReservationTrackBits(tile), AxisToTrack(axis)) :
|
||||
HasStationReservation(tile);
|
||||
MakeRailWaypoint(tile, wp->owner, wp->index, axis, *it++, GetRailType(tile));
|
||||
MakeRailWaypoint(tile, wp->owner, wp->index, axis, *it, GetRailType(tile));
|
||||
SetCustomStationSpecIndex(tile, *specindex);
|
||||
|
||||
SetRailStationTileFlags(tile, spec);
|
||||
|
||||
Reference in New Issue
Block a user