diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-11-30 13:59:45 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-01-20 21:58:39 +0300 |
commit | bc3a7cf853510ffe1e42dc683f854d360f6528c7 (patch) | |
tree | 9898f13eafc3e1a20388d8d592bfcc05c8f50ba7 /src/resources | |
parent | a058af57bddd4a4394401cc75d33461e17aab8c1 (diff) | |
download | mv-bc3a7cf853510ffe1e42dc683f854d360f6528c7.tar.gz mv-bc3a7cf853510ffe1e42dc683f854d360f6528c7.tar.bz2 mv-bc3a7cf853510ffe1e42dc683f854d360f6528c7.tar.xz mv-bc3a7cf853510ffe1e42dc683f854d360f6528c7.zip |
Add pugixml backend incomplete.
Add some defines for xml nodes manipulation.
With pugixml backend no xml writing.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/animation/simpleanimation.cpp | 3 | ||||
-rw-r--r-- | src/resources/beingcommon.cpp | 15 | ||||
-rw-r--r-- | src/resources/db/avatardb.cpp | 6 | ||||
-rw-r--r-- | src/resources/db/deaddb.cpp | 2 | ||||
-rw-r--r-- | src/resources/db/emotedb.cpp | 16 | ||||
-rw-r--r-- | src/resources/db/horsedb.cpp | 9 | ||||
-rw-r--r-- | src/resources/db/itemdb.cpp | 25 | ||||
-rw-r--r-- | src/resources/db/npcdb.cpp | 10 | ||||
-rw-r--r-- | src/resources/db/petdb.cpp | 8 | ||||
-rw-r--r-- | src/resources/db/skillunitdb.cpp | 8 | ||||
-rw-r--r-- | src/resources/mapreader.cpp | 17 |
11 files changed, 46 insertions, 73 deletions
diff --git a/src/resources/animation/simpleanimation.cpp b/src/resources/animation/simpleanimation.cpp index 4d1add3be..1a1d30094 100644 --- a/src/resources/animation/simpleanimation.cpp +++ b/src/resources/animation/simpleanimation.cpp @@ -170,8 +170,7 @@ void SimpleAnimation::initializeAnimation(const XmlNodePtr animationNode, const int y1 = imageset->getHeight() - mapTileSize; // Get animation frames - for (XmlNodePtr frameNode = animationNode->xmlChildrenNode; - frameNode; frameNode = frameNode->next) + for_each_xml_child_node (frameNode, animationNode) { const int delay = XML::getIntProperty( frameNode, "delay", 0, 0, 100000); diff --git a/src/resources/beingcommon.cpp b/src/resources/beingcommon.cpp index 92411a895..999b19980 100644 --- a/src/resources/beingcommon.cpp +++ b/src/resources/beingcommon.cpp @@ -105,12 +105,11 @@ bool BeingCommon::readObjectNodes(XmlNodePtrConst &spriteNode, { if (xmlNameEqual(spriteNode, "sprite")) { - if (!spriteNode->xmlChildrenNode) + if (!XmlHaveChildContent(spriteNode)) return true; SpriteReference *const currentSprite = new SpriteReference; - currentSprite->sprite = reinterpret_cast<const char*>( - spriteNode->xmlChildrenNode->content); + currentSprite->sprite = XmlChildContent(spriteNode); currentSprite->variant = XML::getProperty( spriteNode, "variant", 0); @@ -119,15 +118,14 @@ bool BeingCommon::readObjectNodes(XmlNodePtrConst &spriteNode, } else if (xmlNameEqual(spriteNode, "sound")) { - if (!spriteNode->xmlChildrenNode) + if (!XmlHaveChildContent(spriteNode)) return true; const std::string event = XML::getProperty( spriteNode, "event", ""); const int delay = XML::getProperty( spriteNode, "delay", 0); - const char *const filename = reinterpret_cast<const char*>( - spriteNode->xmlChildrenNode->content); + const char *const filename = XmlChildContent(spriteNode); if (event == "hit") { @@ -209,11 +207,10 @@ bool BeingCommon::readObjectNodes(XmlNodePtrConst &spriteNode, } else if (xmlNameEqual(spriteNode, "particlefx")) { - if (!spriteNode->xmlChildrenNode) + if (!XmlHaveChildContent(spriteNode)) return true; - display.particles.push_back(reinterpret_cast<const char*>( - spriteNode->xmlChildrenNode->content)); + display.particles.push_back(XmlChildContent(spriteNode)); return true; } return false; diff --git a/src/resources/db/avatardb.cpp b/src/resources/db/avatardb.cpp index 783954006..5b377b173 100644 --- a/src/resources/db/avatardb.cpp +++ b/src/resources/db/avatardb.cpp @@ -107,13 +107,11 @@ void AvatarDB::loadXmlFile(const std::string &fileName) { if (xmlNameEqual(spriteNode, "sprite")) { - if (!spriteNode->xmlChildrenNode) + if (!XmlHaveChildContent(spriteNode)) continue; SpriteReference *const currentSprite = new SpriteReference; - currentSprite->sprite = reinterpret_cast<const char*>( - spriteNode->xmlChildrenNode->content); - + currentSprite->sprite = XmlChildContent(spriteNode); currentSprite->variant = XML::getProperty( spriteNode, "variant", 0); display.sprites.push_back(currentSprite); diff --git a/src/resources/db/deaddb.cpp b/src/resources/db/deaddb.cpp index dcd658f0e..a2a6a6494 100644 --- a/src/resources/db/deaddb.cpp +++ b/src/resources/db/deaddb.cpp @@ -73,7 +73,7 @@ void DeadDB::loadXmlFile(const std::string &fileName) else if (xmlNameEqual(node, "message")) { const char *const data = reinterpret_cast<const char*>( - xmlNodeGetContent(node)); + XmlNodeGetContent(node)); if (!data || !*data) continue; mMessages.push_back(data); diff --git a/src/resources/db/emotedb.cpp b/src/resources/db/emotedb.cpp index eeaaaf0a2..b2f9a0581 100644 --- a/src/resources/db/emotedb.cpp +++ b/src/resources/db/emotedb.cpp @@ -116,7 +116,7 @@ void EmoteDB::loadXmlFile(const std::string &fileName) for_each_xml_child_node(spriteNode, emoteNode) { - if (!spriteNode->xmlChildrenNode) + if (!XmlHaveChildContent(spriteNode)) continue; if (xmlNameEqual(spriteNode, "sprite")) @@ -124,8 +124,7 @@ void EmoteDB::loadXmlFile(const std::string &fileName) EmoteSprite *const currentSprite = new EmoteSprite; currentSprite->sprite = AnimatedSprite::load( paths.getStringValue("sprites").append(std::string( - reinterpret_cast<const char*>( - spriteNode->xmlChildrenNode->content))), + XmlChildContent(spriteNode))), XML::getProperty(spriteNode, "variant", 0)); currentSprite->name = XML::langProperty( spriteNode, "name", ""); @@ -134,8 +133,7 @@ void EmoteDB::loadXmlFile(const std::string &fileName) } else if (xmlNameEqual(spriteNode, "particlefx")) { - currentInfo->particles.push_back(reinterpret_cast<const char*>( - spriteNode->xmlChildrenNode->content)); + currentInfo->particles.push_back(XmlChildContent(spriteNode)); } } mEmoteInfos[id] = currentInfo; @@ -190,7 +188,7 @@ void EmoteDB::loadSpecialXmlFile(const std::string &fileName) for_each_xml_child_node(spriteNode, emoteNode) { - if (!spriteNode->xmlChildrenNode) + if (!XmlHaveChildContent(spriteNode)) continue; if (xmlNameEqual(spriteNode, "sprite")) @@ -198,8 +196,7 @@ void EmoteDB::loadSpecialXmlFile(const std::string &fileName) EmoteSprite *const currentSprite = new EmoteSprite; currentSprite->sprite = AnimatedSprite::load( paths.getStringValue("sprites").append(std::string( - reinterpret_cast<const char*>( - spriteNode->xmlChildrenNode->content))), + XmlChildContent(spriteNode))), XML::getProperty(spriteNode, "variant", 0)); currentSprite->name = XML::langProperty( spriteNode, "name", ""); @@ -208,8 +205,7 @@ void EmoteDB::loadSpecialXmlFile(const std::string &fileName) } else if (xmlNameEqual(spriteNode, "particlefx")) { - currentInfo->particles.push_back(reinterpret_cast<const char*>( - spriteNode->xmlChildrenNode->content)); + currentInfo->particles.push_back(XmlChildContent(spriteNode)); } } mEmoteInfos[id] = currentInfo; diff --git a/src/resources/db/horsedb.cpp b/src/resources/db/horsedb.cpp index 011548b1f..27987c657 100644 --- a/src/resources/db/horsedb.cpp +++ b/src/resources/db/horsedb.cpp @@ -42,8 +42,7 @@ namespace { \ SpriteReference *const currentSprite = new SpriteReference; \ currentSprite->sprite = paths.getStringValue("sprites").append( \ - std::string(reinterpret_cast<const char*>( \ - spriteNode->xmlChildrenNode->content))); \ + std::string(XmlChildContent(spriteNode))); \ currentSprite->variant = XML::getProperty( \ spriteNode, "variant", 0); \ currentInfo->name.push_back(currentSprite); \ @@ -142,7 +141,7 @@ void HorseDB::loadXmlFile(const std::string &fileName) for_each_xml_child_node(spriteNode, horseNode) { - if (!spriteNode->xmlChildrenNode) + if (!XmlHaveChildContent(spriteNode)) continue; if (xmlNameEqual(spriteNode, "sprite")) @@ -162,7 +161,7 @@ static void loadDownSprites(XmlNodePtrConst parentNode, { for_each_xml_child_node(spriteNode, parentNode) { - if (!spriteNode->xmlChildrenNode) + if (!XmlHaveChildContent(spriteNode)) continue; if (xmlNameEqual(spriteNode, "sprite")) @@ -175,7 +174,7 @@ static void loadUpSprites(XmlNodePtrConst parentNode, { for_each_xml_child_node(spriteNode, parentNode) { - if (!spriteNode->xmlChildrenNode) + if (!XmlHaveChildContent(spriteNode)) continue; if (xmlNameEqual(spriteNode, "sprite")) diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp index 9a815bed6..6a3766cc6 100644 --- a/src/resources/db/itemdb.cpp +++ b/src/resources/db/itemdb.cpp @@ -545,11 +545,8 @@ void ItemDB::loadXmlFile(const std::string &fileName, int &tagNum) } else if (xmlNameEqual(itemChild, "particlefx")) { - if (itemChild->xmlChildrenNode) - { - display.particles.push_back(reinterpret_cast<const char*>( - itemChild->xmlChildrenNode->content)); - } + if (XmlHaveChildContent(itemChild)) + display.particles.push_back(XmlChildContent(itemChild)); } else if (xmlNameEqual(itemChild, "sound")) { @@ -844,11 +841,10 @@ static int parseDirectionName(const std::string &name) static void loadSpriteRef(ItemInfo *const itemInfo, const XmlNodePtr node) { const std::string gender = XML::getProperty(node, "gender", "unisex"); - if (!node || !node->xmlChildrenNode) + if (!node || !XmlHaveChildContent(node)) return; - const std::string filename = reinterpret_cast<const char*>( - node->xmlChildrenNode->content); + const std::string filename = XmlChildContent(node); const int race = XML::getProperty(node, "race", 0); if (gender == "male" || gender == "unisex") @@ -861,11 +857,10 @@ static void loadSpriteRef(ItemInfo *const itemInfo, const XmlNodePtr node) static void loadSoundRef(ItemInfo *const itemInfo, const XmlNodePtr node) { - if (!node || !node->xmlChildrenNode) + if (!node || !XmlHaveChildContent(node)) return; const std::string event = XML::getProperty(node, "event", ""); - const std::string filename = reinterpret_cast<const char*>( - node->xmlChildrenNode->content); + const std::string filename = XmlChildContent(node); const int delay = XML::getProperty(node, "delay", 0); const std::map<std::string, ItemSoundEvent::Type>::const_iterator @@ -888,21 +883,19 @@ static void loadFloorSprite(SpriteDisplay &display, return; for_each_xml_child_node(spriteNode, floorNode) { - if (!spriteNode->xmlChildrenNode) + if (!XmlHaveChildContent(spriteNode)) continue; if (xmlNameEqual(spriteNode, "sprite")) { SpriteReference *const currentSprite = new SpriteReference; - currentSprite->sprite = reinterpret_cast<const char*>( - spriteNode->xmlChildrenNode->content); + currentSprite->sprite = XmlChildContent(spriteNode); currentSprite->variant = XML::getProperty(spriteNode, "variant", 0); display.sprites.push_back(currentSprite); } else if (xmlNameEqual(spriteNode, "particlefx")) { - display.particles.push_back(reinterpret_cast<const char*>( - spriteNode->xmlChildrenNode->content)); + display.particles.push_back(XmlChildContent(spriteNode)); } } } diff --git a/src/resources/db/npcdb.cpp b/src/resources/db/npcdb.cpp index 3362c02c9..1827cd859 100644 --- a/src/resources/db/npcdb.cpp +++ b/src/resources/db/npcdb.cpp @@ -118,23 +118,21 @@ void NPCDB::loadXmlFile(const std::string &fileName) { if (xmlNameEqual(spriteNode, "sprite")) { - if (!spriteNode->xmlChildrenNode) + if (!XmlHaveChildContent(spriteNode)) continue; SpriteReference *const currentSprite = new SpriteReference; - currentSprite->sprite = reinterpret_cast<const char*>( - spriteNode->xmlChildrenNode->content); + currentSprite->sprite = XmlChildContent(spriteNode); currentSprite->variant = XML::getProperty(spriteNode, "variant", 0); display.sprites.push_back(currentSprite); } else if (xmlNameEqual(spriteNode, "particlefx")) { - if (!spriteNode->xmlChildrenNode) + if (!XmlHaveChildContent(spriteNode)) continue; - display.particles.push_back(reinterpret_cast<const char*>( - spriteNode->xmlChildrenNode->content)); + display.particles.push_back(XmlChildContent(spriteNode)); } else if (xmlNameEqual(spriteNode, "menu")) { diff --git a/src/resources/db/petdb.cpp b/src/resources/db/petdb.cpp index 53f34fae8..160306d71 100644 --- a/src/resources/db/petdb.cpp +++ b/src/resources/db/petdb.cpp @@ -153,22 +153,20 @@ void PETDB::loadXmlFile(const std::string &fileName) SpriteDisplay display; for_each_xml_child_node(spriteNode, petNode) { - if (!spriteNode->xmlChildrenNode) + if (!XmlHaveChildContent(spriteNode)) continue; if (xmlNameEqual(spriteNode, "sprite")) { SpriteReference *const currentSprite = new SpriteReference; - currentSprite->sprite = reinterpret_cast<const char*>( - spriteNode->xmlChildrenNode->content); + currentSprite->sprite = XmlChildContent(spriteNode); currentSprite->variant = XML::getProperty(spriteNode, "variant", 0); display.sprites.push_back(currentSprite); } else if (xmlNameEqual(spriteNode, "particlefx")) { - std::string particlefx = reinterpret_cast<const char*>( - spriteNode->xmlChildrenNode->content); + std::string particlefx = XmlChildContent(spriteNode); display.particles.push_back(particlefx); } } diff --git a/src/resources/db/skillunitdb.cpp b/src/resources/db/skillunitdb.cpp index d89eca896..30d0b3918 100644 --- a/src/resources/db/skillunitdb.cpp +++ b/src/resources/db/skillunitdb.cpp @@ -111,22 +111,20 @@ void SkillUnitDb::loadXmlFile(const std::string &fileName) SpriteDisplay display; for_each_xml_child_node(spriteNode, skillUnitNode) { - if (!spriteNode->xmlChildrenNode) + if (!XmlHaveChildContent(spriteNode)) continue; if (xmlNameEqual(spriteNode, "sprite")) { SpriteReference *const currentSprite = new SpriteReference; - currentSprite->sprite = reinterpret_cast<const char*>( - spriteNode->xmlChildrenNode->content); + currentSprite->sprite = XmlChildContent(spriteNode); currentSprite->variant = XML::getProperty(spriteNode, "variant", 0); display.sprites.push_back(currentSprite); } else if (xmlNameEqual(spriteNode, "particlefx")) { - std::string particlefx = reinterpret_cast<const char*>( - spriteNode->xmlChildrenNode->content); + std::string particlefx = XmlChildContent(spriteNode); display.particles.push_back(particlefx); } } diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 1c9e5af9f..9da094d54 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -614,14 +614,12 @@ bool MapReader::readBase64Layer(const XmlNodePtrConst childNode, } // Read base64 encoded map file - XmlNodePtrConst dataChild = childNode->xmlChildrenNode; - if (!dataChild) + if (!XmlHaveChildContent(childNode)) return true; - const size_t len = strlen( - reinterpret_cast<const char*>(dataChild->content)) + 1; + const size_t len = strlen(XmlChildContent(childNode)) + 1; unsigned char *charData = new unsigned char[len + 1]; - xmlChar *const xmlChars = xmlNodeGetContent(dataChild); + const char *const xmlChars = XmlChildContent(childNode); const char *charStart = reinterpret_cast<const char*>(xmlChars); if (!charStart) { @@ -649,7 +647,7 @@ bool MapReader::readBase64Layer(const XmlNodePtrConst childNode, charData))), &binLen); delete [] charData; - xmlFree(xmlChars); +// XmlFree(const_cast<char*>(xmlChars)); if (binData) { @@ -710,11 +708,10 @@ bool MapReader::readCsvLayer(const XmlNodePtrConst childNode, if (!map || !childNode) return false; - XmlNodePtrConst dataChild = childNode->xmlChildrenNode; - if (!dataChild) + if (!XmlHaveChildContent(childNode)) return true; - xmlChar *const xmlChars = xmlNodeGetContent(dataChild); + const char *const xmlChars = XmlChildContent(childNode); const char *const data = reinterpret_cast<const char*>(xmlChars); if (!data) return false; @@ -747,7 +744,7 @@ bool MapReader::readCsvLayer(const XmlNodePtrConst childNode, oldPos = pos + 1; } - xmlFree(xmlChars); + //XmlFree(const_cast<char*>(xmlChars)); return true; } |