Commits

rude committed 80d96b6

Fix warnings in MSVC 2010.

Comments (0)

Files changed (8)

src/common/math.h

 	float x, y;
 	float s, t;
 };
-	
+
 inline int next_p2(int x)
 {
 	x += (x == 0);
 	return ++x;
 }
 
+inline float next_p2(float x)
+{
+	return static_cast<float>(next_p2(static_cast<int>(x)));
+}
+
 } // love
 
 #endif // LOVE_MATH_H

src/common/runtime.h

 	Type luax_type(lua_State * L, int idx);
 
 	/**
+	 * Convert the value at the specified index to an Lua number, and then
+	 * convert to a float.
+	 *
+	 * @param L The Lua state.
+	 * @param idx The index on the stack.
+	 */
+	inline float luax_tofloat(lua_State *L, int idx)
+	{
+		return static_cast<float>(lua_tonumber(L, idx));
+	}
+
+	/**
+	 * Like luax_tofloat, but checks that the value is a number.
+	 *
+	 * @see luax_tofloat
+	 */
+	inline float luax_checkfloat(lua_State *L, int idx)
+	{
+		return static_cast<float>(luaL_checknumber(L, idx));
+	}
+
+	/**
 	* Converts the value at idx to the specified type without checking that
 	* this conversion is valid. If the type has been previously verified with
 	* luax_istype, then this can be safely used. Otherwise, use luax_checktype.

src/modules/filesystem/physfs/wrap_Filesystem.cpp

 	{
 		// no error checking needed, everything, even nothing
 		// can be converted to a boolean
-		instance->setRelease(lua_toboolean(L, 1));
+		instance->setRelease(luax_toboolean(L, 1));
 		return 0;
 	}
 

src/modules/graphics/opengl/Graphics.cpp

 	DisplayState Graphics::saveState()
 	{
 		DisplayState s;
-		//create a table in which to store the color data in float format, before converting it
-		float color[4];
-		//get the color
-		glGetFloatv(GL_CURRENT_COLOR, color);
-		s.color.set( (color[0]*255.0f), (color[1]*255.0f), (color[2]*255.0f), (color[3]*255.0f) );
-		//get the background color
-		glGetFloatv(GL_COLOR_CLEAR_VALUE, color);
-		s.backgroundColor.set( color[0]*255.0f, color[1]*255.0f, color[2]*255.0f, color[3]*255.0f );
+
+		s.color = getColor();
+		s.backgroundColor = getBackgroundColor();
+
 		//store modes here
 		GLint mode;
 		//get blend mode
 		currentMode.colorDepth = 32;
 		currentMode.fsaa = fsaa;
 		currentMode.fullscreen = fullscreen;
-		currentMode.vsync = real_vsync;
+		currentMode.vsync = (real_vsync != 0);
 
 		// Reload all volatile objects.
 		if(!Volatile::loadAll())

src/modules/graphics/opengl/ParticleSystem.cpp

 		pLast->tangentialAcceleration = (rand() / (float(RAND_MAX)+1)) * (max - min) + min;
 
 		pLast->sizeOffset       = (rand() / (float(RAND_MAX)+1)) * sizeVariation; // time offset for size change
-		pLast->sizeIntervalSize = (1.0 - (rand() / (float(RAND_MAX)+1)) * sizeVariation) - pLast->sizeOffset;
+		pLast->sizeIntervalSize = (1.0f - (rand() / (float(RAND_MAX)+1)) * sizeVariation) - pLast->sizeOffset;
 		pLast->size = sizes[(size_t)(pLast->sizeOffset - .5f) * (sizes.size() - 1)];
 
 		min = rotationMin;

src/modules/graphics/opengl/wrap_Graphics.cpp

 			for (int i = 0; i < args; ++i) {
 				lua_pushnumber(L, i + 1);
 				lua_rawget(L, 1);
-				coords[i] = lua_tonumber(L, -1);
+				coords[i] = luax_tofloat(L, -1);
 				lua_pop(L, 1);
 			}
 		} else {
 			for (int i = 0; i < args; ++i)
-				coords[i] = lua_tonumber(L, i + 1);
+				coords[i] = luax_tofloat(L, i + 1);
 		}
 
 		instance->polyline(coords, args);
 			for (int i = 0; i < args; ++i) {
 				lua_pushnumber(L, i + 1);
 				lua_rawget(L, 2);
-				coords[i] = lua_tonumber(L, -1);
+				coords[i] = luax_tofloat(L, -1);
 				lua_pop(L, 1);
 			}
 		} else {
 			for (int i = 0; i < args; ++i)
-				coords[i] = lua_tonumber(L, i + 2);
+				coords[i] = luax_tofloat(L, i + 2);
 		}
 
 		// make a closed loop

src/modules/graphics/opengl/wrap_ParticleSystem.cpp

 		ParticleSystem * t = luax_checkparticlesystem(L, 1);
 		size_t nSizes = lua_gettop(L) - 1;
 		if (nSizes == 1) {
-			t->setSize(luaL_checknumber(L, 2));
+			t->setSize(luax_checkfloat(L, 2));
 		} else {
 			std::vector<float> sizes(nSizes);
 			for (size_t i = 0; i < nSizes; ++i)
-				sizes[i] = luaL_checknumber(L, 1 + i + 1);
+				sizes[i] = luax_checkfloat(L, 1 + i + 1);
 
 			t->setSize(sizes);
 		}

src/modules/sound/lullaby/Mpg123Decoder.cpp

 
 	bool Mpg123Decoder::seek(float s)
 	{
-		off_t offset = s * sampleRate;
+		off_t offset = static_cast<off_t>(s * static_cast<float>(sampleRate));
 
 		if(offset < 0)
 			return false;