mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-08-15 14:43:32 -07:00
Compare commits
3 commits
84567e66c2
...
d6bdf51d83
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6bdf51d83 | ||
|
|
ae936e8177 | ||
|
|
06e199b12a |
13 changed files with 38 additions and 53 deletions
|
|
@ -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> CObjectBase::CopyWithQuality(u8 newQualityLevel) const
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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<int>(GetType()));
|
||||
}
|
||||
|
||||
CNetMessage* CNetMessageFactory::CreateMessage(const void* pData,
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <fmt/format.h>
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
|
|
@ -70,6 +71,10 @@
|
|||
#include <miniupnpc/upnperrors.h>
|
||||
#endif
|
||||
|
||||
#if FMT_VERSION >= 80000
|
||||
#include <fmt/xchar.h>
|
||||
#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++);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "NetStats.h"
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <string>
|
||||
|
||||
enum
|
||||
|
|
@ -77,7 +78,7 @@ const std::vector<ProfileColumn>& CNetStatsTable::GetColumns()
|
|||
std::lock_guard<std::mutex> 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<std::mutex> 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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,27 +202,6 @@ CStr CStr::Repeat(const CStr& str, size_t reps)
|
|||
|
||||
// Construction from numbers:
|
||||
|
||||
CStr CStr::FromInt(int n)
|
||||
{
|
||||
tstringstream<StrBase> ss;
|
||||
ss << n;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
CStr CStr::FromUInt(unsigned int n)
|
||||
{
|
||||
tstringstream<StrBase> ss;
|
||||
ss << n;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
CStr CStr::FromInt64(i64 n)
|
||||
{
|
||||
tstringstream<StrBase> ss;
|
||||
ss << n;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
CStr CStr::FromDouble(double n)
|
||||
{
|
||||
tstringstream<StrBase> ss;
|
||||
|
|
|
|||
|
|
@ -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,9 +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);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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 <SDL_keycode.h>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <fmt/format.h>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
|
@ -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<int>(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<int>(scancode));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -517,7 +517,7 @@ void rewriteBuffer(u8* buffer, u32& bufferSize)
|
|||
std::string basic = attrib;
|
||||
std::map<std::string, double>::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<u32>(basic.size());
|
||||
memcpy(buffer + writePos, &length, sizeof(length));
|
||||
|
|
|
|||
|
|
@ -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 <cstring>
|
||||
#include <ctime>
|
||||
#include <deque>
|
||||
#include <fmt/format.h>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
|
@ -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<int>(err), errorString));
|
||||
}
|
||||
|
||||
// We got an unhandled return code or a connection failure;
|
||||
|
|
@ -385,12 +386,12 @@ private:
|
|||
r += "user_id=";
|
||||
AppendEscaped(r, m_UserID);
|
||||
|
||||
r += "&time=" + CStr::FromInt64(report.m_Time);
|
||||
r = fmt::format("{}&time={}", std::move(r), report.m_Time);
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
} // namespace Script
|
||||
|
|
|
|||
Loading…
Reference in a new issue