Browse Source

Some small fixes to make LOVE compilable in MSVC2010.

rude 15 years ago
parent
commit
8c721ceb6a

+ 4 - 2
src/modules/font/freetype/Font.cpp

@@ -48,11 +48,13 @@ namespace freetype
 	Rasterizer * Font::newRasterizer(love::image::ImageData * data, std::string glyphs)
 	Rasterizer * Font::newRasterizer(love::image::ImageData * data, std::string glyphs)
 	{
 	{
 		int length = glyphs.size();
 		int length = glyphs.size();
-		unsigned short g[length];
+		unsigned short * g = new unsigned short[length];
 		for (int i = 0; i < length; i++) {
 		for (int i = 0; i < length; i++) {
 			g[i] = glyphs[i];
 			g[i] = glyphs[i];
 		}
 		}
-		return newRasterizer(data, g, length);
+		Rasterizer * r = newRasterizer(data, g, length);
+		delete [] g;
+		return r;
 	}
 	}
 
 
 	Rasterizer * Font::newRasterizer(love::image::ImageData * data, unsigned short * glyphs, int length)
 	Rasterizer * Font::newRasterizer(love::image::ImageData * data, unsigned short * glyphs, int length)

+ 5 - 0
src/modules/physics/box2d/Body.cpp

@@ -309,6 +309,11 @@ namespace box2d
 		return (body->m_flags & b2Body::e_fixedRotationFlag) != 0;
 		return (body->m_flags & b2Body::e_fixedRotationFlag) != 0;
 	}
 	}
 
 
+	World * Body::getWorld() const
+	{
+		return world;
+	}
+
 	b2Vec2 Body::getVector(lua_State * L)
 	b2Vec2 Body::getVector(lua_State * L)
 	{
 	{
 		love::luax_assert_argc(L, 2, 2);
 		love::luax_assert_argc(L, 2, 2);

+ 5 - 0
src/modules/physics/box2d/Body.h

@@ -341,6 +341,11 @@ namespace box2d
 
 
 		void setFixedRotation(bool fixed);
 		void setFixedRotation(bool fixed);
 		bool getFixedRotation() const;
 		bool getFixedRotation() const;
+
+		/**
+		* Get the World this Body resides in.
+		*/
+		World * getWorld() const;
 	private:
 	private:
 
 
 		/**
 		/**

+ 6 - 6
src/modules/physics/box2d/Shape.cpp

@@ -115,7 +115,7 @@ namespace box2d
 
 
 	bool Shape::testPoint(float x, float y) const
 	bool Shape::testPoint(float x, float y) const
 	{
 	{
-		return shape->TestPoint(shape->GetBody()->GetXForm(), body->world->scaleDown(b2Vec2(x, y)));
+		return shape->TestPoint(shape->GetBody()->GetXForm(), body->getWorld()->scaleDown(b2Vec2(x, y)));
 	}
 	}
 
 
 	int Shape::testSegment(lua_State * L)
 	int Shape::testSegment(lua_State * L)
@@ -129,8 +129,8 @@ namespace box2d
 		s.p2.x = (float)lua_tonumber(L, 3);
 		s.p2.x = (float)lua_tonumber(L, 3);
 		s.p2.y = (float)lua_tonumber(L, 4);
 		s.p2.y = (float)lua_tonumber(L, 4);
 
 
-		s.p1 = body->world->scaleDown(s.p1);
-		s.p2 = body->world->scaleDown(s.p2);
+		s.p1 = body->getWorld()->scaleDown(s.p1);
+		s.p2 = body->getWorld()->scaleDown(s.p2);
 
 
 		float lambda;
 		float lambda;
 		b2Vec2 normal;
 		b2Vec2 normal;
@@ -138,7 +138,7 @@ namespace box2d
 		if(shape->TestSegment(shape->GetBody()->GetXForm(), &lambda, &normal, s, 1.0f))
 		if(shape->TestSegment(shape->GetBody()->GetXForm(), &lambda, &normal, s, 1.0f))
 		{
 		{
 			lua_pushnumber(L, lambda);
 			lua_pushnumber(L, lambda);
-			normal = body->world->scaleUp(normal);
+			normal = body->getWorld()->scaleUp(normal);
 			lua_pushnumber(L, normal.x);
 			lua_pushnumber(L, normal.x);
 			lua_pushnumber(L, normal.y);
 			lua_pushnumber(L, normal.y);
 			return 3;
 			return 3;
@@ -229,7 +229,7 @@ namespace box2d
 	int Shape::pushBits(lua_State * L, uint16 bits)
 	int Shape::pushBits(lua_State * L, uint16 bits)
 	{
 	{
 		// Create a bitset.
 		// Create a bitset.
-		std::bitset<16> b((unsigned long)bits);
+		std::bitset<16> b((int)bits);
 
 
 		// Push all set bits.
 		// Push all set bits.
 		for(int i = 0;i<16;i++)
 		for(int i = 0;i<16;i++)
@@ -270,7 +270,7 @@ namespace box2d
 		love::luax_assert_argc(L, 0, 0);
 		love::luax_assert_argc(L, 0, 0);
 		b2AABB bb;
 		b2AABB bb;
 		shape->ComputeAABB(&bb, shape->GetBody()->GetXForm());
 		shape->ComputeAABB(&bb, shape->GetBody()->GetXForm());
-		bb = body->world->scaleUp(bb);
+		bb = body->getWorld()->scaleUp(bb);
 
 
 		// Top left.
 		// Top left.
 		lua_pushnumber(L, bb.lowerBound.x);
 		lua_pushnumber(L, bb.lowerBound.x);

+ 1 - 0
src/modules/physics/box2d/graham/GrahamScanConvexHull.cpp

@@ -1,6 +1,7 @@
 #include "GrahamScanConvexHull.h"
 #include "GrahamScanConvexHull.h"
 
 
 #include <cmath>
 #include <cmath>
+#include <iterator>
 
 
 bool GrahamScanConvexHull::operator()(const std::vector < point2d >& pnt, std::vector< point2d >& final_hull)
 bool GrahamScanConvexHull::operator()(const std::vector < point2d >& pnt, std::vector< point2d >& final_hull)
 {
 {