summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-01-16 01:47:17 +0300
committerAndrei Karas <akaras@inbox.ru>2014-01-16 01:47:17 +0300
commitb293d99a34d21d137374e46386b8669907cb3c1d (patch)
tree7e5e20e2b81e239878c13229c4d02139e8b85c2b
parent34f943198afd1f7f342d63bd70d30cdeacd3dbad (diff)
downloadmv-b293d99a34d21d137374e46386b8669907cb3c1d.tar.gz
mv-b293d99a34d21d137374e46386b8669907cb3c1d.tar.bz2
mv-b293d99a34d21d137374e46386b8669907cb3c1d.tar.xz
mv-b293d99a34d21d137374e46386b8669907cb3c1d.zip
add missing const in xmlnode pointers.
-rw-r--r--src/configuration.cpp6
-rw-r--r--src/configuration.h2
-rw-r--r--src/effectmanager.cpp2
-rw-r--r--src/gui/theme.cpp4
-rw-r--r--src/gui/windows/equipmentwindow.h2
-rw-r--r--src/gui/windows/questswindow.cpp2
-rw-r--r--src/gui/windows/skilldialog.cpp2
-rw-r--r--src/gui/windows/updaterwindow.cpp2
-rw-r--r--src/particle/animationparticle.cpp2
-rw-r--r--src/particle/animationparticle.h2
-rw-r--r--src/particle/particle.cpp2
-rw-r--r--src/particle/particleemitter.cpp6
-rw-r--r--src/particle/particleemitter.h10
-rw-r--r--src/resources/beingcommon.cpp3
-rw-r--r--src/resources/beingcommon.h3
-rw-r--r--src/resources/db/avatardb.cpp2
-rw-r--r--src/resources/db/chardb.cpp2
-rw-r--r--src/resources/db/colordb.cpp4
-rw-r--r--src/resources/db/deaddb.cpp2
-rw-r--r--src/resources/db/emotedb.cpp4
-rw-r--r--src/resources/db/itemdb.cpp20
-rw-r--r--src/resources/db/mapdb.cpp12
-rw-r--r--src/resources/db/moddb.cpp2
-rw-r--r--src/resources/db/npcdb.cpp2
-rw-r--r--src/resources/db/petdb.cpp2
-rw-r--r--src/resources/db/sounddb.cpp2
-rw-r--r--src/resources/mapreader.cpp20
-rw-r--r--src/resources/mapreader.h13
-rw-r--r--src/resources/spritedef.cpp5
-rw-r--r--src/resources/spritedef.h9
-rw-r--r--src/statuseffect.cpp2
-rw-r--r--src/units.cpp2
-rw-r--r--src/utils/xml.cpp23
-rw-r--r--src/utils/xml.h23
34 files changed, 120 insertions, 81 deletions
diff --git a/src/configuration.cpp b/src/configuration.cpp
index cb7adf8f1..ca4542155 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -666,7 +666,7 @@ bool Configuration::resetBoolValue(const std::string &key)
}
-void ConfigurationObject::initFromXML(const XmlNodePtr parent_node)
+void ConfigurationObject::initFromXML(const XmlNodePtrConst parent_node)
{
clear();
@@ -729,7 +729,7 @@ void Configuration::init(const std::string &filename, const bool useResManager)
return;
}
- const XmlNodePtr rootNode = doc.rootNode();
+ const XmlNodePtrConst rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "configuration"))
{
@@ -749,7 +749,7 @@ void Configuration::reInit()
return;
}
- const XmlNodePtr rootNode = doc.rootNode();
+ const XmlNodePtrConst rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "configuration"))
{
diff --git a/src/configuration.h b/src/configuration.h
index 71f59d2fd..322d4c934 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -208,7 +208,7 @@ class ConfigurationObject
protected:
ConfigurationObject();
- virtual void initFromXML(const XmlNodePtr parent_node);
+ virtual void initFromXML(const XmlNodePtrConst parent_node);
virtual void writeToXML(const XmlTextWriterPtr writer);
void deleteList(const std::string &name);
diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp
index 6b5a4617c..6bf32ecb9 100644
--- a/src/effectmanager.cpp
+++ b/src/effectmanager.cpp
@@ -46,7 +46,7 @@ EffectManager::EffectManager() :
void EffectManager::loadXmlFile(const std::string &fileName)
{
XML::Document doc(fileName);
- const XmlNodePtr root = doc.rootNode();
+ const XmlNodePtrConst root = doc.rootNode();
if (!root || !xmlNameEqual(root, "being-effects"))
{
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index d78a5d5f5..44f2ca24e 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -1072,7 +1072,7 @@ void Theme::loadColors(std::string file)
file.append("/colors.xml");
XML::Document doc(resolveThemePath(file));
- const XmlNodePtr root = doc.rootNode();
+ const XmlNodePtrConst root = doc.rootNode();
if (!root || !xmlNameEqual(root, "colors"))
{
@@ -1260,7 +1260,7 @@ ThemeInfo *Theme::loadInfo(const std::string &themeName)
}
logger->log("loading: " + path);
XML::Document doc(path);
- const XmlNodePtr rootNode = doc.rootNode();
+ const XmlNodePtrConst rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "info"))
return nullptr;
diff --git a/src/gui/windows/equipmentwindow.h b/src/gui/windows/equipmentwindow.h
index 1877d1309..d291a5f81 100644
--- a/src/gui/windows/equipmentwindow.h
+++ b/src/gui/windows/equipmentwindow.h
@@ -115,7 +115,7 @@ class EquipmentWindow final : public Window, public gcn::ActionListener
void addBox(const int idx, int x, int y, const int imageIndex);
- void loadWindow(const XmlNodePtr windowNode);
+ void loadWindow(const XmlNodePtrConst windowNode);
void loadPlayerBox(const XmlNodePtr playerBoxNode);
diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp
index fff6f352a..e5f599f0f 100644
--- a/src/gui/windows/questswindow.cpp
+++ b/src/gui/windows/questswindow.cpp
@@ -225,7 +225,7 @@ QuestsWindow::~QuestsWindow()
void QuestsWindow::loadXmlFile(const std::string &fileName)
{
XML::Document doc(fileName);
- const XmlNodePtr root = doc.rootNode();
+ const XmlNodePtrConst root = doc.rootNode();
if (!root)
return;
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index aabe02e1c..197c60a90 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -441,7 +441,7 @@ void SkillDialog::loadSkills()
void SkillDialog::loadXmlFile(const std::string &fileName)
{
XML::Document doc(fileName);
- XmlNodePtr root = doc.rootNode();
+ XmlNodePtrConst root = doc.rootNode();
int setCount = 0;
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index fcb26cc36..5eebbaf13 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -64,7 +64,7 @@ static std::vector<UpdateFile> loadXMLFile(const std::string &fileName)
{
std::vector<UpdateFile> files;
XML::Document doc(fileName, false);
- const XmlNodePtr rootNode = doc.rootNode();
+ const XmlNodePtrConst rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "updates"))
{
diff --git a/src/particle/animationparticle.cpp b/src/particle/animationparticle.cpp
index d7f31ca1e..4381ceb8a 100644
--- a/src/particle/animationparticle.cpp
+++ b/src/particle/animationparticle.cpp
@@ -32,7 +32,7 @@ AnimationParticle::AnimationParticle(Animation *const animation) :
{
}
-AnimationParticle::AnimationParticle(XmlNodePtr const animationNode,
+AnimationParticle::AnimationParticle(XmlNodePtrConst animationNode,
const std::string& dyePalettes):
ImageParticle(nullptr),
mAnimation(new SimpleAnimation(animationNode, dyePalettes))
diff --git a/src/particle/animationparticle.h b/src/particle/animationparticle.h
index da4d8f6cd..8b9df63e4 100644
--- a/src/particle/animationparticle.h
+++ b/src/particle/animationparticle.h
@@ -35,7 +35,7 @@ class AnimationParticle final : public ImageParticle
public:
explicit AnimationParticle(Animation *const animation);
- explicit AnimationParticle(XmlNodePtr const animationNode,
+ explicit AnimationParticle(XmlNodePtrConst animationNode,
const std::string& dyePalettes
= std::string());
diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp
index 576b292fa..a9cc9993f 100644
--- a/src/particle/particle.cpp
+++ b/src/particle/particle.cpp
@@ -290,7 +290,7 @@ Particle *Particle::addEffect(const std::string &particleEffectFile,
const std::string dyePalettes = (pos != std::string::npos)
? particleEffectFile.substr(pos + 1) : "";
XML::Document doc(particleEffectFile.substr(0, pos));
- const XmlNodePtr rootNode = doc.rootNode();
+ const XmlNodePtrConst rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "effect"))
{
diff --git a/src/particle/particleemitter.cpp b/src/particle/particleemitter.cpp
index 13f9d8d41..27f01d4e1 100644
--- a/src/particle/particleemitter.cpp
+++ b/src/particle/particleemitter.cpp
@@ -43,7 +43,7 @@ static const float DEG_RAD_FACTOR = 0.017453293F;
typedef std::vector<ImageSet*>::const_iterator ImageSetVectorCIter;
typedef std::list<ParticleEmitter>::const_iterator ParticleEmitterListCIter;
-ParticleEmitter::ParticleEmitter(const XmlNodePtr emitterNode,
+ParticleEmitter::ParticleEmitter(const XmlNodePtrConst emitterNode,
Particle *const target,
Map *const map, const int rotation,
const std::string& dyePalettes) :
@@ -425,7 +425,7 @@ ParticleEmitter::ParticleEmitter(const ParticleEmitter &o)
*this = o;
}
-ImageSet *ParticleEmitter::getImageSet(XmlNodePtr node)
+ImageSet *ParticleEmitter::getImageSet(XmlNodePtrConst node)
{
ResourceManager *const resman = ResourceManager::getInstance();
ImageSet *imageset = nullptr;
@@ -525,7 +525,7 @@ ParticleEmitter::~ParticleEmitter()
}
template <typename T> ParticleEmitterProp<T>
-ParticleEmitter::readParticleEmitterProp(XmlNodePtr propertyNode, T def)
+ParticleEmitter::readParticleEmitterProp(XmlNodePtrConst propertyNode, T def)
{
ParticleEmitterProp<T> retval;
diff --git a/src/particle/particleemitter.h b/src/particle/particleemitter.h
index bf0e05ae5..9e149034f 100644
--- a/src/particle/particleemitter.h
+++ b/src/particle/particleemitter.h
@@ -43,8 +43,10 @@ class Particle;
class ParticleEmitter final
{
public:
- ParticleEmitter(const XmlNodePtr emitterNode, Particle *const target,
- Map *const map, const int rotation = 0,
+ ParticleEmitter(const XmlNodePtrConst emitterNode,
+ Particle *const target,
+ Map *const map,
+ const int rotation = 0,
const std::string& dyePalettes = std::string());
/**
@@ -82,9 +84,9 @@ class ParticleEmitter final
private:
template <typename T> ParticleEmitterProp<T>
- readParticleEmitterProp(XmlNodePtr propertyNode, T def);
+ readParticleEmitterProp(XmlNodePtrConst propertyNode, T def);
- ImageSet *getImageSet(XmlNodePtr node);
+ ImageSet *getImageSet(XmlNodePtrConst node);
/**
* initial position of particles:
diff --git a/src/resources/beingcommon.cpp b/src/resources/beingcommon.cpp
index 668d67259..7b7a57d9e 100644
--- a/src/resources/beingcommon.cpp
+++ b/src/resources/beingcommon.cpp
@@ -29,7 +29,8 @@
#include "debug.h"
-void BeingCommon::readBasicAttributes(BeingInfo *const info, XmlNodePtr node,
+void BeingCommon::readBasicAttributes(BeingInfo *const info,
+ XmlNodePtrConst node,
const std::string &hoverCursor)
{
info->setTargetCursorSize(XML::getProperty(node,
diff --git a/src/resources/beingcommon.h b/src/resources/beingcommon.h
index 5fb1df71b..6124de5a1 100644
--- a/src/resources/beingcommon.h
+++ b/src/resources/beingcommon.h
@@ -38,7 +38,8 @@ class BeingInfo;
namespace BeingCommon
{
- void readBasicAttributes(BeingInfo *const info, XmlNodePtr node,
+ void readBasicAttributes(BeingInfo *const info,
+ XmlNodePtrConst node,
const std::string &hoverCursor);
void getIncludeFiles(const std::string &dir, StringVect &list);
diff --git a/src/resources/db/avatardb.cpp b/src/resources/db/avatardb.cpp
index b522c6b76..e51a8d468 100644
--- a/src/resources/db/avatardb.cpp
+++ b/src/resources/db/avatardb.cpp
@@ -52,7 +52,7 @@ void AvatarDB::load()
void AvatarDB::loadXmlFile(const std::string &fileName)
{
XML::Document doc(fileName);
- const XmlNodePtr rootNode = doc.rootNode();
+ const XmlNodePtrConst rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "avatars"))
{
diff --git a/src/resources/db/chardb.cpp b/src/resources/db/chardb.cpp
index 80ddedc37..2d4e2fee2 100644
--- a/src/resources/db/chardb.cpp
+++ b/src/resources/db/chardb.cpp
@@ -48,7 +48,7 @@ void CharDB::load()
XML::Document *doc = new XML::Document(
paths.getStringValue("charCreationFile"));
- const XmlNodePtr root = doc->rootNode();
+ const XmlNodePtrConst root = doc->rootNode();
if (!root || !xmlNameEqual(root, "chars"))
{
diff --git a/src/resources/db/colordb.cpp b/src/resources/db/colordb.cpp
index 34e0614c0..1236a35f1 100644
--- a/src/resources/db/colordb.cpp
+++ b/src/resources/db/colordb.cpp
@@ -78,7 +78,7 @@ void ColorDB::loadHair(const std::string &fileName,
std::map<int, ItemColor> &colors)
{
XML::Document *doc = new XML::Document(fileName);
- XmlNodePtr root = doc->rootNode();
+ XmlNodePtrConst root = doc->rootNode();
if (!root || !xmlNameEqual(root, "colors"))
{
@@ -116,7 +116,7 @@ void ColorDB::loadHair(const std::string &fileName,
void ColorDB::loadColorLists(const std::string &fileName)
{
XML::Document *doc = new XML::Document(fileName);
- const XmlNodePtr root = doc->rootNode();
+ const XmlNodePtrConst root = doc->rootNode();
if (!root)
{
delete doc;
diff --git a/src/resources/db/deaddb.cpp b/src/resources/db/deaddb.cpp
index 870b77394..e66e87e6a 100644
--- a/src/resources/db/deaddb.cpp
+++ b/src/resources/db/deaddb.cpp
@@ -49,7 +49,7 @@ void DeadDB::load()
void DeadDB::loadXmlFile(const std::string &fileName)
{
XML::Document *doc = new XML::Document(fileName);
- const XmlNodePtr root = doc->rootNode();
+ const XmlNodePtrConst root = doc->rootNode();
if (!root || !xmlNameEqual(root, "messages"))
{
diff --git a/src/resources/db/emotedb.cpp b/src/resources/db/emotedb.cpp
index 7c710795f..594bcce5d 100644
--- a/src/resources/db/emotedb.cpp
+++ b/src/resources/db/emotedb.cpp
@@ -65,7 +65,7 @@ void EmoteDB::load()
void EmoteDB::loadXmlFile(const std::string &fileName)
{
XML::Document doc(fileName);
- XmlNodePtr rootNode = doc.rootNode();
+ XmlNodePtrConst rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "emotes"))
{
@@ -139,7 +139,7 @@ void EmoteDB::loadXmlFile(const std::string &fileName)
void EmoteDB::loadSpecialXmlFile(const std::string &fileName)
{
XML::Document doc(fileName);
- XmlNodePtr rootNode = doc.rootNode();
+ XmlNodePtrConst rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "emotes"))
{
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp
index 4c47658e6..9865cc3ef 100644
--- a/src/resources/db/itemdb.cpp
+++ b/src/resources/db/itemdb.cpp
@@ -48,13 +48,16 @@ namespace
extern int serverVersion;
// Forward declarations
-static void loadSpriteRef(ItemInfo *const itemInfo, const XmlNodePtr node);
-static void loadSoundRef(ItemInfo *const itemInfo, const XmlNodePtr node);
+static void loadSpriteRef(ItemInfo *const itemInfo,
+ const XmlNodePtr node);
+static void loadSoundRef(ItemInfo *const itemInfo,
+ const XmlNodePtr node);
static void loadFloorSprite(SpriteDisplay *const display,
- const XmlNodePtr node);
+ const XmlNodePtrConst node);
static void loadReplaceSprite(ItemInfo *const itemInfo,
const XmlNodePtr replaceNode);
-static void loadOrderSprite(ItemInfo *const itemInfo, const XmlNodePtr node,
+static void loadOrderSprite(ItemInfo *const itemInfo,
+ const XmlNodePtr node,
const bool drawAfter);
static int parseSpriteName(const std::string &name);
static int parseDirectionName(const std::string &name);
@@ -757,7 +760,8 @@ void loadSoundRef(ItemInfo *const itemInfo, const XmlNodePtr node)
}
}
-void loadFloorSprite(SpriteDisplay *const display, const XmlNodePtr floorNode)
+void loadFloorSprite(SpriteDisplay *const display,
+ const XmlNodePtrConst floorNode)
{
for_each_xml_child_node(spriteNode, floorNode)
{
@@ -778,7 +782,8 @@ void loadFloorSprite(SpriteDisplay *const display, const XmlNodePtr floorNode)
}
}
-void loadReplaceSprite(ItemInfo *const itemInfo, const XmlNodePtr replaceNode)
+void loadReplaceSprite(ItemInfo *const itemInfo,
+ const XmlNodePtr replaceNode)
{
const std::string removeSprite = XML::getProperty(
replaceNode, "sprite", "");
@@ -909,7 +914,8 @@ void loadReplaceSprite(ItemInfo *const itemInfo, const XmlNodePtr replaceNode)
}
}
-void loadOrderSprite(ItemInfo *const itemInfo, const XmlNodePtr node,
+void loadOrderSprite(ItemInfo *const itemInfo,
+ const XmlNodePtr node,
const bool drawAfter)
{
const int sprite = parseSpriteName(XML::getProperty(node, "name", ""));
diff --git a/src/resources/db/mapdb.cpp b/src/resources/db/mapdb.cpp
index 4b5fb0f42..20d108f13 100644
--- a/src/resources/db/mapdb.cpp
+++ b/src/resources/db/mapdb.cpp
@@ -38,8 +38,8 @@ namespace
namespace MapDB
{
- void readMap(XmlNodePtr node);
- void readAtlas(XmlNodePtr node);
+ void readMap(XmlNodePtrConst node);
+ void readAtlas(XmlNodePtrConst node);
}
void MapDB::load()
@@ -59,7 +59,7 @@ void MapDB::loadRemap()
XML::Document *const doc = new XML::Document(
paths.getStringValue("mapsRemapFile"));
- const XmlNodePtr root = doc->rootNode();
+ const XmlNodePtrConst root = doc->rootNode();
if (!root)
{
delete doc;
@@ -85,7 +85,7 @@ void MapDB::loadRemap()
delete doc;
}
-void MapDB::readMap(XmlNodePtr node)
+void MapDB::readMap(XmlNodePtrConst node)
{
const std::string map = XML::getProperty(node, "name", "");
if (map.empty())
@@ -103,7 +103,7 @@ void MapDB::readMap(XmlNodePtr node)
}
}
-void MapDB::readAtlas(XmlNodePtr node)
+void MapDB::readAtlas(XmlNodePtrConst node)
{
const std::string atlas = XML::getProperty(node, "name", "");
if (atlas.empty())
@@ -132,7 +132,7 @@ void MapDB::readAtlas(XmlNodePtr node)
void MapDB::loadInfo(const std::string &fileName)
{
XML::Document *doc = new XML::Document(fileName);
- const XmlNodePtr root = doc->rootNode();
+ const XmlNodePtrConst root = doc->rootNode();
if (!root)
{
delete doc;
diff --git a/src/resources/db/moddb.cpp b/src/resources/db/moddb.cpp
index 32846696b..4cdc96b3d 100644
--- a/src/resources/db/moddb.cpp
+++ b/src/resources/db/moddb.cpp
@@ -51,7 +51,7 @@ void ModDB::load()
void ModDB::loadXmlFile(const std::string &fileName)
{
XML::Document doc(fileName);
- const XmlNodePtr rootNode = doc.rootNode();
+ const XmlNodePtrConst rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "mods"))
{
diff --git a/src/resources/db/npcdb.cpp b/src/resources/db/npcdb.cpp
index 412de1a1b..359c86c4a 100644
--- a/src/resources/db/npcdb.cpp
+++ b/src/resources/db/npcdb.cpp
@@ -57,7 +57,7 @@ void NPCDB::load()
void NPCDB::loadXmlFile(const std::string &fileName)
{
XML::Document doc(fileName);
- const XmlNodePtr rootNode = doc.rootNode();
+ const XmlNodePtrConst rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "npcs"))
{
diff --git a/src/resources/db/petdb.cpp b/src/resources/db/petdb.cpp
index 0529ee874..c9f3bdbeb 100644
--- a/src/resources/db/petdb.cpp
+++ b/src/resources/db/petdb.cpp
@@ -56,7 +56,7 @@ void PETDB::load()
void PETDB::loadXmlFile(const std::string &fileName)
{
XML::Document doc(fileName);
- const XmlNodePtr rootNode = doc.rootNode();
+ const XmlNodePtrConst rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "pets"))
{
diff --git a/src/resources/db/sounddb.cpp b/src/resources/db/sounddb.cpp
index ad98b2705..17ff4bc71 100644
--- a/src/resources/db/sounddb.cpp
+++ b/src/resources/db/sounddb.cpp
@@ -47,7 +47,7 @@ void SoundDB::load()
void SoundDB::loadXmlFile(const std::string &fileName)
{
XML::Document *doc = new XML::Document(fileName);
- const XmlNodePtr root = doc->rootNode();
+ const XmlNodePtrConst root = doc->rootNode();
if (!root || !xmlNameEqual(root, "sounds"))
{
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 9caa14945..bcafe4bb7 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -227,7 +227,7 @@ Map *MapReader::readMap(const std::string &restrict filename,
XML::Document doc(reinterpret_cast<char*>(inflated), inflatedSize);
free(inflated);
- XmlNodePtr node = doc.rootNode();
+ XmlNodePtrConst node = doc.rootNode();
// Parse the inflated map data
if (node)
@@ -256,7 +256,7 @@ Map *MapReader::readMap(const std::string &restrict filename,
return map;
}
-Map *MapReader::readMap(XmlNodePtr node, const std::string &path)
+Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path)
{
if (!node)
return nullptr;
@@ -405,7 +405,8 @@ Map *MapReader::readMap(XmlNodePtr node, const std::string &path)
return map;
}
-void MapReader::readProperties(const XmlNodePtr node, Properties *const props)
+void MapReader::readProperties(const XmlNodePtrConst node,
+ Properties *const props)
{
if (!node || !props)
return;
@@ -511,7 +512,8 @@ inline static void setTile(Map *const map, MapLayer *const layer,
} \
} \
-bool MapReader::readBase64Layer(const XmlNodePtr childNode, Map *const map,
+bool MapReader::readBase64Layer(const XmlNodePtrConst childNode,
+ Map *const map,
MapLayer *const layer,
const MapLayer::Type &layerType,
MapHeights *const heights,
@@ -528,7 +530,7 @@ bool MapReader::readBase64Layer(const XmlNodePtr childNode, Map *const map,
}
// Read base64 encoded map file
- XmlNodePtr dataChild = childNode->xmlChildrenNode;
+ XmlNodePtrConst dataChild = childNode->xmlChildrenNode;
if (!dataChild)
return true;
@@ -613,14 +615,15 @@ bool MapReader::readBase64Layer(const XmlNodePtr childNode, Map *const map,
return true;
}
-bool MapReader::readCsvLayer(const XmlNodePtr childNode, Map *const map,
+bool MapReader::readCsvLayer(const XmlNodePtrConst childNode,
+ Map *const map,
MapLayer *const layer,
const MapLayer::Type &layerType,
MapHeights *const heights,
int &restrict x, int &restrict y,
const int w, const int h)
{
- XmlNodePtr dataChild = childNode->xmlChildrenNode;
+ XmlNodePtrConst dataChild = childNode->xmlChildrenNode;
if (!dataChild)
return true;
@@ -803,7 +806,8 @@ void MapReader::readLayer(const XmlNodePtr node, Map *const map)
}
}
-Tileset *MapReader::readTileset(XmlNodePtr node, const std::string &path,
+Tileset *MapReader::readTileset(XmlNodePtr node,
+ const std::string &path,
Map *const map)
{
if (!map)
diff --git a/src/resources/mapreader.h b/src/resources/mapreader.h
index 3573fcc89..4f84f1a1a 100644
--- a/src/resources/mapreader.h
+++ b/src/resources/mapreader.h
@@ -52,7 +52,7 @@ class MapReader final
* Read an XML map from a parsed XML tree. The path is used to find the
* location of referenced tileset images.
*/
- static Map *readMap(XmlNodePtr node,
+ static Map *readMap(XmlNodePtrConst node,
const std::string &path) A_WARN_UNUSED;
static Map *createEmptyMap(const std::string &restrict filename,
@@ -67,7 +67,7 @@ class MapReader final
* @param props The Properties instance to which the properties will
* be assigned.
*/
- static void readProperties(const XmlNodePtr node,
+ static void readProperties(const XmlNodePtrConst node,
Properties *const props);
/**
@@ -75,7 +75,8 @@ class MapReader final
*/
static void readLayer(const XmlNodePtr node, Map *const map);
- static bool readBase64Layer(const XmlNodePtr childNode, Map *const map,
+ static bool readBase64Layer(const XmlNodePtrConst childNode,
+ Map *const map,
MapLayer *const layer,
const MapLayer::Type &layerType,
MapHeights *const heights,
@@ -83,7 +84,8 @@ class MapReader final
int &restrict x, int &restrict y,
const int w, const int h);
- static bool readCsvLayer(const XmlNodePtr childNode, Map *const map,
+ static bool readCsvLayer(const XmlNodePtrConst childNode,
+ Map *const map,
MapLayer *const layer,
const MapLayer::Type &layerType,
MapHeights *const heights,
@@ -93,7 +95,8 @@ class MapReader final
/**
* Reads a tile set.
*/
- static Tileset *readTileset(XmlNodePtr node, const std::string &path,
+ static Tileset *readTileset(XmlNodePtr node,
+ const std::string &path,
Map *const map) A_WARN_UNUSED;
static void updateMusic(Map *const map);
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index 9970063c8..e37aa1aa8 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -85,7 +85,7 @@ SpriteDef *SpriteDef::load(const std::string &animationFile,
palettes = animationFile.substr(pos + 1);
XML::Document doc(animationFile.substr(0, pos));
- XmlNodePtr rootNode = doc.rootNode();
+ XmlNodePtrConst rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "sprite"))
{
@@ -225,7 +225,8 @@ void SpriteDef::loadImageSet(const XmlNodePtr node,
mImageSets[name] = imageSet;
}
-void SpriteDef::loadAction(const XmlNodePtr node, const int variant_offset)
+void SpriteDef::loadAction(const XmlNodePtr node,
+ const int variant_offset)
{
const std::string actionName = XML::getProperty(node, "name", "");
const std::string imageSetName = XML::getProperty(node, "imageset", "");
diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h
index fe84096c3..ecedde507 100644
--- a/src/resources/spritedef.h
+++ b/src/resources/spritedef.h
@@ -185,18 +185,21 @@ class SpriteDef final : public Resource
/**
* Loads a sprite element.
*/
- void loadSprite(const XmlNodePtr spriteNode, const int variant,
+ void loadSprite(const XmlNodePtr spriteNode,
+ const int variant,
const std::string &palettes = "");
/**
* Loads an imageset element.
*/
- void loadImageSet(const XmlNodePtr node, const std::string &palettes);
+ void loadImageSet(const XmlNodePtr node,
+ const std::string &palettes);
/**
* Loads an action element.
*/
- void loadAction(const XmlNodePtr node, const int variant_offset);
+ void loadAction(const XmlNodePtr node,
+ const int variant_offset);
/**
* Loads an animation element.
diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp
index 33579b2dc..049c010b3 100644
--- a/src/statuseffect.cpp
+++ b/src/statuseffect.cpp
@@ -138,7 +138,7 @@ void StatusEffect::load()
void StatusEffect::loadXmlFile(const std::string &fileName)
{
XML::Document doc(fileName);
- const XmlNodePtr rootNode = doc.rootNode();
+ const XmlNodePtrConst rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "status-effects"))
{
diff --git a/src/units.cpp b/src/units.cpp
index 7260acf68..f095d7bbf 100644
--- a/src/units.cpp
+++ b/src/units.cpp
@@ -112,7 +112,7 @@ void Units::loadUnits()
void Units::loadXmlFile(const std::string &fileName)
{
XML::Document doc(fileName);
- const XmlNodePtr root = doc.rootNode();
+ const XmlNodePtrConst root = doc.rootNode();
if (!root || !xmlNameEqual(root, "units"))
{
diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp
index a2de26ee3..94fc18f98 100644
--- a/src/utils/xml.cpp
+++ b/src/utils/xml.cpp
@@ -140,7 +140,9 @@ namespace XML
return mDoc ? xmlDocGetRootElement(mDoc) : nullptr;
}
- int getProperty(const XmlNodePtr node, const char *const name, int def)
+ int getProperty(const XmlNodePtr node,
+ const char *const name,
+ int def)
{
int &ret = def;
@@ -154,8 +156,11 @@ namespace XML
return ret;
}
- int getIntProperty(const XmlNodePtr node, const char *const name, int def,
- const int min, const int max)
+ int getIntProperty(const XmlNodePtr node,
+ const char *const name,
+ int def,
+ const int min,
+ const int max)
{
int &ret = def;
@@ -172,7 +177,8 @@ namespace XML
return ret;
}
- double getFloatProperty(const XmlNodePtr node, const char *const name,
+ double getFloatProperty(const XmlNodePtr node,
+ const char *const name,
double def)
{
double &ret = def;
@@ -187,7 +193,8 @@ namespace XML
return ret;
}
- std::string getProperty(const XmlNodePtr node, const char *const name,
+ std::string getProperty(const XmlNodePtr node,
+ const char *const name,
const std::string &def)
{
xmlChar *const prop = XmlGetProp(node, name);
@@ -201,7 +208,8 @@ namespace XML
return def;
}
- std::string langProperty(const XmlNodePtr node, const char *const name,
+ std::string langProperty(const XmlNodePtr node,
+ const char *const name,
const std::string &def)
{
std::string str = getProperty(node, name, def);
@@ -211,7 +219,8 @@ namespace XML
return translator->getStr(str);
}
- bool getBoolProperty(const XmlNodePtr node, const char *const name,
+ bool getBoolProperty(const XmlNodePtr node,
+ const char *const name,
const bool def)
{
const xmlChar *const prop = XmlGetProp(node, name);
diff --git a/src/utils/xml.h b/src/utils/xml.h
index 0fa0ba078..5c1fb7605 100644
--- a/src/utils/xml.h
+++ b/src/utils/xml.h
@@ -31,6 +31,7 @@
#include "localconsts.h"
#define XmlNodePtr xmlNodePtr
+#define XmlNodePtrConst xmlNode *const
#define XmlStrEqual(str1, str2) xmlStrEqual(str1, \
reinterpret_cast<const xmlChar*>(str2))
#define xmlNameEqual(node, str) xmlStrEqual((node)->name, \
@@ -96,37 +97,45 @@ namespace XML
/**
* Gets an floating point property from an XmlNodePtr.
*/
- double getFloatProperty(const XmlNodePtr node, const char *const name,
+ double getFloatProperty(const XmlNodePtr node,
+ const char *const name,
double def) A_WARN_UNUSED;
/**
* Gets an integer property from an XmlNodePtr.
*/
- int getProperty(const XmlNodePtr node, const char *const name,
+ int getProperty(const XmlNodePtr node,
+ const char *const name,
int def) A_WARN_UNUSED;
/**
* Gets an integer property from an XmlNodePtr.
*/
- int getIntProperty(const XmlNodePtr node, const char *const name, int def,
- const int min, const int max) A_WARN_UNUSED;
+ int getIntProperty(const XmlNodePtr node,
+ const char *const name,
+ int def,
+ const int min,
+ const int max) A_WARN_UNUSED;
/**
* Gets a string property from an XmlNodePtr.
*/
- std::string getProperty(const XmlNodePtr node, const char *const name,
+ std::string getProperty(const XmlNodePtr node,
+ const char *const name,
const std::string &def) A_WARN_UNUSED;
/**
* Gets a translated string property from an XmlNodePtr.
*/
- std::string langProperty(const XmlNodePtr node, const char *const name,
+ std::string langProperty(const XmlNodePtr node,
+ const char *const name,
const std::string &def) A_WARN_UNUSED;
/**
* Gets a boolean property from an XmlNodePtr.
*/
- bool getBoolProperty(const XmlNodePtr node, const char *const name,
+ bool getBoolProperty(const XmlNodePtr node,
+ const char *const name,
const bool def) A_WARN_UNUSED;
/**