summaryrefslogtreecommitdiff
path: root/src/resources/mapreader.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-01-26 16:07:54 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-01-26 16:07:54 +0100
commit5afe88df2538274859a162ffd63ed52118e80c19 (patch)
treeb610dfd58dc748fd63f49565b2a43eea2316714f /src/resources/mapreader.cpp
parent73ba2a95f5bd4a0dd09af52d5864800be2b0a4c6 (diff)
downloadmana-5afe88df2538274859a162ffd63ed52118e80c19.tar.gz
mana-5afe88df2538274859a162ffd63ed52118e80c19.tar.bz2
mana-5afe88df2538274859a162ffd63ed52118e80c19.tar.xz
mana-5afe88df2538274859a162ffd63ed52118e80c19.zip
Apply C++11 fixits
modernize-use-auto modernize-use-nullptr modernize-use-override modernize-use-using
Diffstat (limited to 'src/resources/mapreader.cpp')
-rw-r--r--src/resources/mapreader.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index b2642ae8..af41da12 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -68,7 +68,7 @@ static std::string resolveRelativePath(std::string base, std::string relative)
Map *MapReader::readMap(const std::string &filename)
{
logger->log("Attempting to read map %s", filename.c_str());
- Map *map = NULL;
+ Map *map = nullptr;
XML::Document doc(filename);
@@ -111,7 +111,7 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path)
logger->log("MapReader: Warning: "
"Unitialized tile width or height value for map: %s",
path.c_str());
- return 0;
+ return nullptr;
}
Map *map = new Map(w, h, tilew, tileh);
@@ -237,7 +237,7 @@ static void setTile(Map *map, MapLayer *layer, int x, int y, unsigned gid)
if (layer)
{
// Set regular tile on a layer
- Image * const img = set ? set->get(gid - set->getFirstGid()) : 0;
+ Image * const img = set ? set->get(gid - set->getFirstGid()) : nullptr;
layer->setTile(x, y, img);
}
else
@@ -261,7 +261,7 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
const bool isFringeLayer = (name.substr(0,6) == "fringe");
const bool isCollisionLayer = (name.substr(0,9) == "collision");
- MapLayer *layer = 0;
+ MapLayer *layer = nullptr;
if (!isCollisionLayer)
{
@@ -300,7 +300,7 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
continue;
int len = strlen((const char*)dataChild->content) + 1;
- unsigned char *charData = new unsigned char[len + 1];
+ auto *charData = new unsigned char[len + 1];
const char *charStart = (const char*) xmlNodeGetContent(dataChild);
unsigned char *charIndex = charData;
@@ -440,8 +440,8 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path,
unsigned firstGid = XML::getProperty(node, "firstgid", 0);
int margin = XML::getProperty(node, "margin", 0);
int spacing = XML::getProperty(node, "spacing", 0);
- XML::Document* doc = NULL;
- Tileset *set = NULL;
+ XML::Document* doc = nullptr;
+ Tileset *set = nullptr;
std::string pathDir(path);
if (xmlHasProp(node, BAD_CAST "source"))
@@ -507,7 +507,7 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path,
// create animation
if (!set) continue;
- Animation *ani = new Animation;
+ auto *ani = new Animation;
for (int i = 0; ;i++)
{
std::map<std::string, int>::iterator iFrame, iDelay;