From 9b82a33b1cef428b431b2cce84172b745b087209 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 2 Feb 2020 16:33:53 +0100 Subject: [PATCH] Remove default_idx parameter from load_mapgen_function. This feature is not available anymore. It was added by 04e45eabbdd80a238e61c771fcf0c05073b5ca54 without any explanation. --- src/mapgen.cpp | 38 ++++---------------------------------- src/mapgen.h | 2 +- src/overmap.cpp | 8 ++------ 3 files changed, 7 insertions(+), 41 deletions(-) diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 8fee0a39ff965..415849964b7ed 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -206,14 +206,6 @@ class mapgen_basic_container mapgens_.push_back( ptr ); return mapgens_.size() - 1; } - void erase( const size_t index ) { - if( index > mapgens_.size() ) { - return; - } - assert( mapgens_[index] ); - // Can't actually erase it as this might invalid the index stored elsewhere - mapgens_[index]->weight = 0; - } /** * Pick a mapgen function randomly and call its generate function. * This basically runs the mapgen functions with the given @ref mapgendata @@ -328,10 +320,6 @@ class mapgen_factory } return iter->second.generate( dat, hardcoded_weight ); } - /// @see mapgen_basic_container::erase - void erase( const std::string &key, const size_t index ) { - mapgens_[key].erase( index ); - } }; static mapgen_factory oter_mapgen; @@ -405,21 +393,11 @@ static void set_mapgen_defer( const JsonObject &jsi, const std::string &member, * load a single mapgen json structure; this can be inside an overmap_terrain, or on it's own. */ std::shared_ptr -load_mapgen_function( const JsonObject &jio, const std::string &id_base, - int default_idx, const point &offset ) +load_mapgen_function( const JsonObject &jio, const std::string &id_base, const point &offset ) { int mgweight = jio.get_int( "weight", 1000 ); std::shared_ptr ret; if( mgweight <= 0 || jio.get_bool( "disabled", false ) ) { - const std::string mgtype = jio.get_string( "method" ); - if( default_idx != -1 && mgtype == "builtin" ) { - if( jio.has_string( "name" ) ) { - const std::string mgname = jio.get_string( "name" ); - if( mgname == id_base ) { - oter_mapgen.erase( id_base, default_idx ); - } - } - } jio.allow_omitted_members(); return nullptr; // nothing } @@ -489,7 +467,7 @@ void load_mapgen( const JsonObject &jo ) point offset; for( JsonArray row_items : ja ) { for( const std::string mapgenid : row_items ) { - const auto mgfunc = load_mapgen_function( jo, mapgenid, -1, offset ); + const auto mgfunc = load_mapgen_function( jo, mapgenid, offset ); if( mgfunc ) { oter_mapgen.add( mapgenid, mgfunc ); } @@ -505,7 +483,7 @@ void load_mapgen( const JsonObject &jo ) } if( !mapgenid_list.empty() ) { const std::string mapgenid = mapgenid_list[0]; - const auto mgfunc = load_mapgen_function( jo, mapgenid, -1, point_zero ); + const auto mgfunc = load_mapgen_function( jo, mapgenid, point_zero ); if( mgfunc ) { for( auto &i : mapgenid_list ) { oter_mapgen.add( i, mgfunc ); @@ -514,7 +492,7 @@ void load_mapgen( const JsonObject &jo ) } } } else if( jo.has_string( "om_terrain" ) ) { - load_mapgen_function( jo, jo.get_string( "om_terrain" ), -1, point_zero ); + load_mapgen_function( jo, jo.get_string( "om_terrain" ), point_zero ); } else if( jo.has_string( "nested_mapgen_id" ) ) { load_nested_mapgen( jo, jo.get_string( "nested_mapgen_id" ) ); } else if( jo.has_string( "update_mapgen_id" ) ) { @@ -7346,14 +7324,6 @@ bool run_mapgen_func( const std::string &mapgen_id, mapgendata &dat ) return oter_mapgen.generate( dat, mapgen_id ); } -int register_mapgen_function( const std::string &key ) -{ - if( const auto ptr = get_mapgen_cfunction( key ) ) { - return oter_mapgen.add( key, std::make_shared( ptr ) ); - } - return -1; -} - bool has_mapgen_for( const std::string &key ) { return oter_mapgen.has( key ); diff --git a/src/mapgen.h b/src/mapgen.h index a73284aeead6e..8e051518b3673 100644 --- a/src/mapgen.h +++ b/src/mapgen.h @@ -371,7 +371,7 @@ class mapgen_function_json_nested : public mapgen_function_json_base * Load mapgen function of any type from a json object */ std::shared_ptr load_mapgen_function( const JsonObject &jio, - const std::string &id_base, int default_idx, const point &offset ); + const std::string &id_base, const point &offset ); /* * Load the above directly from a file via init, as opposed to riders attached to overmap_terrain. Added check * for oter_mapgen key, multiple possible ( ie, [ "house", "house_base" ] ) diff --git a/src/overmap.cpp b/src/overmap.cpp index cd7046e6b50b6..a507431fe369c 100644 --- a/src/overmap.cpp +++ b/src/overmap.cpp @@ -529,14 +529,10 @@ static void load_overmap_terrain_mapgens( const JsonObject &jo, const std::strin { const std::string fmapkey( id_base + suffix ); const std::string jsonkey( "mapgen" + suffix ); - bool default_mapgen = jo.get_bool( "default_mapgen", true ); - int default_idx = -1; - if( default_mapgen ) { - default_idx = register_mapgen_function( fmapkey ); - } + register_mapgen_function( fmapkey ); if( jo.has_array( jsonkey ) ) { for( JsonObject jio : jo.get_array( jsonkey ) ) { - load_mapgen_function( jio, fmapkey, default_idx, point_zero ); + load_mapgen_function( jio, fmapkey, point_zero ); } } }