summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/Makefile.am1
-rw-r--r--src/being/compoundsprite.h6
-rw-r--r--src/game.h2
-rw-r--r--src/graphicsmanager.h2
-rw-r--r--src/gui/color.cpp149
-rw-r--r--src/gui/color.h83
-rw-r--r--src/input/joystick.h2
-rw-r--r--src/resources/fboinfo.h2
-rw-r--r--src/resources/imagehelper.h6
-rw-r--r--src/resources/mstack.h2
-rw-r--r--src/resources/openglimagehelper.h12
-rw-r--r--src/resources/safeopenglimagehelper.h8
-rw-r--r--src/resources/sdl2imagehelper.h7
-rw-r--r--src/resources/sdl2softwareimagehelper.h6
-rw-r--r--src/resources/sdlimagehelper.h4
-rw-r--r--src/resources/sprite/animatedsprite.h2
-rw-r--r--src/resources/surfaceimagehelper.h4
18 files changed, 105 insertions, 196 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 55fd86d09..f7b7282f4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1327,7 +1327,6 @@ SET(SRCS
enums/gui/chatmsgtype.h
enums/gui/chattabtype.h
gui/cliprect.h
- gui/color.cpp
gui/color.h
gui/colorpair.h
enums/gui/dialogtype.h
@@ -1399,7 +1398,6 @@ SET(SRCS
gui/widgets/basiccontainer2.h
gui/widgets/basiccontainer.cpp
gui/cliprect.cpp
- gui/color.cpp
gui/dialogsmanager.cpp
gui/dialogsmanager.h
input/key.cpp
@@ -1614,7 +1612,6 @@ SET(SRCS
SET(DYE_CMD_SRCS
gui/cliprect.cpp
- gui/color.cpp
gui/rect.cpp
events/actionevent.h
gui/cliprect.h
diff --git a/src/Makefile.am b/src/Makefile.am
index cf2f1ce76..ffb0a7459 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -178,7 +178,6 @@ SRC += events/actionevent.h \
gui/widgets/basiccontainer2.h \
gui/widgets/basiccontainer.cpp \
gui/cliprect.cpp \
- gui/color.cpp \
gui/colorpair.h \
gui/dialogsmanager.cpp \
gui/dialogsmanager.h \
diff --git a/src/being/compoundsprite.h b/src/being/compoundsprite.h
index 3c4002569..de9c8cf6e 100644
--- a/src/being/compoundsprite.h
+++ b/src/being/compoundsprite.h
@@ -97,13 +97,13 @@ class CompoundSprite notfinal : public Sprite
bool updateNumber(const unsigned num) override final;
- static void setEnableDelay(bool b)
+ constexpr static void setEnableDelay(bool b) noexcept2
{ mEnableDelay = b; }
- int getLastTime() const A_WARN_UNUSED
+ int getLastTime() const noexcept2 A_WARN_UNUSED
{ return mLastTime; }
- int getStartTime() const A_WARN_UNUSED
+ int getStartTime() const noexcept2 A_WARN_UNUSED
{ return mStartTime; }
std::vector<Sprite*> mSprites;
diff --git a/src/game.h b/src/game.h
index 767af0ef9..1d5a0b9a8 100644
--- a/src/game.h
+++ b/src/game.h
@@ -70,7 +70,7 @@ class Game final
static Game *instance() A_WARN_UNUSED
{ return mInstance; }
- static void clearInstance()
+ constexpr static void clearInstance() noexcept2
{ mInstance = nullptr; }
/**
diff --git a/src/graphicsmanager.h b/src/graphicsmanager.h
index 003d32d6c..f61f3a1f3 100644
--- a/src/graphicsmanager.h
+++ b/src/graphicsmanager.h
@@ -161,7 +161,7 @@ class GraphicsManager final
static GLenum getLastErrorCached()
{ return mLastError; }
- static void resetCachedError()
+ constexpr static void resetCachedError() noexcept2
{ mLastError = GL_NO_ERROR; }
#endif // USE_OPENGL
diff --git a/src/gui/color.cpp b/src/gui/color.cpp
deleted file mode 100644
index 6d0e3037e..000000000
--- a/src/gui/color.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2016 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "gui/color.h"
-
-#include "debug.h"
-
-Color::Color() :
- r(0U),
- g(0U),
- b(0U),
- a(255U)
-{
-}
-
-Color::Color(const unsigned int color) :
- r((color >> 16) & 0xFFU),
- g((color >> 8) & 0xFFU),
- b(color & 0xFFU),
- a(255U)
-{
-}
-
-Color::Color(const unsigned int ar,
- const unsigned int ag,
- const unsigned int ab,
- const unsigned int aa) :
- r(ar),
- g(ag),
- b(ab),
- a(aa)
-{
-}
-
-Color Color::operator+(const Color& color) const
-{
- Color result(r + color.r,
- g + color.g,
- b + color.b,
- 255U);
-
- result.r = (result.r > 255U ? 255U : result.r);
- result.g = (result.g > 255U ? 255U : result.g);
- result.b = (result.b > 255U ? 255U : result.b);
-
- return result;
-}
-
-Color Color::operator-(const Color& color) const
-{
- Color result(r - color.r,
- g - color.g,
- b - color.b,
- 255U);
-
- result.r = (result.r > 255U ? 255U : result.r);
- result.g = (result.g > 255U ? 255U : result.g);
- result.b = (result.b > 255U ? 255U : result.b);
-
- return result;
-}
-
-Color Color::operator*(const float value) const
-{
- Color result(CAST_U32(static_cast<float>(r) * value),
- CAST_U32(static_cast<float>(g) * value),
- CAST_U32(static_cast<float>(b) * value),
- a);
-
- result.r = (result.r > 255U ? 255U : result.r);
- result.g = (result.g > 255U ? 255U : result.g);
- result.b = (result.b > 255U ? 255U : result.b);
-
- return result;
-}
-
-bool Color::operator==(const Color& color) const
-{
- return r == color.r && g == color.g && b == color.b && a == color.a;
-}
-
-bool Color::operator!=(const Color& color) const
-{
- return !(r == color.r && g == color.g && b == color.b && a == color.a);
-}
diff --git a/src/gui/color.h b/src/gui/color.h
index ffcf93ce6..c6c3accbc 100644
--- a/src/gui/color.h
+++ b/src/gui/color.h
@@ -75,7 +75,13 @@ class Color final
/**
* Constructor. Initializes the color to black.
*/
- Color();
+ constexpr Color() :
+ r(0U),
+ g(0U),
+ b(0U),
+ a(255U)
+ {
+ }
/**
* Constructor. Constructs a color from the bytes in an integer.
@@ -90,7 +96,13 @@ class Color final
*
* @param color The color to initialise the object with.
*/
- explicit Color(const unsigned int color);
+ constexpr Color(const unsigned int color) :
+ r((color >> 16) & 0xFFU),
+ g((color >> 8) & 0xFFU),
+ b(color & 0xFFU),
+ a(255U)
+ {
+ }
/**
* Constructor. The default alpha value is 255.
@@ -101,10 +113,17 @@ class Color final
* @param a Alpha, used for transparency. A value of 0 means
* totaly transparent, 255 is totaly opaque.
*/
- Color(const unsigned int r,
- const unsigned int g,
- const unsigned int b,
- const unsigned int a = 255);
+ constexpr Color(const unsigned int ar,
+ const unsigned int ag,
+ const unsigned int ab,
+ const unsigned int aa = 255) :
+ r(ar),
+ g(ag),
+ b(ab),
+ a(aa)
+ {
+ }
+
/**
* Adds the RGB values of two colors together. The values will be
@@ -116,7 +135,19 @@ class Color final
* @param color A color to add to this color.
* @return The added colors with an alpha value set to 255.
*/
- Color operator+(const Color& color) const;
+ constexpr Color operator+(const Color& color) const
+ {
+ Color result(r + color.r,
+ g + color.g,
+ b + color.b,
+ 255U);
+
+ result.r = (result.r > 255U ? 255U : result.r);
+ result.g = (result.g > 255U ? 255U : result.g);
+ result.b = (result.b > 255U ? 255U : result.b);
+
+ return result;
+ }
/**
* Subtracts the RGB values of one color from another.
@@ -128,7 +159,19 @@ class Color final
* @param color A color to subtract from this color.
* @return The subtracted colors with an alpha value set to 255.
*/
- Color operator-(const Color& color) const;
+ constexpr Color operator-(const Color& color) const
+ {
+ Color result(r - color.r,
+ g - color.g,
+ b - color.b,
+ 255U);
+
+ result.r = (result.r > 255U ? 255U : result.r);
+ result.g = (result.g > 255U ? 255U : result.g);
+ result.b = (result.b > 255U ? 255U : result.b);
+
+ return result;
+ }
/**
* Multiplies the RGB values of a color with a float value.
@@ -139,7 +182,19 @@ class Color final
* the add and subtract operations, be multiplied as
* well.
*/
- Color operator*(const float value) const;
+ constexpr Color operator*(const float value) const
+ {
+ Color result(CAST_U32(static_cast<float>(r) * value),
+ CAST_U32(static_cast<float>(g) * value),
+ CAST_U32(static_cast<float>(b) * value),
+ a);
+
+ result.r = (result.r > 255U ? 255U : result.r);
+ result.g = (result.g > 255U ? 255U : result.g);
+ result.b = (result.b > 255U ? 255U : result.b);
+
+ return result;
+ }
/**
* Compares two colors.
@@ -147,7 +202,10 @@ class Color final
* @return True if the two colors have the same RGBA components
* false otherwise.
*/
- bool operator==(const Color& color) const;
+ constexpr bool operator==(const Color& color) const
+ {
+ return r == color.r && g == color.g && b == color.b && a == color.a;
+ }
/**
* Compares two colors.
@@ -155,7 +213,10 @@ class Color final
* @return True if the two colors have different RGBA components,
* false otherwise.
*/
- bool operator!=(const Color& color) const;
+ constexpr bool operator!=(const Color& color) const
+ {
+ return !(r == color.r && g == color.g && b == color.b && a == color.a);
+ }
/**
* Holds the red color component (range 0-255).
diff --git a/src/input/joystick.h b/src/input/joystick.h
index ee4b9de20..e302de53e 100644
--- a/src/input/joystick.h
+++ b/src/input/joystick.h
@@ -79,7 +79,7 @@ class Joystick final
void setNumber(const int n);
- static void setEnabled(const bool enabled)
+ constexpr static void setEnabled(const bool enabled) noexcept2
{ mEnabled = enabled; }
static void getNames(std::vector <std::string> &names);
diff --git a/src/resources/fboinfo.h b/src/resources/fboinfo.h
index 81d753856..e8c4ace88 100644
--- a/src/resources/fboinfo.h
+++ b/src/resources/fboinfo.h
@@ -39,7 +39,7 @@
struct FBOInfo final
{
- FBOInfo() :
+ constexpr2 FBOInfo() :
fboId(0), textureId(0), rboId(0)
{
}
diff --git a/src/resources/imagehelper.h b/src/resources/imagehelper.h
index 2f4276305..4ade89199 100644
--- a/src/resources/imagehelper.h
+++ b/src/resources/imagehelper.h
@@ -91,15 +91,15 @@ class ImageHelper notfinal
static void dumpSurfaceFormat(const SDL_Surface *const image);
- static void setEnableAlpha(const bool n)
+ constexpr static void setEnableAlpha(const bool n) noexcept2
{ mEnableAlpha = n; }
static SDL_Surface *loadPng(SDL_RWops *const rw);
- static void setOpenGlMode(const RenderType useOpenGL)
+ constexpr static void setOpenGlMode(const RenderType useOpenGL) noexcept2
{ mUseOpenGL = useOpenGL; }
- virtual RenderType useOpenGL() const A_WARN_UNUSED
+ virtual RenderType useOpenGL() const noexcept2 A_WARN_UNUSED
{ return mUseOpenGL; }
virtual void postInit()
diff --git a/src/resources/mstack.h b/src/resources/mstack.h
index f8a49af49..2fcf558a2 100644
--- a/src/resources/mstack.h
+++ b/src/resources/mstack.h
@@ -28,7 +28,7 @@
template<typename T>
struct MStack final
{
- explicit MStack(const size_t maxSize) :
+ constexpr2 explicit MStack(const size_t maxSize) :
mStack(new T[maxSize]),
mMaxSize(maxSize),
mPointer(mStack - 1),
diff --git a/src/resources/openglimagehelper.h b/src/resources/openglimagehelper.h
index 5f6e0b8aa..87faaefe7 100644
--- a/src/resources/openglimagehelper.h
+++ b/src/resources/openglimagehelper.h
@@ -92,28 +92,28 @@ class OpenGLImageHelper final : public ImageHelper
// OpenGL only public functions
- static int getTextureType() A_WARN_UNUSED
+ static int getTextureType() noexcept2 A_WARN_UNUSED
{ return mTextureType; }
- static int getInternalTextureType() A_WARN_UNUSED
+ static int getInternalTextureType() noexcept2 A_WARN_UNUSED
{ return mInternalTextureType; }
- static void setInternalTextureType(const int n)
+ constexpr static void setInternalTextureType(const int n) noexcept2
{ mInternalTextureType = n; }
- static void setBlur(const bool n)
+ constexpr static void setBlur(const bool n) noexcept2
{ mBlur = n; }
static int mTextureType;
static int mInternalTextureType;
- static int getTextureSize() A_WARN_UNUSED
+ static int getTextureSize() noexcept2 A_WARN_UNUSED
{ return mTextureSize; }
static void initTextureSampler(const GLint id);
- static void setUseTextureSampler(const bool b)
+ constexpr static void setUseTextureSampler(const bool b) noexcept2
{ mUseTextureSampler = b; }
static void invalidate(const GLuint textureId);
diff --git a/src/resources/safeopenglimagehelper.h b/src/resources/safeopenglimagehelper.h
index 90a168bad..0f2382d98 100644
--- a/src/resources/safeopenglimagehelper.h
+++ b/src/resources/safeopenglimagehelper.h
@@ -98,22 +98,22 @@ class SafeOpenGLImageHelper final : public ImageHelper
static int getInternalTextureType() A_WARN_UNUSED
{ return mInternalTextureType; }
- static void setInternalTextureType(const int n)
+ constexpr static void setInternalTextureType(const int n) noexcept2
{ mInternalTextureType = n; }
- static void setBlur(const bool n)
+ constexpr static void setBlur(const bool n) noexcept2
{ mBlur = n; }
static int mTextureType;
static int mInternalTextureType;
- static int getTextureSize() A_WARN_UNUSED
+ static int getTextureSize() noexcept2 A_WARN_UNUSED
{ return mTextureSize; }
static void initTextureSampler(const GLint id);
- static void setUseTextureSampler(const bool b)
+ constexpr static void setUseTextureSampler(const bool b) noexcept2
{ mUseTextureSampler = b; }
static void invalidate(const GLuint textureId);
diff --git a/src/resources/sdl2imagehelper.h b/src/resources/sdl2imagehelper.h
index 59cec36ea..aa40aa065 100644
--- a/src/resources/sdl2imagehelper.h
+++ b/src/resources/sdl2imagehelper.h
@@ -67,10 +67,10 @@ class SDLImageHelper final : public ImageHelper
SDL_Surface *const surface)
const override final;
- static void SDLSetEnableAlphaCache(const bool n)
+ constexpr static void SDLSetEnableAlphaCache(const bool n) noexcept2
{ mEnableAlphaCache = n; }
- static bool SDLGetEnableAlphaCache() A_WARN_UNUSED
+ static bool SDLGetEnableAlphaCache() noexcept2 A_WARN_UNUSED
{ return mEnableAlphaCache; }
static SDL_Surface* SDLDuplicateSurface(SDL_Surface *const tmpImage)
@@ -81,7 +81,8 @@ class SDLImageHelper final : public ImageHelper
SDL_Surface *restrict const dst,
SDL_Rect *restrict const dstrect);
- static void setRenderer(SDL_Renderer *const renderer)
+ constexpr static void setRenderer(SDL_Renderer *const renderer)
+ noexcept2
{ mRenderer = renderer; }
protected:
diff --git a/src/resources/sdl2softwareimagehelper.h b/src/resources/sdl2softwareimagehelper.h
index 0160a5660..38bd0f9d0 100644
--- a/src/resources/sdl2softwareimagehelper.h
+++ b/src/resources/sdl2softwareimagehelper.h
@@ -60,10 +60,10 @@ class SDL2SoftwareImageHelper final : public ImageHelper
const float alpha)
override final A_WARN_UNUSED;
- static void SDLSetEnableAlphaCache(const bool n)
+ constexpr static void SDLSetEnableAlphaCache(const bool n) noexcept2
{ mEnableAlphaCache = n; }
- static bool SDLGetEnableAlphaCache() A_WARN_UNUSED
+ static bool SDLGetEnableAlphaCache() noexcept2 A_WARN_UNUSED
{ return mEnableAlphaCache; }
static SDL_Surface* SDLDuplicateSurface(SDL_Surface *const tmpImage)
@@ -74,7 +74,7 @@ class SDL2SoftwareImageHelper final : public ImageHelper
SDL_Surface *restrict const dst,
SDL_Rect *restrict const dstrect);
- static void setFormat(SDL_PixelFormat *const format)
+ constexpr2 static void setFormat(SDL_PixelFormat *const format) noexcept2
{
mFormat = format;
if (mFormat)
diff --git a/src/resources/sdlimagehelper.h b/src/resources/sdlimagehelper.h
index 347a8b585..57fd33d68 100644
--- a/src/resources/sdlimagehelper.h
+++ b/src/resources/sdlimagehelper.h
@@ -81,10 +81,10 @@ class SDLImageHelper final : public ImageHelper
SDL_Surface *const surface)
const override final;
- static void SDLSetEnableAlphaCache(const bool n)
+ constexpr static void SDLSetEnableAlphaCache(const bool n) noexcept2
{ mEnableAlphaCache = n; }
- static bool SDLGetEnableAlphaCache() A_WARN_UNUSED
+ static bool SDLGetEnableAlphaCache() noexcept2 A_WARN_UNUSED
{ return mEnableAlphaCache; }
static SDL_Surface* SDLDuplicateSurface(SDL_Surface *const tmpImage)
diff --git a/src/resources/sprite/animatedsprite.h b/src/resources/sprite/animatedsprite.h
index 7f8332e46..27d6b61a5 100644
--- a/src/resources/sprite/animatedsprite.h
+++ b/src/resources/sprite/animatedsprite.h
@@ -114,7 +114,7 @@ class AnimatedSprite final : public Sprite
bool isTerminated() const restrict2 noexcept2
{ return mTerminated; }
- static void setEnableCache(const bool b) noexcept2
+ constexpr static void setEnableCache(const bool b) noexcept2
{ mEnableCache = b; }
void setLastTime(const int time) noexcept2
diff --git a/src/resources/surfaceimagehelper.h b/src/resources/surfaceimagehelper.h
index 15c8d66d2..243a370c1 100644
--- a/src/resources/surfaceimagehelper.h
+++ b/src/resources/surfaceimagehelper.h
@@ -63,10 +63,10 @@ class SurfaceImageHelper final : public ImageHelper
const float alpha)
override final A_WARN_UNUSED;
- static void SDLSetEnableAlphaCache(const bool n)
+ constexpr static void SDLSetEnableAlphaCache(const bool n) noexcept2
{ mEnableAlphaCache = n; }
- static bool SDLGetEnableAlphaCache() A_WARN_UNUSED
+ static bool SDLGetEnableAlphaCache() noexcept2 A_WARN_UNUSED
{ return mEnableAlphaCache; }
/**