diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-02-22 19:50:00 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-02-22 22:33:52 +0300 |
commit | a8d90b8a84b5a21c53fb5d279dc983ae1e2c3217 (patch) | |
tree | f1e35affbe927a1e81fcfafe91747fe3c1e3f56d /src/guichan | |
parent | 3e75f388c21a7c9a00ef2ff802023be00431248a (diff) | |
download | manaplus-a8d90b8a84b5a21c53fb5d279dc983ae1e2c3217.tar.gz manaplus-a8d90b8a84b5a21c53fb5d279dc983ae1e2c3217.tar.bz2 manaplus-a8d90b8a84b5a21c53fb5d279dc983ae1e2c3217.tar.xz manaplus-a8d90b8a84b5a21c53fb5d279dc983ae1e2c3217.zip |
Fix code style.
Diffstat (limited to 'src/guichan')
-rw-r--r-- | src/guichan/color.cpp | 18 | ||||
-rw-r--r-- | src/guichan/defaultfont.cpp | 2 | ||||
-rw-r--r-- | src/guichan/focushandler.cpp | 20 | ||||
-rw-r--r-- | src/guichan/include/guichan/sdl/sdlpixel.hpp | 23 | ||||
-rw-r--r-- | src/guichan/sdl/sdlimage.cpp | 4 |
5 files changed, 35 insertions, 32 deletions
diff --git a/src/guichan/color.cpp b/src/guichan/color.cpp index d3dc7a738..f58e7b58e 100644 --- a/src/guichan/color.cpp +++ b/src/guichan/color.cpp @@ -97,23 +97,23 @@ namespace gcn b - color.b, 255); - result.r = (result.r>255?255:(result.r<0?0:result.r)); - result.g = (result.g>255?255:(result.g<0?0:result.g)); - result.b = (result.b>255?255:(result.b<0?0:result.b)); + result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r)); + result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g)); + result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b)); return result; } Color Color::operator*(float value) const { - Color result((int)(r * value), - (int)(g * value), - (int)(b * value), + Color result(static_cast<int>(r * value), + static_cast<int>(g * value), + static_cast<int>(b * value), a); - result.r = (result.r>255?255:(result.r<0?0:result.r)); - result.g = (result.g>255?255:(result.g<0?0:result.g)); - result.b = (result.b>255?255:(result.b<0?0:result.b)); + result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r)); + result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g)); + result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b)); return result; } diff --git a/src/guichan/defaultfont.cpp b/src/guichan/defaultfont.cpp index 8871d51de..70901bc8e 100644 --- a/src/guichan/defaultfont.cpp +++ b/src/guichan/defaultfont.cpp @@ -89,7 +89,7 @@ namespace gcn int DefaultFont::getStringIndexAt(const std::string& text, int x) const { - if (x > (int)text.size() * 8) + if (x > static_cast<int>(text.size() * 8)) return text.size(); return x / 8; diff --git a/src/guichan/focushandler.cpp b/src/guichan/focushandler.cpp index 832a201ad..e3610fb1e 100644 --- a/src/guichan/focushandler.cpp +++ b/src/guichan/focushandler.cpp @@ -158,7 +158,7 @@ namespace gcn { int i; int focusedWidget = -1; - for (i = 0; i < (int)mWidgets.size(); ++i) + for (i = 0; i < static_cast<int>(mWidgets.size()); ++i) { if (mWidgets[i] == mFocusedWidget) focusedWidget = i; @@ -167,7 +167,7 @@ namespace gcn // i is a counter that ensures that the following loop // won't get stuck in an infinite loop - i = (int)mWidgets.size(); + i = static_cast<int>(mWidgets.size()); do { ++ focusedWidget; @@ -180,7 +180,7 @@ namespace gcn -- i; - if (focusedWidget >= (int)mWidgets.size()) + if (focusedWidget >= static_cast<int>(mWidgets.size())) focusedWidget = 0; if (focusedWidget == focused) @@ -213,7 +213,7 @@ namespace gcn int i; int focusedWidget = -1; - for (i = 0; i < (int)mWidgets.size(); ++ i) + for (i = 0; i < static_cast<int>(mWidgets.size()); ++ i) { if (mWidgets[i] == mFocusedWidget) focusedWidget = i; @@ -222,7 +222,7 @@ namespace gcn // i is a counter that ensures that the following loop // won't get stuck in an infinite loop - i = (int)mWidgets.size(); + i = static_cast<int>(mWidgets.size()); do { -- focusedWidget; @@ -342,7 +342,7 @@ namespace gcn int i; int focusedWidget = -1; - for (i = 0; i < (int)mWidgets.size(); ++i) + for (i = 0; i < static_cast<int>(mWidgets.size()); ++ i) { if (mWidgets[i] == mFocusedWidget) focusedWidget = i; @@ -352,7 +352,7 @@ namespace gcn // i is a counter that ensures that the following loop // won't get stuck in an infinite loop - i = (int)mWidgets.size(); + i = static_cast<int>(mWidgets.size()); do { ++ focusedWidget; @@ -365,7 +365,7 @@ namespace gcn -- i; - if (focusedWidget >= (int)mWidgets.size()) + if (focusedWidget >= static_cast<int>(mWidgets.size())) focusedWidget = 0; if (focusedWidget == focused) @@ -411,7 +411,7 @@ namespace gcn int i; int focusedWidget = -1; - for (i = 0; i < (int)mWidgets.size(); ++i) + for (i = 0; i < static_cast<int>(mWidgets.size()); ++ i) { if (mWidgets[i] == mFocusedWidget) focusedWidget = i; @@ -421,7 +421,7 @@ namespace gcn // i is a counter that ensures that the following loop // won't get stuck in an infinite loop - i = (int)mWidgets.size(); + i = static_cast<int>(mWidgets.size()); do { -- focusedWidget; diff --git a/src/guichan/include/guichan/sdl/sdlpixel.hpp b/src/guichan/include/guichan/sdl/sdlpixel.hpp index a0221ca7c..bfd08341b 100644 --- a/src/guichan/include/guichan/sdl/sdlpixel.hpp +++ b/src/guichan/include/guichan/sdl/sdlpixel.hpp @@ -68,7 +68,8 @@ namespace gcn SDL_LockSurface(surface); - Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; + Uint8 *p = static_cast<Uint8*>(surface->pixels) + + y * surface->pitch + x * bpp; unsigned int color = 0; @@ -79,7 +80,7 @@ namespace gcn break; case 2: - color = *(Uint16 *)p; + color = *reinterpret_cast<Uint16*>(p); break; case 3: @@ -90,7 +91,7 @@ namespace gcn break; case 4: - color = *(Uint32 *)p; + color = *reinterpret_cast<Uint32*>(p); break; default: @@ -123,7 +124,7 @@ namespace gcn SDL_LockSurface(surface); - Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; + Uint8 *p = static_cast<Uint8*>(surface->pixels) + y * surface->pitch + x * bpp; Uint32 pixel = SDL_MapRGB(surface->format, color.r, color.g, color.b); @@ -134,7 +135,7 @@ namespace gcn break; case 2: - *(Uint16 *)p = pixel; + *reinterpret_cast<Uint16*>(p) = pixel; break; case 3: @@ -153,7 +154,7 @@ namespace gcn break; case 4: - *(Uint32 *)p = pixel; + *reinterpret_cast<Uint32*>(p) = pixel; break; default: @@ -199,7 +200,7 @@ namespace gcn unsigned int r = ((src & f->Bmask) * a + (dst & f->Bmask) * (255 - a)) >> 8; - return (unsigned short)((b & f->Rmask) + return static_cast<unsigned short>((b & f->Rmask) | (g & f->Gmask) | (r & f->Bmask)); } @@ -230,7 +231,8 @@ namespace gcn SDL_LockSurface(surface); - Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; + Uint8 *p = static_cast<Uint8*>(surface->pixels) + + y * surface->pitch + x * bpp; Uint32 pixel = SDL_MapRGB(surface->format, color.r, color.g, color.b); @@ -241,7 +243,7 @@ namespace gcn break; case 2: - *(Uint16 *)p = SDLAlpha16(pixel, *(Uint32 *)p, + *reinterpret_cast<Uint16*>(p) = SDLAlpha16(pixel, *(Uint32 *)p, color.a, surface->format); break; @@ -275,7 +277,8 @@ namespace gcn break; case 4: - *(Uint32 *)p = SDLAlpha32(pixel, *(Uint32 *)p, color.a); + *reinterpret_cast<Uint32*>(p) = SDLAlpha32(pixel, + *reinterpret_cast<Uint32*>(p), color.a); break; default: break; diff --git a/src/guichan/sdl/sdlimage.cpp b/src/guichan/sdl/sdlimage.cpp index e4aadc465..4f9b9565c 100644 --- a/src/guichan/sdl/sdlimage.cpp +++ b/src/guichan/sdl/sdlimage.cpp @@ -130,8 +130,8 @@ namespace gcn for (i = 0; i < mSurface->w * mSurface->h; ++i) { - if (((unsigned int*)mSurface->pixels)[i] == SDL_MapRGB( - mSurface->format, 255, 0, 255)) + if ((static_cast<unsigned int*>(mSurface->pixels))[i] + == SDL_MapRGB(mSurface->format, 255, 0, 255)) { hasPink = true; break; |