Skip to content

Commit

Permalink
Reset harvest data in unload_data
Browse files Browse the repository at this point in the history
Harvest data from the previously loaded world was not reset, leading to
a bunch of errors from unrelated mods in a different world.

Add a harvest_list::reset() method to clear the previously loaded
harvest list, and call it from unload_data().

Fix CleverRaven#47932
  • Loading branch information
wapcaplet authored and Ramza13 committed Apr 12, 2021
1 parent b83c083 commit 2778439
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/harvest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ void harvest_list::check_consistency()
}
}

void harvest_list::reset()
{
harvest_list_factory.reset();
}

std::list<harvest_entry>::const_iterator harvest_list::begin() const
{
return entries().begin();
Expand Down
2 changes: 2 additions & 0 deletions src/harvest.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class harvest_list

/** Check consistency of all loaded harvest data */
static void check_consistency();
/** Reset all loaded harvest data */
static void reset();

bool was_loaded = false;
void load( const JsonObject &obj, const std::string & );
Expand Down
1 change: 1 addition & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ void DynamicDataLoader::unload_data()
fault::reset();
field_types::reset();
gates::reset();
harvest_list::reset();
item_controller->reset();
json_flag::reset();
mapgen_palette::reset();
Expand Down

0 comments on commit 2778439

Please sign in to comment.