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

refactor(content): JSONize Pumps #3633

Merged
merged 13 commits into from
Nov 15, 2023
21 changes: 21 additions & 0 deletions data/json/furniture_and_terrain/furniture-plumbing.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,27 @@
"items": [ { "item": "cu_pipe", "prob": 50 }, { "item": "ceramic_shard", "count": [ 2, 8 ] }, { "item": "wax", "count": 1 } ]
}
},
{
"type": "furniture",
"id": "f_debug_pump",
"name": "debug beer pump",
"symbol": "&",
"color": "white",
"description": "Time to get infinitely drunk",
"move_cost_mod": 2,
"coverage": 30,
"required_str": -1,
"provides_liquids": "beer",
"flags": [ "TRANSPARENT", "FLAMMABLE_HARD" ],
"examine_action": "liquid_source",
"bash": {
"str_min": 8,
"str_max": 30,
"sound": "reality shattering!",
"sound_fail": "whunk!",
"items": [ { "item": "cu_pipe", "prob": 50 }, { "item": "sheet_metal", "count": [ 2, 8 ] }, { "item": "pipe", "count": 1 } ]
}
},
{
"type": "furniture",
"id": "f_water_heater",
Expand Down
6 changes: 6 additions & 0 deletions doc/src/content/docs/en/mod/json/reference/json_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -2610,6 +2610,7 @@ entries.
"open": "f_foo_open",
"lockpick_result": "f_safe_open",
"lockpick_message": "With a click, you unlock the safe.",
"provides_liquids": "beer",
"bash": "TODO",
"deconstruct": "TODO",
"max_volume": "1000 L",
Expand Down Expand Up @@ -2672,6 +2673,11 @@ also add a harvest or growth multiplier if it has the `GROWTH_HARVEST` flag.
(Optional) Surgery skill multiplier (float) applied by this furniture to survivor standing next to
it for the purpose of surgery.

#### `provides_liquids`

(Optional) Dispenses infinite amounts of specified liquid item when interacted. Must be used with
`"examine_action": "liquid_source"` to work.

### Terrain

```json
Expand Down
11 changes: 9 additions & 2 deletions src/iexamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3810,18 +3810,24 @@ void iexamine::trap( player &p, const tripoint &examp )
here.disarm_trap( examp );
}
}
//Note that these two functions are checked by pointer in map::water_from. Yes it's awful.
//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 )
{
liquid_handler::handle_liquid( examp );
}

//Note that these two functions are checked by pointer in map::water_from. Yes it's awful.
//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 )
{
liquid_handler::handle_liquid( examp );
}
Comment on lines +3813 to 3823
Copy link
Member

Choose a reason for hiding this comment

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

since iexamine::liquid_source can handle any liquid, it'd be great to be able to replace iexamine::water_source and iexamine::clean_water_source with it someday to cleanup more code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

since iexamine::liquid_source can handle any liquid, it'd be great to be able to replace iexamine::water_source and iexamine::clean_water_source with it someday to cleanup more code.

but wont it break the older mods which has its own water sources? these two old functions should last until 0.5 at least.

Copy link
Member

Choose a reason for hiding this comment

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

we could soft deprecate them by

  • making furn_t::crafting_pseudo_item_types call &iexamine::liquid_source for both water_source and clean_water_source
  • convert existing "examine_action": "water_source" into "examine_action": "liquid_source"


//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 );
}

std::vector<itype> furn_t::crafting_pseudo_item_types() const
{
std::vector<itype> conversion;
Expand Down Expand Up @@ -6324,6 +6330,7 @@ iexamine_function iexamine_function_from_string( const std::string &function_nam
{ "trap", &iexamine::trap },
{ "water_source", &iexamine::water_source },
{ "clean_water_source", &iexamine::clean_water_source },
{ "liquid_source", &iexamine::liquid_source },
{ "reload_furniture", &iexamine::reload_furniture },
{ "use_furn_fake_item", &iexamine::use_furn_fake_item },
{ "curtains", &iexamine::curtains },
Expand Down
1 change: 1 addition & 0 deletions src/iexamine.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ void recycle_compactor( player &p, const tripoint &examp );
void trap( player &p, const tripoint &examp );
void water_source( player &p, const tripoint &examp );
void clean_water_source( player &, const tripoint &examp );
void liquid_source( player &p, const tripoint &examp );
void kiln_empty( player &p, const tripoint &examp );
void kiln_full( player &p, const tripoint &examp );
void arcfurnace_empty( player &p, const tripoint &examp );
Expand Down
3 changes: 3 additions & 0 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4546,6 +4546,9 @@ detached_ptr<item> map::water_from( const tripoint &p )
if( furn( p ).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 ) {
return item::spawn( furn( p ).obj().provides_liquids, calendar::turn, item::INFINITE_CHARGES );
}
return detached_ptr<item>();
}

Expand Down
1 change: 1 addition & 0 deletions src/mapdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,7 @@ void furn_t::load( const JsonObject &jo, const std::string &src )
optional( jo, was_loaded, "comfort", comfort, 0 );
optional( jo, was_loaded, "floor_bedding_warmth", floor_bedding_warmth, 0 );
optional( jo, was_loaded, "emissions", emissions );
optional( jo, was_loaded, "provides_liquids", provides_liquids );
optional( jo, was_loaded, "bonus_fire_warmth_feet", bonus_fire_warmth_feet, 300 );
optional( jo, was_loaded, "keg_capacity", keg_capacity, legacy_volume_reader, 0_ml );
mandatory( jo, was_loaded, "required_str", move_str_req );
Expand Down
2 changes: 1 addition & 1 deletion src/mapdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ struct ter_t : map_data_common_t {
ter_str_id close; // Close action: transform into terrain with matching id
ter_str_id lockpick_result; // Lockpick action: transform when successfully lockpicked
translation lockpick_message; // Lockpick action: message when successfully lockpicked

std::string trap_id_str; // String storing the id string of the trap.
ter_str_id transforms_into; // Transform into what terrain?
ter_str_id roof; // What will be the floor above this terrain
Expand Down Expand Up @@ -501,6 +500,7 @@ struct furn_t : map_data_common_t {
furn_str_id transforms_into; // Transform into what furniture?
furn_str_id lockpick_result; // Lockpick action: transform when successfully lockpicked
translation lockpick_message; // Lockpick action: message when successfully lockpicked
itype_id provides_liquids; // The liquid that is given as liquid source

std::set<itype_id> crafting_pseudo_items;
units::volume keg_capacity = 0_ml;
Expand Down
Loading