From d242631245edb66816ef9960bdb2c61b68e56cec Mon Sep 17 00:00:00 2001 From: phosit Date: Wed, 13 Dec 2023 19:42:00 +0000 Subject: [PATCH] Fix build with libxml2 v2.12.1 libxml2 v2.12.1 includes less header indirectly. Also `xmlError*` has to be changed to `const xmlError*`. Original Patch By: Riesi Accepted By: @vladislavbelov Differential Revision: https://code.wildfiregames.com/D5219 git-svn-id: https://svn.wildfiregames.com/public/ps/trunk@27980 3db68df2-c116-0410-a063-a993310a9797 --- .../src/FCollada/FUtils/FUXmlDocument.cpp | 6 ++- .../FArchiveXML/FArchiveXML.cpp | 43 ++++++++++--------- source/collada/CommonConvert.cpp | 5 ++- source/collada/XMLFix.cpp | 4 +- source/ps/XML/RelaxNG.cpp | 7 ++- source/ps/XML/Xeromyces.cpp | 6 ++- 6 files changed, 41 insertions(+), 30 deletions(-) diff --git a/libraries/source/fcollada/src/FCollada/FUtils/FUXmlDocument.cpp b/libraries/source/fcollada/src/FCollada/FUtils/FUXmlDocument.cpp index 5349249a876..dd7be516724 100644 --- a/libraries/source/fcollada/src/FCollada/FUtils/FUXmlDocument.cpp +++ b/libraries/source/fcollada/src/FCollada/FUtils/FUXmlDocument.cpp @@ -2,7 +2,7 @@ Copyright (C) 2005-2007 Feeling Software Inc. Portions of the code are: Copyright (C) 2005-2007 Sony Computer Entertainment America - + MIT License: http://www.opensource.org/licenses/mit-license.php */ @@ -13,10 +13,12 @@ #include "FUFile.h" #include "FCDocument/FCDocument.h" +#include + #define MAX_FILE_SIZE 10240000 // // FUXmlDocument -// +// FUXmlDocument::FUXmlDocument(FUFileManager* manager, const fchar* _filename, bool _isParsing) : isParsing(_isParsing), filename(_filename) diff --git a/libraries/source/fcollada/src/FColladaPlugins/FArchiveXML/FArchiveXML.cpp b/libraries/source/fcollada/src/FColladaPlugins/FArchiveXML/FArchiveXML.cpp index af674789603..8222f6b2442 100644 --- a/libraries/source/fcollada/src/FColladaPlugins/FArchiveXML/FArchiveXML.cpp +++ b/libraries/source/fcollada/src/FColladaPlugins/FArchiveXML/FArchiveXML.cpp @@ -2,7 +2,7 @@ Copyright (C) 2005-2007 Feeling Software Inc. Portions of the code are: Copyright (C) 2005-2007 Sony Computer Entertainment America - + MIT License: http://www.opensource.org/licenses/mit-license.php */ @@ -77,6 +77,7 @@ #include "FCDocument/FCDVersion.h" #include "FUtils/FUXmlDocument.h" +#include // // Constants @@ -442,7 +443,7 @@ bool FArchiveXML::ImportFileFromMemory(const fchar* filePath, FCDocument* fcdocu } if (status) FUError::Error(FUError::DEBUG_LEVEL, FUError::DEBUG_LOAD_SUCCESSFUL); - return status; + return status; } bool FArchiveXML::ExportFile(FCDocument* fcdocument, const fchar* filePath) @@ -515,13 +516,13 @@ bool FArchiveXML::EndExport(fm::vector& outData) xmlOutputBufferPtr buf = xmlAllocOutputBuffer(NULL); xmlNodeDumpOutput(buf, rootNode->doc, rootNode, 0, 0, NULL); -#ifdef LIBXML2_NEW_BUFFER - outData.resize(xmlOutputBufferGetSize(buf) * sizeof(xmlChar)); - memcpy(outData.begin(), xmlOutputBufferGetContent(buf), outData.size()); -#else - outData.resize(buf->buffer->use * sizeof(xmlChar)); - memcpy(outData.begin(), buf->buffer->content, outData.size()); -#endif +#ifdef LIBXML2_NEW_BUFFER + outData.resize(xmlOutputBufferGetSize(buf) * sizeof(xmlChar)); + memcpy(outData.begin(), xmlOutputBufferGetContent(buf), outData.size()); +#else + outData.resize(buf->buffer->use * sizeof(xmlChar)); + memcpy(outData.begin(), buf->buffer->content, outData.size()); +#endif xmlOutputBufferClose(buf); daeDocument.ReleaseXmlData(); @@ -591,7 +592,7 @@ bool FArchiveXML::Import(FCDocument* theDocument, xmlNode* colladaNode) else if (IsEquivalent(child->name, DAE_LIBRARY_PMATERIAL_ELEMENT)) n.order = PHYSICS_MATERIAL; else if (IsEquivalent(child->name, DAE_LIBRARY_PMODEL_ELEMENT)) n.order = PHYSICS_MODEL; else if (IsEquivalent(child->name, DAE_LIBRARY_PSCENE_ELEMENT)) n.order = PHYSICS_SCENE; - else if (IsEquivalent(child->name, DAE_ASSET_ELEMENT)) + else if (IsEquivalent(child->name, DAE_ASSET_ELEMENT)) { // Read in the asset information status &= (FArchiveXML::LoadAsset(theDocument->GetAsset(), child)); @@ -679,9 +680,9 @@ bool FArchiveXML::Import(FCDocument* theDocument, xmlNode* colladaNode) case IMAGE: status &= (FArchiveXML::LoadImageLibrary(theDocument->GetImageLibrary(), n.node)); break; case LIGHT: status &= (FArchiveXML::LoadLightLibrary(theDocument->GetLightLibrary(), n.node)); break; case MATERIAL: status &= (FArchiveXML::LoadMaterialLibrary(theDocument->GetMaterialLibrary(), n.node)); break; - case PHYSICS_MODEL: + case PHYSICS_MODEL: { - status &= (FArchiveXML::LoadPhysicsModelLibrary(theDocument->GetPhysicsModelLibrary(), n.node)); + status &= (FArchiveXML::LoadPhysicsModelLibrary(theDocument->GetPhysicsModelLibrary(), n.node)); size_t physicsModelCount = theDocument->GetPhysicsModelLibrary()->GetEntityCount(); for (size_t physicsModelCounter = 0; physicsModelCounter < physicsModelCount; physicsModelCounter++) { @@ -790,7 +791,7 @@ bool FArchiveXML::Import(FCDocument* theDocument, xmlNode* colladaNode) { // [staylor] Why is this done here? Shouldn't it be in FCDExternalReferenceManager? // If it is, change it, either way delete the FUAssert (thanks) - //FUAssert(false == true, ;); + // FUAssert(false == true, ;); FArchiveXML::RegisterLoadedDocument(theDocument); //FCDExternalReferenceManager::RegisterLoadedDocument(theDocument); } @@ -891,14 +892,14 @@ bool FArchiveXML::ExportDocument(FCDocument* theDocument, xmlNode* colladaNode) // Export the emitter library xmlNode* libraryNode = AddChild(typedTechniqueNode, DAE_LIBRARY_EMITTER_ELEMENT); - if (!theDocument->GetEmitterLibrary()->GetTransientFlag()) + if (!theDocument->GetEmitterLibrary()->GetTransientFlag()) FArchiveXML::WriteLibrary(theDocument->GetEmitterLibrary(), libraryNode); } // Write out the animations if (animationLibraryNode != NULL) { - if (!theDocument->GetAnimationLibrary()->GetTransientFlag()) + if (!theDocument->GetAnimationLibrary()->GetTransientFlag()) FArchiveXML::WriteLibrary(theDocument->GetAnimationLibrary(), animationLibraryNode); } @@ -978,7 +979,7 @@ xmlNode* FArchiveXML::WriteParentSwitch(FCDObject* object, const FUObjectType* o { return FArchiveXML::WriteSwitch(object, &objectType->GetParent(), node); } - else + else { FUBreak; return NULL; @@ -986,7 +987,7 @@ xmlNode* FArchiveXML::WriteParentSwitch(FCDObject* object, const FUObjectType* o } bool FArchiveXML::LoadAnimationLibrary(FCDObject* object, xmlNode* node) -{ +{ return FArchiveXML::LoadLibrary(object, node); } @@ -996,17 +997,17 @@ bool FArchiveXML::LoadAnimationClipLibrary(FCDObject* object, xmlNode* node) } bool FArchiveXML::LoadCameraLibrary(FCDObject* object, xmlNode* node) -{ +{ return FArchiveXML::LoadLibrary(object, node); } bool FArchiveXML::LoadControllerLibrary(FCDObject* object, xmlNode* node) -{ +{ return FArchiveXML::LoadLibrary(object, node); } bool FArchiveXML::LoadEffectLibrary(FCDObject* object, xmlNode* node) -{ +{ return FArchiveXML::LoadLibrary(object, node); } @@ -1016,7 +1017,7 @@ bool FArchiveXML::LoadEmitterLibrary(FCDObject* object, xmlNode* node) } bool FArchiveXML::LoadForceFieldLibrary(FCDObject* object, xmlNode* node) -{ +{ return FArchiveXML::LoadLibrary(object, node); } diff --git a/source/collada/CommonConvert.cpp b/source/collada/CommonConvert.cpp index 391fcf47f6f..c742873b45a 100644 --- a/source/collada/CommonConvert.cpp +++ b/source/collada/CommonConvert.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Wildfire Games. +/* Copyright (C) 2023 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -28,8 +28,9 @@ #include "FUtils/FUDaeSyntax.h" #include "FUtils/FUFileManager.h" -#include #include +#include +#include void require_(int line, bool value, const char* type, const char* message) { diff --git a/source/collada/XMLFix.cpp b/source/collada/XMLFix.cpp index 2f1d67770e7..fc5aa6bb388 100644 --- a/source/collada/XMLFix.cpp +++ b/source/collada/XMLFix.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Wildfire Games. +/* Copyright (C) 2023 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -23,6 +23,8 @@ #include "FUtils/FUXmlParser.h" +#include + /* Things that are fixed here: diff --git a/source/ps/XML/RelaxNG.cpp b/source/ps/XML/RelaxNG.cpp index 116b0007bfc..296ed144038 100644 --- a/source/ps/XML/RelaxNG.cpp +++ b/source/ps/XML/RelaxNG.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2023 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -25,9 +25,11 @@ #include "ps/CStr.h" #include "ps/Filesystem.h" +#include #include #include #include +#include TIMER_ADD_CLIENT(xml_validation); @@ -46,7 +48,8 @@ void ClearSchemaCache() g_SchemaCache.clear(); } -static void relaxNGErrorHandler(void* UNUSED(userData), xmlErrorPtr error) +static void relaxNGErrorHandler(void* UNUSED(userData), + std::conditional_t= 21200, const xmlError, xmlError>* error) { // Strip a trailing newline std::string message = error->message; diff --git a/source/ps/XML/Xeromyces.cpp b/source/ps/XML/Xeromyces.cpp index 5051c2bc749..3e83859d6f9 100644 --- a/source/ps/XML/Xeromyces.cpp +++ b/source/ps/XML/Xeromyces.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2023 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -33,12 +33,14 @@ #include "Xeromyces.h" #include +#include static std::mutex g_ValidatorCacheLock; static std::map g_ValidatorCache; static bool g_XeromycesStarted = false; -static void errorHandler(void* UNUSED(userData), xmlErrorPtr error) +static void errorHandler(void* UNUSED(userData), + std::conditional_t= 21200, const xmlError, xmlError>* error) { // Strip a trailing newline std::string message = error->message;