Browse Source

Fix some compile warnings

Sasha Szpakowski 7 months ago
parent
commit
fe23e1920b

+ 3 - 1
src/modules/graphics/Buffer.cpp

@@ -106,7 +106,7 @@ Buffer::Buffer(Graphics *gfx, const Settings &settings, const std::vector<DataDe
 			if (info.baseType == DATA_BASETYPE_BOOL)
 				throw love::Exception("Bool types are not supported in vertex buffers.");
 
-			if (decl.bindingLocation < 0 || decl.bindingLocation >= VertexAttributes::MAX)
+			if (decl.bindingLocation < 0 || decl.bindingLocation >= (int) VertexAttributes::MAX)
 			{
 				if (decl.bindingLocation == -1 && !decl.name.empty())
 					legacyVertexBindings = true;
@@ -344,6 +344,8 @@ std::vector<Buffer::DataDeclaration> Buffer::getCommonFormatDeclaration(CommonFo
 			{ getConstant(ATTRIB_TEXCOORD), DATAFORMAT_FLOAT_VEC2, 0, ATTRIB_TEXCOORD },
 			{ getConstant(ATTRIB_COLOR), DATAFORMAT_UNORM8_VEC4, 0, ATTRIB_COLOR },
 		};
+	case CommonFormat::COUNT:
+		return {};
 	}
 
 	return {};

+ 1 - 1
src/modules/graphics/Mesh.cpp

@@ -227,7 +227,7 @@ void Mesh::finalizeAttribute(BufferAttribute &attrib) const
 			attrib.bindingLocation = (int)builtinattrib;
 	}
 
-	if (attrib.bindingLocation >= VertexAttributes::MAX || (attrib.bindingLocation < 0 && attrib.name.empty()))
+	if (attrib.bindingLocation >= (int) VertexAttributes::MAX || (attrib.bindingLocation < 0 && attrib.name.empty()))
 		throw love::Exception("Vertex attributes must have a valid binding location value within [0, %d).", VertexAttributes::MAX);
 }
 

+ 1 - 1
src/modules/graphics/Shader.cpp

@@ -1232,7 +1232,7 @@ static bool AddFieldsToFormat(std::vector<Buffer::DataDeclaration> &format, int
 		DataFormat dataformat = getDataFormat(type->getBasicType(), type->getVectorSize(), type->getMatrixRows(), type->getMatrixCols(), type->isMatrix());
 		if (dataformat == DATAFORMAT_MAX_ENUM)
 		{
-			err = "Shader validation error:\nUnhandled data format for type " + (int)type->getBasicType() + std::string(" with name ") + basename;
+			err = "Shader validation error:\nUnhandled data format for type " + std::to_string((int)type->getBasicType()) + std::string(" with name ") + basename;
 			return false;
 		}
 

+ 7 - 0
src/modules/graphics/vertex.cpp

@@ -52,6 +52,7 @@ size_t getFormatStride(CommonFormat format)
 		case CommonFormat::XYf_STf_RGBAub: return sizeof(XYf_STf_RGBAub);
 		case CommonFormat::XYf_STus_RGBAub: return sizeof(XYf_STus_RGBAub);
 		case CommonFormat::XYf_STPf_RGBAub: return sizeof(XYf_STPf_RGBAub);
+		case CommonFormat::COUNT: return 0;
 	}
 	return 0;
 }
@@ -77,6 +78,8 @@ uint32 getFormatFlags(CommonFormat format)
 	case CommonFormat::XYf_STus_RGBAub:
 	case CommonFormat::XYf_STPf_RGBAub:
 		return ATTRIBFLAG_POS | ATTRIBFLAG_TEXCOORD | ATTRIBFLAG_COLOR;
+	case CommonFormat::COUNT:
+		return 0;
 	}
 	return 0;
 }
@@ -99,6 +102,8 @@ int getFormatPositionComponents(CommonFormat format)
 		return 2;
 	case CommonFormat::XYZf:
 		return 3;
+	case CommonFormat::COUNT:
+		return 0;
 	}
 	return 0;
 }
@@ -321,6 +326,8 @@ void VertexAttributes::setCommonFormat(CommonFormat format, uint8 bufferindex)
 		set(ATTRIB_TEXCOORD, DATAFORMAT_FLOAT_VEC3, uint16(sizeof(float) * 2), bufferindex);
 		set(ATTRIB_COLOR, DATAFORMAT_UNORM8_VEC4, uint16(sizeof(float) * 5), bufferindex);
 		break;
+	case CommonFormat::COUNT:
+		break;
 	}
 }
 

+ 9 - 12
src/modules/physics/box2d/World.cpp

@@ -126,9 +126,8 @@ bool World::ContactFilter::process(Shape *a, Shape *b)
 	return true;
 }
 
-World::QueryCallback::QueryCallback(World *world, lua_State *L, int idx)
-	: world(world)
-	, L(L)
+World::QueryCallback::QueryCallback(lua_State *L, int idx)
+	: L(L)
 	, funcidx(idx)
 {
 	luaL_checktype(L, funcidx, LUA_TFUNCTION);
@@ -159,9 +158,8 @@ bool World::QueryCallback::ReportFixture(b2Fixture *fixture)
 	return true;
 }
 
-World::CollectCallback::CollectCallback(World *world, uint16 categoryMask, lua_State *L)
-	: world(world)
-	, categoryMask(categoryMask)
+World::CollectCallback::CollectCallback(uint16 categoryMask, lua_State *L)
+	: categoryMask(categoryMask)
 	, L(L)
 {
 	lua_newtable(L);
@@ -185,9 +183,8 @@ bool World::CollectCallback::ReportFixture(b2Fixture *f)
 	return true;
 }
 
-World::RayCastCallback::RayCastCallback(World *world, lua_State *L, int idx)
-	: world(world)
-	, L(L)
+World::RayCastCallback::RayCastCallback(lua_State *L, int idx)
+	: L(L)
 	, funcidx(idx)
 {
 	luaL_checktype(L, funcidx, LUA_TFUNCTION);
@@ -605,7 +602,7 @@ int World::queryShapesInArea(lua_State *L)
 	box.lowerBound = Physics::scaleDown(b2Vec2(lx, ly));
 	box.upperBound = Physics::scaleDown(b2Vec2(ux, uy));
 	luaL_checktype(L, 5, LUA_TFUNCTION);
-	QueryCallback query(this, L, 5);
+	QueryCallback query(L, 5);
 	world->QueryAABB(&query, box);
 	return 0;
 }
@@ -620,7 +617,7 @@ int World::getShapesInArea(lua_State *L)
 	b2AABB box;
 	box.lowerBound = Physics::scaleDown(b2Vec2(lx, ly));
 	box.upperBound = Physics::scaleDown(b2Vec2(ux, uy));
-	CollectCallback query(this, categoryMaskBits, L);
+	CollectCallback query(categoryMaskBits, L);
 	world->QueryAABB(&query, box);
 	return 1;
 }
@@ -634,7 +631,7 @@ int World::rayCast(lua_State *L)
 	b2Vec2 v1 = Physics::scaleDown(b2Vec2(x1, y1));
 	b2Vec2 v2 = Physics::scaleDown(b2Vec2(x2, y2));
 	luaL_checktype(L, 5, LUA_TFUNCTION);
-	RayCastCallback raycast(this, L, 5);
+	RayCastCallback raycast(L, 5);
 	world->RayCast(&raycast, v1, v2);
 	return 0;
 }

+ 3 - 6
src/modules/physics/box2d/World.h

@@ -93,11 +93,10 @@ public:
 	class QueryCallback : public b2QueryCallback
 	{
 	public:
-		QueryCallback(World *world, lua_State *L, int idx);
+		QueryCallback(lua_State *L, int idx);
 		virtual ~QueryCallback();
 		bool ReportFixture(b2Fixture *fixture) override;
 	private:
-		World *world;
 		lua_State *L;
 		int funcidx;
 		int userargs;
@@ -106,11 +105,10 @@ public:
 	class CollectCallback : public b2QueryCallback
 	{
 	public:
-		CollectCallback(World *world, uint16 categoryMask, lua_State *L);
+		CollectCallback(uint16 categoryMask, lua_State *L);
 		virtual ~CollectCallback();
 		bool ReportFixture(b2Fixture *fixture) override;
 	private:
-		World *world;
 		uint16 categoryMask;
 		lua_State *L;
 		int i = 1;
@@ -119,11 +117,10 @@ public:
 	class RayCastCallback : public b2RayCastCallback
 	{
 	public:
-		RayCastCallback(World *world, lua_State *L, int idx);
+		RayCastCallback(lua_State *L, int idx);
 		virtual ~RayCastCallback();
 		float ReportFixture(b2Fixture *fixture, const b2Vec2 &point, const b2Vec2 &normal, float fraction) override;
 	private:
-		World *world;
 		lua_State *L;
 		int funcidx;
 		int userargs;