Ticket #3577: isInRange.patch

File isInRange.patch, 1020 bytes (added by mimo, 9 years ago)
  • source/simulation2/components/CCmpUnitMotion.cpp

     
    17171717            entity_pos_t circleDistance = (pos - CFixedVector2D(obstruction.x, obstruction.z)).Length() - circleRadius;
    17181718            entity_pos_t previousCircleDistance = (pos - CFixedVector2D(previousObstruction.x, previousObstruction.z)).Length() - circleRadius;
    17191719
    1720             if (circleDistance <= maxRange || previousCircleDistance <= maxRange)
    1721                 return true;
     1720            return circleDistance <= maxRange || previousCircleDistance <= maxRange;
    17221721        }
    17231722
    1724         return false;
     1723        // take minimal clearance required in MoveToTargetRange into account, multiplying by 3/2 for diagonals
     1724        entity_pos_t maxDist = std::max(maxRange, (m_Clearance + entity_pos_t::FromInt(TERRAIN_TILE_SIZE)/16)*3/2);
     1725        return distance <= maxDist || distance <= maxDist;
    17251726    }
    17261727    else
    17271728    {