mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-03 00:46:55 +02:00
Refactor BattleHex, remake the use of precomputed neighbouring tiles containers.
- Moved short, frequently used functions to the BattleHex header for inlining - Made BattleHex a class with a private hex value - Moved getClosestTile implementation back to BattleHex - Enabled access to static precomputed data in BattleHexArray via BattleHex (note: circular dependency prevented static precomputed containers being directly placed in BattleHex)
This commit is contained in:
@ -482,7 +482,7 @@ std::vector<std::vector<BattleHex::EDir>> BattleFieldController::getOutsideNeigh
|
||||
{
|
||||
// get all neighbours and their directions
|
||||
|
||||
const BattleHexArray & neighbouringTiles = BattleHexArray::getAllNeighbouringTiles(hex);
|
||||
const BattleHexArray & neighbouringTiles = hex.getAllNeighbouringTiles();
|
||||
|
||||
std::vector<BattleHex::EDir> outsideNeighbourDirections;
|
||||
|
||||
@ -492,9 +492,7 @@ std::vector<std::vector<BattleHex::EDir>> BattleFieldController::getOutsideNeigh
|
||||
if(!neighbouringTiles[direction].isAvailable())
|
||||
continue;
|
||||
|
||||
auto it = std::find(wholeRangeHexes.begin(), wholeRangeHexes.end(), neighbouringTiles[direction]);
|
||||
|
||||
if(it == wholeRangeHexes.end())
|
||||
if(!wholeRangeHexes.contains(neighbouringTiles[direction]))
|
||||
outsideNeighbourDirections.push_back(BattleHex::EDir(direction)); // push direction
|
||||
}
|
||||
|
||||
@ -680,7 +678,7 @@ BattleHex BattleFieldController::getHexAtPosition(Point hoverPos)
|
||||
BattleHex::EDir BattleFieldController::selectAttackDirection(BattleHex myNumber)
|
||||
{
|
||||
const bool doubleWide = owner.stacksController->getActiveStack()->doubleWide();
|
||||
const BattleHexArray & neighbours = BattleHexArray::getAllNeighbouringTiles(myNumber);
|
||||
const BattleHexArray & neighbours = myNumber.getAllNeighbouringTiles();
|
||||
// 0 1
|
||||
// 5 x 2
|
||||
// 4 3
|
||||
|
Reference in New Issue
Block a user