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:
parent
b8ad5b41f3
commit
56b8fb39f3
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user