GL - Fixed memory leaks in LevelLoader.

This commit is contained in:
Pontus Fransson 2014-02-07 14:44:25 +01:00
parent 9bdf258c5d
commit fef40f58f9
2 changed files with 12 additions and 4 deletions

View File

@ -43,14 +43,14 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
while(counter < bufferSize)
{
//Get typeID
ObjectTypeHeader typeID;
ObjectType typeID;
ParseObject(&buffer[counter], &typeID, sizeof(typeID));
switch((int)typeID.typeID)
switch((int)typeID)
{
case ObjectType_LevelMetaData:
{
LevelMetaData* header = new LevelMetaData;
ParseLevelMetaData(&buffer[counter], *header, counter);
SmartPointer<ObjectTypeHeader> header = new LevelMetaData;
ParseLevelMetaData(&buffer[counter], *(LevelMetaData*)header.Get(), counter);
objects.push_back(header);
break;
}

View File

@ -126,6 +126,9 @@ namespace GameLogic
struct ObjectTypeHeader
{
ObjectType typeID;
//Unless this is here the object destructor wont be called.
virtual ~ObjectTypeHeader(){}
};
namespace LevelLoaderInternal
@ -182,6 +185,9 @@ namespace GameLogic
WorldSize worldSize;
std::string overviewPicturePath;
std::vector<GameMode> gameModesSupported;
virtual ~LevelMetaData(){}
};
struct ObjectHeader : public ObjectTypeHeader, public LevelLoaderInternal::PhysicsObject
@ -197,6 +203,8 @@ namespace GameLogic
float angle;
//Scale
float scale[3];
virtual ~ObjectHeader(){}
};
/************************************