Pārlūkot izejas kodu

3187 - fix whirlpool crash when exits are blocked

Andrii Danylchenko 4 gadi atpakaļ
vecāks
revīzija
e219e1febf
1 mainītis faili ar 7 papildinājumiem un 2 dzēšanām
  1. 7 2
      lib/mapObjects/MiscObjects.cpp

+ 7 - 2
lib/mapObjects/MiscObjects.cpp

@@ -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);
 	}
 	}