summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-07 18:37:50 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-07 18:37:50 +0300
commit3dbdda0d3070a093f8a341f897ce4310a8b52bd2 (patch)
treeddb5a48767c97cbb95e8204acfeb667483477051 /src
parent3173688b7c1a1027257aa057039bd50738ac8bb5 (diff)
downloadmanaverse-3dbdda0d3070a093f8a341f897ce4310a8b52bd2.tar.gz
manaverse-3dbdda0d3070a093f8a341f897ce4310a8b52bd2.tar.bz2
manaverse-3dbdda0d3070a093f8a341f897ce4310a8b52bd2.tar.xz
manaverse-3dbdda0d3070a093f8a341f897ce4310a8b52bd2.zip
Add some missing nonnull attributes to map/maplayer classes.
Diffstat (limited to 'src')
-rw-r--r--src/resources/map/map.cpp6
-rw-r--r--src/resources/map/map.h12
-rw-r--r--src/resources/map/maplayer.h4
-rw-r--r--src/resources/mapreader.cpp11
-rw-r--r--src/resources/mapreader.h13
5 files changed, 24 insertions, 22 deletions
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp
index b2697ddcf..ada25e3d6 100644
--- a/src/resources/map/map.cpp
+++ b/src/resources/map/map.cpp
@@ -163,8 +163,6 @@ Map::~Map()
config.removeListeners(this);
CHECKLISTENERS
- delete [] mMetaTiles;
-
if (mWalkLayer)
{
mWalkLayer->decRef();
@@ -186,6 +184,7 @@ Map::~Map()
mAtlas = nullptr;
}
delete2(mHeights);
+ delete [] mMetaTiles;
}
void Map::optionChanged(const std::string &restrict value) restrict2
@@ -298,9 +297,6 @@ void Map::addLayer(MapLayer *const layer) restrict2
void Map::addTileset(Tileset *const tileset) restrict2
{
- if (!tileset)
- return;
-
mTilesets.push_back(tileset);
const int height = tileset->getHeight();
if (height > mMaxTileHeight)
diff --git a/src/resources/map/map.h b/src/resources/map/map.h
index 3ffedc3de..61d328313 100644
--- a/src/resources/map/map.h
+++ b/src/resources/map/map.h
@@ -125,12 +125,12 @@ class Map final : public Properties, public ConfigListener
/**
* Adds a layer to this map. The map takes ownership of the layer.
*/
- void addLayer(MapLayer *const layer) restrict2;
+ void addLayer(MapLayer *const layer) restrict2 A_NONNULL(2);
/**
* Adds a tileset to this map. The map takes ownership of the tileset.
*/
- void addTileset(Tileset *const tileset) restrict2;
+ void addTileset(Tileset *const tileset) restrict2 A_NONNULL(2);
/**
* Finds the tile set that a tile with the given global id is part of.
@@ -229,7 +229,8 @@ class Map final : public Properties, public ConfigListener
* Adds a tile animation to the map
*/
void addAnimation(const int gid,
- TileAnimation *restrict const animation) restrict2;
+ TileAnimation *restrict const animation) restrict2
+ A_NONNULL(3);
void setDrawLayersFlags(const MapTypeT &restrict n) restrict2;
@@ -348,7 +349,8 @@ class Map final : public Properties, public ConfigListener
void setWalkLayer(WalkLayer *restrict const layer) restrict2 noexcept
{ mWalkLayer = layer; }
- void addHeights(const MapHeights *restrict const heights) restrict2;
+ void addHeights(const MapHeights *restrict const heights) restrict2
+ A_NONNULL(2);
uint8_t getHeightOffset(const int x, const int y) const restrict2;
@@ -368,7 +370,7 @@ class Map final : public Properties, public ConfigListener
/**
* Adds an actor to the map.
*/
- Actors::iterator addActor(Actor *const actor) restrict2;
+ Actors::iterator addActor(Actor *const actor) restrict2 A_NONNULL(2);
/**
* Removes an actor from the map.
diff --git a/src/resources/map/maplayer.h b/src/resources/map/maplayer.h
index b4aec3ac3..45dcaec02 100644
--- a/src/resources/map/maplayer.h
+++ b/src/resources/map/maplayer.h
@@ -165,11 +165,11 @@ class MapLayer final: public ConfigListener
protected:
static int getTileDrawWidth(const TileInfo *restrict img,
const int endX,
- int &width) A_WARN_UNUSED;
+ int &width) A_WARN_UNUSED A_NONNULL(1);
void updateConditionTiles(MetaTile *restrict const metaTiles,
const int width,
- const int height) restrict;
+ const int height) restrict A_NONNULL(2);
private:
const int mX;
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 6078d8d7e..555185094 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -295,7 +295,10 @@ void MapReader::unloadTempLayers()
mKnownDocs.clear();
}
-static void loadReplaceLayer(const LayerInfoIterator &it, Map *const map)
+static void loadReplaceLayer(const LayerInfoIterator &it,
+ Map *const map) A_NONNULL(2);
+static void loadReplaceLayer(const LayerInfoIterator &it,
+ Map *const map)
{
MapReader::readLayer((*it).second, map);
}
@@ -604,7 +607,7 @@ bool MapReader::readBase64Layer(const XmlNodePtrConst childNode,
int &restrict x, int &restrict y,
const int w, const int h)
{
- if (!map || !childNode)
+ if (!childNode)
return false;
if (!compression.empty() && compression != "gzip"
@@ -707,7 +710,7 @@ bool MapReader::readCsvLayer(const XmlNodePtrConst childNode,
int &restrict x, int &restrict y,
const int w, const int h)
{
- if (!map || !childNode)
+ if (!childNode)
return false;
if (!XmlHaveChildContent(childNode))
@@ -751,7 +754,7 @@ bool MapReader::readCsvLayer(const XmlNodePtrConst childNode,
void MapReader::readLayer(const XmlNodePtr node, Map *const map)
{
- if (!map || !node)
+ if (!node)
return;
// Layers are not necessarily the same size as the map
diff --git a/src/resources/mapreader.h b/src/resources/mapreader.h
index 7afd72109..27fc44271 100644
--- a/src/resources/mapreader.h
+++ b/src/resources/mapreader.h
@@ -60,7 +60,8 @@ class MapReader final
/**
* Reads a map layer and adds it to the given map.
*/
- static void readLayer(const XmlNodePtr node, Map *const map);
+ static void readLayer(const XmlNodePtr node,
+ Map *const map) A_NONNULL(2);
private:
/**
@@ -71,7 +72,7 @@ class MapReader final
* be assigned.
*/
static void readProperties(const XmlNodePtrConst node,
- Properties *const props);
+ Properties *const props) A_NONNULL(2);
static bool readBase64Layer(const XmlNodePtrConst childNode,
Map *const map,
@@ -80,7 +81,7 @@ class MapReader final
MapHeights *const heights,
const std::string &compression,
int &restrict x, int &restrict y,
- const int w, const int h);
+ const int w, const int h) A_NONNULL(2);
static bool readCsvLayer(const XmlNodePtrConst childNode,
Map *const map,
@@ -88,16 +89,16 @@ class MapReader final
const MapLayer::Type &layerType,
MapHeights *const heights,
int &restrict x, int &restrict y,
- const int w, const int h);
+ const int w, const int h) A_NONNULL(2);
/**
* Reads a tile set.
*/
static Tileset *readTileset(XmlNodePtr node,
const std::string &path,
- Map *const map) A_WARN_UNUSED;
+ Map *const map) A_WARN_UNUSED A_NONNULL(3);
- static void updateMusic(Map *const map);
+ static void updateMusic(Map *const map) A_NONNULL(1);
static void addLayerToList(const std::string &fileName);