From eb9841897bbe93da6aa4ca2537a3e22b3a868d98 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 27 Aug 2013 19:30:48 +0300 Subject: fix compilation warnings. --- src/graphics.cpp | 14 +++++---- src/gui/sdlinput.cpp | 2 +- src/sdl2graphics.cpp | 16 +++++------ src/sdlgraphics.cpp | 72 ++++++++++++++++++++++++----------------------- src/utils/physfsrwops.cpp | 4 +-- 5 files changed, 56 insertions(+), 52 deletions(-) (limited to 'src') diff --git a/src/graphics.cpp b/src/graphics.cpp index 4e2129cbf..604454e94 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -386,12 +386,9 @@ bool Graphics::resizeScreen(const int width, const int height) if (mWidth == width && mHeight == height) return true; - const int prevWidth = mWidth; - const int prevHeight = mHeight; - +#ifdef USE_SDL2 _endDraw(); -#ifdef USE_SDL2 mRect.w = width; mRect.h = height; mWidth = width; @@ -404,12 +401,17 @@ bool Graphics::resizeScreen(const int width, const int height) glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); #else // +++ need impliment resize in soft mode -#endif +#endif // USE_OPENGL _beginDraw(); return true; #else + const int prevWidth = mWidth; + const int prevHeight = mHeight; + + _endDraw(); + const bool success = setVideoMode(width, height, mBpp, mFullscreen, mHWAccel, mEnableResize, mNoFrame); @@ -427,7 +429,7 @@ bool Graphics::resizeScreen(const int width, const int height) _beginDraw(); return success; -#endif +#endif // USE_SDL2 } int Graphics::getWidth() const diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index ae8c6d7d4..4655bcbec 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -162,7 +162,7 @@ void SDLInput::pushInput(const SDL_Event &event) case SDL_MOUSEWHEEL: { - const int x = event.wheel.x; +// const int x = event.wheel.x; const int y = event.wheel.y; if (y) { diff --git a/src/sdl2graphics.cpp b/src/sdl2graphics.cpp index 51493eb0f..e76335f3e 100644 --- a/src/sdl2graphics.cpp +++ b/src/sdl2graphics.cpp @@ -95,14 +95,14 @@ bool SDLGraphics::drawRescaledImage(const Image *const image, int srcX, int srcY const gcn::ClipRectangle &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; - const SDL_Rect srcRect + const SDL_Rect srcRect = { static_cast(srcX + bounds.x), static_cast(srcY + bounds.y), static_cast(width), static_cast(height) }; - const SDL_Rect dstRect + const SDL_Rect dstRect = { static_cast(dstX + top.xOffset), static_cast(dstY + top.yOffset), @@ -128,7 +128,7 @@ bool SDLGraphics::drawImage2(const Image *const image, int srcX, int srcY, return false; const SDL_Rect &bounds = image->mBounds; - const SDL_Rect srcRect + const SDL_Rect srcRect = { static_cast(srcX + bounds.x), static_cast(srcY + bounds.y), @@ -136,7 +136,7 @@ bool SDLGraphics::drawImage2(const Image *const image, int srcX, int srcY, static_cast(height) }; - const SDL_Rect dstRect + const SDL_Rect dstRect = { static_cast(dstX + top.xOffset), static_cast(dstY + top.yOffset), @@ -491,7 +491,7 @@ bool SDLGraphics::calcWindow(ImageCollection *const vertCol, void SDLGraphics::fillRectangle(const gcn::Rectangle &rectangle) { const gcn::ClipRectangle &top = mClipStack.top(); - const SDL_Rect rect + const SDL_Rect rect = { static_cast(rectangle.x + top.xOffset), static_cast(rectangle.y + top.yOffset), @@ -518,7 +518,7 @@ bool SDLGraphics::pushClipArea(gcn::Rectangle area) const bool result = gcn::Graphics::pushClipArea(area); const gcn::ClipRectangle &carea = mClipStack.top(); - const SDL_Rect rect + const SDL_Rect rect = { static_cast(carea.x), static_cast(carea.y), @@ -537,7 +537,7 @@ void SDLGraphics::popClipArea() return; const gcn::ClipRectangle &carea = mClipStack.top(); - const SDL_Rect rect + const SDL_Rect rect = { static_cast(carea.x), static_cast(carea.y), @@ -562,7 +562,7 @@ void SDLGraphics::drawPoint(int x, int y) return; SDL_SetRenderDrawColor(mRenderer, mColor.r, mColor.g, mColor.b, mColor.a); - const SDL_Point point + const SDL_Point point = { x, y diff --git a/src/sdlgraphics.cpp b/src/sdlgraphics.cpp index 2eb7c88df..4d7e49afa 100644 --- a/src/sdlgraphics.cpp +++ b/src/sdlgraphics.cpp @@ -83,7 +83,7 @@ bool SDLGraphics::drawRescaledImage(const Image *const image, int srcX, int srcY const gcn::ClipRectangle &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; - SDL_Rect srcRect + SDL_Rect srcRect = { static_cast(srcX + bounds.x), static_cast(srcY + bounds.y), @@ -91,7 +91,7 @@ bool SDLGraphics::drawRescaledImage(const Image *const image, int srcX, int srcY static_cast(height) }; - SDL_Rect dstRect + SDL_Rect dstRect = { static_cast(dstX + top.xOffset), static_cast(dstY + top.yOffset), @@ -176,7 +176,7 @@ bool SDLGraphics::drawImage2(const Image *const image, int srcX, int srcY, if (w > 0 && h > 0) { - SDL_Rect srcRect + SDL_Rect srcRect = { static_cast(srcX), static_cast(srcY), @@ -184,7 +184,7 @@ bool SDLGraphics::drawImage2(const Image *const image, int srcX, int srcY, static_cast(h) }; - SDL_Rect dstRect + SDL_Rect dstRect = { static_cast(dstX), static_cast(dstY), @@ -229,73 +229,73 @@ void SDLGraphics::drawImagePattern(const Image *const image, const int dh = (py + ih >= h) ? h - py : ih; int dstY = py + yOffset; int y2 = srcY; - int h = dh; + int h2 = dh; if (y2 < 0) { - h += y2; + h2 += y2; dstY -= static_cast(y2); y2 = 0; } const int maxh = src->h - y2; - if (maxh < h) - h = maxh; + if (maxh < h2) + h2 = maxh; int dy = clipY - dstY; if (dy > 0) { - h -= dy; + h2 -= dy; dstY += static_cast(dy); y2 += dy; } - dy = dstY + h - clipY - clip->h; + dy = dstY + h2 - clipY - clip->h; if (dy > 0) - h -= dy; + h2 -= dy; - if (h > 0) + if (h2 > 0) { for (int px = 0; px < w; px += iw) { const int dw = (px + iw >= w) ? w - px : iw; int dstX = px + xOffset; int x2 = srcX; - int w = dw; + int w2 = dw; if (x2 < 0) { - w += x2; + w2 += x2; dstX -= static_cast(x2); x2 = 0; } const int maxw = src->w - x2; - if (maxw < w) - w = maxw; + if (maxw < w2) + w2 = maxw; int dx = clipX - dstX; if (dx > 0) { - w -= dx; + w2 -= dx; dstX += static_cast(dx); x2 += dx; } - dx = dstX + w - clipX - clip->w; + dx = dstX + w2 - clipX - clip->w; if (dx > 0) - w -= dx; + w2 -= dx; - if (w > 0) + if (w2 > 0) { - SDL_Rect srcRect + SDL_Rect srcRect = { static_cast(x2), static_cast(y2), - static_cast(w), - static_cast(h) + static_cast(w2), + static_cast(h2) }; - SDL_Rect dstRect + SDL_Rect dstRect = { static_cast(dstX), static_cast(dstY), - static_cast(w), - static_cast(h) + static_cast(w2), + static_cast(h2) }; SDL_LowerBlit(src, &srcRect, mWindow, &dstRect); @@ -349,7 +349,7 @@ void SDLGraphics::drawRescaledImagePattern(const Image *const image, const int dw = (px + iw >= w) ? w - px : iw; const int dstX = px + xOffset; - SDL_Rect srcRect + SDL_Rect srcRect = { static_cast(srcX), static_cast(srcY), @@ -357,7 +357,7 @@ void SDLGraphics::drawRescaledImagePattern(const Image *const image, static_cast(dh) }; - SDL_Rect dstRect + SDL_Rect dstRect = { static_cast(dstX), static_cast(dstY), @@ -878,11 +878,13 @@ void SDLGraphics::fillRectangle(const gcn::Rectangle& rectangle) } else { - SDL_Rect rect; - rect.x = static_cast(area.x); - rect.y = static_cast(area.y); - rect.w = static_cast(area.width); - rect.h = static_cast(area.height); + SDL_Rect rect = + { + static_cast(area.x), + static_cast(area.y), + static_cast(area.width), + static_cast(area.height) + }; const uint32_t color = SDL_MapRGBA(mWindow->format, static_cast(mColor.r), @@ -907,7 +909,7 @@ bool SDLGraphics::pushClipArea(gcn::Rectangle area) { const bool result = gcn::Graphics::pushClipArea(area); const gcn::ClipRectangle &carea = mClipStack.top(); - const SDL_Rect rect + const SDL_Rect rect = { static_cast(carea.x), static_cast(carea.y), @@ -927,7 +929,7 @@ void SDLGraphics::popClipArea() return; const gcn::ClipRectangle &carea = mClipStack.top(); - const SDL_Rect rect + const SDL_Rect rect = { static_cast(carea.x), static_cast(carea.y), diff --git a/src/utils/physfsrwops.cpp b/src/utils/physfsrwops.cpp index d0560fb1e..8216e3794 100644 --- a/src/utils/physfsrwops.cpp +++ b/src/utils/physfsrwops.cpp @@ -115,7 +115,7 @@ static PHYSFSSIZE physfsrwops_read(SDL_RWops *const rw, void *ptr, PHYSFS_file *const handle = static_cast( rw->hidden.unknown.data1); const PHYSFS_sint64 rc = PHYSFS_read(handle, ptr, size, maxnum); - if (rc != maxnum) + if (rc != static_cast(maxnum)) { if (!PHYSFS_eof(handle)) /* not EOF? Must be an error. */ SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError()); @@ -131,7 +131,7 @@ static PHYSFSSIZE physfsrwops_write(SDL_RWops *const rw, const void *ptr, PHYSFS_file *const handle = static_cast( rw->hidden.unknown.data1); const PHYSFS_sint64 rc = PHYSFS_write(handle, ptr, size, num); - if (rc != num) + if (rc != static_cast(num)) SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError()); return static_cast(rc); -- cgit v1.2.3-70-g09d2