summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-07-22 00:07:44 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-07-22 00:08:37 +0200
commit89d1862497222ea48fb38995492df7947b00c4d7 (patch)
tree65559d094f931b847eaa46c2031a22d1d98ba89c /src/utils
parent26d8eba0ad906cd9b4a95bbd94fc1556719fd5d2 (diff)
downloadmanaserv-89d1862497222ea48fb38995492df7947b00c4d7.tar.gz
manaserv-89d1862497222ea48fb38995492df7947b00c4d7.tar.xz
manaserv-89d1862497222ea48fb38995492df7947b00c4d7.zip
Upgraded Skill Map loading.
- Added a new 'default' boolean parameter in mana-skills.xml. If set to true, unknown weapon types will be defaulted to the given value. - Added better checks on skill id and names and improved error reporting. - Corrected minor typos, and made small cleanups. Reviewed-by: jaxad0127
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/xml.cpp29
-rw-r--r--src/utils/xml.hpp10
2 files changed, 39 insertions, 0 deletions
diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp
index 659f928..8bc9ebe 100644
--- a/src/utils/xml.cpp
+++ b/src/utils/xml.cpp
@@ -96,6 +96,35 @@ namespace XML
return mDoc ? xmlDocGetRootElement(mDoc) : 0;
}
+ bool hasProperty(xmlNodePtr node, const char *name)
+ {
+ xmlChar *prop = xmlGetProp(node, BAD_CAST name);
+ if (prop)
+ {
+ xmlFree(prop);
+ return true;
+ }
+
+ return false;
+ }
+
+ bool getBoolProperty(xmlNodePtr node, const char *name, bool def)
+ {
+ bool ret = def;
+ xmlChar *prop = xmlGetProp(node, BAD_CAST name);
+ if (prop)
+ {
+ if (xmlStrEqual(prop, BAD_CAST "true")
+ ||xmlStrEqual(prop, BAD_CAST "yes"))
+ ret = true;
+ if (xmlStrEqual(prop, BAD_CAST "false")
+ ||xmlStrEqual(prop, BAD_CAST "no"))
+ ret = false;
+ xmlFree(prop);
+ }
+ return ret;
+ }
+
int getProperty(xmlNodePtr node, const char *name, int def)
{
int &ret = def;
diff --git a/src/utils/xml.hpp b/src/utils/xml.hpp
index ee37b48..eba88e5 100644
--- a/src/utils/xml.hpp
+++ b/src/utils/xml.hpp
@@ -70,6 +70,16 @@ namespace XML
};
/**
+ * Tells if a property from an xmlNodePtr exists.
+ */
+ bool hasProperty(xmlNodePtr node, const char *name);
+
+ /**
+ * Gets a boolean property from an xmlNodePtr.
+ */
+ bool getBoolProperty(xmlNodePtr node, const char *name, bool def);
+
+ /**
* Gets an integer property from an xmlNodePtr.
*/
int getProperty(xmlNodePtr node, const char *name, int def);