summaryrefslogtreecommitdiff
path: root/src/resources/mapreader.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-01-28 20:56:41 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-01-28 20:57:58 +0100
commit264be2108c51837fa92085f6c839e66aebbcfc9e (patch)
treee1f535d4cda5f399e5e622f6154690a0a4e08c4b /src/resources/mapreader.cpp
parentd86a1df562e00a6e930683534b9d001f45a951ff (diff)
downloadMana-264be2108c51837fa92085f6c839e66aebbcfc9e.tar.gz
Mana-264be2108c51837fa92085f6c839e66aebbcfc9e.tar.bz2
Mana-264be2108c51837fa92085f6c839e66aebbcfc9e.tar.xz
Mana-264be2108c51837fa92085f6c839e66aebbcfc9e.zip
Added support for map/layer mask
A custom "Mask" property on a layer or a "foregroundXmask" property on a map can now be used in combination with the SMSG_MAP_MASK to dynamically disable certain map layers from the server. Feature previously seen on ManaPlus and implemented for Mana client for compatibility. Also added a ResourceRef class for automating the Resource reference counting. Closes #44
Diffstat (limited to 'src/resources/mapreader.cpp')
-rw-r--r--src/resources/mapreader.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index af41da12..aba9f85d 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -276,6 +276,26 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
// Load the tile data
for_each_xml_child_node(childNode, node)
{
+ if (xmlStrEqual(childNode->name, BAD_CAST "properties"))
+ {
+ for_each_xml_child_node(prop, childNode)
+ {
+ if (!xmlStrEqual(prop->name, BAD_CAST "property"))
+ continue;
+
+ const std::string pname = XML::getProperty(prop, "name", "");
+ const std::string value = XML::getProperty(prop, "value", "");
+
+ // TODO: Consider supporting "Hidden", "Version" and "NotVersion"
+
+ if (pname == "Mask")
+ {
+ layer->setMask(atoi(value.c_str()));
+ }
+ }
+ continue;
+ }
+
if (!xmlStrEqual(childNode->name, BAD_CAST "data"))
continue;