1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Use isTeleportChannel callback functions to check teleport channel type

This commit is contained in:
ArseniyShestakov 2015-03-09 02:13:40 +03:00
parent 0c1a37e5a7
commit 8f8d237d5d
3 changed files with 12 additions and 28 deletions

View File

@ -127,7 +127,7 @@ void VCAI::heroMoved(const TryMoveHero & details)
auto t2 = dynamic_cast<const CGTeleport *>(o2);
if(t1 && t2)
{
if(ETeleportChannelType::BIDIRECTIONAL == cb->getTeleportChannelType(t1->channel))
if(cb->isTeleportChannelBidirectional(t1->channel))
{
if(o1->ID == Obj::SUBTERRANEAN_GATE)
{

View File

@ -3557,17 +3557,12 @@ CRandomGenerator & CGameState::getRandomGenerator()
bool CPathfinder::addTeleportTwoWay(const CGTeleport * obj) const
{
if(allowTeleportTwoWay)
{
if(ETeleportChannelType::BIDIRECTIONAL == gs->getTeleportChannelType(obj->channel, hero->tempOwner))
return true;
}
return false;
return allowTeleportTwoWay && gs->isTeleportChannelBidirectional(obj->channel, hero->tempOwner);
}
bool CPathfinder::addTeleportOneWay(const CGTeleport * obj) const
{
if(allowTeleportOneWay)
if(allowTeleportOneWay && isTeleportChannelUnidirectional(obj->channel, hero->tempOwner))
{
auto passableExits = CGTeleport::getPassableExits(gs, hero, gs->getTeleportChannelExits(obj->channel, ObjectInstanceID(), hero->tempOwner));
if(passableExits.size() == 1)
@ -3578,24 +3573,16 @@ bool CPathfinder::addTeleportOneWay(const CGTeleport * obj) const
bool CPathfinder::addTeleportOneWayRandom(const CGTeleport * obj) const
{
if(allowTeleportOneWayRandom)
if(allowTeleportOneWayRandom && isTeleportChannelUnidirectional(obj->channel, hero->tempOwner))
{
if(ETeleportChannelType::UNIDIRECTIONAL == gs->getTeleportChannelType(obj->channel, hero->tempOwner))
{
auto passableExits = CGTeleport::getPassableExits(gs, hero, gs->getTeleportChannelExits(obj->channel, ObjectInstanceID(), hero->tempOwner));
if(passableExits.size() > 1)
return true;
}
auto passableExits = CGTeleport::getPassableExits(gs, hero, gs->getTeleportChannelExits(obj->channel, ObjectInstanceID(), hero->tempOwner));
if(passableExits.size() > 1)
return true;
}
return false;
}
bool CPathfinder::addTeleportWhirlpool(const CGWhirlpool * obj) const
{
if(allowTeleportWhirlpool && obj)
{
if(ETeleportChannelType::IMPASSABLE != gs->getTeleportChannelType(obj->channel, hero->tempOwner))
return true;
}
return false;
return allowTeleportWhirlpool && !gs->isTeleportChannelImpassable(obj->channel, hero->tempOwner);
}

View File

@ -878,13 +878,10 @@ void CGMonolith::onHeroVisit( const CGHeroInstance * h ) const
TeleportDialog td(h, channel);
if(isEntrance())
{
if(ETeleportChannelType::BIDIRECTIONAL == cb->getTeleportChannelType(channel)
&& cb->getTeleportChannelExits(channel).size() > 1)
{
if(cb->isTeleportChannelBidirectional(channel) && 1 < cb->getTeleportChannelExits(channel).size())
td.exits = cb->getTeleportChannelExits(channel);
}
if(ETeleportChannelType::IMPASSABLE == cb->getTeleportChannelType(channel))
if(cb->isTeleportChannelImpassable(channel))
{
logGlobal->debugStream() << "Cannot find corresponding exit monolith for "<< id << " (obj at " << pos << ") :(";
td.impassable = true;
@ -948,7 +945,7 @@ void CGMonolith::initObj()
void CGSubterraneanGate::onHeroVisit( const CGHeroInstance * h ) const
{
TeleportDialog td(h, channel);
if(ETeleportChannelType::IMPASSABLE == cb->getTeleportChannelType(channel)) //no exit
if(cb->isTeleportChannelImpassable(channel))
{
showInfoDialog(h,153,0);//Just inside the entrance you find a large pile of rubble blocking the tunnel. You leave discouraged.
logGlobal->debugStream() << "Cannot find exit subterranean gate for "<< id << " (obj at " << pos << ") :(";
@ -1018,7 +1015,7 @@ void CGSubterraneanGate::postInit( CGameState * gs ) //matches subterranean gate
void CGWhirlpool::onHeroVisit( const CGHeroInstance * h ) const
{
TeleportDialog td(h, channel);
if(ETeleportChannelType::IMPASSABLE == cb->getTeleportChannelType(channel))
if(cb->isTeleportChannelImpassable(channel))
{
logGlobal->debugStream() << "Cannot find exit whirlpool for "<< id << " (obj at " << pos << ") :(";
td.impassable = true;