Skip to content

Commit

Permalink
Fixes for abandoning camps (CleverRaven#60521)
Browse files Browse the repository at this point in the history
* Fix crash

* Allow building camps near abandoned camps

* Update src/faction_camp.cpp

* Update src/faction_camp.cpp
  • Loading branch information
angleKH authored Aug 29, 2022
1 parent 87a598f commit fd28f48
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/basecamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ expansion_data basecamp::parse_expansion( const std::string &terrain,
expansion_data e;
size_t last_bar = terrain.find_last_of( '_' );
e.type = terrain.substr( base_camps::prefix_len, last_bar - base_camps::prefix_len );
e.cur_level = std::stoi( terrain.substr( last_bar + 1 ) );
e.cur_level = std::stoi( "0" + terrain.substr( last_bar + 1 ) );
e.pos = new_pos;
return e;
}
Expand Down
10 changes: 8 additions & 2 deletions src/faction_camp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,14 @@ void talk_function::start_camp( npc &p )
for( const auto &om_near : om_building_region( omt_pos, 3 ) ) {
const oter_id &om_type = oter_id( om_near.first );
if( is_ot_match( "faction_base", om_type, ot_match_type::contains ) ) {
popup( _( "You are too close to another camp!" ) );
return;
tripoint_abs_omt const &building_omt_pos = om_near.second;
std::vector<basecamp> const &camps = overmap_buffer.get_om_global( building_omt_pos ).om->camps;
if( std::any_of( camps.cbegin(), camps.cend(), [&building_omt_pos]( const basecamp & camp ) {
return camp.camp_omt_pos() == building_omt_pos;
} ) ) {
popup( _( "You are too close to another camp!" ) );
return;
}
}
}
const recipe &making = camp_type.obj();
Expand Down

0 comments on commit fd28f48

Please sign in to comment.