Răsfoiți Sursa

Removed neighbouringTilesWithDirection and using

allNeighbouringTiles
krs 2 ani în urmă
părinte
comite
56b8fb39f3

+ 9 - 5
client/battle/BattleFieldController.cpp

@@ -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);

+ 0 - 15
lib/battle/BattleHex.cpp

@@ -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;

+ 0 - 4
lib/battle/BattleHex.h

@@ -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;