diff --git a/lib/CTownHandler.cpp b/lib/CTownHandler.cpp index 17e299e22..69f019ab9 100644 --- a/lib/CTownHandler.cpp +++ b/lib/CTownHandler.cpp @@ -56,6 +56,30 @@ si32 CBuilding::getDistance(BuildingID buildID) const return -1; } +CFaction::CFaction() +{ + +} + +CFaction::~CFaction() +{ + delete town; +} + +CTown::CTown() +{ + +} + +CTown::~CTown() +{ + BOOST_FOREACH(auto build, buildings) + build.second.dellNull(); + + BOOST_FOREACH(CStructure * str, clientInfo.structures) + delete str; +} + CTownHandler::CTownHandler() { VLC->townh = this; @@ -554,6 +578,9 @@ CFaction * CTownHandler::loadFromJson(const JsonNode &source) faction->town->faction = faction; loadTown(*faction->town, source["town"]); } + else + faction->town = nullptr; + if (!source["puzzleMap"].isNull()) loadPuzzle(*faction, source["puzzleMap"]); diff --git a/lib/CTownHandler.h b/lib/CTownHandler.h index 3a366eec1..539f44cf6 100644 --- a/lib/CTownHandler.h +++ b/lib/CTownHandler.h @@ -97,6 +97,9 @@ struct DLL_LINKAGE SPuzzleInfo class CFaction { public: + CFaction(); + ~CFaction(); + std::string name; //town name, by default - from TownName.txt TFaction index; @@ -122,6 +125,9 @@ public: class DLL_LINKAGE CTown { public: + CTown(); + ~CTown(); + CFaction * faction; std::vector names; //names of the town instances