From fcf1da7a161c3e18d393a9b998effc6aa1c366b9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 13 Sep 2013 19:10:50 +0300 Subject: fix code style. --- src/chatlogger.cpp | 1 + src/configuration.h | 1 - src/game.h | 1 - src/graphicsmanager.cpp | 6 ++++-- src/gui/debugwindow.cpp | 2 ++ src/gui/setup_players.cpp | 4 ++-- src/gui/setup_video.cpp | 2 +- src/gui/shopwindow.h | 1 - src/gui/widgets/extendedlistbox.cpp | 2 -- src/gui/widgets/itemcontainer.cpp | 3 ++- src/gui/widgets/textfield.cpp | 4 ++++ src/input/inputmanager.cpp | 4 ++-- src/net/tmwa/beinghandler.cpp | 4 ++-- src/render/graphics.h | 6 +++--- src/render/mobileopenglgraphics.h | 6 +++--- src/render/normalopenglgraphics.h | 6 +++--- src/render/nullopenglgraphics.h | 6 +++--- src/render/renderers.h | 2 +- src/render/rendererslistsdl.h | 6 ++++-- src/render/rendererslistsdl2.h | 6 ++++-- src/render/safeopenglgraphics.h | 6 +++--- src/render/sdl2graphics.h | 6 +++--- src/render/sdl2softwaregraphics.cpp | 12 ++++++------ src/render/sdl2softwaregraphics.h | 6 +++--- src/render/sdlgraphics.h | 6 +++--- src/render/surfacegraphics.h | 6 +++--- src/resources/openglimagehelper.cpp | 2 ++ src/resources/sdlmusic.cpp | 3 +++ 28 files changed, 67 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/src/chatlogger.cpp b/src/chatlogger.cpp index a0067690b..778b0c31e 100644 --- a/src/chatlogger.cpp +++ b/src/chatlogger.cpp @@ -27,6 +27,7 @@ #ifdef WIN32 #include +#include #elif defined __APPLE__ #include #endif diff --git a/src/configuration.h b/src/configuration.h index 38bee5d8d..5c36ca4e6 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -29,7 +29,6 @@ #include "defaults.h" #include "localconsts.h" -//#include #include #include #include diff --git a/src/game.h b/src/game.h index 7fdaa8388..b7db9c7b9 100644 --- a/src/game.h +++ b/src/game.h @@ -34,7 +34,6 @@ static const int MAX_LASTKEYS = 10; extern volatile int cur_time; class Map; -//class WindowMenu; struct LastKey final { diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp index 73ed3d88a..8891c1856 100644 --- a/src/graphicsmanager.cpp +++ b/src/graphicsmanager.cpp @@ -253,6 +253,8 @@ void GraphicsManager::initGraphics(const bool noOpenGL) #ifndef USE_SDL2 case RENDER_SDL2_DEFAULT: #endif + case RENDER_LAST: + case RENDER_NULL: default: #ifndef ANDROID imageHelper = new OpenGLImageHelper; @@ -305,6 +307,8 @@ void GraphicsManager::initGraphics(const bool noOpenGL A_UNUSED) case RENDER_SAFE_OPENGL: case RENDER_GLES_OPENGL: case RENDER_NORMAL_OPENGL: + case RENDER_NULL: + case RENDER_LAST: default: #ifndef USE_SDL2 case RENDER_SDL2_DEFAULT: @@ -328,9 +332,7 @@ void GraphicsManager::initGraphics(const bool noOpenGL A_UNUSED) break; #endif }; - #endif // USE_OPENGL - } void GraphicsManager::setVideoMode() diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index 7d19da293..b3cff3087 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -204,6 +204,8 @@ MapDebugTab::MapDebugTab(const Widget2 *const widget) : mFPSText = _("%d FPS (Software)"); break; case RENDER_NORMAL_OPENGL: + case RENDER_NULL: + case RENDER_LAST: default: // TRANSLATORS: debug window label mFPSText = _("%d FPS (fast OpenGL)"); diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index 69a395b4c..928f9952d 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -97,8 +97,8 @@ Setup_Players::Setup_Players(const Widget2 *const widget) : "hideErased", this, "hideErasedEvent"); // TRANSLATORS: settings option - new SetupItemCheckBox(_("Use special diagonal speed in players moving"), "", - "useDiagonalSpeed", this, "useDiagonalSpeedEvent"); + new SetupItemCheckBox(_("Use special diagonal speed in players moving"), + "", "useDiagonalSpeed", this, "useDiagonalSpeedEvent"); setDimension(gcn::Rectangle(0, 0, 550, 350)); } diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index b04bf7681..b82b25f25 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -565,7 +565,7 @@ void Setup_Video::action(const gcn::ActionEvent &event) { const int val = test->getConfig().getValueInt("opengl", -1); if (val >= 0 && static_cast(val) - < sizeof(renderToIndex)) + < sizeof(renderToIndex) / sizeof (int)) { mOpenGLDropDown->setSelected(renderToIndex[val]); } diff --git a/src/gui/shopwindow.h b/src/gui/shopwindow.h index 4bcf139cb..7e33416e9 100644 --- a/src/gui/shopwindow.h +++ b/src/gui/shopwindow.h @@ -32,7 +32,6 @@ class Button; class CheckBox; class Item; class Label; -//class ListBox; class ScrollArea; class ShopItem; class ShopItems; diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 4cf3153b1..cdfafc480 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -165,8 +165,6 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) } } - - for (int f = 0; f < selSz; ++f) { const ExtendedListBoxItem &item = mSelectedItems[f]; diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index a69716f75..5151e44fd 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -282,7 +282,8 @@ void ItemContainer::draw(gcn::Graphics *graphics) image->setAlpha(1.0f); // ensure the image if fully drawn... g->drawImage(image, itemX + mPaddingItemX, itemY + mPaddingItemY); - if (mProtectedImg && PlayerInfo::isItemProtected(item->getId())) + if (mProtectedImg && PlayerInfo::isItemProtected( + item->getId())) { g->drawImage(mProtectedImg, itemX + mPaddingItemX, itemY + mPaddingItemY); diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 022a20781..9390e3a24 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -24,6 +24,10 @@ #include "client.h" +#ifdef ANDROID +#include "input/inputmanager.h" +#endif + #include "input/keydata.h" #include "input/keyevent.h" diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index a731dc1f5..12831560a 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -533,7 +533,7 @@ bool InputManager::handleEvent(const SDL_Event &event) if (gui) gui->handleInput(); } - catch (const gcn::Exception &e) + catch(const gcn::Exception &e) { const char *const err = e.getMessage().c_str(); logger->log("Warning: guichan input exception: %s", err); @@ -577,7 +577,7 @@ bool InputManager::handleEvent(const SDL_Event &event) if (guiInput) guiInput->pushInput(event); } - catch (const gcn::Exception &e) + catch(const gcn::Exception &e) { const char *const err = e.getMessage().c_str(); logger->log("Warning: guichan input exception: %s", err); diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 1a099b3d8..13504cde3 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -669,8 +669,8 @@ void BeingHandler::processBeingMove3(Net::MessageIn &msg) const if (serverVersion < 10) return; - const static int dirx[8] = {0, -1, -1, -1, 0, 1, 1, 1}; - const static int diry[8] = {1, 1, 0, -1, -1, -1, 0, 1}; + static const int dirx[8] = {0, -1, -1, -1, 0, 1, 1, 1}; + static const int diry[8] = {1, 1, 0, -1, -1, -1, 0, 1}; const int len = msg.readInt16() - 14; Being *const dstBeing = actorSpriteManager->findBeing(msg.readInt32()); diff --git a/src/render/graphics.h b/src/render/graphics.h index 3d6a9fa62..16cce7ae6 100644 --- a/src/render/graphics.h +++ b/src/render/graphics.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef GRAPHICS_H -#define GRAPHICS_H +#ifndef RENDER_GRAPHICS_H +#define RENDER_GRAPHICS_H #include "SDL.h" @@ -431,4 +431,4 @@ class Graphics : public gcn::Graphics extern Graphics *mainGraphics; -#endif // GRAPHICS_H +#endif // RENDER_GRAPHICS_H diff --git a/src/render/mobileopenglgraphics.h b/src/render/mobileopenglgraphics.h index 1597d3bd9..75b1b3371 100644 --- a/src/render/mobileopenglgraphics.h +++ b/src/render/mobileopenglgraphics.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef MOBILEOPENGLGRAPHICS_H -#define MOBILEOPENGLGRAPHICS_H +#ifndef RENDER_MOBILEOPENGLGRAPHICS_H +#define RENDER_MOBILEOPENGLGRAPHICS_H #include "main.h" #ifdef USE_OPENGL @@ -229,4 +229,4 @@ class MobileOpenGLGraphics final : public Graphics }; #endif -#endif // MOBILEOPENGLGRAPHICS_H +#endif // RENDER_MOBILEOPENGLGRAPHICS_H diff --git a/src/render/normalopenglgraphics.h b/src/render/normalopenglgraphics.h index 2b489c985..737cb9718 100644 --- a/src/render/normalopenglgraphics.h +++ b/src/render/normalopenglgraphics.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef NORMALOPENGLGRAPHICS_H -#define NORMALOPENGLGRAPHICS_H +#ifndef RENDER_NORMALOPENGLGRAPHICS_H +#define RENDER_NORMALOPENGLGRAPHICS_H #include "main.h" #if defined USE_OPENGL && !defined ANDROID @@ -241,4 +241,4 @@ class NormalOpenGLGraphics final : public Graphics }; #endif -#endif // NORMALOPENGLGRAPHICS_H +#endif // RENDER_NORMALOPENGLGRAPHICS_H diff --git a/src/render/nullopenglgraphics.h b/src/render/nullopenglgraphics.h index 856b646bc..0f27590be 100644 --- a/src/render/nullopenglgraphics.h +++ b/src/render/nullopenglgraphics.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef NULLOPENGLGRAPHICS_H -#define NULLOPENGLGRAPHICS_H +#ifndef RENDER_NULLOPENGLGRAPHICS_H +#define RENDER_NULLOPENGLGRAPHICS_H #include "main.h" #if defined USE_OPENGL @@ -236,4 +236,4 @@ class NullOpenGLGraphics final : public Graphics }; #endif -#endif // NULLOPENGLGRAPHICS_H +#endif // RENDER_NULLOPENGLGRAPHICS_H diff --git a/src/render/renderers.h b/src/render/renderers.h index c49ca81c4..2a6af27d2 100644 --- a/src/render/renderers.h +++ b/src/render/renderers.h @@ -31,7 +31,7 @@ enum RenderType RENDER_GLES_OPENGL = 3, RENDER_SDL2_DEFAULT = 4, RENDER_NULL = 5, - RENDER_LAST, + RENDER_LAST }; RenderType intToRenderType(const int mode); diff --git a/src/render/rendererslistsdl.h b/src/render/rendererslistsdl.h index aa68eeb6b..ed808485b 100644 --- a/src/render/rendererslistsdl.h +++ b/src/render/rendererslistsdl.h @@ -18,8 +18,6 @@ * along with this program. If not, see . */ -#include "utils/gettext.h" - #ifndef RENDER_RENDERERSLISTSDL_H #define RENDER_RENDERERSLISTSDL_H @@ -28,6 +26,10 @@ #else // USE_SDL2 +#include "utils/gettext.h" + +#include "render/renderers.h" + #ifdef USE_OPENGL #ifdef ANDROID // defined OPENGL ANDROID diff --git a/src/render/rendererslistsdl2.h b/src/render/rendererslistsdl2.h index 966b53726..10c5d80f3 100644 --- a/src/render/rendererslistsdl2.h +++ b/src/render/rendererslistsdl2.h @@ -18,11 +18,13 @@ * along with this program. If not, see . */ -#include "utils/gettext.h" - #ifndef RENDER_RENDERERSLISTSDL2_H #define RENDER_RENDERERSLISTSDL2_H +#include "utils/gettext.h" + +#include "render/renderers.h" + #ifdef USE_SDL2 #ifdef USE_OPENGL diff --git a/src/render/safeopenglgraphics.h b/src/render/safeopenglgraphics.h index 2c31bb696..93f67d75e 100644 --- a/src/render/safeopenglgraphics.h +++ b/src/render/safeopenglgraphics.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef SAFEOPENGLGRAPHICS_H -#define SAFEOPENGLGRAPHICS_H +#ifndef RENDER_SAFEOPENGLGRAPHICS_H +#define RENDER_SAFEOPENGLGRAPHICS_H #include "main.h" #if defined USE_OPENGL && !defined ANDROID @@ -180,4 +180,4 @@ class SafeOpenGLGraphics final : public Graphics }; #endif -#endif // SAFEOPENGLGRAPHICS_H +#endif // RENDER_SAFEOPENGLGRAPHICS_H diff --git a/src/render/sdl2graphics.h b/src/render/sdl2graphics.h index 383e93540..e53719049 100644 --- a/src/render/sdl2graphics.h +++ b/src/render/sdl2graphics.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef SDL2GRAPHICS_H -#define SDL2GRAPHICS_H +#ifndef RENDER_SDL2GRAPHICS_H +#define RENDER_SDL2GRAPHICS_H #ifdef USE_SDL2 @@ -144,4 +144,4 @@ class SDLGraphics : public Graphics }; #endif // USE_SDL2 -#endif // SDL2GRAPHICS_H +#endif // RENDER_SDL2GRAPHICS_H diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp index ac9f962ac..c1df5b3d0 100644 --- a/src/render/sdl2softwaregraphics.cpp +++ b/src/render/sdl2softwaregraphics.cpp @@ -745,8 +745,8 @@ void SDL2SoftwareGraphics::fillRectangle(const gcn::Rectangle &rectangle) case 2: for (y = y1; y < y2; y++) { - uint8_t *const p0 = static_cast(mSurface->pixels) - + y * mSurface->pitch; + uint8_t *const p0 = static_cast( + mSurface->pixels) + y * mSurface->pitch; for (x = x1; x < x2; x++) { uint8_t *const p = p0 + x * 2; @@ -766,8 +766,8 @@ void SDL2SoftwareGraphics::fillRectangle(const gcn::Rectangle &rectangle) for (y = y1; y < y2; y++) { - uint8_t *const p0 = static_cast(mSurface->pixels) - + y * mSurface->pitch; + uint8_t *const p0 = static_cast( + mSurface->pixels) + y * mSurface->pitch; for (x = x1; x < x2; x++) { uint8_t *const p = p0 + x * 3; @@ -794,8 +794,8 @@ void SDL2SoftwareGraphics::fillRectangle(const gcn::Rectangle &rectangle) for (y = y1; y < y2; y++) { - uint8_t *const p0 = static_cast(mSurface->pixels) - + y * mSurface->pitch; + uint8_t *const p0 = static_cast( + mSurface->pixels) + y * mSurface->pitch; for (x = x1; x < x2; x++) { uint8_t *p = p0 + x * 4; diff --git a/src/render/sdl2softwaregraphics.h b/src/render/sdl2softwaregraphics.h index 9fd53909d..19bf49373 100644 --- a/src/render/sdl2softwaregraphics.h +++ b/src/render/sdl2softwaregraphics.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef SDL2SOFTWAREGRAPHICS_H -#define SDL2SOFTWAREGRAPHICS_H +#ifndef RENDER_SDL2SOFTWAREGRAPHICS_H +#define RENDER_SDL2SOFTWAREGRAPHICS_H #ifdef USE_SDL2 @@ -156,4 +156,4 @@ class SDL2SoftwareGraphics : public Graphics }; #endif // USE_SDL2 -#endif // SDL2SOFTWAREGRAPHICS_H +#endif // RENDER_SDL2SOFTWAREGRAPHICS_H diff --git a/src/render/sdlgraphics.h b/src/render/sdlgraphics.h index a7e4be85b..28393d251 100644 --- a/src/render/sdlgraphics.h +++ b/src/render/sdlgraphics.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef SDLGRAPHICS_H -#define SDLGRAPHICS_H +#ifndef RENDER_SDLGRAPHICS_H +#define RENDER_SDLGRAPHICS_H #ifdef USE_SDL2 #include "render/sdl2graphics.h" @@ -152,4 +152,4 @@ class SDLGraphics : public Graphics }; #endif // USE_SDL2 -#endif // SDLGRAPHICS_H +#endif // RENDER_SDLGRAPHICS_H diff --git a/src/render/surfacegraphics.h b/src/render/surfacegraphics.h index f5194946a..06dffd4ed 100644 --- a/src/render/surfacegraphics.h +++ b/src/render/surfacegraphics.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef SURFACEGRAPHICS_H -#define SURFACEGRAPHICS_H +#ifndef RENDER_SURFACEGRAPHICS_H +#define RENDER_SURFACEGRAPHICS_H #include "render/graphics.h" @@ -182,4 +182,4 @@ class SurfaceGraphics : public Graphics SDL_Surface *mTarget; }; -#endif // SURFACEGRAPHICS_H +#endif // RENDER_SURFACEGRAPHICS_H diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp index 014c33362..2216659a3 100644 --- a/src/resources/openglimagehelper.cpp +++ b/src/resources/openglimagehelper.cpp @@ -215,6 +215,8 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage, break; case RENDER_SOFTWARE: case RENDER_SDL2_DEFAULT: + case RENDER_NULL: + case RENDER_LAST: default: logger->log("Unknown OpenGL backend: %d", mUseOpenGL); break; diff --git a/src/resources/sdlmusic.cpp b/src/resources/sdlmusic.cpp index 6f1d81731..ef8ebb56d 100644 --- a/src/resources/sdlmusic.cpp +++ b/src/resources/sdlmusic.cpp @@ -41,6 +41,9 @@ Resource *SDLMusic::load(SDL_RWops *const rw) { #ifdef USE_SDL2 if (Mix_Music *const music = Mix_LoadMUSType_RW(rw, MUS_OGG, 1)) +#elif defined ANDROID + // +++ here probably mem leak + if (Mix_Music *const music = Mix_LoadMUS_RW(rw)) #else if (Mix_Music *const music = Mix_LoadMUSType_RW(rw, MUS_OGG, SDL_TRUE)) #endif -- cgit v1.2.3-70-g09d2