From 31c9995082fd92b5317a1314b8dbc00f123664d0 Mon Sep 17 00:00:00 2001 From: rude Date: Sun, 9 Jan 2011 16:28:30 +0100 Subject: [PATCH] Fixed some type conversion warnings in VC. Mostly float <-> int and bool <-> int. --- src/common/runtime.cpp | 2 +- src/modules/event/sdl/Event.cpp | 2 +- src/modules/event/sdl/wrap_Event.cpp | 2 +- src/modules/filesystem/physfs/Filesystem.cpp | 2 +- src/modules/graphics/opengl/Font.cpp | 8 ++++---- src/modules/graphics/opengl/Framebuffer.cpp | 9 ++++++--- src/modules/graphics/opengl/Glyph.cpp | 2 +- src/modules/graphics/opengl/Graphics.cpp | 11 ++++++++--- src/modules/physics/box2d/Body.cpp | 2 +- 9 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/common/runtime.cpp b/src/common/runtime.cpp index 3a6fffd49..67563faf0 100644 --- a/src/common/runtime.cpp +++ b/src/common/runtime.cpp @@ -98,7 +98,7 @@ namespace love bool luax_toboolean(lua_State * L, int idx) { - return (lua_toboolean(L, idx) == 1 ? true : false); + return (lua_toboolean(L, idx) != 0); } void luax_pushboolean(lua_State * L, bool b) diff --git a/src/modules/event/sdl/Event.cpp b/src/modules/event/sdl/Event.cpp index 1e73400dc..99046d489 100644 --- a/src/modules/event/sdl/Event.cpp +++ b/src/modules/event/sdl/Event.cpp @@ -99,7 +99,7 @@ namespace sdl case SDL_ACTIVEEVENT: if (e.active.state & SDL_APPINPUTFOCUS) { m.type = Event::TYPE_FOCUS; - m.focus.f = e.active.gain; + m.focus.f = (e.active.gain != 0); return true; } else break; case SDL_QUIT: diff --git a/src/modules/event/sdl/wrap_Event.cpp b/src/modules/event/sdl/wrap_Event.cpp index 1a8b14309..c154ed23f 100644 --- a/src/modules/event/sdl/wrap_Event.cpp +++ b/src/modules/event/sdl/wrap_Event.cpp @@ -65,7 +65,7 @@ namespace sdl msg.joystick.button = luaL_checkint(L, 3); return true; case Event::TYPE_FOCUS: - msg.focus.f = lua_toboolean(L, 2); + msg.focus.f = luax_toboolean(L, 2); return true; case Event::TYPE_QUIT: return true; diff --git a/src/modules/filesystem/physfs/Filesystem.cpp b/src/modules/filesystem/physfs/Filesystem.cpp index 21a42f349..919e200d4 100644 --- a/src/modules/filesystem/physfs/Filesystem.cpp +++ b/src/modules/filesystem/physfs/Filesystem.cpp @@ -567,7 +567,7 @@ namespace physfs lua_pushstring(L, "Could not determine file modification date."); return 2; } - lua_pushnumber(L, time); + lua_pushnumber(L, static_cast(time)); return 1; } diff --git a/src/modules/graphics/opengl/Font.cpp b/src/modules/graphics/opengl/Font.cpp index 97ba816bb..175a362cc 100644 --- a/src/modules/graphics/opengl/Font.cpp +++ b/src/modules/graphics/opengl/Font.cpp @@ -62,7 +62,7 @@ namespace opengl float Font::getHeight() const { - return height; + return static_cast(height); } void Font::print(std::string text, float x, float y, float angle, float sx, float sy) const @@ -86,7 +86,7 @@ namespace opengl if (type == FONT_TRUETYPE) glTranslatef(0, floor(getHeight() / 1.25f + 0.5f), 0); glyphs[g]->draw(0, 0, 0, 1, 1, 0, 0); glPopMatrix(); - glTranslatef(spacing[g], 0, 0); + glTranslatef(static_cast(spacing[g]), 0, 0); dx += spacing[g]; } glPopMatrix(); @@ -108,7 +108,7 @@ namespace opengl for(unsigned int i = 0; i < line.size(); i++) { - temp += (spacing[(int)line[i]] * mSpacing); + temp += static_cast((spacing[(int)line[i]] * mSpacing)); } return temp; @@ -144,7 +144,7 @@ namespace opengl temp = getWidth(text); linen++; } - temp += (spacing[(int)line[i]] * mSpacing); + temp += static_cast((spacing[(int)line[i]] * mSpacing)); text += line[i]; } diff --git a/src/modules/graphics/opengl/Framebuffer.cpp b/src/modules/graphics/opengl/Framebuffer.cpp index 87e75ce29..298f39c74 100644 --- a/src/modules/graphics/opengl/Framebuffer.cpp +++ b/src/modules/graphics/opengl/Framebuffer.cpp @@ -146,11 +146,14 @@ namespace opengl { strategy = NULL; + float w = static_cast(width); + float h = static_cast(height); + // world coordinates vertices[0].x = 0; vertices[0].y = 0; - vertices[1].x = 0; vertices[1].y = height; - vertices[2].x = width; vertices[2].y = height; - vertices[3].x = width; vertices[3].y = 0; + vertices[1].x = 0; vertices[1].y = h; + vertices[2].x = w; vertices[2].y = h; + vertices[3].x = w; vertices[3].y = 0; // texture coordinates vertices[0].s = 0; vertices[0].t = 1; diff --git a/src/modules/graphics/opengl/Glyph.cpp b/src/modules/graphics/opengl/Glyph.cpp index bbee12489..27f51f5d6 100644 --- a/src/modules/graphics/opengl/Glyph.cpp +++ b/src/modules/graphics/opengl/Glyph.cpp @@ -70,7 +70,7 @@ namespace opengl glPushMatrix(); glMultMatrixf((const GLfloat*)t.getElements()); - glTranslatef(data->getBearingX(), -data->getBearingY(), 0.0f); + glTranslatef(static_cast(data->getBearingX()), static_cast(-data->getBearingY()), 0.0f); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 972ca9838..f0808d3c3 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -341,7 +341,12 @@ namespace opengl bmask = 0x00FF0000; amask = 0xFF000000; #endif - SDL_Surface * icon = SDL_CreateRGBSurfaceFrom(image->getData()->getData(), image->getWidth(), image->getHeight(), 32, image->getWidth() * 4, rmask, gmask, bmask, amask); + + int w = static_cast(image->getWidth()); + int h = static_cast(image->getHeight()); + int pitch = static_cast(image->getWidth() * 4); + + SDL_Surface * icon = SDL_CreateRGBSurfaceFrom(image->getData()->getData(), w, h, 32, pitch, rmask, gmask, bmask, amask); SDL_WM_SetIcon(icon, NULL); SDL_FreeSurface(icon); } @@ -943,7 +948,7 @@ namespace opengl void Graphics::circle(DrawMode mode, float x, float y, float radius, int points ) { - float two_pi = LOVE_M_PI * 2; + float two_pi = static_cast(LOVE_M_PI * 2); if(points <= 0) points = 1; float angle_shift = (two_pi / points); @@ -1125,7 +1130,7 @@ namespace opengl bool Graphics::hasFocus() { - return SDL_GetAppState() & SDL_APPINPUTFOCUS; + return (SDL_GetAppState() & SDL_APPINPUTFOCUS) != 0; } } // opengl } // graphics diff --git a/src/modules/physics/box2d/Body.cpp b/src/modules/physics/box2d/Body.cpp index 889ceabb4..44f4f000c 100644 --- a/src/modules/physics/box2d/Body.cpp +++ b/src/modules/physics/box2d/Body.cpp @@ -283,7 +283,7 @@ namespace box2d bool Body::getAllowSleeping() { - return (body->m_flags & b2Body::e_allowSleepFlag); + return (body->m_flags & b2Body::e_allowSleepFlag) != 0; } void Body::putToSleep()