std::vector<overmap *> overmapbuffer::get_overmaps_near( point location, int radius )
{
    // Grab the corners of a square around the target location at distance radius.
    // Convert to overmap coordinates and iterate from the minimum to the maximum.
    std::set<point> distinct_corners;
    const point upper_left = sm_to_om_copy( point( location.x - radius, location.y - radius ) );
    const point lower_right = sm_to_om_copy( point( location.x + radius, location.y + radius ) );

    for( int x = upper_left.x; x <= lower_right.x; x++ ) {
        for( int y = upper_left.y; y <= lower_right.y; y++ ) {
            distinct_corners.insert( point( x, y ) );
        }
    }
    // Grab references to the overmaps at those coordinates, but only if they exist.
    // Might use this to drive creation of these overmaps at some point if we want to
    // more agressively expand the created overmaps.
    std::vector<overmap *> nearby_overmaps;
    for( auto overmap_origin : distinct_corners ) {
        overmap *nearby_overmap = get_existing( overmap_origin.x, overmap_origin.y );
        if( nearby_overmap ) {
            nearby_overmaps.push_back( nearby_overmap );
        }
    }
    return nearby_overmaps;
}
std::vector<overmap*> overmapbuffer::get_overmaps_near( tripoint const &location, int const radius )
{
    // Grab the corners of a square around the target location at distance radius.
    // Convert to overmap coordinates and iterate from the minimum to the maximum.
    point const start = sm_to_om_copy(location.x - radius, location.y - radius);
    point const end = sm_to_om_copy(location.x + radius, location.y + radius);
    point const offset = end - start;

    std::vector<overmap*> result;
    result.reserve( ( offset.x + 1 ) * ( offset.y + 1 ) );

    for (int x = start.x; x <= end.x; ++x) {
        for (int y = start.y; y <= end.y; ++y) {
            if (auto const existing_om = get_existing(x, y)) {
                result.emplace_back(existing_om);
            }
        }
    }

    return result;
}
const overmap *overmapbuffer::get_existing_om_global(const point& p) const
{
    const point om_pos = omt_to_om_copy(p);
    return get_existing(om_pos.x, om_pos.y);
}
const overmap *overmapbuffer::get_existing_om_global(int &x, int &y) const
{
    const point om_pos = omt_to_om_remain(x, y);
    return get_existing(om_pos.x, om_pos.y);
}
bool overmapbuffer::has(int x, int y) const
{
    return get_existing(x, y) != NULL;
}
Example #6
0
bool overmapbuffer::has( int x, int y )
{
    return get_existing( x, y ) != nullptr;
}