diff --git a/source/graphics/MapGenerator.cpp b/source/graphics/MapGenerator.cpp index 91d26e9d5c..ed9a8d075d 100644 --- a/source/graphics/MapGenerator.cpp +++ b/source/graphics/MapGenerator.cpp @@ -222,7 +222,7 @@ std::vector CMapGeneratorWorker::GetCivData(ScriptInterface::CxPriv { // Some error reading directory wchar_t error[200]; - LOGERROR("CMapGeneratorWorker::GetCivData: Error reading directory '%s': %s", path.string8(), StatusDescription(ret, error, ARRAY_SIZE(error))); + LOGERROR("CMapGeneratorWorker::GetCivData: Error reading directory '%s': %s", path.string8(), utf8_from_wstring(StatusDescription(ret, error, ARRAY_SIZE(error)))); } return data; @@ -284,7 +284,7 @@ bool CMapGeneratorWorker::LoadScripts(const std::wstring& libraryName) { // Some error reading directory wchar_t error[200]; - LOGERROR("CMapGeneratorWorker::LoadScripts: Error reading scripts in directory '%s': %s", path.string8(), StatusDescription(ret, error, ARRAY_SIZE(error))); + LOGERROR("CMapGeneratorWorker::LoadScripts: Error reading scripts in directory '%s': %s", path.string8(), utf8_from_wstring(StatusDescription(ret, error, ARRAY_SIZE(error)))); return false; } diff --git a/source/graphics/MapReader.cpp b/source/graphics/MapReader.cpp index fd11ee52ba..96833239f2 100644 --- a/source/graphics/MapReader.cpp +++ b/source/graphics/MapReader.cpp @@ -1052,7 +1052,7 @@ int CXMLReader::ReadEntities(XMBElement parent, double end_time) entity_id_t player = cmpPlayerManager->GetPlayerByID(PlayerID); if (ent == INVALID_ENTITY || player == INVALID_ENTITY) { // Don't add entities with invalid player IDs - LOGERROR("Failed to load entity template '%s'", TemplateName.c_str()); + LOGERROR("Failed to load entity template '%s'", utf8_from_wstring(TemplateName)); } else { @@ -1430,7 +1430,7 @@ int CMapReader::ParseEntities() entity_id_t player = cmpPlayerManager->GetPlayerByID(currEnt.playerID); if (ent == INVALID_ENTITY || player == INVALID_ENTITY) { // Don't add entities with invalid player IDs - LOGERROR("Failed to load entity template '%s'", currEnt.templateName.c_str()); + LOGERROR("Failed to load entity template '%s'", utf8_from_wstring(currEnt.templateName)); } else { diff --git a/source/graphics/ObjectEntry.cpp b/source/graphics/ObjectEntry.cpp index e4c26a03b3..fcd511308b 100644 --- a/source/graphics/ObjectEntry.cpp +++ b/source/graphics/ObjectEntry.cpp @@ -73,7 +73,7 @@ bool CObjectEntry::BuildVariation(const std::vector >& selections str << variation.color; int r, g, b; if (! (str >> r >> g >> b)) // Any trailing data is ignored - LOGERROR("Actor '%s' has invalid RGB colour '%s'", m_Base->m_ShortName.c_str(), variation.color.c_str()); + LOGERROR("Actor '%s' has invalid RGB colour '%s'", utf8_from_wstring(m_Base->m_ShortName), variation.color); else m_Color = CColor(r/255.0f, g/255.0f, b/255.0f, 1.0f); } @@ -133,7 +133,7 @@ bool CObjectEntry::BuildVariation(const std::vector >& selections if (m_Samplers.size() == 0) { - LOGERROR("Actor '%s' has no textures.", m_Base->m_ShortName.c_str()); + LOGERROR("Actor '%s' has no textures.", utf8_from_wstring(m_Base->m_ShortName)); } std::vector::iterator samp; @@ -209,7 +209,7 @@ bool CObjectEntry::BuildVariation(const std::vector >& selections CObjectEntry* oe = objectManager.FindObjectVariation(prop.m_ModelName.c_str(), selections); if (!oe) { - LOGERROR("Failed to build prop model \"%s\" on actor \"%s\"", prop.m_ModelName.c_str(), m_Base->m_ShortName.c_str()); + LOGERROR("Failed to build prop model \"%s\" on actor \"%s\"", utf8_from_wstring(prop.m_ModelName), utf8_from_wstring(m_Base->m_ShortName)); continue; } @@ -240,7 +240,7 @@ bool CObjectEntry::BuildVariation(const std::vector >& selections propmodel->ToCModel()->SetAnimation(oe->GetRandomAnimation("idle")); } else - LOGERROR("Failed to find matching prop point called \"%s\" in model \"%s\" for actor \"%s\"", ppn.c_str(), m_ModelName.string8(), m_Base->m_ShortName.c_str()); + LOGERROR("Failed to find matching prop point called \"%s\" in model \"%s\" for actor \"%s\"", ppn, m_ModelName.string8(), utf8_from_wstring(m_Base->m_ShortName)); } // setup flags diff --git a/source/graphics/ObjectManager.cpp b/source/graphics/ObjectManager.cpp index 5a0ab1a26a..9d23072335 100644 --- a/source/graphics/ObjectManager.cpp +++ b/source/graphics/ObjectManager.cpp @@ -96,7 +96,7 @@ CObjectBase* CObjectManager::FindObjectBase(const CStrW& objectname) else delete obj; - LOGERROR("CObjectManager::FindObjectBase(): Cannot find object '%s'", objectname.c_str()); + LOGERROR("CObjectManager::FindObjectBase(): Cannot find object '%s'", utf8_from_wstring(objectname)); return 0; } diff --git a/source/graphics/TerrainProperties.cpp b/source/graphics/TerrainProperties.cpp index f5d7427657..3be85b721a 100644 --- a/source/graphics/TerrainProperties.cpp +++ b/source/graphics/TerrainProperties.cpp @@ -56,8 +56,8 @@ CTerrainPropertiesPtr CTerrainProperties::FromXML(const CTerrainPropertiesPtr& p if (rootName != "Terrains") { LOGERROR("TerrainProperties: Loading %s: Root node is not terrains (found \"%s\")", - pathname.string().c_str(), - rootName.c_str()); + pathname.string8(), + rootName); return CTerrainPropertiesPtr(); } @@ -80,8 +80,8 @@ CTerrainPropertiesPtr CTerrainProperties::FromXML(const CTerrainPropertiesPtr& p else { LOGWARNING("TerrainProperties: Loading %s: Unexpected node %s\n", - pathname.string().c_str(), - XeroFile.GetElementString(child.GetNodeName()).c_str()); + pathname.string8(), + XeroFile.GetElementString(child.GetNodeName())); // Keep reading - typos shouldn't be showstoppers } } diff --git a/source/graphics/TerrainTextureEntry.cpp b/source/graphics/TerrainTextureEntry.cpp index d1c8ce3e3b..756fb2d5f5 100644 --- a/source/graphics/TerrainTextureEntry.cpp +++ b/source/graphics/TerrainTextureEntry.cpp @@ -253,7 +253,7 @@ void CTerrainTextureEntry::LoadAlphaMaps(VfsPath &amtype) if (textures[i] < 0) { g_TexMan.m_TerrainAlphas.erase(it); - LOGERROR("Failed to load alphamap: %s", amtype.string()); + LOGERROR("Failed to load alphamap: %s", amtype.string8()); VfsPath standard("standard"); if (path != standard) diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index cc88ff555b..06e86d8ab6 100644 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -1185,7 +1185,7 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec // Try setting the value if (object->SetSetting(pFile->GetAttributeString(attr.Name), attr.Value.FromUTF8(), true) != PSRETURN_OK) { - LOGERROR("GUI: (object: %s) Can't set \"%s\" to \"%s\"", object->GetPresentableName().c_str(), pFile->GetAttributeString(attr.Name).c_str(), attr.Value.FromUTF8().c_str()); + LOGERROR("GUI: (object: %s) Can't set \"%s\" to \"%s\"", object->GetPresentableName(), pFile->GetAttributeString(attr.Name), attr.Value); // This is not a fatal error } @@ -1248,7 +1248,7 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec CVFSFile scriptfile; if (scriptfile.Load(g_VFS, filename) != PSRETURN_OK) { - LOGERROR("Error opening GUI script action file '%s'", filename.c_str()); + LOGERROR("Error opening GUI script action file '%s'", utf8_from_wstring(filename)); throw PSERROR_GUI_JSOpenFailed(); } @@ -1348,21 +1348,21 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec if (!filename.empty()) { if (!directory.empty()) - LOGWARNING("GUI: Include element found with file name (%s) and directory name (%s). Only the file will be processed.", filename.c_str(), directory.c_str()); + LOGWARNING("GUI: Include element found with file name (%s) and directory name (%s). Only the file will be processed.", utf8_from_wstring(filename), utf8_from_wstring(directory)); Paths.insert(filename); CXeromyces XeroIncluded; if (XeroIncluded.Load(g_VFS, filename) != PSRETURN_OK) { - LOGERROR("GUI: Error reading included XML: '%s'", filename.c_str()); + LOGERROR("GUI: Error reading included XML: '%s'", utf8_from_wstring(filename)); continue; } XMBElement node = XeroIncluded.GetRoot(); if (node.GetNodeName() != XeroIncluded.GetElementID("object")) { - LOGERROR("GUI: Error reading included XML: '%s', root element must have be of type 'object'.", filename.c_str()); + LOGERROR("GUI: Error reading included XML: '%s', root element must have be of type 'object'.", utf8_from_wstring(filename)); continue; } Xeromyces_ReadObject(node, &XeroIncluded, object, NameSubst, Paths, nesting_depth+1); @@ -1491,7 +1491,7 @@ void CGUI::Xeromyces_ReadScript(XMBElement Element, CXeromyces* pFile, boost::un } catch (PSERROR_Scripting& e) { - LOGERROR("GUI: Error executing script %s: %s", file.c_str(), e.what()); + LOGERROR("GUI: Error executing script %s: %s", utf8_from_wstring(file), e.what()); } } @@ -1636,7 +1636,7 @@ void CGUI::Xeromyces_ReadImage(XMBElement Element, CXeromyces* pFile, CGUISprite { CClientArea ca; if (!GUI::ParseString(attr_value, ca)) - LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); + LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); else Image->m_Size = ca; } else @@ -1644,7 +1644,7 @@ void CGUI::Xeromyces_ReadImage(XMBElement Element, CXeromyces* pFile, CGUISprite { CClientArea ca; if (!GUI::ParseString(attr_value, ca)) - LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); + LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); else Image->m_TextureSize = ca; } else @@ -1652,7 +1652,7 @@ void CGUI::Xeromyces_ReadImage(XMBElement Element, CXeromyces* pFile, CGUISprite { CRect rect; if (!GUI::ParseString(attr_value, rect)) - LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); + LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); else Image->m_TexturePlacementInFile = rect; } else @@ -1660,7 +1660,7 @@ void CGUI::Xeromyces_ReadImage(XMBElement Element, CXeromyces* pFile, CGUISprite { CSize size; if (!GUI::ParseString(attr_value, size)) - LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); + LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); else Image->m_CellSize = size; } else @@ -1668,7 +1668,7 @@ void CGUI::Xeromyces_ReadImage(XMBElement Element, CXeromyces* pFile, CGUISprite { float val; if (!GUI::ParseString(attr_value, val)) - LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); + LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); else Image->m_FixedHAspectRatio = val; } else @@ -1676,7 +1676,7 @@ void CGUI::Xeromyces_ReadImage(XMBElement Element, CXeromyces* pFile, CGUISprite { bool b; if (!GUI::ParseString(attr_value, b)) - LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); + LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); else Image->m_RoundCoordinates = b; } else @@ -1689,14 +1689,14 @@ void CGUI::Xeromyces_ReadImage(XMBElement Element, CXeromyces* pFile, CGUISprite else if (attr_value == L"clamp_to_edge") Image->m_WrapMode = GL_CLAMP_TO_EDGE; else - LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); + LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); } else if (attr_name == "z_level") { float z_level; if (!GUI::ParseString(attr_value, z_level)) - LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); + LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); else Image->m_DeltaZ = z_level/100.f; } else @@ -1704,7 +1704,7 @@ void CGUI::Xeromyces_ReadImage(XMBElement Element, CXeromyces* pFile, CGUISprite { CColor color; if (!GUI::ParseString(attr_value, color)) - LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); + LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); else Image->m_BackColor = color; } else @@ -1712,7 +1712,7 @@ void CGUI::Xeromyces_ReadImage(XMBElement Element, CXeromyces* pFile, CGUISprite { CColor color; if (!GUI::ParseString(attr_value, color)) - LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); + LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); else Image->m_BorderColor = color; } else @@ -1720,7 +1720,7 @@ void CGUI::Xeromyces_ReadImage(XMBElement Element, CXeromyces* pFile, CGUISprite { bool b; if (!GUI::ParseString(attr_value, b)) - LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); + LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); else Image->m_Border = b; } else @@ -1773,7 +1773,7 @@ void CGUI::Xeromyces_ReadEffects(XMBElement Element, CXeromyces* pFile, SGUIImag { CColor color; if (!GUI::ParseColor(attr_value, color, 0)) - LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); + LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); else effects.m_AddColor = color; } else if (attr_name == "grayscale") @@ -1853,7 +1853,7 @@ void CGUI::Xeromyces_ReadScrollBarStyle(XMBElement Element, CXeromyces* pFile) { bool b; if (!GUI::ParseString(attr_value.FromUTF8(), b)) - LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); + LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, attr_value); else scrollbar.m_UseEdgeButtons = b; } @@ -1861,7 +1861,7 @@ void CGUI::Xeromyces_ReadScrollBarStyle(XMBElement Element, CXeromyces* pFile) { float f; if (!GUI::ParseString(attr_value.FromUTF8(), f)) - LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); + LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, attr_value); else scrollbar.m_Width = f; } @@ -1870,7 +1870,7 @@ void CGUI::Xeromyces_ReadScrollBarStyle(XMBElement Element, CXeromyces* pFile) { float f; if (!GUI::ParseString(attr_value.FromUTF8(), f)) - LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); + LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, attr_value); else scrollbar.m_MinimumBarSize = f; } @@ -1879,7 +1879,7 @@ void CGUI::Xeromyces_ReadScrollBarStyle(XMBElement Element, CXeromyces* pFile) { float f; if (!GUI::ParseString(attr_value.FromUTF8(), f)) - LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); + LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, attr_value); else scrollbar.m_MaximumBarSize = f; } @@ -1952,7 +1952,7 @@ void CGUI::Xeromyces_ReadIcon(XMBElement Element, CXeromyces* pFile) { CSize size; if (!GUI::ParseString(attr_value.FromUTF8(), size)) - LOGERROR("Error parsing '%s' (\"%s\") inside .", attr_name.c_str(), attr_value.c_str()); + LOGERROR("Error parsing '%s' (\"%s\") inside .", attr_name, attr_value); else icon.m_Size = size; } @@ -1960,7 +1960,7 @@ void CGUI::Xeromyces_ReadIcon(XMBElement Element, CXeromyces* pFile) { int cell_id; if (!GUI::ParseString(attr_value.FromUTF8(), cell_id)) - LOGERROR("GUI: Error parsing '%s' (\"%s\") inside .", attr_name.c_str(), attr_value.c_str()); + LOGERROR("GUI: Error parsing '%s' (\"%s\") inside .", attr_name, attr_value); else icon.m_CellID = cell_id; } diff --git a/source/gui/GUIManager.cpp b/source/gui/GUIManager.cpp index 55db7d6431..4656f37c15 100644 --- a/source/gui/GUIManager.cpp +++ b/source/gui/GUIManager.cpp @@ -137,7 +137,7 @@ void CGUIManager::PopPageCB(shared_ptr args) JS::RootedValue global(cx, scriptInterface->GetGlobalObject()); if (!scriptInterface->HasProperty(global, callback.c_str())) { - LOGERROR("The specified callback function %s does not exist in the page %s", callback.c_str(), m_PageStack.back().name.c_str()); + LOGERROR("The specified callback function %s does not exist in the page %s", callback, utf8_from_wstring(m_PageStack.back().name)); return; } @@ -146,7 +146,7 @@ void CGUIManager::PopPageCB(shared_ptr args) scriptInterface->ReadStructuredClone(args, &argVal); if (!scriptInterface->CallFunctionVoid(global, callback.c_str(), argVal)) { - LOGERROR("Failed to call the callback function %s in the page %s", callback.c_str(), m_PageStack.back().name.c_str()); + LOGERROR("Failed to call the callback function %s in the page %s", callback, utf8_from_wstring(m_PageStack.back().name)); return; } } @@ -204,7 +204,7 @@ void CGUIManager::LoadPage(SGUIPage& page) if (root.GetNodeName() != elmt_page) { - LOGERROR("GUI page '%s' must have root element ", page.name.c_str()); + LOGERROR("GUI page '%s' must have root element ", utf8_from_wstring(page.name)); return; } @@ -212,7 +212,7 @@ void CGUIManager::LoadPage(SGUIPage& page) { if (node.GetNodeName() != elmt_include) { - LOGERROR("GUI page '%s' must only have elements inside ", page.name.c_str()); + LOGERROR("GUI page '%s' must only have elements inside ", utf8_from_wstring(page.name)); continue; } @@ -252,7 +252,7 @@ void CGUIManager::LoadPage(SGUIPage& page) hotloadDataVal) ) { - LOGERROR("GUI page '%s': Failed to call init() function", page.name.c_str()); + LOGERROR("GUI page '%s': Failed to call init() function", utf8_from_wstring(page.name)); } m_CurrentGUI = oldGUI; @@ -264,7 +264,7 @@ Status CGUIManager::ReloadChangedFile(const VfsPath& path) { if (it->inputs.count(path)) { - LOGMESSAGE("GUI file '%s' changed - reloading page '%s'", path.string8(), it->name.c_str()); + LOGMESSAGE("GUI file '%s' changed - reloading page '%s'", path.string8(), utf8_from_wstring(it->name)); LoadPage(*it); // TODO: this can crash if LoadPage runs an init script which modifies the page stack and breaks our iterators } diff --git a/source/gui/GUIRenderer.cpp b/source/gui/GUIRenderer.cpp index ec5087b015..88f31151e8 100644 --- a/source/gui/GUIRenderer.cpp +++ b/source/gui/GUIRenderer.cpp @@ -144,7 +144,7 @@ void GUIRenderer::UpdateDrawCallCache(DrawCalls &Calls, const CStr& SpriteName, // Check colour is valid if (!GUI::ParseString(value, color)) { - LOGERROR("GUI: Error parsing sprite 'colour' (\"%s\")", value.c_str()); + LOGERROR("GUI: Error parsing sprite 'colour' (\"%s\")", utf8_from_wstring(value)); return; } diff --git a/source/gui/GUItext.cpp b/source/gui/GUItext.cpp index 15ca677577..783bb30c41 100644 --- a/source/gui/GUItext.cpp +++ b/source/gui/GUItext.cpp @@ -306,7 +306,7 @@ void CGUIString::SetValue(const CStrW& str) closing = false; if (++p == l) { - LOGERROR("Partial tag at end of string '%s'", str.c_str()); + LOGERROR("Partial tag at end of string '%s'", utf8_from_wstring(str)); break; } if (str[p] == L'/') @@ -314,12 +314,12 @@ void CGUIString::SetValue(const CStrW& str) closing = true; if (tags.empty()) { - LOGERROR("Encountered closing tag without having any open tags. At %d in '%s'", p, str.c_str()); + LOGERROR("Encountered closing tag without having any open tags. At %d in '%s'", p, utf8_from_wstring(str)); break; } if (++p == l) { - LOGERROR("Partial closing tag at end of string '%s'", str.c_str()); + LOGERROR("Partial closing tag at end of string '%s'", utf8_from_wstring(str)); break; } } @@ -332,7 +332,7 @@ void CGUIString::SetValue(const CStrW& str) { case L' ': if (closing) // We still parse them to make error handling cleaner - LOGERROR("Closing tags do not support parameters (at pos %d '%s')", p, str.c_str()); + LOGERROR("Closing tags do not support parameters (at pos %d '%s')", p, utf8_from_wstring(str)); // parse something="something else" for (++p; p < l && str[p] != L'='; ++p) @@ -340,23 +340,23 @@ void CGUIString::SetValue(const CStrW& str) if (p == l) { - LOGERROR("Parameter without value at pos %d '%s'", p, str.c_str()); + LOGERROR("Parameter without value at pos %d '%s'", p, utf8_from_wstring(str)); break; } // fall-through case L'=': // parse a quoted parameter if (closing) // We still parse them to make error handling cleaner - LOGERROR("Closing tags do not support parameters (at pos %d '%s')", p, str.c_str()); + LOGERROR("Closing tags do not support parameters (at pos %d '%s')", p, utf8_from_wstring(str)); if (++p == l) { - LOGERROR("Expected parameter, got end of string '%s'", str.c_str()); + LOGERROR("Expected parameter, got end of string '%s'", utf8_from_wstring(str)); break; } if (str[p] != L'"') { - LOGERROR("Unquoted parameters are not supported (at pos %d '%s')", p, str.c_str()); + LOGERROR("Unquoted parameters are not supported (at pos %d '%s')", p, utf8_from_wstring(str)); break; } for (++p; p < l && str[p] != L'"'; ++p) @@ -366,7 +366,7 @@ void CGUIString::SetValue(const CStrW& str) case L'\\': if (++p == l) { - LOGERROR("Escape character at end of string '%s'", str.c_str()); + LOGERROR("Escape character at end of string '%s'", utf8_from_wstring(str)); break; } // NOTE: We do not support \n in tag parameters @@ -392,7 +392,7 @@ void CGUIString::SetValue(const CStrW& str) if (!tag_.SetTagType(tag)) { - LOGERROR("Invalid tag '%s' at %d in '%s'", tag.c_str(), p, str.c_str()); + LOGERROR("Invalid tag '%s' at %d in '%s'", utf8_from_wstring(tag), p, utf8_from_wstring(str)); break; } if (!closing) @@ -415,7 +415,7 @@ void CGUIString::SetValue(const CStrW& str) { if (tag != tags.back()) { - LOGERROR("Closing tag '%s' does not match last opened tag '%s' at %d in '%s'", tag.c_str(), tags.back().c_str(), p, str.c_str()); + LOGERROR("Closing tag '%s' does not match last opened tag '%s' at %d in '%s'", utf8_from_wstring(tag), utf8_from_wstring(tags.back()), p, utf8_from_wstring(str)); break; } @@ -426,7 +426,7 @@ void CGUIString::SetValue(const CStrW& str) case L'\\': if (++p == l) { - LOGERROR("Escape character at end of string '%s'", str.c_str()); + LOGERROR("Escape character at end of string '%s'", utf8_from_wstring(str)); break; } if (str[p] == L'n') diff --git a/source/network/NetClient.cpp b/source/network/NetClient.cpp index 68b253c9f0..fec7a80e40 100644 --- a/source/network/NetClient.cpp +++ b/source/network/NetClient.cpp @@ -428,7 +428,7 @@ bool CNetClient::OnAuthenticate(void* context, CFsmEvent* event) CAuthenticateResultMessage* message = (CAuthenticateResultMessage*)event->GetParamRef(); - LOGMESSAGE("Net: Authentication result: host=%u, %s", message->m_HostID, message->m_Message.c_str()); + LOGMESSAGE("Net: Authentication result: host=%u, %s", message->m_HostID, utf8_from_wstring(message->m_Message)); bool isRejoining = (message->m_Code == ARC_OK_REJOINING); diff --git a/source/network/NetServer.cpp b/source/network/NetServer.cpp index b3c14f3440..1a8187a2b3 100644 --- a/source/network/NetServer.cpp +++ b/source/network/NetServer.cpp @@ -810,7 +810,7 @@ bool CNetServerWorker::OnAuthenticate(void* context, CFsmEvent* event) // Players who weren't already in the game are not allowed to join now that it's started if (!isRejoining) { - LOGMESSAGE("Refused connection after game start from not-previously-known user \"%s\"", username.c_str()); + LOGMESSAGE("Refused connection after game start from not-previously-known user \"%s\"", utf8_from_wstring(username)); session->Disconnect(NDR_SERVER_ALREADY_IN_GAME); return true; } diff --git a/source/network/NetTurnManager.cpp b/source/network/NetTurnManager.cpp index 5a5747020e..fbbfef3645 100644 --- a/source/network/NetTurnManager.cpp +++ b/source/network/NetTurnManager.cpp @@ -48,12 +48,12 @@ static const int COMMAND_DELAY = 2; #define NETTURN_LOG(args) #endif -static std::wstring Hexify(const std::string& s) +static std::string Hexify(const std::string& s) { - std::wstringstream str; + std::stringstream str; str << std::hex; for (size_t i = 0; i < s.size(); ++i) - str << std::setfill(L'0') << std::setw(2) << (int)(unsigned char)s[i]; + str << std::setfill('0') << std::setw(2) << (int)(unsigned char)s[i]; return str.str(); } @@ -220,7 +220,7 @@ bool CNetTurnManager::UpdateFastForward() void CNetTurnManager::OnSyncError(u32 turn, const std::string& expectedHash) { - NETTURN_LOG((L"OnSyncError(%d, %ls)\n", turn, Hexify(expectedHash).c_str())); + NETTURN_LOG((L"OnSyncError(%d, %hs)\n", turn, Hexify(expectedHash).c_str())); // Only complain the first time if (m_HasSyncError) @@ -237,14 +237,14 @@ void CNetTurnManager::OnSyncError(u32 turn, const std::string& expectedHash) m_Simulation2.DumpDebugState(file); file.close(); - std::wstringstream msg; - msg << L"Out of sync on turn " << turn << L": expected hash " << Hexify(expectedHash) << L"\n\n"; - msg << L"Current state: turn " << m_CurrentTurn << L", hash " << Hexify(hash) << L"\n\n"; - msg << L"Dumping current state to " << path; + std::stringstream msg; + msg << "Out of sync on turn " << turn << ": expected hash " << Hexify(expectedHash) << "\n\n"; + msg << "Current state: turn " << m_CurrentTurn << ", hash " << Hexify(hash) << "\n\n"; + msg << "Dumping current state to " << utf8_from_wstring(path.string()); if (g_GUI) - g_GUI->DisplayMessageBox(600, 350, L"Sync error", msg.str()); + g_GUI->DisplayMessageBox(600, 350, L"Sync error", wstring_from_utf8(msg.str())); else - LOGERROR("%s", msg.str().c_str()); + LOGERROR("%s", msg.str()); } void CNetTurnManager::Interpolate(float simFrameLength, float realFrameLength) @@ -408,7 +408,7 @@ void CNetClientTurnManager::NotifyFinishedUpdate(u32 turn) ENSURE(ok); } - NETTURN_LOG((L"NotifyFinishedUpdate(%d, %ls)\n", turn, Hexify(hash).c_str())); + NETTURN_LOG((L"NotifyFinishedUpdate(%d, %hs)\n", turn, Hexify(hash).c_str())); m_Replay.Hash(hash, quick); @@ -546,7 +546,7 @@ void CNetServerTurnManager::NotifyFinishedClientUpdate(int client, u32 turn, con for (std::map::iterator cit = it->second.begin(); cit != it->second.end(); ++cit) { - NETTURN_LOG((L"sync check %d: %d = %ls\n", it->first, cit->first, Hexify(cit->second).c_str())); + NETTURN_LOG((L"sync check %d: %d = %hs\n", it->first, cit->first, Hexify(cit->second).c_str())); if (cit->second != expected) { // Oh no, out of sync diff --git a/source/ps/ConfigDB.cpp b/source/ps/ConfigDB.cpp index 2c14e15226..ab4dca326d 100644 --- a/source/ps/ConfigDB.cpp +++ b/source/ps/ConfigDB.cpp @@ -337,18 +337,18 @@ bool CConfigDB::Reload(EConfigNamespace ns) CStr key(header + name); newMap[key] = values; if (key == "lobby.password") - LOGMESSAGE("Loaded config string \"%s\"", key.c_str()); + LOGMESSAGE("Loaded config string \"%s\"", key); else { std::string vals; for (size_t i = 0; i < newMap[key].size() - 1; ++i) vals += "\"" + EscapeString(newMap[key][i]) + "\", "; vals += "\"" + EscapeString(newMap[key][values.size()-1]) + "\""; - LOGMESSAGE("Loaded config string \"%s\" = %s", key.c_str(), vals.c_str()); + LOGMESSAGE("Loaded config string \"%s\" = %s", key, vals); } } else if (!name.empty()) - LOGERROR("Encountered config setting '%s' without value while parsing '%s' on line %d", name.c_str(), m_ConfigFile[ns].string8(), line); + LOGERROR("Encountered config setting '%s' without value while parsing '%s' on line %d", name, m_ConfigFile[ns].string8(), line); name.clear(); values.clear(); @@ -356,7 +356,7 @@ bool CConfigDB::Reload(EConfigNamespace ns) } if (!name.empty()) - LOGERROR("Config file does not have a new line after the last config setting '%s'", name.c_str()); + LOGERROR("Config file does not have a new line after the last config setting '%s'", name); m_Map[ns].swap(newMap); diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index d1fb63cce0..44b166e2a2 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -293,7 +293,7 @@ void Render() #warning TODO: cursors for Android #else if (cursor_draw(g_VFS, cursorName.c_str(), g_mouse_x, g_yres-g_mouse_y, forceGL) < 0) - LOGWARNING("Failed to draw cursor '%s'", cursorName.c_str()); + LOGWARNING("Failed to draw cursor '%s'", utf8_from_wstring(cursorName)); #endif #if CONFIG2_GLES @@ -1246,7 +1246,7 @@ bool Autostart(const CmdLineArgs& args) else { // Problem with JSON file - LOGERROR("Autostart: Error reading random map script '%s'", scriptPath.c_str()); + LOGERROR("Autostart: Error reading random map script '%s'", utf8_from_wstring(scriptPath)); throw PSERROR_Game_World_MapLoadFailed("Error reading random map script.\nCheck application log for details."); } @@ -1301,7 +1301,7 @@ bool Autostart(const CmdLineArgs& args) } else { - LOGERROR("Autostart: Unrecognized map type '%s'", mapDirectory.c_str()); + LOGERROR("Autostart: Unrecognized map type '%s'", utf8_from_wstring(mapDirectory)); throw PSERROR_Game_World_MapLoadFailed("Unrecognized map type.\nConsult readme.txt for the currently supported types."); } scriptInterface.SetProperty(attrs, "mapType", mapType); diff --git a/source/ps/XML/Xeromyces.cpp b/source/ps/XML/Xeromyces.cpp index 9e2709e949..68ba0c6a03 100644 --- a/source/ps/XML/Xeromyces.cpp +++ b/source/ps/XML/Xeromyces.cpp @@ -39,8 +39,8 @@ static void errorHandler(void* UNUSED(userData), xmlErrorPtr error) message.erase(message.length()-1); LOGERROR("CXeromyces: Parse %s: %s:%d: %s", - error->level == XML_ERR_WARNING ? L"warning" : L"error", - error->file, error->line, message.c_str()); + error->level == XML_ERR_WARNING ? "warning" : "error", + error->file, error->line, message); // TODO: The (non-fatal) warnings and errors don't get stored in the XMB, // so the caching is less transparent than it should be } diff --git a/source/scriptinterface/ScriptInterface.cpp b/source/scriptinterface/ScriptInterface.cpp index 975cde1f70..a86ab5d24c 100644 --- a/source/scriptinterface/ScriptInterface.cpp +++ b/source/scriptinterface/ScriptInterface.cpp @@ -163,7 +163,7 @@ JSBool logmsg(JSContext* cx, uint argc, jsval* vp) std::wstring str; if (!ScriptInterface::FromJSVal(cx, args.handleAt(0), str)) return JS_FALSE; - LOGMESSAGE("%s", str.c_str()); + LOGMESSAGE("%s", utf8_from_wstring(str)); args.rval().setUndefined(); return JS_TRUE; } @@ -180,7 +180,7 @@ JSBool warn(JSContext* cx, uint argc, jsval* vp) std::wstring str; if (!ScriptInterface::FromJSVal(cx, args.handleAt(0), str)) return JS_FALSE; - LOGWARNING("%s", str.c_str()); + LOGWARNING("%s", utf8_from_wstring(str)); args.rval().setUndefined(); return JS_TRUE; } @@ -197,7 +197,7 @@ JSBool error(JSContext* cx, uint argc, jsval* vp) std::wstring str; if (!ScriptInterface::FromJSVal(cx, args.handleAt(0), str)) return JS_FALSE; - LOGERROR("%s", str.c_str()); + LOGERROR("%s", utf8_from_wstring(str)); args.rval().setUndefined(); return JS_TRUE; } @@ -946,7 +946,7 @@ bool ScriptInterface::ParseJSON(const std::string& string_utf8, JS::MutableHandl std::wstring error; ScriptInterface::FromJSVal(m->m_cx, rval, error); - LOGERROR("%s", error.c_str()); + LOGERROR("%s", utf8_from_wstring(error)); return false; } diff --git a/source/simulation2/Simulation2.cpp b/source/simulation2/Simulation2.cpp index fbb1664ad1..ac7010959f 100644 --- a/source/simulation2/Simulation2.cpp +++ b/source/simulation2/Simulation2.cpp @@ -828,7 +828,7 @@ static std::vector GetJSONData(const VfsPath& path) { // Some error reading directory wchar_t error[200]; - LOGERROR("Error reading directory '%s': %s", path.string8(), StatusDescription(ret, error, ARRAY_SIZE(error))); + LOGERROR("Error reading directory '%s': %s", path.string8(), utf8_from_wstring(StatusDescription(ret, error, ARRAY_SIZE(error)))); return std::vector(); } diff --git a/source/simulation2/components/CCmpAIManager.cpp b/source/simulation2/components/CCmpAIManager.cpp index ffe0fc46e0..e2a067ab66 100644 --- a/source/simulation2/components/CCmpAIManager.cpp +++ b/source/simulation2/components/CCmpAIManager.cpp @@ -124,7 +124,7 @@ private: if (!m_ScriptInterface->GetProperty(global, moduleName.c_str(), &objectWithConstructor) || objectWithConstructor.isUndefined()) { - LOGERROR("Failed to create AI player: %s: can't find the module that should contain the constructor: '%s'", path.string8(), moduleName.c_str()); + LOGERROR("Failed to create AI player: %s: can't find the module that should contain the constructor: '%s'", path.string8(), moduleName); return false; } @@ -138,7 +138,7 @@ private: if (!m_ScriptInterface->GetProperty(objectWithConstructor, constructor.c_str(), &ctor) || ctor.isNull()) { - LOGERROR("Failed to create AI player: %s: can't find constructor '%s'", path.string8(), constructor.c_str()); + LOGERROR("Failed to create AI player: %s: can't find constructor '%s'", path.string8(), constructor); return false; } @@ -160,7 +160,7 @@ private: if (obj.isNull()) { - LOGERROR("Failed to create AI player: %s: error calling constructor '%s'", path.string8(), constructor.c_str()); + LOGERROR("Failed to create AI player: %s: error calling constructor '%s'", path.string8(), constructor); return false; } @@ -261,7 +261,7 @@ public: VfsPaths pathnames; if (vfs::GetPathnames(g_VFS, L"simulation/ai/" + moduleName + L"/", L"*.js", pathnames) < 0) { - LOGERROR("Failed to load AI scripts for module %s", moduleName.c_str()); + LOGERROR("Failed to load AI scripts for module %s", utf8_from_wstring(moduleName)); return false; } @@ -748,7 +748,7 @@ public: std::pair::iterator, bool> ret1 = m_SerializablePrototypes.insert(std::make_pair(obj, name)); std::pair::iterator, bool> ret2 = m_DeserializablePrototypes.insert(std::make_pair(name, obj)); if (!ret1.second || !ret2.second) - LOGERROR("RegisterSerializablePrototype called with same prototype multiple times: p=%p n='%s'", obj, name.c_str()); + LOGERROR("RegisterSerializablePrototype called with same prototype multiple times: p=%p n='%s'", (void *)obj, utf8_from_wstring(name)); } private: diff --git a/source/simulation2/components/CCmpProjectileManager.cpp b/source/simulation2/components/CCmpProjectileManager.cpp index d8af2310e2..8e0d5c368a 100644 --- a/source/simulation2/components/CCmpProjectileManager.cpp +++ b/source/simulation2/components/CCmpProjectileManager.cpp @@ -175,7 +175,7 @@ uint32_t CCmpProjectileManager::LaunchProjectile(entity_id_t source, CFixedVecto { // If the actor was actually loaded, complain that it doesn't have a projectile if (!cmpSourceVisual->GetActorShortName().empty()) - LOGERROR("Unit with actor '%s' launched a projectile but has no actor on 'projectile' attachpoint", cmpSourceVisual->GetActorShortName().c_str()); + LOGERROR("Unit with actor '%s' launched a projectile but has no actor on 'projectile' attachpoint", utf8_from_wstring(cmpSourceVisual->GetActorShortName())); return 0; } diff --git a/source/simulation2/serialization/BinarySerializer.cpp b/source/simulation2/serialization/BinarySerializer.cpp index f6da94fa3c..4878226da4 100644 --- a/source/simulation2/serialization/BinarySerializer.cpp +++ b/source/simulation2/serialization/BinarySerializer.cpp @@ -317,7 +317,7 @@ void CBinarySerializerScriptImpl::HandleScriptVal(JS::HandleValue val) } } - LOGERROR("Cannot serialise JS objects of type 'function': %s", funcname.c_str()); + LOGERROR("Cannot serialise JS objects of type 'function': %s", utf8_from_wstring(funcname)); throw PSERROR_Serialize_InvalidScriptValue(); } case JSTYPE_STRING: diff --git a/source/simulation2/system/ComponentManager.cpp b/source/simulation2/system/ComponentManager.cpp index 53e69eeb79..0ee90a085b 100644 --- a/source/simulation2/system/ComponentManager.cpp +++ b/source/simulation2/system/ComponentManager.cpp @@ -887,13 +887,13 @@ entity_id_t CComponentManager::AddEntity(const std::wstring& templateName, entit CComponentManager::ComponentTypeId cid = LookupCID(it->first); if (cid == CID__Invalid) { - LOGERROR("Unrecognised component type name '%s' in entity template '%s'", it->first.c_str(), templateName.c_str()); + LOGERROR("Unrecognised component type name '%s' in entity template '%s'", 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.c_str(), templateName.c_str()); + LOGERROR("Failed to construct component type name '%s' in entity template '%s'", it->first, utf8_from_wstring(templateName)); return INVALID_ENTITY; } // TODO: maybe we should delete already-constructed components if one of them fails? @@ -1226,7 +1226,7 @@ std::vector CComponentManager::Script_FindJSONFiles(ScriptInterface { // Some error reading directory wchar_t error[200]; - LOGERROR("Error reading directory '%s': %s", cbData.path.string8(), StatusDescription(ret, error, ARRAY_SIZE(error))); + LOGERROR("Error reading directory '%s': %s", cbData.path.string8(), utf8_from_wstring(StatusDescription(ret, error, ARRAY_SIZE(error)))); } return cbData.templates; diff --git a/source/simulation2/system/ParamNode.cpp b/source/simulation2/system/ParamNode.cpp index 0e5dc41774..2e4b1720ea 100644 --- a/source/simulation2/system/ParamNode.cpp +++ b/source/simulation2/system/ParamNode.cpp @@ -124,7 +124,7 @@ void CParamNode::ApplyLayer(const XMBFile& xmb, const XMBElement& element, const tokens.erase(tokenIt); else LOGWARNING("[ParamNode] Could not remove token '%s' from node '%s'%s; not present in list nor inherited (possible typo?)", - newTokens[i].substr(1).c_str(), name.c_str(), sourceIdentifier ? (L" in '" + std::wstring(sourceIdentifier) + L"'").c_str() : L""); + utf8_from_wstring(newTokens[i].substr(1)), name, sourceIdentifier ? (" in '" + utf8_from_wstring(sourceIdentifier) + "'").c_str() : ""); } else { diff --git a/source/soundmanager/SoundManager.cpp b/source/soundmanager/SoundManager.cpp index 5bf843dc59..48d091723b 100644 --- a/source/soundmanager/SoundManager.cpp +++ b/source/soundmanager/SoundManager.cpp @@ -354,7 +354,7 @@ Status CSoundManager::AlcInit() debug_printf(L"Sound: AlcInit success, using %hs\n", dev_name); else { - LOGERROR("Sound: AlcInit failed, m_Device=%p m_Context=%p dev_name=%s err=%x\n", m_Device, m_Context, dev_name, err); + LOGERROR("Sound: AlcInit failed, m_Device=%p m_Context=%p dev_name=%s err=%x\n", (void *)m_Device, (void *)m_Context, dev_name, err); // FIXME Hack to get around exclusive access to the sound device #if OS_UNIX diff --git a/source/soundmanager/scripting/SoundGroup.cpp b/source/soundmanager/scripting/SoundGroup.cpp index 2b7a4be541..0dc524ce96 100644 --- a/source/soundmanager/scripting/SoundGroup.cpp +++ b/source/soundmanager/scripting/SoundGroup.cpp @@ -227,7 +227,7 @@ static void HandleError(const CStrW& message, const VfsPath& pathname, Status er { if (err == ERR::AGAIN) return; // open failed because sound is disabled (don't log this) - LOGERROR("%s: pathname=%s, error=%s", message.c_str(), pathname.string8(), ErrorString(err)); + LOGERROR("%s: pathname=%s, error=%s", utf8_from_wstring(message), pathname.string8(), utf8_from_wstring(ErrorString(err))); } void CSoundGroup::PlayNext(const CVector3D& position, entity_id_t source)