diff --git a/lib/mapObjectConstructors/CommonConstructors.cpp b/lib/mapObjectConstructors/CommonConstructors.cpp index 13f286cbf..6a558b96a 100644 --- a/lib/mapObjectConstructors/CommonConstructors.cpp +++ b/lib/mapObjectConstructors/CommonConstructors.cpp @@ -133,7 +133,7 @@ void CHeroInstanceConstructor::afterLoadFinalization() { filters[entry.first] = LogicalExpression(entry.second, [](const JsonNode & node) { - return HeroTypeID(VLC->identifiers()->getIdentifier("hero", node.Vector()[0]).value()); + return HeroTypeID(VLC->identifiers()->getIdentifier("hero", node.Vector()[0]).value_or(-1)); }); } } diff --git a/lib/spells/effects/Summon.cpp b/lib/spells/effects/Summon.cpp index ac3c0206b..39b4dceca 100644 --- a/lib/spells/effects/Summon.cpp +++ b/lib/spells/effects/Summon.cpp @@ -42,6 +42,12 @@ void Summon::adjustTargetTypes(std::vector & types) const bool Summon::applicable(Problem & problem, const Mechanics * m) const { + if (creature == CreatureID::NONE) + { + logMod->error("Attempt to summon non-existing creature!"); + return m->adaptGenericProblem(problem); + } + if(exclusive) { //check if there are summoned creatures of other type