Browse Source

Free memory at TerrainTypeHandler destruction

Tomasz Zieliński 3 years ago
parent
commit
64fd896978
2 changed files with 17 additions and 0 deletions
  1. 16 0
      lib/Terrain.cpp
  2. 1 0
      lib/Terrain.h

+ 16 - 0
lib/Terrain.cpp

@@ -29,6 +29,22 @@ TerrainTypeHandler::TerrainTypeHandler()
 	initTerrains(allConfigs); //maps will be populated inside
 }
 
+TerrainTypeHandler::~TerrainTypeHandler()
+{
+	for (const auto * terrain : objects)
+	{
+		delete terrain;
+	}
+	for (const auto * river : riverTypes)
+	{
+		delete river;
+	}
+	for (const auto * road : roadTypes)
+	{
+		delete road;
+	}
+}
+
 void TerrainTypeHandler::initTerrains(const std::vector<std::string> & allConfigs)
 {
 	std::vector<std::function<void()>> resolveLater;

+ 1 - 0
lib/Terrain.h

@@ -133,6 +133,7 @@ class DLL_LINKAGE TerrainTypeHandler //TODO: public IHandlerBase ?
 public:
 
 	TerrainTypeHandler();
+	~TerrainTypeHandler();
 
 	const std::vector<TerrainType *> & terrains() const;
 	const TerrainType * getInfoByName(const std::string & terrainName) const;