Skip to content

Commit

Permalink
#6107: Fix mapx layer hierarchy loading code
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Oct 1, 2022
1 parent b091ef7 commit d68a92d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions radiantcore/map/format/portable/PortableMapReader.cpp
Expand Up @@ -88,12 +88,18 @@ void PortableMapReader::readLayers(const xml::Node& mapNode)
auto id = string::convert<int>(layer.getAttributeValue(ATTR_MAP_LAYER_ID));
auto name = layer.getAttributeValue(ATTR_MAP_LAYER_NAME);

layerManager.createLayer(name, id);
}

// Restore the layer hierarchy after all layers have been created
for (const auto& layer : layers)
{
auto childLayerId = string::convert<int>(layer.getAttributeValue(ATTR_MAP_LAYER_ID));
// Parent layer ID is optional and defaults to -1
auto parentLayerId = string::convert<int>(layer.getAttributeValue(ATTR_MAP_LAYER_PARENT_ID), -1);

layerManager.createLayer(name, id);
layerManager.setParentLayer(id, parentLayerId);
}
layerManager.setParentLayer(childLayerId, parentLayerId);
}
}
catch (const BadDocumentFormatException& ex)
{
Expand Down

0 comments on commit d68a92d

Please sign in to comment.