1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00

Free memory at TerrainTypeHandler destruction

This commit is contained in:
Tomasz Zieliński 2022-09-25 20:52:51 +02:00
parent 4ea57ea7fc
commit 64fd896978
2 changed files with 17 additions and 0 deletions

View File

@ -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;

View File

@ -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;