Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix root cellars on map load #41346

Merged
merged 1 commit into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8466,10 +8466,10 @@ bool item::has_rotten_away() const
}
}

bool item::has_rotten_away( const tripoint &pnt, float spoil_multiplier )
bool item::has_rotten_away( const tripoint &pnt, float spoil_multiplier, temperature_flag flag )
{
if( goes_bad() ) {
process_temperature_rot( 1, pnt, nullptr, temperature_flag::NORMAL, spoil_multiplier );
process_temperature_rot( 1, pnt, nullptr, flag, spoil_multiplier );
return has_rotten_away();
} else {
contents.remove_rotten( pnt );
Expand Down
3 changes: 2 additions & 1 deletion src/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,8 @@ class item : public visitable<item>
* used for rot calculation.
* @return true if the item has rotten away and should be removed, false otherwise.
*/
bool has_rotten_away( const tripoint &pnt, float spoil_multiplier = 1.0f );
bool has_rotten_away( const tripoint &pnt, float spoil_multiplier = 1.0f,
temperature_flag flag = temperature_flag::NORMAL );

/**
* Accumulate rot of the item since last rot calculation.
Expand Down
8 changes: 7 additions & 1 deletion src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6742,8 +6742,14 @@ void map::loadn( const tripoint &grid, const bool update_vehicles )
template <typename Container>
void map::remove_rotten_items( Container &items, const tripoint &pnt )
{
temperature_flag flag;
if( ter( pnt ) == t_rootcellar ) {

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fridges are vehicle parts.
Items inside vehicle containers are not touched here.

flag = temperature_flag::ROOT_CELLAR;
} else {
flag = temperature_flag::NORMAL;
}
for( auto it = items.begin(); it != items.end(); ) {
if( it->has_rotten_away( pnt ) ) {
if( it->has_rotten_away( pnt, 1, flag ) ) {
if( it->is_comestible() ) {
rotten_item_spawn( *it, pnt );
}
Expand Down