From cff1232cce30cd07bf4eb9b597e06a08a6be1c5b Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Mon, 16 Nov 2026 07:25:04 +0100 Subject: [PATCH] refactor: the dates of the scenery wizard and of the editor's backups through std::format, ranges all_of (Sonar S6229, S6197) --- launcher/scenery_wizard.cpp | 4 ++-- scene/scenelayerssave.cpp | 4 ++-- scene/scenenodegroups.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/launcher/scenery_wizard.cpp b/launcher/scenery_wizard.cpp index 7038415d6..e28c52248 100644 --- a/launcher/scenery_wizard.cpp +++ b/launcher/scenery_wizard.cpp @@ -26,6 +26,7 @@ http://mozilla.org/MPL/2.0/. #include #include #include +#include #include namespace @@ -400,9 +401,8 @@ bool ui::scenerywizard_panel::create_scenery() return false; } auto const now{std::time(nullptr)}; - char date[32]; std::tm const local{local_tm(now)}; - std::strftime(date, sizeof(date), "%Y-%m-%d", &local); + auto const date{std::format("{:04}-{:02}-{:02}", local.tm_year + 1900, local.tm_mon + 1, local.tm_mday)}; char reference[96]; std::snprintf(reference, sizeof(reference), "//$g PUWG1992 %.3f %.3f", m_map.point().x / 1000.0, m_map.point().y / 1000.0); auto const area{range()}; diff --git a/scene/scenelayerssave.cpp b/scene/scenelayerssave.cpp index 8321c1844..7c0b84241 100644 --- a/scene/scenelayerssave.cpp +++ b/scene/scenelayerssave.cpp @@ -27,6 +27,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/translation.h" #include "editor/editorFormat.hpp" +#include #include #include #include @@ -1667,9 +1668,8 @@ save_result node_layers::save(std::vector const &Rootstatements, st // without the copy nothing is replaced { auto const now{std::time(nullptr)}; - char stamp[32]; std::tm const local{local_tm(now)}; - std::strftime(stamp, sizeof(stamp), "%Y%m%d-%H%M%S", &local); + auto const stamp{std::format("{:04}{:02}{:02}-{:02}{:02}{:02}", local.tm_year + 1900, local.tm_mon + 1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec)}; for (auto const output : written) { auto const filepath{path(output)}; diff --git a/scene/scenenodegroups.cpp b/scene/scenenodegroups.cpp index dd10fc143..e3d1bc463 100644 --- a/scene/scenenodegroups.cpp +++ b/scene/scenenodegroups.cpp @@ -208,7 +208,7 @@ node_groups::update_map() last_switch->track[lastc - 'a'] = track; // all four tracks of the cross switch have to be known before it's assigned - if (!std::all_of(last_switch->track.begin(), last_switch->track.end(), [](TTrack const *Track) { return Track != nullptr; })) + if (!std::ranges::all_of(last_switch->track, [](TTrack const *Track) { return Track != nullptr; })) continue; if (!assign_cross_switch(*last_switch, sw_name, "ac", 0))