Skip to content

Commit

Permalink
Merge pull request #41346 from Hirmuolio/rootcellar
Browse files Browse the repository at this point in the history
fix root cellars on map load
  • Loading branch information
ZhilkinSerg authored Jun 17, 2020
2 parents 2c5f2e7 + ad255e3 commit fec9f3d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
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 @@ -6747,8 +6747,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 ) {
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

0 comments on commit fec9f3d

Please sign in to comment.