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

Fix crash due to missing boat for neutrla heroes

This commit is contained in:
Tomasz Zieliński 2023-08-02 17:19:23 +02:00
parent f6247164ad
commit 250b27ba46
2 changed files with 7 additions and 3 deletions

@ -110,7 +110,11 @@ void CBuilding::addNewBonus(const std::shared_ptr<Bonus> & 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)

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