Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework river generation #74261

Closed
wants to merge 9 commits into from
597 changes: 274 additions & 323 deletions src/overmap.cpp

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion src/overmap.h
Original file line number Diff line number Diff line change
@@ -107,6 +107,15 @@ struct overmap_special_placement {
const overmap_special *special_details;
};

// Wrapper around a river node to contain river data.
// Could be used to determine entry/exit points for boats across overmaps.
// Could also contain name.
struct overmap_river_node {
const point_om_omt p1; // position, overmap origin node.
const point_om_omt p2; // position, overmap exit node.
const size_t size; // total omt of this river
};

// A batch of overmap specials to place.
class overmap_special_batch
{
@@ -297,6 +306,12 @@ class overmap
*/
bool is_omt_generated( const tripoint_om_omt &loc ) const;

/* Returns true if position is an entry/exit position of a river node. */
bool is_river_node( const point_om_omt &p ) const;

/* Returns the overmap river node if the position is an entry/exit node of river. */
const overmap_river_node *get_river_node_at( const point_om_omt &p ) const;

/** Returns the (0, 0) corner of the overmap in the global coordinates. */
point_abs_omt global_base_point() const;

@@ -323,6 +338,7 @@ class overmap
std::map<int, om_vehicle> vehicles;
std::vector<basecamp> camps;
std::vector<city> cities;
std::vector<overmap_river_node> rivers;
std::map<string_id<overmap_connection>, std::vector<tripoint_om_omt>> connections_out;
std::optional<basecamp *> find_camp( const point_abs_omt &p );
/// Adds the npc to the contained list of npcs ( @ref npcs ).
@@ -430,7 +446,7 @@ class overmap
// code deduplication - calc ocean gradient
float calculate_ocean_gradient( const point_om_omt &p, point_abs_om this_omt );
// Overall terrain
void place_river( const point_om_omt &pa, const point_om_omt &pb );
void place_river( const point_om_omt &pa, const point_om_omt &pb, int river_scale = 1.0 );
void place_forests();
void place_lakes();
void place_oceans();
4 changes: 4 additions & 0 deletions src/point.h
Original file line number Diff line number Diff line change
@@ -347,6 +347,10 @@ inline constexpr std::array<point, 4> four_cardinal_directions{{
point_west, point_east, point_north, point_south
}};

inline constexpr std::array<point, 4> four_intercardinal_directions{{
point_north_east, point_south_east, point_south_west, point_north_west
}};

inline constexpr std::array<point, 5> five_cardinal_directions{{
point_west, point_east, point_north, point_south, point_zero
}};
23 changes: 23 additions & 0 deletions src/savegame.cpp
Original file line number Diff line number Diff line change
@@ -497,6 +497,17 @@ void overmap::unserialize( const JsonObject &jsobj )
}
cities.push_back( new_city );
}
} else if( name == "rivers" ) {
JsonArray rivers_json = om_member;
for( JsonObject river_json : rivers_json ) {
point_om_omt p1;
point_om_omt p2;
size_t size;
mandatory( river_json, false, "entry", p1 );
mandatory( river_json, false, "exit", p2 );
mandatory( river_json, false, "size", size );
rivers.push_back( overmap_river_node{ p1, p2, size } );
}
} else if( name == "connections_out" ) {
om_member.read( connections_out );
} else if( name == "roads_out" ) {
@@ -1196,6 +1207,18 @@ void overmap::serialize( std::ostream &fout ) const
json.end_array();
fout << std::endl;

json.member( "rivers" );
json.start_array();
for( const overmap_river_node &i : rivers ) {
json.start_object();
json.member( "entry", i.p1 );
json.member( "exit", i.p2 );
json.member( "size", i.size );
json.end_object();
}
json.end_array();
fout << std::endl;

json.member( "connections_out", connections_out );
fout << std::endl;


Unchanged files with check annotations Beta

" Acid: <color_c_yellow>9.00</color>\n"
" Fire: <color_c_yellow>1.00</color>\n"
" Environmental: <color_c_yellow>20</color>\n"
);

Check failure on line 1304 in tests/iteminfo_test.cpp

GitHub Actions / Basic Build and Test (Clang 10, Ubuntu, Curses)

"--
}
SECTION( "check that material resistances are properly overriden" ) {
" Acid: <color_c_yellow>9.00</color>\n"
" Fire: <color_c_yellow>2.00</color>\n"
" Environmental: <color_c_yellow>10</color>\n"
);

Check failure on line 1328 in tests/iteminfo_test.cpp

GitHub Actions / Basic Build and Test (Clang 10, Ubuntu, Curses)

"--
}
SECTION( "complex protection from physical and environmental damage" ) {