Skip to content

Commit

Permalink
Remove inline of function.
Browse files Browse the repository at this point in the history
  • Loading branch information
CLIDragon committed Aug 30, 2024
1 parent 7666a48 commit f12bfe2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
16 changes: 16 additions & 0 deletions src/point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,22 @@ std::istream &operator>>( std::istream &is, tripoint &pos )
return is;
}

std::optional<int> rectangle_size( int min_dist, int max_dist )
{
min_dist = std::max( min_dist, 0 );
max_dist = std::max( max_dist, 0 );

if( min_dist > max_dist ) {
return std::nullopt;
}

const int min_edge = min_dist * 2 + 1;
const int max_edge = max_dist * 2 + 1;

const int n = max_edge * max_edge - ( min_edge - 2 ) * ( min_edge - 2 ) + ( min_dist == 0 ? 1 : 0 );
return n;
}

std::vector<tripoint> closest_points_first( const tripoint &center, int max_dist )
{
return closest_points_first( center, 0, max_dist );
Expand Down
16 changes: 1 addition & 15 deletions src/point.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,21 +301,7 @@ std::optional<Point> find_point_closest_first( const Point &center, int max_dist


// Calculate the number of tiles in a square from min_dist to max_dist about an arbitrary centre.
inline std::optional<int> rectangle_size( int min_dist, int max_dist )
{
min_dist = std::max( min_dist, 0 );
max_dist = std::max( max_dist, 0 );

if( min_dist > max_dist ) {
return std::nullopt;
}

const int min_edge = min_dist * 2 + 1;
const int max_edge = max_dist * 2 + 1;

const int n = max_edge * max_edge - ( min_edge - 2 ) * ( min_edge - 2 ) + ( min_dist == 0 ? 1 : 0 );
return n;
};
std::optional<int> rectangle_size( int min_dist, int max_dist );

inline constexpr tripoint tripoint_min { INT_MIN, INT_MIN, INT_MIN };
inline constexpr tripoint tripoint_max{ INT_MAX, INT_MAX, INT_MAX };
Expand Down

0 comments on commit f12bfe2

Please sign in to comment.