Skip to content

Commit

Permalink
Add dimensions property to overmap special
Browse files Browse the repository at this point in the history
Minimum size of the box that can contain whole overmap special
  • Loading branch information
ZhilkinSerg committed Dec 15, 2019
1 parent 87d79bd commit e6e512b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/omdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ class overmap_special
void load( const JsonObject &jo, const std::string &src );
void finalize();
void check() const;
// Minimum size of the box that can contain whole overmap special
box dimensions;
private:
// These locations are the default values if ones are not specified for the individual OMTs.
std::set<string_id<overmap_location>> default_locations;
Expand Down
13 changes: 13 additions & 0 deletions src/overmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,19 @@ void overmap_special::finalize()
}
}

// Calculate dimensions
tripoint dimension_min;
tripoint dimension_max;
for( auto &t : terrains ) {
dimension_min = tripoint( std::min( dimension_min.x, t.p.x ),
std::min( dimension_min.y, t.p.y ),
std::min( dimension_min.z, t.p.z ) );
dimension_max = tripoint( std::max( dimension_max.x, t.p.x ),
std::max( dimension_max.y, t.p.y ),
std::max( dimension_max.z, t.p.z ) );
}
dimensions = box( dimension_min, dimension_max );

for( auto &elem : connections ) {
const auto &oter = get_terrain_at( elem.p );
if( !elem.terrain && oter.terrain ) {
Expand Down

0 comments on commit e6e512b

Please sign in to comment.