From 89d1862497222ea48fb38995492df7947b00c4d7 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Thu, 22 Jul 2010 00:07:44 +0200 Subject: 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 --- src/utils/xml.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/utils/xml.cpp') diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp index 659f928b..8bc9ebef 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; -- cgit v1.2.3-60-g2f50