1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

3187 - fix whirlpool crash when exits are blocked

This commit is contained in:
Andrii Danylchenko
2021-10-17 12:18:16 +03:00
committed by Andrii Danylchenko
parent 4da8341024
commit e219e1febf

View File

@@ -1000,7 +1000,7 @@ bool CGTeleport::isExitPassable(CGameState * gs, const CGHeroInstance * h, const
return false; return false;
// Check if it's friendly hero or not // Check if it's friendly hero or not
if(gs->getPlayerRelations(h->tempOwner, objTopVisObj->tempOwner)) if(gs->getPlayerRelations(h->tempOwner, objTopVisObj->tempOwner) != PlayerRelations::ENEMIES)
{ {
// Exchange between heroes only possible via subterranean gates // Exchange between heroes only possible via subterranean gates
if(!dynamic_cast<const CGSubterraneanGate *>(obj)) if(!dynamic_cast<const CGSubterraneanGate *>(obj))
@@ -1269,7 +1269,12 @@ void CGWhirlpool::teleportDialogAnswered(const CGHeroInstance *hero, ui32 answer
dPos = exits[answer].second; dPos = exits[answer].second;
else else
{ {
auto obj = cb->getObj(getRandomExit(hero)); auto exit = getRandomExit(hero);
if(exit == ObjectInstanceID())
return;
auto obj = cb->getObj(exit);
std::set<int3> tiles = obj->getBlockedPos(); std::set<int3> tiles = obj->getBlockedPos();
dPos = CGHeroInstance::convertPosition(*RandomGeneratorUtil::nextItem(tiles, CRandomGenerator::getDefault()), true); dPos = CGHeroInstance::convertPosition(*RandomGeneratorUtil::nextItem(tiles, CRandomGenerator::getDefault()), true);
} }