1
0
forked from 0ad/0ad

Fix an issue where square diagonals were incorrectly handled when checking the distance to the target. Fixes #3577 properly. Patch by mimo.

Decrease fishing ship gathering range in consequence (revert [17178]).

This was SVN commit r17190.
This commit is contained in:
wraitii 2015-11-06 19:56:52 +00:00
parent 1ed3761859
commit 9efd79e240
2 changed files with 5 additions and 4 deletions

View File

@ -35,7 +35,7 @@
<Formations disable=""/>
</Identity>
<ResourceGatherer>
<MaxDistance>10.0</MaxDistance>
<MaxDistance>6.0</MaxDistance>
<BaseSpeed>1.0</BaseSpeed>
<Rates>
<food.fish>2</food.fish>

View File

@ -1711,11 +1711,12 @@ bool CCmpUnitMotion::IsInTargetRange(entity_id_t target, entity_pos_t minRange,
entity_pos_t circleDistance = (pos - CFixedVector2D(obstruction.x, obstruction.z)).Length() - circleRadius;
entity_pos_t previousCircleDistance = (pos - CFixedVector2D(previousObstruction.x, previousObstruction.z)).Length() - circleRadius;
if (circleDistance <= maxRange || previousCircleDistance <= maxRange)
return true;
return circleDistance <= maxRange || previousCircleDistance <= maxRange;
}
return false;
// take minimal clearance required in MoveToTargetRange into account, multiplying by 3/2 for diagonals
entity_pos_t maxDist = std::max(maxRange, (m_Clearance + entity_pos_t::FromInt(TERRAIN_TILE_SIZE)/16)*3/2);
return distance <= maxDist || distance <= maxDist;
}
else
{