diff --git a/src/faction_camp.cpp b/src/faction_camp.cpp index 5e1a30d770a42..939c3247849c4 100644 --- a/src/faction_camp.cpp +++ b/src/faction_camp.cpp @@ -1410,12 +1410,26 @@ void basecamp::get_available_missions( mission_data &mission_key, map &here ) { if( directions.size() < 8 ) { bool free_non_field_found = false; + bool possible_expansion_found = false; for( const auto &dir : base_camps::all_directions ) { - if( dir.first != base_camps::base_dir && expansions.find( dir.first ) == expansions.end() && - overmap_buffer.ter_existing( omt_pos + dir.first ) != oter_id( "field" ) ) { - free_non_field_found = true; - break; + if( dir.first != base_camps::base_dir && expansions.find( dir.first ) == expansions.end() ) { + const oter_id &omt_ref = overmap_buffer.ter( omt_pos + dir.first ); + if( !free_non_field_found && omt_ref != oter_id( "field" ) ) { + free_non_field_found = true; + } + if( !possible_expansion_found ) { + const std::optional *maybe_args = + overmap_buffer.mapgen_args( omt_pos + dir.first ); + const auto &pos_expansions = recipe_group::get_recipes_by_id( "all_faction_base_expansions", + omt_ref, maybe_args, 1 ); + if( !pos_expansions.empty() ) { + possible_expansion_found = true; + } + } + if( free_non_field_found && possible_expansion_found ) { + break; + } } } @@ -1451,22 +1465,6 @@ void basecamp::get_available_missions( mission_data &mission_key, map &here ) } } - bool possible_expansion_found = false; - - for( const auto &dir : base_camps::all_directions ) { - if( dir.first != base_camps::base_dir && expansions.find( dir.first ) == expansions.end() ) { - const oter_id &omt_ref = overmap_buffer.ter( omt_pos + dir.first ); - const std::optional *maybe_args = overmap_buffer.mapgen_args( - omt_pos + dir.first ); - const auto &pos_expansions = recipe_group::get_recipes_by_id( "all_faction_base_expansions", - omt_ref, maybe_args ); - if( !pos_expansions.empty() ) { - possible_expansion_found = true; - break; - } - } - } - const mission_id miss_id = { Camp_Survey_Expansion, "", {}, base_dir }; comp_list npc_list = get_mission_workers( miss_id ); entry = string_format( _( "Notes:\n" diff --git a/src/recipe_groups.cpp b/src/recipe_groups.cpp index 8789bfbf88eee..609546d5ad1bb 100644 --- a/src/recipe_groups.cpp +++ b/src/recipe_groups.cpp @@ -112,7 +112,7 @@ std::map recipe_group::get_recipes_by_id( const std::str } std::map recipe_group::get_recipes_by_id( const std::string &id, - const oter_id &omt_ter, const std::optional *maybe_args ) + const oter_id &omt_ter, const std::optional *maybe_args, const size_t limit ) { std::map all_rec; if( !recipe_groups_data.is_valid( group_id( id ) ) ) { @@ -120,6 +120,9 @@ std::map recipe_group::get_recipes_by_id( const std::str } const recipe_group_data &group = recipe_groups_data.obj( group_id( id ) ); for( const auto &recp : group.recipes ) { + if( limit > 0 && all_rec.size() >= limit ) { + break; + } const auto &recp_terrain_it = group.om_terrains.find( recp.first ); if( recp_terrain_it == group.om_terrains.end() ) { debugmsg( "Recipe %s doesn't specify 'om_terrains', use ANY instead if intended to work anywhere", diff --git a/src/recipe_groups.h b/src/recipe_groups.h index 663b17c8c2dbb..9c8d59e84138a 100644 --- a/src/recipe_groups.h +++ b/src/recipe_groups.h @@ -21,7 +21,7 @@ void reset(); std::map get_recipes_by_bldg( const std::string &bldg ); std::map get_recipes_by_id( const std::string &id ); std::map get_recipes_by_id( const std::string &id, const oter_id &omt_ter, - const std::optional *maybe_args ); + const std::optional *maybe_args, size_t limit = 0 ); std::string get_building_of_recipe( const std::string &recipe ); } // namespace recipe_group