diff --git a/Code/Game/GameLogic/LevelLoader/LevelParser.cpp b/Code/Game/GameLogic/LevelLoader/LevelParser.cpp index 75fed5cf..667633f9 100644 --- a/Code/Game/GameLogic/LevelLoader/LevelParser.cpp +++ b/Code/Game/GameLogic/LevelLoader/LevelParser.cpp @@ -43,14 +43,14 @@ std::vector> 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 header = new LevelMetaData; + ParseLevelMetaData(&buffer[counter], *(LevelMetaData*)header.Get(), counter); objects.push_back(header); break; } diff --git a/Code/Game/GameLogic/LevelLoader/ObjectDefines.h b/Code/Game/GameLogic/LevelLoader/ObjectDefines.h index b1264162..ff18553d 100644 --- a/Code/Game/GameLogic/LevelLoader/ObjectDefines.h +++ b/Code/Game/GameLogic/LevelLoader/ObjectDefines.h @@ -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 gameModesSupported; + + virtual ~LevelMetaData(){} + }; struct ObjectHeader : public ObjectTypeHeader, public LevelLoaderInternal::PhysicsObject @@ -197,6 +203,8 @@ namespace GameLogic float angle; //Scale float scale[3]; + + virtual ~ObjectHeader(){} }; /************************************