1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Survive giving Commander's badge to stacks

Used to SEGFAULT
This commit is contained in:
Vadim Markovtsev 2016-10-30 10:00:25 +01:00
parent 79c85be93f
commit 220e4d2030
2 changed files with 238 additions and 229 deletions

View File

@ -2512,7 +2512,14 @@ void CPlayerInterface::askToAssembleArtifact(const ArtifactLocation &al)
auto hero = dynamic_cast<const CGHeroInstance*>(al.relatedObj());
if (hero)
{
CArtPlace::askToAssemble(hero->getArt(al.slot), al.slot, hero);
auto art = hero->getArt(al.slot);
if (art == nullptr)
{
logGlobal->error("artifact location %d points to nothing",
al.slot.num);
return;
}
CArtPlace::askToAssemble(art, al.slot, hero);
}
}

View File

@ -214,6 +214,8 @@ void CArtPlace::clickLeft(tribool down, bool previousState)
bool CArtPlace::askToAssemble(const CArtifactInstance *art, ArtifactPosition slot,
const CGHeroInstance *hero)
{
assert(art != nullptr);
assert(hero != nullptr);
std::vector<const CArtifact *> assemblyPossibilities = art->assemblyPossibilities(hero);
// If the artifact can be assembled, display dialog.