summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-27 20:22:09 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-27 21:52:59 +0300
commit53ae7cee19c269a6ebf53e468825305d448ff006 (patch)
treefb43a66adaacc3bb2e42a8d346b5d267f2b807c8 /src
parenteb9841897bbe93da6aa4ca2537a3e22b3a868d98 (diff)
downloadplus-53ae7cee19c269a6ebf53e468825305d448ff006.tar.gz
plus-53ae7cee19c269a6ebf53e468825305d448ff006.tar.bz2
plus-53ae7cee19c269a6ebf53e468825305d448ff006.tar.xz
plus-53ae7cee19c269a6ebf53e468825305d448ff006.zip
fix code style.
Diffstat (limited to 'src')
-rw-r--r--src/animatedsprite_unittest.cc1
-rw-r--r--src/client.cpp2
-rw-r--r--src/graphics.cpp2
-rw-r--r--src/main.cpp2
-rw-r--r--src/resources/atlasmanager.cpp3
-rw-r--r--src/resources/dye_unittest.cc1
-rw-r--r--src/resources/openglimagehelper.cpp2
-rw-r--r--src/resources/sdl2imagehelper.cpp2
-rw-r--r--src/resources/surfaceimagehelper.cpp5
-rw-r--r--src/sdl2gfx/SDL_framerate.c172
-rw-r--r--src/sdl2gfx/SDL_framerate.h81
-rw-r--r--src/sdl2graphics.cpp3
-rw-r--r--src/sdlgraphics.cpp5
-rw-r--r--src/surfacegraphics.cpp5
-rw-r--r--src/surfacegraphics.h10
-rw-r--r--src/utils/sdlcheckutils.cpp7
-rw-r--r--src/utils/sdlcheckutils.h2
17 files changed, 156 insertions, 149 deletions
diff --git a/src/animatedsprite_unittest.cc b/src/animatedsprite_unittest.cc
index fa47e4808..e3e470ac6 100644
--- a/src/animatedsprite_unittest.cc
+++ b/src/animatedsprite_unittest.cc
@@ -152,4 +152,3 @@ TEST(AnimatedSprite, basic2)
delete client;
client = nullptr;
}
-
diff --git a/src/client.cpp b/src/client.cpp
index fef6f98ed..c51083151 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -999,9 +999,11 @@ int Client::gameExec()
handleSDL2WindowEvent(event);
break;
#else
+#ifndef ANDROID
case SDL_ACTIVEEVENT:
handleActive(event);
break;
+#endif
case SDL_VIDEORESIZE:
resizeVideo(event.resize.w, event.resize.h, false);
break;
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 604454e94..2e561c648 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -237,7 +237,6 @@ bool Graphics::setOpenGLMode()
return false;
#endif // USE_OPENGL
-
}
int Graphics::getSoftwareFlags() const
@@ -315,7 +314,6 @@ void Graphics::dumpRendererInfo(const char *const str,
bool Graphics::videoInfo()
{
-
logger->log("SDL video info");
#ifdef USE_SDL2
logger->log("Using video driver: %s", SDL_GetCurrentVideoDriver());
diff --git a/src/main.cpp b/src/main.cpp
index f367d80fa..89738fa93 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -49,7 +49,7 @@
#include <SDL_version.h>
-#if SDL_VERSION_ATLEAST(2,0,0)
+#if SDL_VERSION_ATLEAST(2, 0, 0)
#ifndef USE_SDL2
#error using SDL2 headers but configure set to use SDL1.2
#endif
diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp
index 80b0ad253..3b8f6a326 100644
--- a/src/resources/atlasmanager.cpp
+++ b/src/resources/atlasmanager.cpp
@@ -248,7 +248,8 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas)
{
#ifdef USE_SDL2
SDL_SetSurfaceAlphaMod(image->mSDLSurface, SDL_ALPHA_OPAQUE);
- SDL_SetSurfaceBlendMode (image->mSDLSurface, SDL_BLENDMODE_NONE);
+ SDL_SetSurfaceBlendMode(image->mSDLSurface,
+ SDL_BLENDMODE_NONE);
#else
SDL_SetAlpha(image->mSDLSurface, 0, SDL_ALPHA_OPAQUE);
#endif
diff --git a/src/resources/dye_unittest.cc b/src/resources/dye_unittest.cc
index 05e3401a6..6581298d3 100644
--- a/src/resources/dye_unittest.cc
+++ b/src/resources/dye_unittest.cc
@@ -251,4 +251,3 @@ TEST(Dye, normalOGLDye1)
EXPECT_EQ(0x2a, data[2]);
EXPECT_EQ(0x50, data[3]);
}
-
diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp
index 6e60cc647..abf05e800 100644
--- a/src/resources/openglimagehelper.cpp
+++ b/src/resources/openglimagehelper.cpp
@@ -181,7 +181,7 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
{
oldImage = tmpImage;
#ifdef USE_SDL2
- SDL_SetSurfaceBlendMode (oldImage, SDL_BLENDMODE_NONE);
+ SDL_SetSurfaceBlendMode(oldImage, SDL_BLENDMODE_NONE);
#endif
tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight,
32, rmask, gmask, bmask, amask);
diff --git a/src/resources/sdl2imagehelper.cpp b/src/resources/sdl2imagehelper.cpp
index 66e280c59..65ce5fb8d 100644
--- a/src/resources/sdl2imagehelper.cpp
+++ b/src/resources/sdl2imagehelper.cpp
@@ -174,7 +174,7 @@ int SDLImageHelper::combineSurface(SDL_Surface *const src,
SDL_Surface *const dst,
SDL_Rect *const dstrect)
{
- SDL_SetSurfaceBlendMode (src, SDL_BLENDMODE_BLEND);
+ SDL_SetSurfaceBlendMode(src, SDL_BLENDMODE_BLEND);
SDL_BlitSurface(src, srcrect, dst, dstrect);
return 1;
}
diff --git a/src/resources/surfaceimagehelper.cpp b/src/resources/surfaceimagehelper.cpp
index 75e311a36..44cee32d9 100644
--- a/src/resources/surfaceimagehelper.cpp
+++ b/src/resources/surfaceimagehelper.cpp
@@ -149,7 +149,8 @@ int SurfaceImageHelper::useOpenGL() const
return 0;
}
-SDL_Surface *SurfaceImageHelper::create32BitSurface(int width, int height) const
+SDL_Surface *SurfaceImageHelper::create32BitSurface(int width,
+ int height) const
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const int rmask = 0xff000000;
@@ -172,7 +173,7 @@ int SurfaceImageHelper::combineSurface(SDL_Surface *const src,
SDL_Surface *const dst,
SDL_Rect *const dstrect)
{
- SDL_SetSurfaceBlendMode (src, SDL_BLENDMODE_BLEND);
+ SDL_SetSurfaceBlendMode(src, SDL_BLENDMODE_BLEND);
SDL_BlitSurface(src, srcrect, dst, dstrect);
return 1;
}
diff --git a/src/sdl2gfx/SDL_framerate.c b/src/sdl2gfx/SDL_framerate.c
index 6735f6355..bb1c35fcb 100644
--- a/src/sdl2gfx/SDL_framerate.c
+++ b/src/sdl2gfx/SDL_framerate.c
@@ -25,6 +25,7 @@ distribution.
Andreas Schiffler -- aschiffler at ferzkopp dot net
+Changed for ManaPlus (C) 2013 ManaPlus developers
*/
#include "SDL_framerate.h"
@@ -34,21 +35,20 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net
\return The tick count.
*/
-Uint32 _getTicks()
+uint32_t _getTicks()
{
- Uint32 ticks = SDL_GetTicks();
-
- /*
- * Since baseticks!=0 is used to track initialization
- * we need to ensure that the tick count is always >0
- * since SDL_GetTicks may not have incremented yet and
- * return 0 depending on the timing of the calls.
- */
- if (ticks == 0) {
- return 1;
- } else {
- return ticks;
- }
+ const uint32_t ticks = SDL_GetTicks();
+
+ /*
+ * Since baseticks!=0 is used to track initialization
+ * we need to ensure that the tick count is always >0
+ * since SDL_GetTicks may not have incremented yet and
+ * return 0 depending on the timing of the calls.
+ */
+ if (ticks == 0)
+ return 1;
+ else
+ return ticks;
}
/*!
@@ -59,16 +59,16 @@ reset delay interpolation.
\param manager Pointer to the framerate manager.
*/
-void SDL_initFramerate(FPSmanager * manager)
+void SDL_initFramerate(FPSmanager *const manager)
{
- /*
- * Store some sane values
- */
- manager->framecount = 0;
- manager->rate = FPS_DEFAULT;
- manager->rateticks = (1000.0f / (float) FPS_DEFAULT);
- manager->baseticks = _getTicks();
- manager->lastticks = manager->baseticks;
+ /*
+ * Store some sane values
+ */
+ manager->framecount = 0;
+ manager->rate = FPS_DEFAULT;
+ manager->rateticks = (1000.0f / (float) FPS_DEFAULT);
+ manager->baseticks = _getTicks();
+ manager->lastticks = manager->baseticks;
}
@@ -83,16 +83,19 @@ Rate values must be between FPS_LOWER_LIMIT and FPS_UPPER_LIMIT inclusive to be
\return 0 for sucess and -1 for error.
*/
-int SDL_setFramerate(FPSmanager * manager, Uint32 rate)
+int SDL_setFramerate(FPSmanager *const manager, const uint32_t rate)
{
- if ((rate >= FPS_LOWER_LIMIT) && (rate <= FPS_UPPER_LIMIT)) {
- manager->framecount = 0;
- manager->rate = rate;
- manager->rateticks = (1000.0f / (float) rate);
- return (0);
- } else {
- return (-1);
- }
+ if (rate >= FPS_LOWER_LIMIT && rate <= FPS_UPPER_LIMIT)
+ {
+ manager->framecount = 0;
+ manager->rate = rate;
+ manager->rateticks = (1000.0f / (float) rate);
+ return 0;
+ }
+ else
+ {
+ return -1;
+ }
}
/*!
@@ -104,13 +107,12 @@ Get the currently set framerate of the manager.
\return Current framerate in Hz or -1 for error.
*/
-int SDL_getFramerate(FPSmanager * manager)
+int SDL_getFramerate(FPSmanager *const manager)
{
- if (manager == NULL) {
- return (-1);
- } else {
- return ((int)manager->rate);
- }
+ if (!manager)
+ return -1;
+ else
+ return (int)manager->rate;
}
/*!
@@ -123,13 +125,12 @@ A frame is counted each time SDL_framerateDelay is called.
\return Current frame count or -1 for error.
*/
-int SDL_getFramecount(FPSmanager * manager)
+int SDL_getFramecount(FPSmanager *const manager)
{
- if (manager == NULL) {
- return (-1);
- } else {
- return ((int)manager->framecount);
- }
+ if (!manager)
+ return -1;
+ else
+ return (int)manager->framecount;
}
/*!
@@ -143,47 +144,46 @@ drawing too slow), the delay is zero and the delay interpolation is reset.
\return The time that passed since the last call to the function in ms. May return 0.
*/
-Uint32 SDL_framerateDelay(FPSmanager * manager)
+uint32_t SDL_framerateDelay(FPSmanager *const manager)
{
- Uint32 current_ticks;
- Uint32 target_ticks;
- Uint32 the_delay;
- Uint32 time_passed = 0;
-
- /*
- * No manager, no delay
- */
- if (manager == NULL) {
- return 0;
- }
-
- /*
- * Initialize uninitialized manager
- */
- if (manager->baseticks == 0) {
- SDL_initFramerate(manager);
- }
-
- /*
- * Next frame
- */
- manager->framecount++;
-
- /*
- * Get/calc ticks
- */
- current_ticks = _getTicks();
- time_passed = current_ticks - manager->lastticks;
- manager->lastticks = current_ticks;
- target_ticks = manager->baseticks + (Uint32) ((float) manager->framecount * manager->rateticks);
-
- if (current_ticks <= target_ticks) {
- the_delay = target_ticks - current_ticks;
- SDL_Delay(the_delay);
- } else {
- manager->framecount = 0;
- manager->baseticks = _getTicks();
- }
-
- return time_passed;
+ uint32_t the_delay;
+
+ /*
+ * No manager, no delay
+ */
+ if (!manager)
+ return 0;
+
+ /*
+ * Initialize uninitialized manager
+ */
+ if (manager->baseticks == 0)
+ SDL_initFramerate(manager);
+
+ /*
+ * Next frame
+ */
+ manager->framecount ++;
+
+ /*
+ * Get/calc ticks
+ */
+ const uint32_t current_ticks = _getTicks();
+ const uint32_t time_passed = current_ticks - manager->lastticks;
+ manager->lastticks = current_ticks;
+ const uint32_t target_ticks = manager->baseticks + (uint32_t)(
+ (float)(manager->framecount) * manager->rateticks);
+
+ if (current_ticks <= target_ticks)
+ {
+ the_delay = target_ticks - current_ticks;
+ SDL_Delay(the_delay);
+ }
+ else
+ {
+ manager->framecount = 0;
+ manager->baseticks = _getTicks();
+ }
+
+ return time_passed;
}
diff --git a/src/sdl2gfx/SDL_framerate.h b/src/sdl2gfx/SDL_framerate.h
index b4e7ab8e8..a2e62e944 100644
--- a/src/sdl2gfx/SDL_framerate.h
+++ b/src/sdl2gfx/SDL_framerate.h
@@ -35,39 +35,40 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net
extern "C" {
#endif
- /* --- */
+ /* --- */
#include "SDL.h"
- /* --------- Definitions */
-
- /*!
- \brief Highest possible rate supported by framerate controller in Hz (1/s).
- */
-#define FPS_UPPER_LIMIT 200
-
- /*!
- \brief Lowest possible rate supported by framerate controller in Hz (1/s).
- */
-#define FPS_LOWER_LIMIT 1
-
- /*!
- \brief Default rate of framerate controller in Hz (1/s).
- */
-#define FPS_DEFAULT 30
-
- /*!
- \brief Structure holding the state and timing information of the framerate controller.
- */
- typedef struct {
- Uint32 framecount;
- float rateticks;
- Uint32 baseticks;
- Uint32 lastticks;
- Uint32 rate;
- } FPSmanager;
-
- /* ---- Function Prototypes */
+ /* --------- Definitions */
+
+ /*!
+ \brief Highest possible rate supported by framerate controller in Hz (1/s).
+ */
+#define FPS_UPPER_LIMIT 200
+
+ /*!
+ \brief Lowest possible rate supported by framerate controller in Hz (1/s).
+ */
+#define FPS_LOWER_LIMIT 1
+
+ /*!
+ \brief Default rate of framerate controller in Hz (1/s).
+ */
+#define FPS_DEFAULT 30
+
+ /*!
+ \brief Structure holding the state and timing information of the framerate controller.
+ */
+ typedef struct
+ {
+ uint32_t framecount;
+ float rateticks;
+ uint32_t baseticks;
+ uint32_t lastticks;
+ uint32_t rate;
+ } FPSmanager;
+
+ /* ---- Function Prototypes */
#ifdef _MSC_VER
# if defined(DLL_EXPORT) && !defined(LIBSDL2_GFX_DLL_IMPORT)
@@ -82,19 +83,21 @@ extern "C" {
# define SDL2_FRAMERATE_SCOPE extern
#endif
- /* Functions return 0 or value for sucess and -1 for error */
+ /* Functions return 0 or value for sucess and -1 for error */
- SDL2_FRAMERATE_SCOPE void SDL_initFramerate(FPSmanager * manager);
- SDL2_FRAMERATE_SCOPE int SDL_setFramerate(FPSmanager * manager, Uint32 rate);
- SDL2_FRAMERATE_SCOPE int SDL_getFramerate(FPSmanager * manager);
- SDL2_FRAMERATE_SCOPE int SDL_getFramecount(FPSmanager * manager);
- SDL2_FRAMERATE_SCOPE Uint32 SDL_framerateDelay(FPSmanager * manager);
+ SDL2_FRAMERATE_SCOPE void SDL_initFramerate(FPSmanager *const manager);
+ SDL2_FRAMERATE_SCOPE int SDL_setFramerate(FPSmanager *const manager,
+ const uint32_t rate);
+ SDL2_FRAMERATE_SCOPE int SDL_getFramerate(FPSmanager *const manager);
+ SDL2_FRAMERATE_SCOPE int SDL_getFramecount(FPSmanager *const manager);
+ SDL2_FRAMERATE_SCOPE uint32_t SDL_framerateDelay(FPSmanager *const
+ manager);
- /* --- */
+ /* --- */
- /* Ends C function definitions when using C++ */
+ /* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
-#endif /* _SDL2_framerate_h */
+#endif /* _SDL2_framerate_h */
diff --git a/src/sdl2graphics.cpp b/src/sdl2graphics.cpp
index e76335f3e..ee4e7dbce 100644
--- a/src/sdl2graphics.cpp
+++ b/src/sdl2graphics.cpp
@@ -79,7 +79,8 @@ SDLGraphics::~SDLGraphics()
{
}
-bool SDLGraphics::drawRescaledImage(const Image *const image, int srcX, int srcY,
+bool SDLGraphics::drawRescaledImage(const Image *const image,
+ int srcX, int srcY,
int dstX, int dstY,
const int width, const int height,
const int desiredWidth,
diff --git a/src/sdlgraphics.cpp b/src/sdlgraphics.cpp
index 4d7e49afa..fc9f949a1 100644
--- a/src/sdlgraphics.cpp
+++ b/src/sdlgraphics.cpp
@@ -58,7 +58,8 @@ SDLGraphics::~SDLGraphics()
{
}
-bool SDLGraphics::drawRescaledImage(const Image *const image, int srcX, int srcY,
+bool SDLGraphics::drawRescaledImage(const Image *const image,
+ int srcX, int srcY,
int dstX, int dstY,
const int width, const int height,
const int desiredWidth,
@@ -626,7 +627,7 @@ int SDLGraphics::SDL_FakeUpperBlit(const SDL_Surface *const src,
if (!src || !dst)
return -1;
- if (!srcrect ||!dstrect)
+ if (!srcrect || !dstrect)
return -1;
srcx = srcrect->x;
diff --git a/src/surfacegraphics.cpp b/src/surfacegraphics.cpp
index b1c8dd148..6dbb3ff70 100644
--- a/src/surfacegraphics.cpp
+++ b/src/surfacegraphics.cpp
@@ -51,8 +51,9 @@ SurfaceGraphics::~SurfaceGraphics()
}
bool SurfaceGraphics::drawImage2(const Image *const image, int srcX, int srcY,
- int dstX, int dstY, const int width,
- const int height, const bool useColor A_UNUSED)
+ int dstX, int dstY,
+ const int width, const int height,
+ const bool useColor A_UNUSED)
{
FUNC_BLOCK("Graphics::drawImage2", 1)
// Check that preconditions for blitting are met.
diff --git a/src/surfacegraphics.h b/src/surfacegraphics.h
index 9ba2f183f..801c9079e 100644
--- a/src/surfacegraphics.h
+++ b/src/surfacegraphics.h
@@ -95,11 +95,11 @@ class SurfaceGraphics : public Graphics
{ }
void calcImagePattern(ImageVertexes *const vert A_UNUSED,
- const Image *const image A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED) const
+ const Image *const image A_UNUSED,
+ const int x A_UNUSED,
+ const int y A_UNUSED,
+ const int w A_UNUSED,
+ const int h A_UNUSED) const
{ }
void calcImagePattern(ImageCollection *const vert A_UNUSED,
diff --git a/src/utils/sdlcheckutils.cpp b/src/utils/sdlcheckutils.cpp
index 0d471d005..d8e902e4f 100644
--- a/src/utils/sdlcheckutils.cpp
+++ b/src/utils/sdlcheckutils.cpp
@@ -37,7 +37,7 @@
struct SurfaceObject
{
- SurfaceObject(const std::string name, const char *const file,
+ SurfaceObject(const std::string &name, const char *const file,
const unsigned int line) :
mName(name),
mAddFile(strprintf("%s:%u", file, line)),
@@ -60,7 +60,8 @@ static SDL_Surface *addSurface(const char *const name,
const unsigned line)
{
#ifdef DEBUG_SURFACE_ALLOCATION
- logger->log("add surface: %s %s:%u %p", name, file, line, static_cast<void*>(surface));
+ logger->log("add surface: %s %s:%u %p", name,
+ file, line, static_cast<void*>(surface));
#endif
std::map<SDL_Surface*, SurfaceObject*>::iterator
it = mSurfaces.find(surface);
@@ -173,7 +174,7 @@ SDL_Surface *FakeSDL_ConvertSurface(SDL_Surface *const src,
SDL_Surface *FakeTTF_RenderUTF8_Blended(_TTF_Font *const font,
const char *const text,
- const SDL_Color fg,
+ const SDL_Color &fg,
const char *const file,
const unsigned line)
{
diff --git a/src/utils/sdlcheckutils.h b/src/utils/sdlcheckutils.h
index d65351c45..5a29ab1ba 100644
--- a/src/utils/sdlcheckutils.h
+++ b/src/utils/sdlcheckutils.h
@@ -56,7 +56,7 @@ SDL_Surface *FakeSDL_ConvertSurface(SDL_Surface *const src,
SDL_Surface *FakeTTF_RenderUTF8_Blended(_TTF_Font *const font,
const char *const text,
- const SDL_Color fg,
+ const SDL_Color &fg,
const char *const file,
const unsigned line);