1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

vcmi: really correct obstacle trigger

Now obstacle trigger really matches H3
This commit is contained in:
Konstantin
2023-03-27 16:11:17 +03:00
parent 8c1d6c8e13
commit 9a229d6e48
5 changed files with 32 additions and 19 deletions

View File

@@ -798,17 +798,18 @@ std::vector<std::shared_ptr<const CObstacleInstance>> CBattleInfoCallback::battl
return obstacles;
}
std::vector<std::shared_ptr<const CObstacleInstance>> CBattleInfoCallback::getAllAffectedObstaclesByStack(const battle::Unit * unit) const
std::vector<std::shared_ptr<const CObstacleInstance>> CBattleInfoCallback::getAllAffectedObstaclesByStack(const battle::Unit * unit, const std::set<BattleHex> & passed) const
{
std::vector<std::shared_ptr<const CObstacleInstance>> affectedObstacles = std::vector<std::shared_ptr<const CObstacleInstance>>();
auto affectedObstacles = std::vector<std::shared_ptr<const CObstacleInstance>>();
RETURN_IF_NOT_BATTLE(affectedObstacles);
if(unit->alive())
{
affectedObstacles = battleGetAllObstaclesOnPos(unit->getPosition(), false);
if(!passed.count(unit->getPosition()))
affectedObstacles = battleGetAllObstaclesOnPos(unit->getPosition(), false);
if(unit->doubleWide())
{
BattleHex otherHex = unit->occupiedHex(unit->getPosition());
if(otherHex.isValid())
BattleHex otherHex = unit->occupiedHex();
if(otherHex.isValid() && !passed.count(otherHex))
for(auto & i : battleGetAllObstaclesOnPos(otherHex, false))
if(!vstd::contains(affectedObstacles, i))
affectedObstacles.push_back(i);