diff --git a/lib/CTownHandler.cpp b/lib/CTownHandler.cpp index 78c849e92..f756c79de 100644 --- a/lib/CTownHandler.cpp +++ b/lib/CTownHandler.cpp @@ -110,7 +110,11 @@ void CBuilding::addNewBonus(const std::shared_ptr & b, BonusList & bonusL CFaction::~CFaction() { - delete town; + if (town) + { + delete town; + town = nullptr; + } } int32_t CFaction::getIndex() const @@ -1029,7 +1033,7 @@ CFaction * CTownHandler::loadFromJson(const std::string & scope, const JsonNode faction->creatureBg120 = source["creatureBackground"]["120px"].String(); faction->creatureBg130 = source["creatureBackground"]["130px"].String(); - faction->boatType = EBoatId::NONE; + faction->boatType = EBoatId::CASTLE; //Do not crash if (!source["boat"].isNull()) { VLC->modh->identifiers.requestIdentifier("core:boat", source["boat"], [=](int32_t boatTypeID) diff --git a/lib/CTownHandler.h b/lib/CTownHandler.h index 3acbf9a70..66aec6196 100644 --- a/lib/CTownHandler.h +++ b/lib/CTownHandler.h @@ -207,7 +207,7 @@ public: /// Boat that will be used by town shipyard (if any) /// and for placing heroes directly on boat (in map editor, water prisons & taverns) - BoatId boatType; + BoatId boatType = BoatId(EBoatId::CASTLE); CTown * town = nullptr; //NOTE: can be null