Skip to content

Commit

Permalink
fix: potential fix for liquid iexamine (#3709)
Browse files Browse the repository at this point in the history
* Potential fix for liquid iexamine

* Restored posioning from water_source, and fixed terrains with clean_water_source
  • Loading branch information
Vollch authored Nov 23, 2023
1 parent 193c172 commit cb1c2a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/iexamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3814,19 +3814,22 @@ void iexamine::trap( player &p, const tripoint &examp )
//Note that these three functions are checked by pointer in map::water_from. Yes it's awful.
void iexamine::water_source( player &, const tripoint &examp )
{
// Routed to map::water_from to handle poison
liquid_handler::handle_liquid( examp );
}

//Note that these three functions are checked by pointer in map::water_from. Yes it's awful.
void iexamine::clean_water_source( player &, const tripoint &examp )
void iexamine::clean_water_source( player &, const tripoint & )
{
liquid_handler::handle_liquid( examp );
liquid_handler::handle_liquid( item::spawn( "water_clean", calendar::start_of_cataclysm,
item::INFINITE_CHARGES ) );
}

//Note that these three functions are checked by pointer in map::water_from. Yes it's awful.
void iexamine::liquid_source( player &, const tripoint &examp )
{
liquid_handler::handle_liquid( examp );
liquid_handler::handle_liquid( item::spawn( get_map().furn( examp ).obj().provides_liquids,
calendar::turn, item::INFINITE_CHARGES ) );
}

std::vector<itype> furn_t::crafting_pseudo_item_types() const
Expand Down
4 changes: 3 additions & 1 deletion src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4544,10 +4544,12 @@ detached_ptr<item> map::water_from( const tripoint &p )
if( furn( p ).obj().examine == &iexamine::water_source ) {
return item::spawn( "water", calendar::start_of_cataclysm, item::INFINITE_CHARGES );
}
if( furn( p ).obj().examine == &iexamine::clean_water_source ) {
if( furn( p ).obj().examine == &iexamine::clean_water_source ||
terrain_id.obj().examine == &iexamine::clean_water_source ) {
return item::spawn( "water_clean", calendar::start_of_cataclysm, item::INFINITE_CHARGES );
}
if( furn( p ).obj().examine == &iexamine::liquid_source ) {
// Terrains have no "provides_liquids" to work with generic source
return item::spawn( furn( p ).obj().provides_liquids, calendar::turn, item::INFINITE_CHARGES );
}
return detached_ptr<item>();
Expand Down

0 comments on commit cb1c2a6

Please sign in to comment.