Skip to content

Commit

Permalink
Clear loaded scenario blacklist when leaving world
Browse files Browse the repository at this point in the history
This caused you to be unable to load a world with a mod containing a
scenario blacklist more than once without exiting the game.

Also don't locally redefine all_scenarios when finalizing scenario
blacklists.
  • Loading branch information
anothersimulacrum committed Feb 11, 2020
1 parent a619b02 commit 9f4e399
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ void DynamicDataLoader::unload_data()
reset_mapgens();
reset_effect_types();
reset_speech();
reset_scenarios_blacklist();
overmap_land_use_codes::reset();
overmap_connections::reset();
overmap_locations::reset();
Expand Down
11 changes: 8 additions & 3 deletions src/scenario.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,12 @@ void scen_blacklist::load( const JsonObject &jo, const std::string & )

void scen_blacklist::finalize()
{
std::vector<string_id<scenario>> all_scenarios;
std::vector<string_id<scenario>> all_scens;
for( const scenario &scen : scenario::get_all() ) {
all_scenarios.emplace_back( scen.ident() );
all_scens.emplace_back( scen.ident() );
}
for( const string_id<scenario> &sc : sc_blacklist.scenarios ) {
if( std::find( all_scenarios.begin(), all_scenarios.end(), sc ) == all_scenarios.end() ) {
if( std::find( all_scens.begin(), all_scens.end(), sc ) == all_scens.end() ) {
debugmsg( "Scenario blacklist contains invalid scenario" );
}
}
Expand All @@ -283,6 +283,11 @@ void scen_blacklist::finalize()
}
}

void reset_scenarios_blacklist()
{
sc_blacklist.scenarios.clear();
}

std::vector<string_id<profession>> scenario::permitted_professions() const
{
if( !cached_permitted_professions.empty() ) {
Expand Down
2 changes: 2 additions & 0 deletions src/scenario.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,6 @@ struct scen_blacklist {
void finalize();
};

void reset_scenarios_blacklist();

#endif

0 comments on commit 9f4e399

Please sign in to comment.