Skip to content

Commit

Permalink
mapgen: make add_mapgen_update_func work with mapgen_update_ids
Browse files Browse the repository at this point in the history
if the Json object has a mapgen_update_id string, use that instead of
parsing inline mapgen_update.
  • Loading branch information
mlangsdorf committed Apr 23, 2019
1 parent 420fcf1 commit 54db27d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/MISSIONS_JSON.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ The `update_mapgen`` object or array provides a way to modify existing overmap t

As an array, `update_mapgen` consists of two or more `update_mapgen` objects.

As an object, `update_mapgen` contains any valid JSON mapgen objects. The objects are placed on the mission target terrain from "assign_mission_target" or optionally the closest overmap terrain specified by the `om_terrain` and `om_special` fields.
As an object, `update_mapgen` contains any valid JSON mapgen objects. The objects are placed on the mission target terrain from "assign_mission_target" or optionally the closest overmap terrain specified by the `om_terrain` and `om_special` fields. If "mapgen_update_id" is specified, the "mapge_update" object with the matching "mapgen_update_id" will be executed.

See doc/MAPGEN.md for more details on JSON mapgen and `update_mapgen`.

Expand Down
9 changes: 9 additions & 0 deletions src/mapgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8669,6 +8669,15 @@ bool update_mapgen_function_json::update_map( const tripoint &omt_pos, int offse

mapgen_update_func add_mapgen_update_func( JsonObject &jo, bool &defer )
{
if( jo.has_string( "mapgen_update_id" ) ) {
const std::string mapgen_update_id = jo.get_string( "mapgen_update_id" );
const auto update_function = [mapgen_update_id]( const tripoint & omt_pos,
mission * miss ) {
run_mapgen_update_func( mapgen_update_id, omt_pos, miss, false );
};
return update_function;
}

update_mapgen_function_json json_data( "" );
mapgen_defer::defer = defer;
if( !json_data.setup_update( jo ) ) {
Expand Down

0 comments on commit 54db27d

Please sign in to comment.