mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-07 07:10:04 +02:00
CPathfinder: store pathfinding options in set instead of variables
There is plenty of variables now and in future I'm going to add more more once pathfinder become usable for all kind of things.
This commit is contained in:
parent
886042dc11
commit
0faedde6b9
@ -3407,7 +3407,7 @@ bool CPathfinder::checkDestinationTile()
|
||||
return true; // This one is tricky, we can ignore fact that tile is not ACCESSIBLE in case if it's our hero block it. Though this need investigation
|
||||
if(dp->accessible == CGPathNode::VISITABLE && CGTeleport::isTeleport(dt->topVisitableObj()))
|
||||
return true; // For now we'll walways allos transit for teleports
|
||||
if(useEmbarkCost && allowEmbarkAndDisembark)
|
||||
if(useEmbarkCost && vstd::contains(options, EOptions::EMBARK_AND_DISEMBARK))
|
||||
return true;
|
||||
if(isDestinationGuarded() && !isSourceGuarded())
|
||||
return true; // Can step into a hostile tile once
|
||||
@ -3612,13 +3612,11 @@ CPathfinder::CPathfinder(CPathsInfo &_out, CGameState *_gs, const CGHeroInstance
|
||||
|
||||
initializeGraph();
|
||||
|
||||
allowEmbarkAndDisembark = true;
|
||||
allowTeleportTwoWay = true;
|
||||
allowTeleportOneWay = true;
|
||||
allowTeleportOneWayRandom = false;
|
||||
allowTeleportWhirlpool = false;
|
||||
options.insert(EOptions::EMBARK_AND_DISEMBARK);
|
||||
options.insert(EOptions::TELEPORT_TWO_WAY);
|
||||
options.insert(EOptions::TELEPORT_ONE_WAY);
|
||||
if (CGWhirlpool::isProtected(hero))
|
||||
allowTeleportWhirlpool = true;
|
||||
options.insert(EOptions::TELEPORT_WHIRLPOOL);
|
||||
|
||||
neighbours.reserve(16);
|
||||
}
|
||||
@ -3631,12 +3629,12 @@ CRandomGenerator & CGameState::getRandomGenerator()
|
||||
|
||||
bool CPathfinder::addTeleportTwoWay(const CGTeleport * obj) const
|
||||
{
|
||||
return allowTeleportTwoWay && gs->isTeleportChannelBidirectional(obj->channel, hero->tempOwner);
|
||||
return vstd::contains(options,EOptions::TELEPORT_TWO_WAY) && gs->isTeleportChannelBidirectional(obj->channel, hero->tempOwner);
|
||||
}
|
||||
|
||||
bool CPathfinder::addTeleportOneWay(const CGTeleport * obj) const
|
||||
{
|
||||
if(allowTeleportOneWay && isTeleportChannelUnidirectional(obj->channel, hero->tempOwner))
|
||||
if(vstd::contains(options,EOptions::TELEPORT_ONE_WAY) && isTeleportChannelUnidirectional(obj->channel, hero->tempOwner))
|
||||
{
|
||||
auto passableExits = CGTeleport::getPassableExits(gs, hero, gs->getTeleportChannelExits(obj->channel, hero->tempOwner));
|
||||
if(passableExits.size() == 1)
|
||||
@ -3647,7 +3645,7 @@ bool CPathfinder::addTeleportOneWay(const CGTeleport * obj) const
|
||||
|
||||
bool CPathfinder::addTeleportOneWayRandom(const CGTeleport * obj) const
|
||||
{
|
||||
if(allowTeleportOneWayRandom && isTeleportChannelUnidirectional(obj->channel, hero->tempOwner))
|
||||
if(vstd::contains(options,EOptions::TELEPORT_ONE_WAY_RANDOM) && isTeleportChannelUnidirectional(obj->channel, hero->tempOwner))
|
||||
{
|
||||
auto passableExits = CGTeleport::getPassableExits(gs, hero, gs->getTeleportChannelExits(obj->channel, hero->tempOwner));
|
||||
if(passableExits.size() > 1)
|
||||
@ -3658,5 +3656,5 @@ bool CPathfinder::addTeleportOneWayRandom(const CGTeleport * obj) const
|
||||
|
||||
bool CPathfinder::addTeleportWhirlpool(const CGWhirlpool * obj) const
|
||||
{
|
||||
return allowTeleportWhirlpool && obj;
|
||||
return vstd::contains(options,EOptions::TELEPORT_WHIRLPOOL) && obj;
|
||||
}
|
||||
|
@ -279,11 +279,16 @@ struct DLL_EXPORT DuelParameters
|
||||
class CPathfinder : private CGameInfoCallback
|
||||
{
|
||||
private:
|
||||
bool allowEmbarkAndDisembark;
|
||||
bool allowTeleportTwoWay; // Two-way monoliths and Subterranean Gate
|
||||
bool allowTeleportOneWay; // One-way monoliths with one known exit only
|
||||
bool allowTeleportOneWayRandom; // One-way monoliths with more than one known exit
|
||||
bool allowTeleportWhirlpool; // Force enabled if hero protected or unaffected (have one stack of one creature)
|
||||
enum class EOptions
|
||||
{
|
||||
EMBARK_AND_DISEMBARK,
|
||||
TELEPORT_TWO_WAY, // Two-way monoliths and Subterranean Gate
|
||||
TELEPORT_ONE_WAY, // One-way monoliths with one known exit only
|
||||
TELEPORT_ONE_WAY_RANDOM, // One-way monoliths with more than one known exit
|
||||
TELEPORT_WHIRLPOOL // Force enabled if hero protected or unaffected (have one stack of one creature)
|
||||
};
|
||||
std::set<EOptions> options;
|
||||
|
||||
CPathsInfo &out;
|
||||
const CGHeroInstance *hero;
|
||||
const std::vector<std::vector<std::vector<ui8> > > &FoW;
|
||||
|
Loading…
x
Reference in New Issue
Block a user