diff --git a/source/graphics/MapReader.cpp b/source/graphics/MapReader.cpp index 1464dcf494..f5cb8cfe8a 100644 --- a/source/graphics/MapReader.cpp +++ b/source/graphics/MapReader.cpp @@ -440,7 +440,7 @@ PSRETURN CMapSummaryReader::LoadMap(const VfsPath& pathname) XMBElement root = xmb_file.GetRoot(); ENSURE(root.GetNodeName() == el_scenario); - XERO_ITER_EL(root, child) + for (XMBElement child : root.GetChildNodes()) { int child_name = child.GetNodeName(); if (child_name == el_scriptsettings) @@ -565,7 +565,7 @@ void CXMLReader::Init(const VfsPath& xml_filename) max_uid = SYSTEM_ENTITY; XMBElement ents = nodes.GetFirstNamedItem(xmb_file.GetElementID("Entities")); - XERO_ITER_EL(ents, ent) + for (XMBElement ent : ents.GetChildNodes()) { CStr uid = ent.GetAttributes().GetNamedItem(at_uid); max_uid = std::max(max_uid, (entity_id_t)uid.ToUInt()); @@ -677,7 +677,7 @@ void CXMLReader::ReadEnvironment(XMBElement parent) #undef AT #undef EL - XERO_ITER_EL(parent, element) + for (XMBElement element : parent.GetChildNodes()) { int element_name = element.GetNodeName(); @@ -712,7 +712,7 @@ void CXMLReader::ReadEnvironment(XMBElement parent) } else if (element_name == el_fog) { - XERO_ITER_EL(element, fog) + for (XMBElement fog : element.GetChildNodes()) { int fog_element_name = fog.GetNodeName(); if (fog_element_name == el_fogcolor) @@ -735,7 +735,7 @@ void CXMLReader::ReadEnvironment(XMBElement parent) } else if (element_name == el_postproc) { - XERO_ITER_EL(element, postproc) + for (XMBElement postproc : element.GetChildNodes()) { int post_element_name = postproc.GetNodeName(); if (post_element_name == el_brightness) @@ -763,10 +763,10 @@ void CXMLReader::ReadEnvironment(XMBElement parent) } else if (element_name == el_water) { - XERO_ITER_EL(element, waterbody) + for (XMBElement waterbody : element.GetChildNodes()) { ENSURE(waterbody.GetNodeName() == el_waterbody); - XERO_ITER_EL(waterbody, waterelement) + for (XMBElement waterelement : waterbody.GetChildNodes()) { int water_element_name = waterelement.GetNodeName(); if (water_element_name == el_height) @@ -844,7 +844,7 @@ void CXMLReader::ReadCamera(XMBElement parent) float declination = DEGTORAD(30.f), rotation = DEGTORAD(-45.f); CVector3D translation = CVector3D(100, 150, -100); - XERO_ITER_EL(parent, element) + for (XMBElement element : parent.GetChildNodes()) { int element_name = element.GetNodeName(); @@ -903,7 +903,7 @@ void CXMLReader::ReadPaths(XMBElement parent) #undef AT CmpPtr cmpCinemaManager(*m_MapReader.pSimContext, SYSTEM_ENTITY); - XERO_ITER_EL(parent, element) + for (XMBElement element : parent.GetChildNodes()) { int elementName = element.GetNodeName(); @@ -922,7 +922,7 @@ void CXMLReader::ReadPaths(XMBElement parent) fixed lastPositionTime = fixed::Zero(); fixed lastTargetTime = fixed::Zero(); - XERO_ITER_EL(element, pathChild) + for (XMBElement pathChild : element.GetChildNodes()) { elementName = pathChild.GetNodeName(); attrs = pathChild.GetAttributes(); @@ -932,7 +932,7 @@ void CXMLReader::ReadPaths(XMBElement parent) { lastPositionTime += fixed::FromString(attrs.GetNamedItem(at_deltatime)); lastTargetTime += fixed::FromString(attrs.GetNamedItem(at_deltatime)); - XERO_ITER_EL(pathChild, nodeChild) + for (XMBElement nodeChild : pathChild.GetChildNodes()) { elementName = nodeChild.GetNodeName(); attrs = nodeChild.GetAttributes(); @@ -1012,7 +1012,7 @@ void CXMLReader::ReadEntities(XMBElement entity, CSimulation2& sim) entity_id_t ControlGroup = INVALID_ENTITY; entity_id_t ControlGroup2 = INVALID_ENTITY; - XERO_ITER_EL(entity, setting) + for (XMBElement setting : entity.GetChildNodes()) { int element_name = setting.GetNodeName(); diff --git a/source/graphics/MaterialManager.cpp b/source/graphics/MaterialManager.cpp index 075e741a94..6dab2bd7ab 100644 --- a/source/graphics/MaterialManager.cpp +++ b/source/graphics/MaterialManager.cpp @@ -113,7 +113,7 @@ CMaterial CMaterialManager::LoadMaterial(const VfsPath& pathname) material.AddStaticUniform("qualityLevel", CVector4D(qualityLevel, 0, 0, 0)); XMBElement root = xeroFile.GetRoot(); - XERO_ITER_EL(root, node) + for (XMBElement node : root.GetChildNodes()) { int token = node.GetNodeName(); XMBAttributeList attrs = node.GetAttributes(); diff --git a/source/graphics/ObjectBase.cpp b/source/graphics/ObjectBase.cpp index 403dc8d47f..3577e28015 100644 --- a/source/graphics/ObjectBase.cpp +++ b/source/graphics/ObjectBase.cpp @@ -101,7 +101,7 @@ bool CObjectBase::Load(const CXeromyces& XeroFile, const XMBElement& root) // Set up the group vector to avoid reallocation and copying later. { int groups = 0; - XERO_ITER_EL(root, child) + for (XMBElement child : root.GetChildNodes()) { if (child.GetNodeName() == el_group) ++groups; @@ -123,7 +123,7 @@ bool CObjectBase::Load(const CXeromyces& XeroFile, const XMBElement& root) return false; }; - XERO_ITER_EL(root, child) + for (XMBElement child : root.GetChildNodes()) { int child_name = child.GetNodeName(); @@ -134,7 +134,7 @@ bool CObjectBase::Load(const CXeromyces& XeroFile, const XMBElement& root) { std::vector& currentGroup = m_VariantGroups.emplace_back(); currentGroup.reserve(child.GetChildNodes().size()); - XERO_ITER_EL(child, variant) + for (XMBElement variant : child.GetChildNodes()) { if (shouldSkip(variant)) continue; @@ -239,7 +239,7 @@ bool CObjectBase::LoadVariant(const CXeromyces& XeroFile, const XMBElement& vari currentVariant.m_Frequency = attr.Value.ToInt(); } - XERO_ITER_EL(variant, option) + for (XMBElement option : variant.GetChildNodes()) { int option_name = option.GetNodeName(); @@ -249,7 +249,7 @@ bool CObjectBase::LoadVariant(const CXeromyces& XeroFile, const XMBElement& vari } else if (option_name == el_textures) { - XERO_ITER_EL(option, textures_element) + for (XMBElement textures_element : option.GetChildNodes()) { if (textures_element.GetNodeName() != el_texture) { @@ -295,7 +295,7 @@ bool CObjectBase::LoadVariant(const CXeromyces& XeroFile, const XMBElement& vari } else if (option_name == el_animations) { - XERO_ITER_EL(option, anim_element) + for (XMBElement anim_element : option.GetChildNodes()) { if (anim_element.GetNodeName() != el_animation) { @@ -328,7 +328,7 @@ bool CObjectBase::LoadVariant(const CXeromyces& XeroFile, const XMBElement& vari } else if (option_name == el_props) { - XERO_ITER_EL(option, prop_element) + for (XMBElement prop_element : option.GetChildNodes()) { ENSURE(prop_element.GetNodeName() == el_prop); @@ -878,12 +878,12 @@ bool CActorDef::Load(const VfsPath& pathname) } u8 quality = 0; XMBElement inlineActor; - XERO_ITER_EL(root, child) + for (XMBElement child : root.GetChildNodes()) { if (child.GetNodeName() == el_inline) inlineActor = child; } - XERO_ITER_EL(root, actor) + for (XMBElement actor : root.GetChildNodes()) { if (actor.GetNodeName() != el_actor) continue; diff --git a/source/graphics/ParticleEmitterType.cpp b/source/graphics/ParticleEmitterType.cpp index 68dcc7265a..783bc86c56 100644 --- a/source/graphics/ParticleEmitterType.cpp +++ b/source/graphics/ParticleEmitterType.cpp @@ -435,7 +435,7 @@ bool CParticleEmitterType::LoadXML(const VfsPath& path) XMBElement Root = XeroFile.GetRoot(); - XERO_ITER_EL(Root, Child) + for (XMBElement Child : Root.GetChildNodes()) { if (Child.GetNodeName() == el_texture) { @@ -531,7 +531,7 @@ bool CParticleEmitterType::LoadXML(const VfsPath& path) } else if (Child.GetNodeName() == el_particle) { - XERO_ITER_EL(Child, particleChild) + for (XMBElement particleChild : Child.GetChildNodes()) { if (particleChild.GetNodeName() == el_fixed_orientation) { diff --git a/source/graphics/ShaderManager.cpp b/source/graphics/ShaderManager.cpp index bb0608ad5e..bf724ea1d9 100644 --- a/source/graphics/ShaderManager.cpp +++ b/source/graphics/ShaderManager.cpp @@ -223,11 +223,11 @@ bool CShaderManager::LoadTechnique(CShaderTechniquePtr& tech) // Find a first suitable technique that we can use. std::optional usableTech; std::optional usableShader; - XERO_ITER_EL(root, technique) + for (XMBElement technique : root.GetChildNodes()) { bool isUsable{true}; usableShader.reset(); - XERO_ITER_EL(technique, child) + for (XMBElement child : technique.GetChildNodes()) { XMBAttributeList attrs = child.GetAttributes(); @@ -276,7 +276,7 @@ bool CShaderManager::LoadTechnique(CShaderTechniquePtr& tech) }; CShaderDefines techDefines = tech->GetShaderDefines(); - XERO_ITER_EL((*usableTech), Child) + for (XMBElement Child : usableTech->GetChildNodes()) { if (Child.GetNodeName() == el_define) { @@ -292,7 +292,7 @@ bool CShaderManager::LoadTechnique(CShaderTechniquePtr& tech) // TODO: we might want to implement that in a proper way via splitting passes // and tags in different groups in XML. std::vector techPasses; - XERO_ITER_EL((*usableTech), Child) + for (XMBElement Child : usableTech->GetChildNodes()) { if (Child.GetNodeName() == el_pass) { @@ -301,7 +301,7 @@ bool CShaderManager::LoadTechnique(CShaderTechniquePtr& tech) Renderer::Backend::SGraphicsPipelineStateDesc passPipelineStateDesc = Renderer::Backend::MakeDefaultGraphicsPipelineStateDesc(); - XERO_ITER_EL(Child, Element) + for (XMBElement Element : Child.GetChildNodes()) { if (Element.GetNodeName() == el_define) { diff --git a/source/graphics/TerrainProperties.cpp b/source/graphics/TerrainProperties.cpp index 479ef825e4..3e41755956 100644 --- a/source/graphics/TerrainProperties.cpp +++ b/source/graphics/TerrainProperties.cpp @@ -76,7 +76,7 @@ CTerrainPropertiesPtr CTerrainProperties::FromXML(const CTerrainPropertiesPtr& p // returning it. // Really, we only expect there to be one child and it to be of the right // type, though. - XERO_ITER_EL(root, child) + for (XMBElement child : root.GetChildNodes()) { if (child.GetNodeName() == el_terrain) { diff --git a/source/graphics/TerrainTextureEntry.cpp b/source/graphics/TerrainTextureEntry.cpp index e5c4e5675a..372536d16e 100644 --- a/source/graphics/TerrainTextureEntry.cpp +++ b/source/graphics/TerrainTextureEntry.cpp @@ -83,13 +83,13 @@ CTerrainTextureEntry::CTerrainTextureEntry(CTerrainPropertiesPtr properties, con VfsPath alphamap("standard"); m_Tag = utf8_from_wstring(path.Basename().string()); - XERO_ITER_EL(root, child) + for (XMBElement child : root.GetChildNodes()) { int child_name = child.GetNodeName(); if (child_name == el_textures) { - XERO_ITER_EL(child, textures_element) + for (XMBElement textures_element : child.GetChildNodes()) { ENSURE(textures_element.GetNodeName() == el_texture); diff --git a/source/graphics/TextureConverter.cpp b/source/graphics/TextureConverter.cpp index b8880466e3..a2fe918174 100644 --- a/source/graphics/TextureConverter.cpp +++ b/source/graphics/TextureConverter.cpp @@ -164,7 +164,7 @@ CTextureConverter::SettingsFile* CTextureConverter::LoadSettings(const VfsPath& std::unique_ptr settings = std::make_unique(); - XERO_ITER_EL(root, child) + for (XMBElement child : root.GetChildNodes()) { if (child.GetNodeName() == el_file) { diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index d4018a0ac6..1b47e56c73 100644 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -979,7 +979,7 @@ void CGUI::Xeromyces_ReadRepeat(const XMBData& xmb, XMBElement element, IGUIObje { NameSubst.emplace_back(var, fmt::format("[{}]", n)); - XERO_ITER_EL(element, child) + for (XMBElement child : element.GetChildNodes()) { if (child.GetNodeName() == elmt_object) Xeromyces_ReadObject(xmb, child, parent, NameSubst, Paths, nesting_depth); diff --git a/source/gui/GUIManager.cpp b/source/gui/GUIManager.cpp index fef588f652..9dc2614672 100644 --- a/source/gui/GUIManager.cpp +++ b/source/gui/GUIManager.cpp @@ -211,7 +211,7 @@ void CGUIManager::SGUIPage::LoadPage(Script::Context& scriptContext) } VfsPath rootModule; - XERO_ITER_EL(root, node) + for (XMBElement node : root.GetChildNodes()) { if (node.GetNodeName() != elmt_include) { diff --git a/source/ps/XML/XMLWriter.cpp b/source/ps/XML/XMLWriter.cpp index be0931d4bd..0723c8124d 100644 --- a/source/ps/XML/XMLWriter.cpp +++ b/source/ps/XML/XMLWriter.cpp @@ -135,7 +135,7 @@ void XMLWriter_File::ElementXMB(const XMBData& xmb, XMBElement el) for (XMBAttribute attr : el.GetAttributes()) writer.Attribute(xmb.GetAttributeString(attr.Name), attr.Value); - XERO_ITER_EL(el, child) + for (XMBElement child : el.GetChildNodes()) ElementXMB(xmb, child); } diff --git a/source/ps/XML/Xeromyces.h b/source/ps/XML/Xeromyces.h index 676d99219d..2c932d1dee 100644 --- a/source/ps/XML/Xeromyces.h +++ b/source/ps/XML/Xeromyces.h @@ -91,7 +91,4 @@ private: #define _XERO_CHILDREN _XERO_MAKE_UID1__(_children_, __LINE__) #define _XERO_I _XERO_MAKE_UID1__(_i_, __LINE__) -#define XERO_ITER_EL(parent_element, child_element) \ - for (XMBElement child_element : parent_element.GetChildNodes()) - #endif // INCLUDED_XEROMYCES diff --git a/source/renderer/backend/gl/ShaderProgram.cpp b/source/renderer/backend/gl/ShaderProgram.cpp index d84b1fca0c..0e1de634b8 100644 --- a/source/renderer/backend/gl/ShaderProgram.cpp +++ b/source/renderer/backend/gl/ShaderProgram.cpp @@ -929,7 +929,7 @@ std::unique_ptr CShaderProgram::Create(CDevice* device, const CS VfsPath computeFile; - XERO_ITER_EL(root, child) + for (XMBElement child : root.GetChildNodes()) { if (child.GetNodeName() == el_define) { @@ -939,7 +939,7 @@ std::unique_ptr CShaderProgram::Create(CDevice* device, const CS { vertexFile = L"shaders/" + child.GetAttributes().GetNamedItem(at_file).FromUTF8(); - XERO_ITER_EL(child, param) + for (XMBElement param : child.GetChildNodes()) { XMBAttributeList attributes = param.GetAttributes(); @@ -996,7 +996,7 @@ std::unique_ptr CShaderProgram::Create(CDevice* device, const CS { fragmentFile = L"shaders/" + child.GetAttributes().GetNamedItem(at_file).FromUTF8(); - XERO_ITER_EL(child, param) + for (XMBElement param : child.GetChildNodes()) { XMBAttributeList attributes = param.GetAttributes(); diff --git a/source/renderer/backend/vulkan/ShaderProgram.cpp b/source/renderer/backend/vulkan/ShaderProgram.cpp index 3ca68e51c4..291e2cd631 100644 --- a/source/renderer/backend/vulkan/ShaderProgram.cpp +++ b/source/renderer/backend/vulkan/ShaderProgram.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 @@ -124,16 +124,16 @@ VfsPath FindProgramMatchingDefines(const VfsPath& xmlFilename, const CShaderDefi const CStrIntern strUndefined("UNDEFINED"); VfsPath programFilename; XMBElement root = xeroFile.GetRoot(); - XERO_ITER_EL(root, rootChild) + for (XMBElement rootChild : root.GetChildNodes()) { if (rootChild.GetNodeName() == el_program) { CShaderDefines programDefines; - XERO_ITER_EL(rootChild, programChild) + for (XMBElement programChild : rootChild.GetChildNodes()) { if (programChild.GetNodeName() == el_defines) { - XERO_ITER_EL(programChild, definesChild) + for (XMBElement definesChild : programChild.GetChildNodes()) { XMBAttributeList attributes = definesChild.GetAttributes(); if (definesChild.GetNodeName() == el_define) @@ -269,7 +269,7 @@ std::unique_ptr CShaderProgram::Create( const bool useDescriptorIndexing = device->GetDescriptorManager().UseDescriptorIndexing(); // TODO: reduce the indentation. - XERO_ITER_EL(element, descriporSetsChild) + for (XMBElement descriporSetsChild : element.GetChildNodes()) { if (descriporSetsChild.GetNodeName() == el_descriptor_set) { @@ -279,7 +279,7 @@ std::unique_ptr CShaderProgram::Create( LOGERROR("Descriptor set for descriptor indexing shouldn't contain bindings."); return false; } - XERO_ITER_EL(descriporSetsChild, descriporSetChild) + for (XMBElement descriporSetChild : descriporSetsChild.GetChildNodes()) { if (descriporSetChild.GetNodeName() == el_binding) { @@ -297,7 +297,7 @@ std::unique_ptr CShaderProgram::Create( return false; } shaderProgram->m_MaterialConstantsDataSize = size; - XERO_ITER_EL(descriporSetChild, bindingChild) + for (XMBElement bindingChild : descriporSetChild.GetChildNodes()) { if (bindingChild.GetNodeName() == el_member) { @@ -384,7 +384,7 @@ std::unique_ptr CShaderProgram::Create( return true; }; - XERO_ITER_EL(programRoot, programChild) + for (XMBElement programChild : programRoot.GetChildNodes()) { if (programChild.GetNodeName() == el_vertex) { @@ -408,7 +408,7 @@ std::unique_ptr CShaderProgram::Create( vertexShaderStageInfo.module = shaderProgram->m_ShaderModules.back(); vertexShaderStageInfo.pName = "main"; shaderProgram->m_Stages.emplace_back(std::move(vertexShaderStageInfo)); - XERO_ITER_EL(programChild, stageChild) + for (XMBElement stageChild : programChild.GetChildNodes()) { if (stageChild.GetNodeName() == el_stream) { @@ -476,7 +476,7 @@ std::unique_ptr CShaderProgram::Create( fragmentShaderStageInfo.module = shaderProgram->m_ShaderModules.back(); fragmentShaderStageInfo.pName = "main"; shaderProgram->m_Stages.emplace_back(std::move(fragmentShaderStageInfo)); - XERO_ITER_EL(programChild, stageChild) + for (XMBElement stageChild : programChild.GetChildNodes()) { if (stageChild.GetNodeName() == el_push_constant) { @@ -512,7 +512,7 @@ std::unique_ptr CShaderProgram::Create( computeShaderStageInfo.module = shaderProgram->m_ShaderModules.back(); computeShaderStageInfo.pName = "main"; shaderProgram->m_Stages.emplace_back(std::move(computeShaderStageInfo)); - XERO_ITER_EL(programChild, stageChild) + for (XMBElement stageChild : programChild.GetChildNodes()) { if (stageChild.GetNodeName() == el_push_constant) { diff --git a/source/simulation2/system/ParamNode.cpp b/source/simulation2/system/ParamNode.cpp index a8167da5a4..8be12dfa4c 100644 --- a/source/simulation2/system/ParamNode.cpp +++ b/source/simulation2/system/ParamNode.cpp @@ -229,7 +229,7 @@ void CParamNode::ApplyLayer(const XMBData& xmb, const XMBElement& element, const ChildrenMap childs; // Recurse through the element's children - XERO_ITER_EL(element, child) + for (XMBElement child : element.GetChildNodes()) { node.ApplyLayer(xmb, child, sourceIdentifier); if (filtering) diff --git a/source/soundmanager/scripting/SoundGroup.cpp b/source/soundmanager/scripting/SoundGroup.cpp index fd9514c53b..13902d5c39 100644 --- a/source/soundmanager/scripting/SoundGroup.cpp +++ b/source/soundmanager/scripting/SoundGroup.cpp @@ -350,7 +350,7 @@ bool CSoundGroup::LoadSoundGroup(const VfsPath& pathnameXML) return false; } - XERO_ITER_EL(root, child) + for (XMBElement child : root.GetChildNodes()) { int child_name = child.GetNodeName();