Browse Source

Partial fix for #561

DjWarmonger 15 years ago
parent
commit
9d82d30856
1 changed files with 6 additions and 1 deletions
  1. 6 1
      hch/CObjectHandler.cpp

+ 6 - 1
hch/CObjectHandler.cpp

@@ -3511,7 +3511,12 @@ void CGTeleport::onHeroVisit( const CGHeroInstance * h ) const
 		return;
 	}
 	if (ID == 111)
-		cb->moveHero (h->id,CGHeroInstance::convertPosition(cb->getObj(destinationid)->pos,true) + (h->pos - pos) - int3(1,0,0), true);
+	{
+		std::set<int3> tiles = cb->getObj(destinationid)->getBlockedPos();
+		std::set<int3>::iterator it = tiles.begin();
+		std::advance (it, rand() % tiles.size()); //picking random element of set is tiring
+		cb->moveHero (h->id, *it + int3(1,0,0), true);
+	}
 	else
 		cb->moveHero (h->id,CGHeroInstance::convertPosition(cb->getObj(destinationid)->pos,true) - getVisitableOffset(), true);
 }