Skip to content

Commit

Permalink
Fix examine actions and crafting qualities for several vehicle parts …
Browse files Browse the repository at this point in the history
…and appliances (#60232)

* Fix crafting qualities and examine actions for vehicle purifier/chemset

* Restore crafting qualities and examine actions broken by #56991

* Rename itype_water_purifier per clang-tidy

* Reorder pseudo_water_purifier itype string per clang-tidy

Co-authored-by: David Seguin <[email protected]>
  • Loading branch information
ZeroInternalReflection and dseguin authored Aug 25, 2022
1 parent e479912 commit 9d29e93
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 73 deletions.
6 changes: 3 additions & 3 deletions data/json/furniture_and_terrain/appliances.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"damage_reduction": { "all": 30 },
"durability": 60,
"flags": [ "OBSTACLE", "APPLIANCE" ],
"pseudo_tools": [ { "id": "water_purifier_tool" } ],
"pseudo_tools": [ { "id": "pseudo_water_purifier", "hotkey": "p" } ],
"epower": 0,
"item": "stationary_water_purifier",
"looks_like": "f_water_purifier",
Expand Down Expand Up @@ -175,7 +175,7 @@
"description": "An electric forge for metalworking. When plugged in and powered you could use this for metalworking. If you attempt to craft an item that needs a forge, you will be given the option of selecting it as a tool.",
"item": "forge",
"flags": [ "CARGO", "OBSTACLE", "APPLIANCE" ],
"copy-from": "veh_forge",
"copy-from": "veh_forge_abstract",
"requirements": { "removal": { "time": "6 m" } },
"pseudo_tools": [ { "id": "pseudo_app_forge" } ]
},
Expand All @@ -186,7 +186,7 @@
"description": "Assembled from a set of instructions you found in an old book of DIY projects, the *FOODCO kitchen buddy* claims to be *the perfect solution to all your home-cooking needs!*. While it is surprisingly handy for vacuum-sealing as well as dehydrating food, the cheery sales pitch neglected to mention A - how awkward the damn thing is, B - That you still need a normal kitchen and C - how it doesn't take batteries. You're going to have to weld it to a vehicle, or something else with a supply of electricity, if you want to use it. In addition to the food preservation features, it also has a food processor, a water-purification system, a drawer for holding extra tools, and for some insane reason, a press and die set for hand-loading ammunition.",
"item": "craftrig",
"flags": [ "CARGO", "OBSTACLE", "APPLIANCE" ],
"copy-from": "craft_rig"
"copy-from": "craft_rig_abstract"
},
{
"type": "vehicle_part",
Expand Down
3 changes: 1 addition & 2 deletions data/json/furniture_and_terrain/furniture-appliances.json
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,7 @@
{ "item": "cu_pipe", "count": [ 1, 4 ] },
{ "item": "scrap_copper", "count": [ 0, 2 ] }
]
},
"crafting_pseudo_item": "pseudo_app_oven_hotplate"
}
},
{
"type": "furniture",
Expand Down
177 changes: 118 additions & 59 deletions data/json/items/fake.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,20 @@
"copy-from": "fake_appliance_tool",
"name": { "str": "stationary water purifier" }
},
{
"id": "pseudo_water_purifier",
"//": "All vehicle water purifiers need to use the same pseudo-item because vehicle.cpp matches against a specific id",
"copy-from": "water_purifier",
"sub": "water_purifier",
"type": "TOOL",
"extend": { "flags": [ "ALLOWS_REMOTE_USE", "PSEUDO", "ZERO_WEIGHT" ] },
"pocket_data": [ { "pocket_type": "MAGAZINE_WELL", "default_magazine": "pseudo_battery" } ],
"weight": "1 g",
"volume": "1 ml",
"symbol": "@",
"color": "red",
"name": "water purifier"
},
{
"id": "pseudo_exercise_machine",
"type": "TOOL",
Expand Down Expand Up @@ -312,104 +326,151 @@
"color": "red"
},
{
"id": "fake_power_tool_with_pseudo_battery",
"id": "pseudo_veh_oil_press",
"type": "TOOL",
"copy-from": "fake_power_tool",
"name": { "str": "fake power tool with battery", "str_pl": "fake power tool with batteries" },
"ammo": [ "battery" ],
"flags": [ "ALLOWS_REMOTE_USE", "PSEUDO" ],
"pocket_data": [ { "pocket_type": "MAGAZINE_WELL", "default_magazine": "pseudo_battery" } ]
"flags": [ "ALLOWS_REMOTE_USE", "PSEUDO", "ZERO_WEIGHT" ],
"pocket_data": [ { "pocket_type": "MAGAZINE_WELL", "default_magazine": "pseudo_battery" } ],
"description": "Dummy item. If you see this, then something went wrong.",
"weight": "1 g",
"volume": "1 ml",
"symbol": "@",
"color": "red",
"name": { "str": "mounted electric oil press", "str_pl": "mounted electric oil presses" }
},
{
"id": "pseudo_veh_oil_press",
"copy-from": "fake_power_tool_with_pseudo_battery",
"abstract": "pseudo_forge_abstract",
"copy-from": "forge",
"sub": "forge",
"type": "TOOL",
"name": { "str": "mounted electric oil press", "str_pl": "mounted electric oil presses" }
"extend": { "flags": [ "ALLOWS_REMOTE_USE", "PSEUDO", "ZERO_WEIGHT" ] },
"pocket_data": [ { "pocket_type": "MAGAZINE_WELL", "default_magazine": "pseudo_battery" } ],
"weight": "1 g",
"volume": "1 ml",
"symbol": "@",
"color": "red",
"name": "forge abstract"
},
{
"abstract": "pseudo_kiln_abstract",
"copy-from": "kiln",
"sub": "kiln",
"type": "TOOL",
"extend": { "flags": [ "ALLOWS_REMOTE_USE", "PSEUDO", "ZERO_WEIGHT" ] },
"pocket_data": [ { "pocket_type": "MAGAZINE_WELL", "default_magazine": "pseudo_battery" } ],
"weight": "1 g",
"volume": "1 ml",
"symbol": "@",
"color": "red",
"name": "kiln abstract"
},
{
"copy-from": "pseudo_forge_abstract",
"id": "pseudo_veh_forge",
"copy-from": "fake_power_tool_with_pseudo_battery",
"type": "TOOL",
"name": { "str": "mounted electric forge" },
"sub": "forge"
"name": { "str": "mounted electric forge" }
},
{
"copy-from": "pseudo_kiln_abstract",
"id": "pseudo_veh_kiln",
"copy-from": "fake_power_tool_with_pseudo_battery",
"type": "TOOL",
"name": { "str": "mounted electric kiln" },
"sub": "kiln"
"name": { "str": "mounted electric kiln" }
},
{
"id": "pseudo_veh_chemlab_chemset",
"copy-from": "fake_power_tool_with_pseudo_battery",
"copy-from": "chemistry_set",
"sub": "chemistry_set",
"type": "TOOL",
"name": { "str": "onboard chemistry lab" },
"sub": "chemistry_set"
"extend": { "flags": [ "ALLOWS_REMOTE_USE", "PSEUDO", "ZERO_WEIGHT" ] },
"pocket_data": [ { "pocket_type": "MAGAZINE_WELL", "default_magazine": "pseudo_battery" } ],
"weight": "1 g",
"volume": "1 ml",
"symbol": "@",
"color": "red",
"name": { "str": "lab chemistry set" }
},
{
"id": "pseudo_veh_chemlab_electrolysis_kit",
"copy-from": "fake_power_tool_with_pseudo_battery",
"name": { "str": "lab electrolysis kit" },
"copy-from": "electrolysis_kit",
"sub": "electrolysis_kit",
"type": "TOOL",
"name": { "str": "onboard chemistry lab" },
"sub": "electrolysis_kit"
"extend": { "flags": [ "ALLOWS_REMOTE_USE", "PSEUDO", "ZERO_WEIGHT" ] },
"pocket_data": [ { "pocket_type": "MAGAZINE_WELL", "default_magazine": "pseudo_battery" } ],
"weight": "1 g",
"volume": "1 ml",
"symbol": "@",
"color": "red"
},
{
"id": "pseudo_veh_chemlab_hotplate",
"copy-from": "fake_power_tool_with_pseudo_battery",
"abstract": "pseudo_hotplate_abstract",
"copy-from": "hotplate",
"sub": "hotplate",
"type": "TOOL",
"name": { "str": "onboard chemistry lab" },
"sub": "hotplate"
"extend": { "flags": [ "ALLOWS_REMOTE_USE", "PSEUDO", "ZERO_WEIGHT" ] },
"pocket_data": [ { "pocket_type": "MAGAZINE_WELL", "default_magazine": "pseudo_battery" } ],
"weight": "1 g",
"volume": "1 ml",
"symbol": "@",
"color": "red",
"name": "hotplate abstract"
},
{
"id": "pseudo_veh_foodco_vac_sealer",
"copy-from": "fake_power_tool_with_pseudo_battery",
"copy-from": "pseudo_hotplate_abstract",
"id": "pseudo_veh_chemlab_hotplate",
"type": "TOOL",
"name": { "str": "FOODCO kitchen buddy", "str_pl": "FOODCO kitchen buddies" },
"sub": "vac_sealer"
"name": { "str": "lab hotplate" }
},
{
"id": "pseudo_veh_foodco_dehydrator",
"copy-from": "fake_power_tool_with_pseudo_battery",
"id": "pseudo_veh_foodco_vac_sealer",
"name": { "str": "FOODCO kitchen buddy vacuum sealer" },
"copy-from": "vac_sealer",
"sub": "vac_sealer",
"type": "TOOL",
"name": { "str": "FOODCO kitchen buddy", "str_pl": "FOODCO kitchen buddies" },
"sub": "dehydrator"
"extend": { "flags": [ "ALLOWS_REMOTE_USE", "PSEUDO", "ZERO_WEIGHT" ] },
"pocket_data": [ { "pocket_type": "MAGAZINE_WELL", "default_magazine": "pseudo_battery" } ],
"weight": "1 g",
"volume": "1 ml",
"symbol": "@",
"color": "red"
},
{
"id": "pseudo_veh_foodco_water_purifier",
"copy-from": "fake_power_tool_with_pseudo_battery",
"id": "pseudo_veh_foodco_dehydrator",
"name": { "str": "FOODCO kitchen buddy dehydrator" },
"copy-from": "dehydrator",
"sub": "dehydrator",
"type": "TOOL",
"name": { "str": "FOODCO kitchen buddy", "str_pl": "FOODCO kitchen buddies" },
"sub": "water_purifier"
"extend": { "flags": [ "ALLOWS_REMOTE_USE", "PSEUDO", "ZERO_WEIGHT" ] },
"pocket_data": [ { "pocket_type": "MAGAZINE_WELL", "default_magazine": "pseudo_battery" } ],
"weight": "1 g",
"volume": "1 ml",
"symbol": "@",
"color": "red"
},
{
"id": "pseudo_veh_foodco_food_processor",
"copy-from": "fake_power_tool_with_pseudo_battery",
"name": { "str": "FOODCO kitchen buddy food processor" },
"copy-from": "food_processor",
"sub": "food_processor",
"type": "TOOL",
"name": { "str": "FOODCO kitchen buddy", "str_pl": "FOODCO kitchen buddies" },
"sub": "food_processor"
"extend": { "flags": [ "ALLOWS_REMOTE_USE", "PSEUDO", "ZERO_WEIGHT" ] },
"pocket_data": [ { "pocket_type": "MAGAZINE_WELL", "default_magazine": "pseudo_battery" } ],
"weight": "1 g",
"volume": "1 ml",
"symbol": "@",
"color": "red"
},
{
"copy-from": "pseudo_hotplate_abstract",
"id": "pseudo_veh_kitchen_hotplate",
"copy-from": "fake_power_tool_with_pseudo_battery",
"type": "TOOL",
"name": { "str": "kitchen unit" },
"sub": "hotplate"
},
{
"id": "pseudo_veh_water_purifier",
"copy-from": "fake_power_tool_with_pseudo_battery",
"type": "TOOL",
"name": { "str": "mounted water purifier" },
"sub": "water_purifier"
"name": { "str": "kitchen unit hotplate" }
},
{
"copy-from": "pseudo_hotplate_abstract",
"id": "pseudo_app_oven_hotplate",
"copy-from": "fake_appliance_tool",
"type": "TOOL",
"name": { "str": "oven" },
"sub": "hotplate",
"qualities": [ [ "OVEN", 2 ] ]
"name": { "str": "oven" }
},
{
"id": "fake_oven",
Expand All @@ -419,18 +480,16 @@
"qualities": [ [ "OVEN", 2 ] ]
},
{
"copy-from": "pseudo_forge_abstract",
"id": "pseudo_app_forge",
"copy-from": "fake_power_tool_with_pseudo_battery",
"type": "TOOL",
"name": { "str": "electric forge appliance" },
"sub": "forge"
"name": { "str": "electric forge appliance" }
},
{
"copy-from": "pseudo_kiln_abstract",
"id": "pseudo_app_kiln",
"copy-from": "fake_power_tool_with_pseudo_battery",
"type": "TOOL",
"name": { "str": "electric kiln appliance" },
"sub": "kiln"
"type": "TOOL"
},
{
"id": "fake_lift_light",
Expand Down
2 changes: 1 addition & 1 deletion data/json/vehicleparts/utilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"pseudo_tools": [
{ "id": "pseudo_veh_foodco_vac_sealer" },
{ "id": "pseudo_veh_foodco_dehydrator" },
{ "id": "pseudo_veh_foodco_water_purifier", "hotkey": "p" },
{ "id": "pseudo_water_purifier", "hotkey": "p" },
{ "id": "pseudo_veh_foodco_food_processor" },
{ "id": "press" },
{ "id": "puller" }
Expand Down
2 changes: 1 addition & 1 deletion data/json/vehicleparts/vehicle_parts.json
Original file line number Diff line number Diff line change
Expand Up @@ -3061,7 +3061,7 @@
"repair": { "skills": [ [ "mechanics", 5 ] ], "time": "15 m", "using": [ [ "adhesive", 1 ], [ "soldering_standard", 2 ] ] }
},
"flags": [ ],
"pseudo_tools": [ { "id": "pseudo_veh_water_purifier", "hotkey": "p" } ],
"pseudo_tools": [ { "id": "pseudo_water_purifier", "hotkey": "p" } ],
"breaks_into": [ { "item": "plastic_chunk", "count": [ 1, 2 ] } ],
"damage_reduction": { "all": 26 }
},
Expand Down
6 changes: 3 additions & 3 deletions src/vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ static const itype_id fuel_type_plutonium_cell( "plut_cell" );
static const itype_id fuel_type_wind( "wind" );
static const itype_id itype_battery( "battery" );
static const itype_id itype_plut_cell( "plut_cell" );
static const itype_id itype_pseudo_water_purifier( "pseudo_water_purifier" );
static const itype_id itype_water( "water" );
static const itype_id itype_water_clean( "water_clean" );
static const itype_id itype_water_faucet( "water_faucet" );
static const itype_id itype_water_purifier( "water_purifier" );

static const proficiency_id proficiency_prof_aircraft_mechanic( "prof_aircraft_mechanic" );

Expand Down Expand Up @@ -7316,11 +7316,11 @@ void vehicle::update_time( const time_point &update_to )
double area = std::pow( pt.info().size / units::legacy_volume_factor, 2 ) * M_PI;
int qty = roll_remainder( funnel_charges_per_turn( area, accum_weather.rain_amount ) );
int c_qty = qty + ( tank->can_reload( water_clean ) ? tank->ammo_remaining() : 0 );
int cost_to_purify = c_qty * item::find_type( itype_water_purifier )->charges_to_use();
int cost_to_purify = c_qty * item::find_type( itype_pseudo_water_purifier )->charges_to_use();

if( qty > 0 ) {
const cata::optional<vpart_reference> vp_purifier = vpart_position( *this, idx )
.part_with_tool( itype_water_purifier );
.part_with_tool( itype_pseudo_water_purifier );

if( vp_purifier && ( fuel_left( itype_battery, true ) > cost_to_purify ) ) {
tank->ammo_set( itype_water_clean, c_qty );
Expand Down
8 changes: 4 additions & 4 deletions src/vehicle_use.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ static const itype_id itype_detergent( "detergent" );
static const itype_id itype_fungal_seeds( "fungal_seeds" );
static const itype_id itype_marloss_seed( "marloss_seed" );
static const itype_id itype_null( "null" );
static const itype_id itype_pseudo_water_purifier( "pseudo_water_purifier" );
static const itype_id itype_soldering_iron( "soldering_iron" );
static const itype_id itype_water( "water" );
static const itype_id itype_water_clean( "water_clean" );
static const itype_id itype_water_faucet( "water_faucet" );
static const itype_id itype_water_purifier( "water_purifier" );
static const itype_id itype_welder( "welder" );

static const quality_id qual_SCREW( "SCREW" );
Expand Down Expand Up @@ -2140,7 +2140,7 @@ void vehicle::interact_with( const vpart_position &vp, bool with_pickup )
const turret_data turret = turret_query( vp.pos() );
const cata::optional<vpart_reference> vp_curtain = vp.avail_part_with_feature( "CURTAIN" );
const cata::optional<vpart_reference> vp_faucet = vp.part_with_tool( itype_water_faucet );
const cata::optional<vpart_reference> vp_purify = vp.part_with_tool( itype_water_purifier );
const cata::optional<vpart_reference> vp_purify = vp.part_with_tool( itype_pseudo_water_purifier );
const cata::optional<vpart_reference> vp_controls = vp.avail_part_with_feature( "CONTROLS" );
const cata::optional<vpart_reference> vp_electronics =
vp.avail_part_with_feature( "CTRL_ELECTRONIC" );
Expand Down Expand Up @@ -2257,7 +2257,7 @@ void vehicle::interact_with( const vpart_position &vp, bool with_pickup )
}
if( vp_purify ) {
bool can_purify = fuel_left( itype_water ) &&
fuel_left( itype_battery, true ) >= itype_water_purifier.obj().charges_to_use();
fuel_left( itype_battery, true ) >= itype_pseudo_water_purifier.obj().charges_to_use();
selectmenu.addentry( PURIFY_TANK, can_purify, 'P', _( "Purify water in vehicle tank" ) );
}
if( vp_monster_capture ) {
Expand Down Expand Up @@ -2384,7 +2384,7 @@ void vehicle::interact_with( const vpart_position &vp, bool with_pickup )
get_all_colors().get_name( item::find_type( itype_water )->color ) );
vehicle_part &tank = veh_interact::select_part( *this, sel, title );
if( tank ) {
int64_t cost = static_cast<int64_t>( itype_water_purifier->charges_to_use() );
int64_t cost = static_cast<int64_t>( itype_pseudo_water_purifier->charges_to_use() );
if( fuel_left( itype_battery, true ) < tank.ammo_remaining() * cost ) {
//~ $1 - vehicle name, $2 - part name
add_msg( m_bad, _( "Insufficient power to purify the contents of the %1$s's %2$s" ),
Expand Down

0 comments on commit 9d29e93

Please sign in to comment.