mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-13 11:40:38 +02:00
CGMonolith: avoid crash when all exits are blocked by friendly heroes
This commit is contained in:
parent
9490a5d66d
commit
b6176649ec
@ -940,17 +940,18 @@ void CGMonolith::onHeroVisit( const CGHeroInstance * h ) const
|
|||||||
void CGMonolith::teleportDialogAnswered(const CGHeroInstance *hero, ui32 answer, TTeleportExitsList exits) const
|
void CGMonolith::teleportDialogAnswered(const CGHeroInstance *hero, ui32 answer, TTeleportExitsList exits) const
|
||||||
{
|
{
|
||||||
int3 dPos;
|
int3 dPos;
|
||||||
|
auto randomExit = getRandomExit(hero);
|
||||||
auto realExits = getAllExits(true);
|
auto realExits = getAllExits(true);
|
||||||
if(!isEntrance() // Do nothing if hero visited exit only object
|
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() && !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;
|
return;
|
||||||
}
|
}
|
||||||
else if(vstd::isValidIndex(exits, answer))
|
else if(vstd::isValidIndex(exits, answer))
|
||||||
dPos = exits[answer].second;
|
dPos = exits[answer].second;
|
||||||
else
|
else
|
||||||
dPos = CGHeroInstance::convertPosition(cb->getObj(getRandomExit(hero))->visitablePos(), true);
|
dPos = CGHeroInstance::convertPosition(cb->getObj(randomExit)->visitablePos(), true);
|
||||||
|
|
||||||
cb->moveHero(hero->id, dPos, true);
|
cb->moveHero(hero->id, dPos, true);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user