From 2d30df8110e6f49fb5c216c13e38ec0f9b470af8 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sat, 15 Feb 2025 16:03:27 +0100 Subject: [PATCH] Codefix: 'Declaration hides variable' --- src/autoreplace_cmd.cpp | 2 +- src/fileio.cpp | 3 +-- src/industry_cmd.cpp | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index 132ff9a826..0b513d24a1 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -666,7 +666,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlags flags, bool wago * Note: The vehicle attach callback is disabled here :) */ if (!flags.Test(DoCommandFlag::Execute)) { /* Separate the head, so we can reattach the old vehicles */ - Train *second = Train::From(old_head)->GetNextUnit(); + second = Train::From(old_head)->GetNextUnit(); if (second != nullptr) CmdMoveVehicle(second, nullptr, {DoCommandFlag::Execute, DoCommandFlag::AutoReplace}, true); assert(Train::From(old_head)->GetNextUnit() == nullptr); diff --git a/src/fileio.cpp b/src/fileio.cpp index dd1856ef87..a57007438c 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -259,8 +259,7 @@ std::optional FioFOpenFile(const std::string &filename, const char * /* Resolve ".." */ std::istringstream ss(resolved_name); std::vector tokens; - std::string token; - while (std::getline(ss, token, PATHSEPCHAR)) { + for (std::string token; std::getline(ss, token, PATHSEPCHAR); /* nothing */) { if (token == "..") { if (tokens.size() < 2) return std::nullopt; tokens.pop_back(); diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index d0a92ce5e3..d7c953537f 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -1773,8 +1773,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, i->type = type; auto &industries = Industry::industries[type]; - auto it = std::ranges::lower_bound(industries, i->index); - it = industries.emplace(it, i->index); + industries.emplace(std::ranges::lower_bound(industries, i->index), i->index); for (size_t index = 0; index < std::size(indspec->produced_cargo); ++index) { if (!IsValidCargoType(indspec->produced_cargo[index])) break;