summaryrefslogtreecommitdiff
path: root/src/properties.h
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/properties.h
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/properties.h')
-rw-r--r--src/properties.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/properties.h b/src/properties.h
index 40be8d7f..84b6d184 100644
--- a/src/properties.h
+++ b/src/properties.h
@@ -71,6 +71,27 @@ class Properties
}
/**
+ * Gets a map property as an int.
+ *
+ * @param name The name of the property.
+ * @param def Default value, 0 by default.
+ * @return the value of the given property or the given default when it
+ * doesn't exist.
+ */
+ float getIntProperty(const std::string &name, int def = 0) const
+ {
+ auto i = mProperties.find(name);
+ int ret = def;
+ if (i != mProperties.end())
+ {
+ std::stringstream ss;
+ ss.str(i->second);
+ ss >> ret;
+ }
+ return ret;
+ }
+
+ /**
* Gets a map property as a boolean.
*
* @param name The name of the property.