diff --git a/source/graphics/ObjectBase.cpp b/source/graphics/ObjectBase.cpp index 724dd9ed9c..198f1c94d3 100644 --- a/source/graphics/ObjectBase.cpp +++ b/source/graphics/ObjectBase.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -69,7 +69,7 @@ CObjectBase::CObjectBase(CObjectManager& objectManager, CActorDef& actorDef, u8 m_Properties.m_FloatOnWater = false; // Remove leading art/actors/ & include quality level. - m_Identifier = m_ActorDef.m_Pathname.string8().substr(11) + CStr::FromInt(m_QualityLevel); + m_Identifier = fmt::format("{}{}", m_ActorDef.m_Pathname.string8().substr(11), m_QualityLevel); } std::unique_ptr CObjectBase::CopyWithQuality(u8 newQualityLevel) const diff --git a/source/network/NetMessage.cpp b/source/network/NetMessage.cpp index 31bdeb9be8..f83047df64 100644 --- a/source/network/NetMessage.cpp +++ b/source/network/NetMessage.cpp @@ -88,7 +88,7 @@ CStr CNetMessage::ToString() const if (GetType() == NMT_INVALID) return "MESSAGE_TYPE_NONE { Undefined Message }"; else - return "Unknown Message " + CStr::FromInt(GetType()); + return fmt::format("Unknown Message {}", static_cast(GetType())); } CNetMessage* CNetMessageFactory::CreateMessage(const void* pData, diff --git a/source/ps/CStr.cpp b/source/ps/CStr.cpp index 2a8a345871..7a79bd0907 100644 --- a/source/ps/CStr.cpp +++ b/source/ps/CStr.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -202,13 +202,6 @@ CStr CStr::Repeat(const CStr& str, size_t reps) // Construction from numbers: -CStr CStr::FromInt(int n) -{ - tstringstream ss; - ss << n; - return ss.str(); -} - CStr CStr::FromUInt(unsigned int n) { tstringstream ss; diff --git a/source/ps/CStr.h b/source/ps/CStr.h index b08abb2f29..9edc561765 100644 --- a/source/ps/CStr.h +++ b/source/ps/CStr.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -95,7 +95,6 @@ public: // Conversions: - static CStr FromInt(int n); static CStr FromUInt(unsigned int n); static CStr FromInt64(i64 n); static CStr FromDouble(double n); diff --git a/source/ps/KeyName.cpp b/source/ps/KeyName.cpp index 1ebab4e13f..7b93c269d9 100644 --- a/source/ps/KeyName.cpp +++ b/source/ps/KeyName.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -122,7 +123,7 @@ CStr FindScancodeName(SDL_Scancode scancode) const char* name = SDL_GetScancodeName(scancode); // Some scancodes have no name, but we must have something to save/load/recognize it, so parse it as SYM_XX if (strlen(name) == 0) - return CStr("SYM_") + CStr::FromInt(scancode); + return fmt::format("SYM_{}", static_cast(scancode)); return name; } @@ -221,7 +222,7 @@ CStr FindKeyName(SDL_Scancode scancode) return name; // Else, show something regardless, so the player knows it's at least recognized. - return CStr("SYM_") + CStr::FromInt(scancode); + return fmt::format("SYM_{}", static_cast(scancode)); } diff --git a/source/ps/Profiler2.cpp b/source/ps/Profiler2.cpp index bb24b469bb..8a8d39aeaf 100644 --- a/source/ps/Profiler2.cpp +++ b/source/ps/Profiler2.cpp @@ -517,7 +517,7 @@ void rewriteBuffer(u8* buffer, u32& bufferSize) std::string basic = attrib; std::map::iterator time_attrib = time_per_attribute.find(attrib); if (time_attrib != time_per_attribute.end()) - basic += " " + CStr::FromInt(1000000*time_attrib->second) + "us"; + basic = fmt::format("{} {}us", basic, 1000000 * time_attrib->second); u32 length = static_cast(basic.size()); memcpy(buffer + writePos, &length, sizeof(length)); diff --git a/source/ps/UserReport.cpp b/source/ps/UserReport.cpp index 9a429dcf78..0179600c38 100644 --- a/source/ps/UserReport.cpp +++ b/source/ps/UserReport.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -337,7 +338,7 @@ private: { long code = -1; curl_easy_getinfo(m_Curl, CURLINFO_RESPONSE_CODE, &code); - SetStatus("completed:" + CStr::FromInt(code)); + SetStatus(fmt::format("completed:{}", code)); // Check for success code if (code == 200) @@ -360,7 +361,7 @@ private: if (errorString.empty()) errorString = curl_easy_strerror(err); - SetStatus("failed:" + CStr::FromInt(err) + ":" + errorString); + SetStatus(fmt::format("failed:{}:{}", static_cast(err), errorString)); } // We got an unhandled return code or a connection failure; @@ -390,7 +391,7 @@ private: r += "&type="; AppendEscaped(r, report.m_Type); - r += "&version=" + CStr::FromInt(report.m_Version); + r = fmt::format("{}&version={}", std::move(r), report.m_Version); r += "&data="; AppendEscaped(r, report.m_Data); @@ -529,7 +530,7 @@ bool CUserReporter::IsReportingEnabled() void CUserReporter::SetReportingEnabled(bool enabled) { - CStr val = CStr::FromInt(enabled ? REPORTER_VERSION : 0); + const std::string val{std::to_string(enabled ? REPORTER_VERSION : 0)}; g_ConfigDB.SetValueString(CFG_USER, "userreport.enabledversion", val); g_ConfigDB.WriteValueToFile(CFG_USER, "userreport.enabledversion", val);