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

Real fix for #328

This commit is contained in:
Michał W. Urbańczyk
2010-02-10 03:35:48 +00:00
parent c1cb2c223f
commit b8edea2be9

View File

@ -2764,7 +2764,8 @@ void CGTeleport::onHeroVisit( const CGHeroInstance * h ) const
break; break;
case 103: //find nearest subterranean gate on the other level case 103: //find nearest subterranean gate on the other level
{ {
for(int i=0; i < gates.size(); i++) int i=0;
for(; i < gates.size(); i++)
{ {
if(gates[i].first == id) if(gates[i].first == id)
{ {
@ -2777,6 +2778,14 @@ void CGTeleport::onHeroVisit( const CGHeroInstance * h ) const
break; break;
} }
} }
if(destinationid < 0 || i == gates.size()) //no exit
{
InfoWindow iw;
iw.player = h->tempOwner;
iw.text.addTxt(MetaString::ADVOB_TXT, 153); //Just inside the entrance you find a large pile of rubble blocking the tunnel. You leave discouraged.
cb->sendAndApply(&iw);
}
break; break;
} }
} }
@ -2830,9 +2839,16 @@ void CGTeleport::postInit() //matches subterranean gates into pairs
} }
} }
if(best.first >= 0) //found pair
{
gates.push_back(std::pair<int, int>(cur->id, gatesSplit[1][best.first]->id)); gates.push_back(std::pair<int, int>(cur->id, gatesSplit[1][best.first]->id));
gatesSplit[1][best.first] = NULL; gatesSplit[1][best.first] = NULL;
} }
else
{
gates.push_back(std::pair<int, int>(cur->id, -1));
}
}
objs.erase(103); objs.erase(103);