1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +02:00

CGameInfoCallback: more functions to check teleport channel types

This commit is contained in:
ArseniyShestakov 2015-03-09 02:01:24 +03:00
parent eff4da1d03
commit 0c1a37e5a7
2 changed files with 25 additions and 10 deletions

View File

@ -716,10 +716,10 @@ std::vector<ObjectInstanceID> CGameInfoCallback::getTeleportChannelExits(Telepor
return ret; return ret;
} }
ETeleportChannelType CGameInfoCallback::getTeleportChannelType(TeleportChannelID id, PlayerColor Player) const ETeleportChannelType CGameInfoCallback::getTeleportChannelType(TeleportChannelID id, PlayerColor player) const
{ {
std::vector<ObjectInstanceID> entrances = getTeleportChannelEntraces(id, ObjectInstanceID(), Player); std::vector<ObjectInstanceID> entrances = getTeleportChannelEntraces(id, ObjectInstanceID(), player);
std::vector<ObjectInstanceID> exits = getTeleportChannelExits(id, ObjectInstanceID(), Player); std::vector<ObjectInstanceID> exits = getTeleportChannelExits(id, ObjectInstanceID(), player);
if((!entrances.size() || !exits.size()) // impassable if exits or entrances list are empty if((!entrances.size() || !exits.size()) // impassable if exits or entrances list are empty
|| (entrances.size() == 1 && entrances == exits)) // impassable if only entrance and only exit is same object. e.g bidirectional monolith || (entrances.size() == 1 && entrances == exits)) // impassable if only entrance and only exit is same object. e.g bidirectional monolith
{ {
@ -735,12 +735,24 @@ ETeleportChannelType CGameInfoCallback::getTeleportChannelType(TeleportChannelID
return ETeleportChannelType::MIXED; return ETeleportChannelType::MIXED;
} }
bool CGameInfoCallback::isTeleportEntrancePassable(const CGTeleport * obj, PlayerColor Player) const bool CGameInfoCallback::isTeleportChannelImpassable(TeleportChannelID id, PlayerColor player) const
{ {
if(obj && obj->isEntrance() && ETeleportChannelType::IMPASSABLE != getTeleportChannelType(obj->channel, Player)) return ETeleportChannelType::IMPASSABLE == getTeleportChannelType(id, player);
return true; }
else
return false; bool CGameInfoCallback::isTeleportChannelBidirectional(TeleportChannelID id, PlayerColor player) const
{
return ETeleportChannelType::BIDIRECTIONAL == getTeleportChannelType(id, player);
}
bool CGameInfoCallback::isTeleportChannelUnidirectional(TeleportChannelID id, PlayerColor player) const
{
return ETeleportChannelType::UNIDIRECTIONAL == getTeleportChannelType(id, player);
}
bool CGameInfoCallback::isTeleportEntrancePassable(const CGTeleport * obj, PlayerColor player) const
{
return obj && obj->isEntrance() && !isTeleportChannelImpassable(obj->channel, player);
} }
void IGameEventRealizer::showInfoDialog( InfoWindow *iw ) void IGameEventRealizer::showInfoDialog( InfoWindow *iw )

View File

@ -111,8 +111,11 @@ public:
//teleport //teleport
std::vector<ObjectInstanceID> getTeleportChannelEntraces(TeleportChannelID id, ObjectInstanceID excludeId = ObjectInstanceID(), PlayerColor Player = PlayerColor::UNFLAGGABLE) const; std::vector<ObjectInstanceID> getTeleportChannelEntraces(TeleportChannelID id, ObjectInstanceID excludeId = ObjectInstanceID(), PlayerColor Player = PlayerColor::UNFLAGGABLE) const;
std::vector<ObjectInstanceID> getTeleportChannelExits(TeleportChannelID id, ObjectInstanceID excludeId = ObjectInstanceID(), PlayerColor Player = PlayerColor::UNFLAGGABLE) const; std::vector<ObjectInstanceID> getTeleportChannelExits(TeleportChannelID id, ObjectInstanceID excludeId = ObjectInstanceID(), PlayerColor Player = PlayerColor::UNFLAGGABLE) const;
ETeleportChannelType getTeleportChannelType(TeleportChannelID id, PlayerColor Player = PlayerColor::UNFLAGGABLE) const; ETeleportChannelType getTeleportChannelType(TeleportChannelID id, PlayerColor player = PlayerColor::UNFLAGGABLE) const;
bool isTeleportEntrancePassable(const CGTeleport * obj, PlayerColor Player) const; bool isTeleportChannelImpassable(TeleportChannelID id, PlayerColor player = PlayerColor::UNFLAGGABLE) const;
bool isTeleportChannelBidirectional(TeleportChannelID id, PlayerColor player = PlayerColor::UNFLAGGABLE) const;
bool isTeleportChannelUnidirectional(TeleportChannelID id, PlayerColor player = PlayerColor::UNFLAGGABLE) const;
bool isTeleportEntrancePassable(const CGTeleport * obj, PlayerColor player) const;
}; };
class DLL_LINKAGE CPlayerSpecificInfoCallback : public CGameInfoCallback class DLL_LINKAGE CPlayerSpecificInfoCallback : public CGameInfoCallback