mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-11-08 21:48:38 +00:00
Use fmt::format for LOGERROR
The format string can be checked at compile time. It will be easier to transition to `std::format`.
This commit is contained in:
115 files changed
+631
-454
No files matched your search
@@ -916,7 +916,8 @@ static std::vector<std::string> GetJSONData(const VfsPath& path)
|
||||
{
|
||||
// Some error reading directory
|
||||
wchar_t error[200];
|
||||
LOGERROR("Error reading directory '%s': %s", path.string8(), utf8_from_wstring(StatusDescription(ret, error, ARRAY_SIZE(error))));
|
||||
LOGERROR("Error reading directory '{}': {}", path.string8(),
|
||||
utf8_from_wstring(StatusDescription(ret, error, ARRAY_SIZE(error))));
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
@@ -928,7 +929,8 @@ static std::vector<std::string> GetJSONData(const VfsPath& path)
|
||||
PSRETURN loadStatus = file.Load(g_VFS, p);
|
||||
if (loadStatus != PSRETURN_OK)
|
||||
{
|
||||
LOGERROR("GetJSONData: Failed to load file '%s': %s", p.string8(), GetErrorString(loadStatus));
|
||||
LOGERROR("GetJSONData: Failed to load file '{}': {}", p.string8(),
|
||||
GetErrorString(loadStatus));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -952,7 +954,7 @@ static std::string ReadJSON(const VfsPath& path)
|
||||
{
|
||||
if (!VfsFileExists(path))
|
||||
{
|
||||
LOGERROR("File '%s' does not exist", path.string8());
|
||||
LOGERROR("File '{}' does not exist", path.string8());
|
||||
return std::string();
|
||||
}
|
||||
|
||||
@@ -961,7 +963,7 @@ static std::string ReadJSON(const VfsPath& path)
|
||||
PSRETURN ret = file.Load(g_VFS, path);
|
||||
if (ret != PSRETURN_OK)
|
||||
{
|
||||
LOGERROR("Failed to load file '%s': %s", path.string8(), GetErrorString(ret));
|
||||
LOGERROR("Failed to load file '{}': {}", path.string8(), GetErrorString(ret));
|
||||
return std::string();
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ private:
|
||||
m_Worker.LoadMetadata(path, &metadata);
|
||||
if (metadata.isUndefined())
|
||||
{
|
||||
LOGERROR("Failed to create AI player: can't find %s", path.string8());
|
||||
LOGERROR("Failed to create AI player: can't find {}", path.string8());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ private:
|
||||
JS::RootedValue ctor(rq.cx);
|
||||
if (!Script::HasProperty(rq, metadata, "filename"))
|
||||
{
|
||||
LOGERROR("Failed to create AI player: %s: missing 'filename'", path.string8());
|
||||
LOGERROR("Failed to create AI player: {}: missing 'filename'", path.string8());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ private:
|
||||
|
||||
if (!Script::GetProperty(rq, metadata, "constructor", constructor))
|
||||
{
|
||||
LOGERROR("Failed to create AI player: %s: missing 'constructor'", path.string8());
|
||||
LOGERROR("Failed to create AI player: {}: missing 'constructor'", path.string8());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -170,7 +170,8 @@ private:
|
||||
if (!Script::GetProperty(rq, objectWithConstructor, constructor.c_str(), &ctor)
|
||||
|| ctor.isNull())
|
||||
{
|
||||
LOGERROR("Failed to create AI player: %s: can't find constructor '%s'", path.string8(), constructor);
|
||||
LOGERROR("Failed to create AI player: {}: can't find constructor '{}'",
|
||||
path.string8(), constructor);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -197,7 +198,8 @@ private:
|
||||
|
||||
if (m_Obj.get().isNull())
|
||||
{
|
||||
LOGERROR("Failed to create AI player: %s: error calling constructor '%s'", path.string8(), constructor);
|
||||
LOGERROR("Failed to create AI player: {}: error calling constructor '{}'",
|
||||
path.string8(), constructor);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -432,7 +434,8 @@ public:
|
||||
if (!Script::GetProperty(rq, AIModule, "SharedScript", &ctor)
|
||||
|| ctor.isUndefined())
|
||||
{
|
||||
LOGERROR("Failed to create shared AI component: %s: can't find constructor '%s'", path.string8(), "SharedScript");
|
||||
LOGERROR("Failed to create shared AI component: {}: can't find constructor '{}'",
|
||||
path.string8(), "SharedScript");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -462,7 +465,8 @@ public:
|
||||
|
||||
if (m_SharedAIObj.get().isNull())
|
||||
{
|
||||
LOGERROR("Failed to create shared AI component: %s: error calling constructor '%s'", path.string8(), "SharedScript");
|
||||
LOGERROR("Failed to create shared AI component: {}: error calling constructor '{}'",
|
||||
path.string8(), "SharedScript");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ public:
|
||||
{
|
||||
CColor colorObj(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
if (!colorObj.ParseString(color, 1))
|
||||
LOGERROR("OverlayRenderer: Error parsing '%s'", color);
|
||||
LOGERROR("OverlayRenderer: Error parsing '{}'", color);
|
||||
|
||||
CTextureProperties textureProps(textureName);
|
||||
|
||||
|
||||
@@ -295,7 +295,7 @@ pass_class_t CCmpPathfinder::GetPassabilityClass(const std::string& name) const
|
||||
std::map<std::string, pass_class_t>::const_iterator it = m_PassClassMasks.find(name);
|
||||
if (it == m_PassClassMasks.end())
|
||||
{
|
||||
LOGERROR("Invalid passability class name '%s'", name.c_str());
|
||||
LOGERROR("Invalid passability class name '{}'", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1021,7 +1021,7 @@ public:
|
||||
{
|
||||
if (m_Queries.find(tag) == m_Queries.end())
|
||||
{
|
||||
LOGERROR("CCmpRangeManager: DestroyActiveQuery called with invalid tag %u", tag);
|
||||
LOGERROR("CCmpRangeManager: DestroyActiveQuery called with invalid tag {}", tag);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1033,7 +1033,7 @@ public:
|
||||
std::map<tag_t, Query>::iterator it = m_Queries.find(tag);
|
||||
if (it == m_Queries.end())
|
||||
{
|
||||
LOGERROR("CCmpRangeManager: EnableActiveQuery called with invalid tag %u", tag);
|
||||
LOGERROR("CCmpRangeManager: EnableActiveQuery called with invalid tag {}", tag);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1046,7 +1046,7 @@ public:
|
||||
std::map<tag_t, Query>::iterator it = m_Queries.find(tag);
|
||||
if (it == m_Queries.end())
|
||||
{
|
||||
LOGERROR("CCmpRangeManager: DisableActiveQuery called with invalid tag %u", tag);
|
||||
LOGERROR("CCmpRangeManager: DisableActiveQuery called with invalid tag {}", tag);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1059,7 +1059,7 @@ public:
|
||||
std::map<tag_t, Query>::const_iterator it = m_Queries.find(tag);
|
||||
if (it == m_Queries.end())
|
||||
{
|
||||
LOGERROR("CCmpRangeManager: IsActiveQueryEnabled called with invalid tag %u", tag);
|
||||
LOGERROR("CCmpRangeManager: IsActiveQueryEnabled called with invalid tag {}", tag);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1116,7 +1116,7 @@ public:
|
||||
std::map<tag_t, Query>::iterator it = m_Queries.find(tag);
|
||||
if (it == m_Queries.end())
|
||||
{
|
||||
LOGERROR("CCmpRangeManager: ResetActiveQuery called with invalid tag %u", tag);
|
||||
LOGERROR("CCmpRangeManager: ResetActiveQuery called with invalid tag {}", tag);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -171,7 +171,7 @@ const CParamNode* CCmpTemplateManager::GetTemplate(const std::string& templateNa
|
||||
|
||||
// Show error on the first failure to validate the template
|
||||
if (!m_TemplateSchemaValidity[templateName])
|
||||
LOGERROR("Failed to validate entity template '%s'", templateName.c_str());
|
||||
LOGERROR("Failed to validate entity template '{}'", templateName);
|
||||
}
|
||||
// Refuse to return invalid templates
|
||||
if (!m_TemplateSchemaValidity[templateName])
|
||||
@@ -182,7 +182,7 @@ const CParamNode* CCmpTemplateManager::GetTemplate(const std::string& templateNa
|
||||
if (!templateRoot.IsOk())
|
||||
{
|
||||
// The validator should never let this happen
|
||||
LOGERROR("Invalid root element in entity template '%s'", templateName.c_str());
|
||||
LOGERROR("Invalid root element in entity template '{}'", templateName);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -51,7 +51,8 @@ public:
|
||||
case static_cast<int>(LosVisibility::VISIBLE):
|
||||
return LosVisibility::VISIBLE;
|
||||
default:
|
||||
LOGERROR("Received the invalid visibility value %d from the Visibility scripted component!", visibility);
|
||||
LOGERROR("Received the invalid visibility value {} from the Visibility scripted "
|
||||
"component!", visibility);
|
||||
return LosVisibility::HIDDEN;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
if (it != m_PassClassMasks.end())
|
||||
return it->second;
|
||||
|
||||
LOGERROR("Invalid passability class name '%s'", name.c_str());
|
||||
LOGERROR("Invalid passability class name '{}'", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ PathfinderPassability::PathfinderPassability(pass_class_t mask, const CParamNode
|
||||
m_Obstructions = FOUNDATION;
|
||||
else
|
||||
{
|
||||
LOGERROR("Invalid value for Obstructions in pathfinder.xml for pass class %d", mask);
|
||||
LOGERROR("Invalid value for Obstructions in pathfinder.xml for pass class {}", mask);
|
||||
m_Obstructions = NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ void CComponentTypeScript::HandleMessage(const CMessage& msg, bool global)
|
||||
JS::RootedValue msgVal(rq.cx, msg.ToJSValCached(rq));
|
||||
|
||||
if (!Script::Function::CallVoid(rq, GetInstance(), name, msgVal))
|
||||
LOGERROR("Script message handler %s failed", name);
|
||||
LOGERROR("Script message handler {} failed", name);
|
||||
}
|
||||
|
||||
void CComponentTypeScript::Serialize(ISerializer& serialize)
|
||||
@@ -81,7 +81,8 @@ void CComponentTypeScript::Serialize(ISerializer& serialize)
|
||||
Script::GetProperty(rq, GetInstance(), "entity", ent);
|
||||
std::string name = "(error)";
|
||||
Script::GetObjectClassName(rq, GetInstance(), name);
|
||||
LOGERROR("Script component %s of entity %i failed to serialize: %s\nSerializing:\n%s", name, ent, err.what(), Script::ToString(rq, GetMutInstance()));
|
||||
LOGERROR("Script component {} of entity {} failed to serialize: {}\nSerializing:\n{}",
|
||||
name, ent, err.what(), Script::ToString(rq, GetMutInstance()));
|
||||
// Rethrow now that we added more details
|
||||
throw;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
Script::Request rq(m_ScriptInterface);
|
||||
if (Script::Function::Call(rq, GetInstance(), funcname, ret, params...))
|
||||
return ret;
|
||||
LOGERROR("Error calling component script function %s", funcname);
|
||||
LOGERROR("Error calling component script function {}", funcname);
|
||||
return R();
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
{
|
||||
Script::Request rq(m_ScriptInterface);
|
||||
if (!Script::Function::Call(rq, GetInstance(), funcname, ret, params...))
|
||||
LOGERROR("Error calling component script function %s", funcname);
|
||||
LOGERROR("Error calling component script function {}", funcname);
|
||||
}
|
||||
|
||||
template<typename... Ts>
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
{
|
||||
Script::Request rq(m_ScriptInterface);
|
||||
if (!Script::Function::CallVoid(rq, GetInstance(), funcname, params...))
|
||||
LOGERROR("Error calling component script function %s", funcname);
|
||||
LOGERROR("Error calling component script function {}", funcname);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -72,7 +72,7 @@ static std::uint8_t GetArrayType(js::Scalar::Type arrayType)
|
||||
case js::Scalar::Uint8Clamped:
|
||||
return SCRIPT_TYPED_ARRAY_UINT8_CLAMPED;
|
||||
default:
|
||||
LOGERROR("Cannot serialize unrecognized typed array view: %d", static_cast<int>(arrayType));
|
||||
LOGERROR("Cannot serialize unrecognized typed array view: {}", static_cast<int>(arrayType));
|
||||
throw PSERROR_Serialize_InvalidScriptValue();
|
||||
}
|
||||
}
|
||||
@@ -322,7 +322,8 @@ void CBinarySerializerScriptImpl::HandleScriptVal(const Script::Request& rq, JS:
|
||||
else
|
||||
{
|
||||
// Unrecognized class
|
||||
LOGERROR("Cannot serialize JS objects with unrecognized class '%s'", jsclass->name);
|
||||
LOGERROR("Cannot serialize JS objects with unrecognized class '{}'",
|
||||
jsclass->name);
|
||||
throw PSERROR_Serialize_InvalidScriptValue();
|
||||
}
|
||||
}
|
||||
@@ -395,7 +396,7 @@ void CBinarySerializerScriptImpl::HandleScriptVal(const Script::Request& rq, JS:
|
||||
}
|
||||
}
|
||||
|
||||
LOGERROR("Cannot serialize JS objects of type 'function': %s", utf8_from_wstring(funcname));
|
||||
LOGERROR("Cannot serialize JS objects of type 'function': {}", utf8_from_wstring(funcname));
|
||||
throw PSERROR_Serialize_InvalidScriptValue();
|
||||
}
|
||||
case JSTYPE_STRING:
|
||||
@@ -500,7 +501,7 @@ std::uint32_t CBinarySerializerScriptImpl::GetScriptBackrefTag(const Script::Req
|
||||
if (!m_ScriptBackrefTags.put(JS::Heap<JSObject*>(obj.get()), ++m_ScriptBackrefsNext))
|
||||
{
|
||||
JS::RootedValue objval(rq.cx, JS::ObjectValue(*obj.get()));
|
||||
LOGERROR("BinarySerializer: error at insertion. Object was %s", Script::ToString(rq, &objval));
|
||||
LOGERROR("BinarySerializer: error at insertion. Object was {}", Script::ToString(rq, &objval));
|
||||
return 0;
|
||||
}
|
||||
// Return 0 to mean "you have to serialize this object";
|
||||
|
||||
@@ -88,7 +88,8 @@ inline SPrototypeSerialization GetPrototypeInfo(const Script::Request& rq, JS::H
|
||||
(!ret.hasNullSerialize && !ret.hasCustomDeserialize))
|
||||
{
|
||||
// Don't throw for this error: mods might need updating and this crashes as exceptions are not correctly handled.
|
||||
LOGERROR("Error serializing object '%s': non-null Serialize() but no matching Deserialize().", utf8_from_wstring(ret.name));
|
||||
LOGERROR("Error serializing object '{}': non-null Serialize() but no matching Deserialize().",
|
||||
utf8_from_wstring(ret.name));
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -448,7 +448,7 @@ std::vector<IComponent*> CComponentManager::Script_GetComponentsWithInterface(in
|
||||
CMessage* CComponentManager::ConstructMessage(int mtid, JS::HandleValue data)
|
||||
{
|
||||
if (mtid == MT__Invalid || mtid > (int)m_MessageTypeIdsByName.size()) // (IDs start at 1 so use '>' here)
|
||||
LOGERROR("PostMessage with invalid message type ID '%d'", mtid);
|
||||
LOGERROR("PostMessage with invalid message type ID '{}'", mtid);
|
||||
|
||||
Script::Request rq(m_ScriptInterface);
|
||||
if (mtid < MT__LastNative)
|
||||
@@ -677,11 +677,11 @@ CComponentManager::ComponentTypeId CComponentManager::GetScriptWrapper(Interface
|
||||
for (; iiit != m_InterfaceIdsByName.end(); ++iiit)
|
||||
if (iiit->second == iid)
|
||||
{
|
||||
LOGERROR("No script wrapper found for interface id %d '%s'", iid, iiit->first.c_str());
|
||||
LOGERROR("No script wrapper found for interface id {} '{}'", iid, iiit->first);
|
||||
return CID__Invalid;
|
||||
}
|
||||
|
||||
LOGERROR("No script wrapper found for interface id %d", iid);
|
||||
LOGERROR("No script wrapper found for interface id {}", iid);
|
||||
return CID__Invalid;
|
||||
}
|
||||
|
||||
@@ -759,7 +759,7 @@ IComponent* CComponentManager::ConstructComponent(CEntityHandle ent, ComponentTy
|
||||
std::map<ComponentTypeId, ComponentType>::const_iterator it = m_ComponentTypesById.find(cid);
|
||||
if (it == m_ComponentTypesById.end())
|
||||
{
|
||||
LOGERROR("Invalid component id %d", cid);
|
||||
LOGERROR("Invalid component id {}", cid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -770,7 +770,7 @@ IComponent* CComponentManager::ConstructComponent(CEntityHandle ent, ComponentTy
|
||||
std::unordered_map<entity_id_t, IComponent*>& emap1 = m_ComponentsByInterface[ct.iid];
|
||||
if (emap1.find(ent.GetId()) != emap1.end())
|
||||
{
|
||||
LOGERROR("Multiple components for interface %d", ct.iid);
|
||||
LOGERROR("Multiple components for interface {}", ct.iid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -905,13 +905,15 @@ entity_id_t CComponentManager::AddEntity(const std::wstring& templateName, entit
|
||||
CComponentManager::ComponentTypeId cid = LookupCID(it->first);
|
||||
if (cid == CID__Invalid)
|
||||
{
|
||||
LOGERROR("Unrecognized component type name '%s' in entity template '%s'", it->first, utf8_from_wstring(templateName));
|
||||
LOGERROR("Unrecognized component type name '{}' in entity template '{}'", it->first,
|
||||
utf8_from_wstring(templateName));
|
||||
return INVALID_ENTITY;
|
||||
}
|
||||
|
||||
if (!AddComponent(handle, cid, it->second))
|
||||
{
|
||||
LOGERROR("Failed to construct component type name '%s' in entity template '%s'", it->first, utf8_from_wstring(templateName));
|
||||
LOGERROR("Failed to construct component type name '{}' in entity template '{}'",
|
||||
it->first, utf8_from_wstring(templateName));
|
||||
return INVALID_ENTITY;
|
||||
}
|
||||
// TODO: maybe we should delete already-constructed components if one of them fails?
|
||||
|
||||
@@ -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
|
||||
@@ -322,7 +322,7 @@ bool CComponentManager::DeserializeState(std::istream& stream)
|
||||
ComponentTypeId ctid = LookupCID(ctname);
|
||||
if (ctid == CID__Invalid)
|
||||
{
|
||||
LOGERROR("Deserialization saw unrecognized component type '%s'", ctname.c_str());
|
||||
LOGERROR("Deserialization saw unrecognized component type '{}'", ctname);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ bool CComponentManager::DeserializeState(std::istream& stream)
|
||||
ComponentTypeId ctid = LookupCID(ctname);
|
||||
if (ctid == CID__Invalid)
|
||||
{
|
||||
LOGERROR("Deserialization saw unrecognized component type '%s'", ctname.c_str());
|
||||
LOGERROR("Deserialization saw unrecognized component type '{}'", ctname);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ bool CComponentManager::DeserializeState(std::istream& stream)
|
||||
}
|
||||
catch (PSERROR_Deserialize& e)
|
||||
{
|
||||
LOGERROR("Deserialization failed: %s", e.what());
|
||||
LOGERROR("Deserialization failed: {}", e.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ void CReplayTurnManager::NotifyFinishedUpdate(turn_id_t turn, const UpdateCallba
|
||||
return;
|
||||
|
||||
m_HasSyncError = true;
|
||||
LOGERROR("Replay out of sync on turn %d", turn);
|
||||
LOGERROR("Replay out of sync on turn {}", turn);
|
||||
|
||||
const Script::Interface& scriptInterface = m_Simulation2.GetScriptInterface();
|
||||
Script::Request rq(scriptInterface);
|
||||
|
||||
Reference in new issue
Block a user