1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-11 11:31:52 +02:00

CGMonolith: avoid crash when all exits are blocked by friendly heroes

This commit is contained in:
ArseniyShestakov 2015-12-18 01:08:19 +03:00
parent 9490a5d66d
commit b6176649ec

View File

@ -940,17 +940,18 @@ void CGMonolith::onHeroVisit( const CGHeroInstance * h ) const
void CGMonolith::teleportDialogAnswered(const CGHeroInstance *hero, ui32 answer, TTeleportExitsList exits) const
{
int3 dPos;
auto randomExit = getRandomExit(hero);
auto realExits = getAllExits(true);
if(!isEntrance() // Do nothing if hero visited exit only object
|| (!exits.size() && !realExits.size()) // Do nothing if there no exits on this channel
|| (!exits.size() && ObjectInstanceID() == getRandomExit(hero))) // Do nothing if all exits are blocked by friendly hero and it's not subterranean gate
|| ObjectInstanceID() == randomExit) // Do nothing if all exits are blocked by friendly hero and it's not subterranean gate
{
return;
}
else if(vstd::isValidIndex(exits, answer))
dPos = exits[answer].second;
else
dPos = CGHeroInstance::convertPosition(cb->getObj(getRandomExit(hero))->visitablePos(), true);
dPos = CGHeroInstance::convertPosition(cb->getObj(randomExit)->visitablePos(), true);
cb->moveHero(hero->id, dPos, true);
}