diff --git a/source/graphics/PreprocessorWrapper.cpp b/source/graphics/PreprocessorWrapper.cpp index e75bee3097..2739c754d8 100644 --- a/source/graphics/PreprocessorWrapper.cpp +++ b/source/graphics/PreprocessorWrapper.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 @@ -156,7 +156,8 @@ bool ResolveIncludesImpl( it = includeCache.emplace(path, std::move(includeContent)).first; } // We need to insert #line directives to have correct line numbers in errors. - chunks.emplace_back(lineDirective + "1\n" + it->second + "\n" + lineDirective + CStr::FromUInt(line + 1) + "\n"); + chunks.emplace_back(fmt::format("{}1\n{}\n{}{}\n", lineDirective, it->second, lineDirective, + line + 1)); processedParts.emplace_back(currentPart.substr(0, lineStart)); if (!ResolveIncludesImpl(chunks.back(), includeCache, includeCallback, chunks, processedParts)) return false; diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index 0f607cdc14..50c4bcd126 100644 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -755,7 +755,7 @@ void CGUI::Xeromyces_ReadObject(const XMBData& xmb, XMBElement element, IGUIObje // Check if name isn't set, generate an internal name in that case. if (!NameSet) { - object->SetName("__internal(" + CStr::FromInt(m_InternalNameNumber) + ")"); + object->SetName(fmt::format("__internal({})", m_InternalNameNumber)); ++m_InternalNameNumber; } @@ -977,7 +977,7 @@ void CGUI::Xeromyces_ReadRepeat(const XMBData& xmb, XMBElement element, IGUIObje for (int n = 0; n < count; ++n) { - NameSubst.emplace_back(var, "[" + CStr::FromInt(n) + "]"); + NameSubst.emplace_back(var, fmt::format("[{}]", n)); XERO_ITER_EL(element, child) { diff --git a/source/network/NetServer.cpp b/source/network/NetServer.cpp index 932c58ed36..c4198a797d 100644 --- a/source/network/NetServer.cpp +++ b/source/network/NetServer.cpp @@ -54,6 +54,7 @@ #include #include +#include #include #include #include @@ -70,6 +71,10 @@ #include #endif +#if FMT_VERSION >= 80000 +#include +#endif + /** * Number of peers to allocate for the enet host. * Limited by ENET_PROTOCOL_MAXIMUM_PEER_ID (4096). @@ -1641,7 +1646,7 @@ CStrW CNetServerWorker::DeduplicatePlayerName(const CStrW& original) if (unique) return name; - name = original + L" (" + CStrW::FromUInt(id++) + L")"; + name = fmt::format(L"{}({})", original, id++); } } diff --git a/source/network/NetStats.cpp b/source/network/NetStats.cpp index 5df0f7fac9..cab95f2d0c 100644 --- a/source/network/NetStats.cpp +++ b/source/network/NetStats.cpp @@ -19,6 +19,7 @@ #include "NetStats.h" +#include #include enum @@ -77,7 +78,7 @@ const std::vector& CNetStatsTable::GetColumns() std::lock_guard lock(m_Mutex); for (size_t i = 0; i < m_LatchedData.size(); ++i) - m_ColumnDescriptions.push_back(ProfileColumn("Peer "+CStr::FromUInt(i), 80)); + m_ColumnDescriptions.push_back(ProfileColumn(fmt::format("Peer {}", i), 80)); } return m_ColumnDescriptions; @@ -95,7 +96,7 @@ CStr CNetStatsTable::GetCellText(size_t row, size_t col) #define ROW(id, title, member) \ case id: \ if (col == 0) return title; \ - if (m_Peer) return CStr::FromUInt(m_Peer->member); \ + if (m_Peer) return std::to_string(m_Peer->member); \ return "???" switch(row) @@ -129,7 +130,7 @@ void CNetStatsTable::LatchHostState(const ENetHost& host) std::lock_guard lock(m_Mutex); #define ROW(id, title, member) \ - m_LatchedData[i].push_back(CStr::FromUInt(host.peers[i].member)); + m_LatchedData[i].push_back(std::to_string(host.peers[i].member)); m_LatchedData.clear(); m_LatchedData.resize(host.peerCount); diff --git a/source/network/StringConverters.h b/source/network/StringConverters.h index df0358e010..14709ad54f 100644 --- a/source/network/StringConverters.h +++ b/source/network/StringConverters.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 @@ -25,7 +25,7 @@ static inline CStr NetMessageStringConvert(u32 arg) { - return CStr::FromUInt(arg); + return std::to_string(arg); } static inline CStr NetMessageStringConvert(const CStr8& arg) diff --git a/source/ps/CStr.cpp b/source/ps/CStr.cpp index 7a79bd0907..6ceecfd2e2 100644 --- a/source/ps/CStr.cpp +++ b/source/ps/CStr.cpp @@ -202,13 +202,6 @@ CStr CStr::Repeat(const CStr& str, size_t reps) // Construction from numbers: -CStr CStr::FromUInt(unsigned int n) -{ - tstringstream ss; - ss << n; - return ss.str(); -} - CStr CStr::FromInt64(i64 n) { tstringstream ss; diff --git a/source/ps/CStr.h b/source/ps/CStr.h index 9edc561765..4bae72bb0e 100644 --- a/source/ps/CStr.h +++ b/source/ps/CStr.h @@ -95,7 +95,6 @@ public: // Conversions: - static CStr FromUInt(unsigned int n); static CStr FromInt64(i64 n); static CStr FromDouble(double n); diff --git a/source/scriptinterface/Stats.cpp b/source/scriptinterface/Stats.cpp index 6c40cdd880..e80c230143 100644 --- a/source/scriptinterface/Stats.cpp +++ b/source/scriptinterface/Stats.cpp @@ -90,21 +90,21 @@ CStr CScriptStatsTable::GetCellText(size_t row, size_t col) if (col == 0) return "max nominal heap bytes"; uint32_t n = JS_GetGCParameter(m_ScriptInterfaces.at(col-1).first->GetGeneralJSContext(), JSGC_MAX_BYTES); - return CStr::FromUInt(n); + return std::to_string(n); } case Row_Bytes: { if (col == 0) return "allocated bytes"; uint32_t n = JS_GetGCParameter(m_ScriptInterfaces.at(col-1).first->GetGeneralJSContext(), JSGC_BYTES); - return CStr::FromUInt(n); + return std::to_string(n); } case Row_NumberGC: { if (col == 0) return "number of GCs"; uint32_t n = JS_GetGCParameter(m_ScriptInterfaces.at(col-1).first->GetGeneralJSContext(), JSGC_NUMBER); - return CStr::FromUInt(n); + return std::to_string(n); } default: return "???"; @@ -116,4 +116,4 @@ AbstractProfileTable* CScriptStatsTable::GetChild(size_t /*row*/) return 0; } -} // namespace Script \ No newline at end of file +} // namespace Script