Skip to content

Commit

Permalink
No duplicate linear predecessors (CleverRaven#67773)
Browse files Browse the repository at this point in the history
* Can't figure out save migration

* Scraps making it a flat_set

* Removes the functions for the hack

* Unborked the cherry pick

* Moves comment to a more sensible line
  • Loading branch information
Procyonae authored Aug 20, 2023
1 parent 0776fa5 commit aa6cccf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 28 deletions.
13 changes: 3 additions & 10 deletions src/mapgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5127,16 +5127,9 @@ void mapgen_function_json::generate( mapgendata &md )
do_predecessor_mapgen( predecessor_md );
} else if( expects_predecessor() ) {
if( md.has_predecessor() ) {
// Gets around connections changing terrain type
if( ter.has_flag( oter_flags::line_drawing ) ) {
mapgendata predecessor_md( md, md.first_predecessor() );
predecessor_md.clear_predecessors();
do_predecessor_mapgen( predecessor_md );
} else {
mapgendata predecessor_md( md, md.last_predecessor() );
predecessor_md.pop_last_predecessor();
do_predecessor_mapgen( predecessor_md );
}
mapgendata predecessor_md( md, md.last_predecessor() );
predecessor_md.pop_last_predecessor();
do_predecessor_mapgen( predecessor_md );
} else {
mapgendata predecessor_md( md, fallback_predecessor_mapgen_ );
do_predecessor_mapgen( predecessor_md );
Expand Down
15 changes: 0 additions & 15 deletions src/mapgendata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,6 @@ bool mapgendata::has_predecessor() const
return !predecessors_.empty();
}

const oter_id &mapgendata::first_predecessor() const
{
if( predecessors_.empty() ) {
debugmsg( "Tried to get predecessor when none available in mapgendata" );
static const oter_id null( oter_str_id::NULL_ID() );
return null;
}
return predecessors_.front();
}

const oter_id &mapgendata::last_predecessor() const
{
if( predecessors_.empty() ) {
Expand All @@ -315,8 +305,3 @@ void mapgendata::pop_last_predecessor()
}
predecessors_.pop_back();
}

void mapgendata::clear_predecessors()
{
predecessors_.clear();
}
2 changes: 0 additions & 2 deletions src/mapgendata.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,7 @@ class mapgendata
bool has_join( cube_direction, const std::string &join_id ) const;

bool has_predecessor() const;
const oter_id &first_predecessor() const;
const oter_id &last_predecessor() const;
void clear_predecessors();
void pop_last_predecessor();

template<typename Result>
Expand Down
6 changes: 5 additions & 1 deletion src/overmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2889,7 +2889,11 @@ void overmap::ter_set( const tripoint_om_omt &p, const oter_id &id )

oter_id &val = layer[p.z() + OVERMAP_DEPTH].terrain[p.xy()];
if( id->has_flag( oter_flags::requires_predecessor ) ) {
predecessors_[p].push_back( val );
const oter_type_id id_type = id->get_type_id();
// Stops linear fallback_predecessor maps (roads etc) spawning over themselves
if( !( id_type->is_linear() && id_type == val->get_type_id() ) ) {
predecessors_[p].push_back( val );
}
}
val = id;
}
Expand Down

0 comments on commit aa6cccf

Please sign in to comment.