1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00
This commit is contained in:
mateuszb
2010-07-29 12:54:30 +00:00
parent aba655f200
commit d3bf011270
3 changed files with 13 additions and 4 deletions

View File

@ -3636,9 +3636,7 @@ si8 BattleInfo::hasDistancePenalty( int stackID, int destHex )
{
static bool lowerAnalyze(const CStack * stack, int hex)
{
int xDst = std::abs(hex % BFIELD_WIDTH - stack->position % BFIELD_WIDTH),
yDst = std::abs(hex / BFIELD_WIDTH - stack->position / BFIELD_WIDTH);
int distance = std::max(xDst, yDst) + std::min(xDst, yDst) - (yDst + 1)/2;
int distance = BattleInfo::getDistance(hex, stack->position);
//I hope it's approximately correct
return distance > 10 && !stack->hasBonusOfType(Bonus::NO_DISTANCE_PENALTY);
@ -3721,6 +3719,13 @@ void BattleInfo::getBonuses(BonusList &out, const CSelector &selector, const CBo
}
}
si8 BattleInfo::getDistance( int hex1, int hex2 )
{
int xDst = std::abs(hex1 % BFIELD_WIDTH - hex2 % BFIELD_WIDTH),
yDst = std::abs(hex1 / BFIELD_WIDTH - hex2 / BFIELD_WIDTH);
return std::max(xDst, yDst) + std::min(xDst, yDst) - (yDst + 1)/2;
}
int3 CPath::startPos() const
{
return nodes[nodes.size()-1].coord;