summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2018-11-12 00:24:41 +0300
committerAndrei Karas <akaras@inbox.ru>2018-11-12 18:48:11 +0300
commit7c74a98fb966213ccbdba6e397a6d8a9502f2b17 (patch)
tree60ae28a9b6598889881312fa08360d086f47241c
parentc3b5c3ad370358d4e10b4cbe787dbbd61ce82c08 (diff)
downloadplus-7c74a98fb966213ccbdba6e397a6d8a9502f2b17.tar.gz
plus-7c74a98fb966213ccbdba6e397a6d8a9502f2b17.tar.bz2
plus-7c74a98fb966213ccbdba6e397a6d8a9502f2b17.tar.xz
plus-7c74a98fb966213ccbdba6e397a6d8a9502f2b17.zip
Add missing constexpr and noexcept into maplayer.
-rw-r--r--src/localconsts.h8
-rw-r--r--src/resources/map/maplayer.cpp15
-rw-r--r--src/resources/map/maplayer.h40
3 files changed, 34 insertions, 29 deletions
diff --git a/src/localconsts.h b/src/localconsts.h
index 523f80569..af5d2b002 100644
--- a/src/localconsts.h
+++ b/src/localconsts.h
@@ -91,6 +91,14 @@
name &operator=(const name&) = delete;
#endif // !defined(__GXX_EXPERIMENTAL_CXX0X__)
+#ifdef __clang__
+#define constexpr3
+#elif GCC_VERSION > 70000
+#define constexpr3 constexpr
+#else
+#define constexpr3
+#endif
+
#ifdef __GNUC__
#define A_UNUSED __attribute__ ((unused))
#define A_WARN_UNUSED __attribute__ ((warn_unused_result))
diff --git a/src/resources/map/maplayer.cpp b/src/resources/map/maplayer.cpp
index 0f8c4377b..ce9813c63 100644
--- a/src/resources/map/maplayer.cpp
+++ b/src/resources/map/maplayer.cpp
@@ -96,13 +96,6 @@ void MapLayer::optionChanged(const std::string &value) restrict
}
}
-void MapLayer::setTile(const int x,
- const int y,
- Image *const img) restrict
-{
- mTiles[x + y * mWidth].image = img;
-}
-
void MapLayer::draw(Graphics *const graphics,
int startX,
int startY,
@@ -765,14 +758,6 @@ int MapLayer::getEmptyTileDrawWidth(const TileInfo *restrict tilePtr,
return c;
}
-void MapLayer::setDrawLayerFlags(const MapTypeT &n) restrict
-{
- mDrawLayerFlags = n;
- mSpecialFlag = (mDrawLayerFlags != MapType::SPECIAL &&
- mDrawLayerFlags != MapType::SPECIAL2 &&
- mDrawLayerFlags != MapType::SPECIAL4);
-}
-
void MapLayer::updateConditionTiles(const MetaTile *const metaTiles,
const int width,
const int height) restrict
diff --git a/src/resources/map/maplayer.h b/src/resources/map/maplayer.h
index 081b2537e..5794ca635 100644
--- a/src/resources/map/maplayer.h
+++ b/src/resources/map/maplayer.h
@@ -74,15 +74,18 @@ class MapLayer final : public MemoryCounter, public ConfigListener
/**
* Set tile image, with x and y in layer coordinates.
*/
- void setTile(const int x,
- const int y,
- Image *restrict const img) restrict;
+ constexpr3 void setTile(const int x,
+ const int y,
+ Image *restrict const img) restrict
+ {
+ mTiles[x + y * mWidth].image = img;
+ }
/**
* Set tile image with x + y * width already known.
*/
- void setTile(const int index,
- Image *restrict const img) restrict
+ constexpr3 void setTile(const int index,
+ Image *restrict const img) restrict
{ mTiles[index].image = img; }
/**
@@ -134,27 +137,36 @@ class MapLayer final : public MemoryCounter, public ConfigListener
const int scrollY,
const Actors &actors) const restrict A_NONNULL(2);
- bool isFringeLayer() const restrict noexcept2 A_WARN_UNUSED
+ constexpr3 bool isFringeLayer() const restrict noexcept2 A_WARN_UNUSED
{ return mIsFringeLayer; }
- void setSpecialLayer(const SpecialLayer *restrict const val) restrict
+ constexpr3 void setSpecialLayer(const SpecialLayer *restrict const val)
+ restrict noexcept2
{ mSpecialLayer = val; }
- void setTempLayer(const SpecialLayer *restrict const val) restrict
+ constexpr3 void setTempLayer(const SpecialLayer *restrict const val)
+ restrict noexcept2
{ mTempLayer = val; }
- int getWidth() const restrict noexcept2 A_WARN_UNUSED
+ constexpr3 int getWidth() const restrict noexcept2 A_WARN_UNUSED
{ return mWidth; }
- int getHeight() const restrict noexcept2 A_WARN_UNUSED
+ constexpr3 int getHeight() const restrict noexcept2 A_WARN_UNUSED
{ return mHeight; }
void optionChanged(const std::string &restrict value)
restrict override final;
- void setDrawLayerFlags(const MapTypeT &restrict n) restrict;
+ constexpr3 void setDrawLayerFlags(const MapTypeT &restrict n)
+ restrict noexcept2
+ {
+ mDrawLayerFlags = n;
+ mSpecialFlag = (mDrawLayerFlags != MapType::SPECIAL &&
+ mDrawLayerFlags != MapType::SPECIAL2 &&
+ mDrawLayerFlags != MapType::SPECIAL4);
+ }
- void setActorsFix(const int y) restrict
+ constexpr3 void setActorsFix(const int y) restrict noexcept2
{ mActorsFix = y; }
int calcMemoryLocal() const override final;
@@ -165,12 +177,12 @@ class MapLayer final : public MemoryCounter, public ConfigListener
{ return mName; }
#ifdef UNITTESTS
- TileInfo *getTiles() const
+ constexpr3 TileInfo *getTiles() const restrict noexcept2
{
return mTiles;
}
- void setTileCondition(const int c)
+ constexpr3 void setTileCondition(const int c) restrict noexcept2
{
mTileCondition = c;
}