1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Removed neighbouringTilesWithDirection and using

allNeighbouringTiles
This commit is contained in:
krs 2023-05-17 22:32:44 +03:00
parent b8ad5b41f3
commit 56b8fb39f3
3 changed files with 9 additions and 24 deletions

View File

@ -449,17 +449,21 @@ std::vector<std::vector<BattleHex::EDir>> BattleFieldController::getOutsideNeigh
for(auto & hex : rangedFullDamageLimitHexes)
{
// get all neighbours and their directions
auto neighbours = hex.neighbouringTilesWithDirection();
auto neighbouringTiles = hex.allNeighbouringTiles();
std::vector<BattleHex::EDir> outsideNeighbourDirections;
// for each neighbour add to output only the ones not found in rangedFullDamageHexes
for(auto & neighbour : neighbours)
// for each neighbour add to output only the valid ones and only that are not found in rangedFullDamageHexes
for(auto direction = 0; direction < 6; direction++)
{
auto it = std::find(rangedFullDamageHexes.begin(), rangedFullDamageHexes.end(), neighbour.second);
if(!neighbouringTiles[direction].isAvailable())
continue;
auto it = std::find(rangedFullDamageHexes.begin(), rangedFullDamageHexes.end(), neighbouringTiles[direction]);
if(it == rangedFullDamageHexes.end())
outsideNeighbourDirections.push_back(neighbour.first); // push direction
outsideNeighbourDirections.push_back(BattleHex::EDir(direction)); // push direction
}
output.push_back(outsideNeighbourDirections);

View File

@ -141,21 +141,6 @@ std::vector<BattleHex> BattleHex::neighbouringTiles() const
return ret;
}
std::vector<std::pair<BattleHex::EDir, BattleHex>> BattleHex::neighbouringTilesWithDirection() const
{
std::vector<std::pair<BattleHex::EDir, BattleHex>> ret;
ret.reserve(6);
for(auto dir : hexagonalDirections())
{
auto tile = cloneInDirection(dir, false);
if(tile.isAvailable())
ret.push_back({dir, tile});
}
return ret;
}
std::vector<BattleHex> BattleHex::allNeighbouringTiles() const
{
std::vector<BattleHex> ret;

View File

@ -87,10 +87,6 @@ struct DLL_LINKAGE BattleHex //TODO: decide if this should be changed to class f
/// returns all valid neighbouring tiles
std::vector<BattleHex> neighbouringTiles() const;
/// returns all valid (not first and last columns) neighbouring tiles, with their relative direction
std::vector<std::pair<BattleHex::EDir, BattleHex>> neighbouringTilesWithDirection() const;
/// returns all tiles, unavailable tiles will be set as invalid
/// order of returned tiles matches EDir enim
std::vector<BattleHex> allNeighbouringTiles() const;