Commits

rude  committed 348b7de

Fixed some type conversion warnings in VC. Mostly float <-> int and bool <-> int.

  • Participants
  • Parent commits f754636

Comments (0)

Files changed (9)

File src/common/runtime.cpp

 
 	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)

File src/modules/event/sdl/Event.cpp

 		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:

File src/modules/event/sdl/wrap_Event.cpp

 			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;

File src/modules/filesystem/physfs/Filesystem.cpp

 			lua_pushstring(L, "Could not determine file modification date.");
 			return 2;
 		}
-		lua_pushnumber(L, time);
+		lua_pushnumber(L, static_cast<lua_Number>(time));
 		return 1;
 	}
 

File src/modules/graphics/opengl/Font.cpp

 
 	float Font::getHeight() const
 	{
-		return height;
+		return static_cast<float>(height);
 	}
 
 	void Font::print(std::string text, float x, float y, float angle, float sx, float sy) const
 			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<GLfloat>(spacing[g]), 0, 0);
 			dx += spacing[g];
 		}
 		glPopMatrix();
 
 		for(unsigned int i = 0; i < line.size(); i++)
 		{
-			temp += (spacing[(int)line[i]] * mSpacing);
+			temp += static_cast<int>((spacing[(int)line[i]] * mSpacing));
 		}
 
 		return temp;
 				temp = getWidth(text);
 				linen++;
 			}
-			temp += (spacing[(int)line[i]] * mSpacing);
+			temp += static_cast<int>((spacing[(int)line[i]] * mSpacing));
 			text += line[i];
 		}
 

File src/modules/graphics/opengl/Framebuffer.cpp

 	{
 		strategy = NULL;
 
+		float w = static_cast<float>(width);
+		float h = static_cast<float>(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;

File src/modules/graphics/opengl/Glyph.cpp

 		glPushMatrix();
 
 		glMultMatrixf((const GLfloat*)t.getElements());
-		glTranslatef(data->getBearingX(), -data->getBearingY(), 0.0f);
+		glTranslatef(static_cast<float>(data->getBearingX()), static_cast<float>(-data->getBearingY()), 0.0f);
 
 		glEnableClientState(GL_VERTEX_ARRAY);
 		glEnableClientState(GL_TEXTURE_COORD_ARRAY);

File src/modules/graphics/opengl/Graphics.cpp

 		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<int>(image->getWidth());
+		int h = static_cast<int>(image->getHeight());
+		int pitch = static_cast<int>(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);
 	}
 
 	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<float>(LOVE_M_PI * 2);
 		if(points <= 0) points = 1;
 		float angle_shift = (two_pi / points);
 
 
 	bool Graphics::hasFocus()
 	{
-		return SDL_GetAppState() & SDL_APPINPUTFOCUS;
+		return (SDL_GetAppState() & SDL_APPINPUTFOCUS) != 0;
 	}
 } // opengl
 } // graphics

File src/modules/physics/box2d/Body.cpp

 
 	bool Body::getAllowSleeping()
 	{
-		return (body->m_flags & b2Body::e_allowSleepFlag);
+		return (body->m_flags & b2Body::e_allowSleepFlag) != 0;
 	}
 
 	void Body::putToSleep()