From fabc84280b4d6c8e13e56648648a15bdc8f0a47e Mon Sep 17 00:00:00 2001 From: irwiss Date: Sun, 25 Jun 2023 17:39:25 +0300 Subject: [PATCH] Add strict checking on most vpart_info fields --- .../furniture_and_terrain/appliances.json | 37 ------- data/json/vehicleparts/armor.json | 1 - data/json/vehicleparts/battery.json | 2 - data/json/vehicleparts/boards.json | 2 - data/json/vehicleparts/cargo.json | 4 - data/json/vehicleparts/combustion.json | 6 -- data/json/vehicleparts/doors.json | 5 - data/json/vehicleparts/engineering.json | 10 -- data/json/vehicleparts/frames.json | 2 - data/json/vehicleparts/manual.json | 2 - data/json/vehicleparts/motor.json | 2 - data/json/vehicleparts/rams.json | 2 - data/json/vehicleparts/rotor.json | 4 - data/json/vehicleparts/tanks.json | 3 - data/json/vehicleparts/utilities.json | 3 - data/json/vehicleparts/vehicle_parts.json | 78 +------------- data/json/vehicleparts/wheel.json | 9 -- data/json/vehicleparts/windshields.json | 1 - src/assign.cpp | 9 +- src/assign.h | 3 +- src/veh_type.cpp | 102 +++++++++--------- 21 files changed, 62 insertions(+), 225 deletions(-) diff --git a/data/json/furniture_and_terrain/appliances.json b/data/json/furniture_and_terrain/appliances.json index 9f435f3125305..a13feaa8d714a 100644 --- a/data/json/furniture_and_terrain/appliances.json +++ b/data/json/furniture_and_terrain/appliances.json @@ -115,8 +115,6 @@ "durability": 80, "flags": [ "CARGO", "OBSTACLE", "COVERED", "FLAT_SURF", "APPLIANCE" ], "pseudo_tools": [ { "id": "oven" }, { "id": "hotplate", "hotkey": "h" } ], - "//": "Doesn't draw power at baseline, only when cooking.", - "epower": "0 W", "item": "oven", "looks_like": "f_oven", "breaks_into": [ @@ -142,7 +140,6 @@ "durability": 60, "flags": [ "OBSTACLE", "APPLIANCE" ], "pseudo_tools": [ { "id": "water_purifier", "hotkey": "p" } ], - "epower": "0 W", "item": "stationary_water_purifier", "looks_like": "f_water_purifier", "breaks_into": [ @@ -197,9 +194,6 @@ { "type": "vehicle_part", "id": "ap_stereo", - "name": { "str": "stereo system" }, - "description": "A stereo system. When turned on, it plays music, improving your mood.", - "item": "stereo", "flags": [ "STEREO", "APPLIANCE", "ENABLED_DRAINS_EPOWER" ], "copy-from": "stereo" }, @@ -226,7 +220,6 @@ "durability": 80, "flags": [ "OBSTACLE", "APPLIANCE" ], "pseudo_tools": [ { "id": "drill_press_tool" } ], - "epower": "0 W", "item": "drill_press", "breaks_into": [ { "item": "cable", "charges": [ 0, 4 ] }, @@ -251,7 +244,6 @@ "durability": 80, "flags": [ "OBSTACLE", "APPLIANCE" ], "pseudo_tools": [ { "id": "tablesaw_tool" } ], - "epower": "0 W", "item": "tablesaw", "breaks_into": [ { "item": "cable", "charges": [ 0, 4 ] }, @@ -276,7 +268,6 @@ "durability": 80, "flags": [ "OBSTACLE", "APPLIANCE" ], "pseudo_tools": [ { "id": "mitresaw_tool" } ], - "epower": "0 W", "item": "mitresaw", "breaks_into": [ { "item": "cable", "charges": [ 0, 4 ] }, @@ -301,7 +292,6 @@ "durability": 80, "flags": [ "OBSTACLE", "APPLIANCE" ], "pseudo_tools": [ { "id": "bandsaw_tool" } ], - "epower": "0 W", "item": "bandsaw", "breaks_into": [ { "item": "cable", "charges": [ 0, 4 ] }, @@ -326,7 +316,6 @@ "durability": 80, "flags": [ "OBSTACLE", "APPLIANCE" ], "pseudo_tools": [ { "id": "router_tool" } ], - "epower": "0 W", "item": "router", "breaks_into": [ { "item": "cable", "charges": [ 0, 4 ] }, @@ -351,7 +340,6 @@ "durability": 80, "flags": [ "OBSTACLE", "APPLIANCE" ], "pseudo_tools": [ { "id": "planer_tool" } ], - "epower": "0 W", "item": "planer", "breaks_into": [ { "item": "cable", "charges": [ 0, 4 ] }, @@ -376,7 +364,6 @@ "durability": 80, "flags": [ "OBSTACLE", "APPLIANCE" ], "pseudo_tools": [ { "id": "jointer_tool" } ], - "epower": "0 W", "item": "jointer", "breaks_into": [ { "item": "cable", "charges": [ 0, 4 ] }, @@ -401,7 +388,6 @@ "durability": 80, "flags": [ "OBSTACLE", "APPLIANCE" ], "pseudo_tools": [ { "id": "catalytic_cracking_reactor_tool" } ], - "epower": "0 W", "item": "catalytic_cracking_reactor", "breaks_into": [ { "item": "element", "charges": [ 4, 8 ] }, @@ -427,7 +413,6 @@ "durability": 80, "flags": [ "OBSTACLE", "APPLIANCE" ], "pseudo_tools": [ { "id": "hydraulic_press_tool" } ], - "epower": "0 W", "item": "hydraulic_press", "breaks_into": [ { "item": "cable", "charges": [ 0, 4 ] }, @@ -451,7 +436,6 @@ "durability": 80, "flags": [ "OBSTACLE", "APPLIANCE" ], "pseudo_tools": [ { "id": "air_compressor_tool" } ], - "epower": "0 W", "item": "air_compressor", "breaks_into": [ { "item": "cable", "charges": [ 0, 4 ] }, @@ -600,7 +584,6 @@ "color": "yellow", "broken_color": "dark_gray", "damage_modifier": 10, - "epower": "0 W", "//": "Epower for POWER_TRANSFER stuff is how much percentage-wise loss there is in transmission", "durability": 120, "description": "A power cord sticking out of an appliance. You need to plug it into a powered grid for the appliance to work properly.", @@ -690,8 +673,6 @@ { "type": "vehicle_part", "id": "ap_solar_panel", - "name": { "str": "solar panel" }, - "color": "yellow", "flags": [ "SOLAR_PANEL", "OBSTACLE", "APPLIANCE" ], "description": "A solar panel, mounted on a frame and ready to power other appliances.", "copy-from": "solar_panel", @@ -702,7 +683,6 @@ { "type": "vehicle_part", "id": "ap_reinforced_solar_panel", - "name": { "str": "reinforced solar panel" }, "color": "yellow", "flags": [ "SOLAR_PANEL", "OBSTACLE", "APPLIANCE" ], "description": "A reinforced solar panel, mounted on a frame and ready to power other appliances.", @@ -714,8 +694,6 @@ { "type": "vehicle_part", "id": "ap_solar_panel_v2", - "name": { "str": "advanced solar panel" }, - "color": "yellow", "flags": [ "SOLAR_PANEL", "OBSTACLE", "APPLIANCE" ], "description": "A high-performance solar panel, mounted on a frame and ready to power other appliances.", "copy-from": "solar_panel_v2", @@ -726,7 +704,6 @@ { "type": "vehicle_part", "id": "ap_reinforced_solar_panel_v2", - "name": { "str": "advanced reinforced solar panel" }, "color": "yellow", "flags": [ "SOLAR_PANEL", "OBSTACLE", "APPLIANCE" ], "description": "A high-performance reinforced solar panel, mounted on a frame and ready to power other appliances.", @@ -738,9 +715,7 @@ { "type": "vehicle_part", "id": "ap_wind_turbine", - "name": { "str": "wind turbine" }, "location": "structure", - "color": "yellow", "flags": [ "WIND_TURBINE", "OBSTACLE", "APPLIANCE" ], "description": "A mounted wind turbine, ready to power other appliances.", "copy-from": "wind_turbine", @@ -750,9 +725,7 @@ { "type": "vehicle_part", "id": "ap_xl_wind_turbine", - "name": { "str": "large wind turbine" }, "location": "structure", - "color": "yellow", "flags": [ "WIND_TURBINE", "OBSTACLE", "APPLIANCE" ], "description": "A large mounted wind turbine, ready to power other appliances.", "copy-from": "xl_wind_turbine", @@ -762,9 +735,7 @@ { "type": "vehicle_part", "id": "ap_water_wheel", - "name": { "str": "water wheel" }, "location": "structure", - "color": "yellow", "flags": [ "WATER_WHEEL", "OBSTACLE", "APPLIANCE" ], "description": "A mounted water wheel, ready to power other appliances.", "copy-from": "water_wheel", @@ -774,9 +745,7 @@ { "type": "vehicle_part", "id": "ap_xl_water_wheel", - "name": { "str": "large water wheel" }, "location": "structure", - "color": "yellow", "flags": [ "WATER_WHEEL", "OBSTACLE", "APPLIANCE" ], "description": "A mounted large water wheel, ready to power other appliances.", "copy-from": "xl_water_wheel", @@ -798,7 +767,6 @@ "type": "vehicle_part", "id": "ap_battery_medium", "name": { "str": "medium grid battery" }, - "color": "yellow", "flags": [ "APPLIANCE" ], "description": "A medium battery to store electrical power in a static power grid.", "copy-from": "medium_storage_battery", @@ -849,9 +817,7 @@ { "type": "vehicle_part", "id": "ap_washing_machine", - "name": { "str": "washing machine" }, "looks_like": "f_washer", - "color": "light_blue", "flags": [ "OBSTACLE", "APPLIANCE", "WASHING_MACHINE", "CARGO", "COVERED", "ENABLED_DRAINS_EPOWER" ], "description": "An appliance used to clean laundry, plugged into a power supply and using internal water tanks.", "size": "135 L", @@ -865,7 +831,6 @@ "id": "ap_dishwasher", "name": { "str": "dishwasher" }, "looks_like": "f_dishwasher", - "color": "light_blue", "flags": [ "OBSTACLE", "APPLIANCE", "DISHWASHER", "CARGO", "COVERED", "ENABLED_DRAINS_EPOWER" ], "description": "An appliance used to clean dishes, plugged into a power supply and using internal tanks.", "size": "120 L", @@ -1008,7 +973,6 @@ "type": "vehicle_part", "id": "ap_oxygen_concentrator", "name": { "str": "oxygen concentrator" }, - "color": "light_gray", "categories": [ "utility" ], "broken_color": "dark_gray", "damage_modifier": 35, @@ -1029,7 +993,6 @@ "type": "vehicle_part", "id": "ap_hd_compressor_unit", "name": { "str": "high pressure compressor unit" }, - "color": "light_gray", "categories": [ "utility" ], "broken_color": "dark_gray", "damage_modifier": 45, diff --git a/data/json/vehicleparts/armor.json b/data/json/vehicleparts/armor.json index f25248e0fec9e..d474727f6167c 100644 --- a/data/json/vehicleparts/armor.json +++ b/data/json/vehicleparts/armor.json @@ -7,7 +7,6 @@ "location": "armor", "categories": [ "warfare" ], "color": "dark_gray", - "broken_color": "light_gray", "durability": 150, "folded_volume": "1 L", "//": "4x80cm rebars arranged in a # or //// pattern. Half the surface area is welded (40 cm per rebar)", diff --git a/data/json/vehicleparts/battery.json b/data/json/vehicleparts/battery.json index 2b274f2e0f9cd..284b8a8efd17b 100644 --- a/data/json/vehicleparts/battery.json +++ b/data/json/vehicleparts/battery.json @@ -71,7 +71,6 @@ "copy-from": "large_storage_battery", "type": "vehicle_part", "name": { "str": "swappable very large storage battery" }, - "item": "large_storage_battery", "location": "on_battery_mount", "requirements": { "install": { "skills": [ [ "mechanics", 0 ] ], "time": "10 s", "using": [ ] }, @@ -140,7 +139,6 @@ "copy-from": "storage_battery", "type": "vehicle_part", "name": { "str": "swappable large storage battery" }, - "item": "storage_battery", "location": "on_battery_mount", "requirements": { "install": { "skills": [ [ "mechanics", 0 ] ], "time": "10 s", "using": [ ] }, diff --git a/data/json/vehicleparts/boards.json b/data/json/vehicleparts/boards.json index 7f86f2a511000..25f6bf169ddcc 100644 --- a/data/json/vehicleparts/boards.json +++ b/data/json/vehicleparts/boards.json @@ -161,7 +161,6 @@ "name": { "str": "stow board" }, "item": "sheet_metal", "color": "white", - "broken_color": "light_gray", "durability": 80, "description": "A metal wall with a storage locker. Keeps zombies outside the vehicle and prevents people from seeing through it.", "size": "62500 ml", @@ -215,7 +214,6 @@ "type": "vehicle_part", "copy-from": "hdboard_abstract", "name": { "str": "heavy-duty board" }, - "description": "A strong metal wall. Keeps zombies outside the vehicle and prevents people from seeing through it.", "extend": { "flags": [ "OPAQUE", "FULL_BOARD" ] } }, { diff --git a/data/json/vehicleparts/cargo.json b/data/json/vehicleparts/cargo.json index 1b5fa4aaa3b01..987b2e41933a7 100644 --- a/data/json/vehicleparts/cargo.json +++ b/data/json/vehicleparts/cargo.json @@ -4,7 +4,6 @@ "id": "cargo_bag", "name": { "str": "storage bag" }, "categories": [ "cargo" ], - "color": "light_gray", "broken_color": "dark_gray", "damage_modifier": 60, "durability": 15, @@ -195,7 +194,6 @@ "item": "cargo_rack", "location": "structure", "categories": [ "cargo" ], - "color": "light_gray", "broken_color": "dark_gray", "durability": 250, "description": "Storage space, mounted outside your vehicle's armor and vulnerable to damage.", @@ -222,7 +220,6 @@ "item": "bike_rack", "location": "anywhere", "categories": [ "cargo" ], - "color": "light_gray", "broken_color": "dark_gray", "durability": 150, "description": "A collection of pipes and frames for supporting a bike or other small vehicle and carrying it on your vehicle. Move a single tile wide vehicle so that all of that vehicle's tiles are next to bike racks, and then 'e'xamine any bike rack to mount that vehicle onto the bike rack. 'e'xamine the bike rack to unmount the carried vehicle.", @@ -248,7 +245,6 @@ "item": "mounted_spare_tire", "location": "structure", "categories": [ "other" ], - "color": "light_gray", "broken_color": "dark_gray", "durability": 75, "description": "Spare tire stored on an external carrier rig.", diff --git a/data/json/vehicleparts/combustion.json b/data/json/vehicleparts/combustion.json index e7f5849b470f3..ba502032cdc14 100644 --- a/data/json/vehicleparts/combustion.json +++ b/data/json/vehicleparts/combustion.json @@ -167,7 +167,6 @@ "item": "1cyl_combustion", "description": "A 50cc gasoline engine, suitable for a lawnmower, golf cart or moped.", "durability": 150, - "epower": "0 W", "power": "7370 W", "energy_consumption": "18425 W", "folded_volume": "12 L", @@ -194,7 +193,6 @@ "item": "1cyl_combustion_large", "description": "A 200cc engine, suitable for a dirt bike or scooter.", "durability": 150, - "epower": "0 W", "power": "21000 W", "energy_consumption": "49800 W", "folded_volume": "42 L", @@ -220,9 +218,7 @@ "type": "vehicle_part", "item": "1cyl_combustion_small", "description": "A small 25cc gasoline engine, suitable for a hedge trimmer or installing on a bicycle.", - "fuel_type": "gasoline", "durability": 120, - "epower": "0 W", "power": "3728 W", "energy_consumption": "9320 W", "folded_volume": "6 L", @@ -445,7 +441,6 @@ "type": "vehicle_part", "item": "steam_watts_small", "durability": 200, - "epower": "0 W", "power": "55950 W", "energy_consumption": "112000 W", "breaks_into": [ @@ -471,7 +466,6 @@ "type": "vehicle_part", "item": "steam_triple_small", "durability": 200, - "epower": "0 W", "power": "93250 W", "energy_consumption": "186500 W", "breaks_into": [ diff --git a/data/json/vehicleparts/doors.json b/data/json/vehicleparts/doors.json index 1f28c4fc761d9..34d3f9563a254 100644 --- a/data/json/vehicleparts/doors.json +++ b/data/json/vehicleparts/doors.json @@ -115,7 +115,6 @@ "copy-from": "door_opaque", "damage_modifier": 75, "description": "An interior door. Solid construction means you can't see through it when closed.", - "durability": 240, "name": { "str": "internal door" }, "type": "vehicle_part" }, @@ -201,7 +200,6 @@ "damage_modifier": 75, "durability": 160, "size": "0 ml", - "description": "A door. Has a window so you can see out of it, even when closed.", "item": "frame_wood", "requirements": { "install": { "skills": [ [ "mechanics", 2 ] ], "time": "30 m", "using": [ [ "vehicle_nail_install", 1 ] ] }, @@ -220,7 +218,6 @@ "name": { "str": "opaque wooden door" }, "durability": 170, "description": "A door. Solid construction means you can't see through it when closed.", - "size": "0 ml", "extend": { "flags": [ "OPAQUE" ] }, "delete": { "flags": [ "WINDOW" ] }, "damage_reduction": { "all": 12 } @@ -283,9 +280,7 @@ "copy-from": "door_trunk", "name": { "str": "sliding door" }, "looks_like": "door", - "durability": 150, "description": "A door. A window lets you see through it when closed.", - "item": "frame", "breaks_into": "ig_vp_frame", "delete": { "flags": [ "LOW_FINAL_AIR_DRAG", "NO_ROOF_NEEDED", "WINDOW" ] } } diff --git a/data/json/vehicleparts/engineering.json b/data/json/vehicleparts/engineering.json index e1490f2dfe2b3..fa78deeb0bd47 100644 --- a/data/json/vehicleparts/engineering.json +++ b/data/json/vehicleparts/engineering.json @@ -12,7 +12,6 @@ "item": "cantilever_medium", "location": "structure", "categories": [ "utility" ], - "color": "light_gray", "broken_color": "light_blue", "durability": 200, "description": "A rigid steel boom crane. If it is in your line of sight and within two tiles of another vehicle, you will automatically use it when you want to jack up the other vehicle to change its wheels. To use it to lift a heavy component like an engine that you are installing or removing, the crane must have line of sight to where it is going and it must be within four tiles of it.", @@ -46,7 +45,6 @@ "item": "cantilever_small", "location": "center", "categories": [ "utility" ], - "color": "light_gray", "broken_color": "light_blue", "durability": 100, "description": "An extendable cantilever crane. If it is in your line of sight and within two tiles of another vehicle, you will automatically use it when you want to jack up the other vehicle to change its wheels. To use it to lift a heavy component like an engine that you are installing or removing, the crane must have line of sight to where it is going and it must be within four tiles of it.", @@ -71,7 +69,6 @@ "item": "pallet_lifter", "location": "center", "categories": [ "utility" ], - "color": "light_gray", "broken_color": "light_blue", "durability": 100, "description": "A small pallet lifter. If it is in your line of sight and within two tiles of another vehicle, you will automatically use it when you want to jack up the other vehicle to change its wheels. To use it to lift a heavy component like an engine that you are installing or removing, the crane must have line of sight to where it is going and it must be within four tiles of it.", @@ -95,8 +92,6 @@ "item": "frame", "location": "structure", "categories": [ "utility" ], - "color": "light_gray", - "broken_color": "light_gray", "damage_modifier": 200, "durability": 300, "description": "A pair of forklift arms. If it is in your line of sight and within two tiles of another vehicle, you will automatically use it when you want to jack up the other vehicle to change its wheels. To use it to lift a heavy component like an engine that you are installing or removing, the crane must have line of sight to where it is going and it must be within four tiles of it.", @@ -133,10 +128,7 @@ "item": "v_rockwheel_item", "location": "structure", "categories": [ "utility" ], - "color": "light_gray", - "broken_color": "light_gray", "looks_like": "crane_medium", - "damage_modifier": 100, "durability": 300, "description": "A large metal disc, powered by the vehicle's engines. Use the vehicle controls to turn it on or off. When turned on, it will stop the vehicle unless it has a strong engine. When turned on, it will dig a shallow pit in dirt. Mount it on the edge of your vehicle.", "power": "-70000 W", @@ -171,7 +163,6 @@ "item": "v_airjack_item", "location": "under", "categories": [ "utility" ], - "color": "light_gray", "broken_color": "light_blue", "looks_like": "crane_small", "durability": 200, @@ -206,7 +197,6 @@ "name": { "str": "motorcycle kickstand" }, "item": "v_motorcycle_kickstand_item", "categories": [ "utility" ], - "color": "light_gray", "broken_color": "light_blue", "durability": 200, "description": "A kickstand to keep the bike from falling over. You could use this to lean it forward or backward to change a tire.", diff --git a/data/json/vehicleparts/frames.json b/data/json/vehicleparts/frames.json index 94cfb02be7571..794c6850e2d42 100644 --- a/data/json/vehicleparts/frames.json +++ b/data/json/vehicleparts/frames.json @@ -196,7 +196,6 @@ "copy-from": "frame_abstract", "name": { "str": "extra light frame" }, "item": "xlframe", - "color": "light_gray", "durability": 150, "description": "A light metal framework. Other vehicle components can be mounted on it, and it can be attached to other frames to increase the vehicle's size.", "breaks_into": [ { "item": "scrap_aluminum", "count": [ 5, 30 ] } ], @@ -222,7 +221,6 @@ "copy-from": "frame_abstract", "name": { "str": "foldable extra light frame" }, "item": "foldxlframe", - "color": "light_gray", "durability": 150, "description": "A light metal framework. Other vehicle components can be mounted on it, and it can be attached to other frames to increase the vehicle's size.", "folded_volume": "2500 ml", diff --git a/data/json/vehicleparts/manual.json b/data/json/vehicleparts/manual.json index 89be90fef17fb..f3e4472d6acd8 100644 --- a/data/json/vehicleparts/manual.json +++ b/data/json/vehicleparts/manual.json @@ -5,7 +5,6 @@ "location": "engine_block", "categories": [ "movement", "operations" ], "fuel_type": "muscle", - "color": "light_gray", "broken_color": "red", "damage_modifier": 50, "noise_factor": 5, @@ -44,7 +43,6 @@ "description": "A set of wheelchair style wheels. If mounted on the same tile as seat, they allow you to move the vehicle at the cost of your stamina.", "power": "180 W", "muscle_power_factor": 30, - "damage_modifier": 50, "folded_volume": "500 ml", "requirements": { "install": { "skills": [ [ "mechanics", 0 ] ], "time": "60 m", "using": [ [ "vehicle_wrench_2", 1 ] ] }, diff --git a/data/json/vehicleparts/motor.json b/data/json/vehicleparts/motor.json index e0fa51a9aba44..656da0901757e 100644 --- a/data/json/vehicleparts/motor.json +++ b/data/json/vehicleparts/motor.json @@ -71,9 +71,7 @@ "id": "engine_electric", "copy-from": "engine_motor", "type": "vehicle_part", - "name": { "str": "electric motor" }, "description": "A medium-duty electrical motor, suitable for powering ultra-light vehicles, or as part of a hybrid gas-electric drivetrain.", - "item": "motor", "durability": 200, "power": "36000 W", "energy_consumption": "40 kW", diff --git a/data/json/vehicleparts/rams.json b/data/json/vehicleparts/rams.json index c51f56b8f4d0c..5a531167fd1e8 100644 --- a/data/json/vehicleparts/rams.json +++ b/data/json/vehicleparts/rams.json @@ -184,7 +184,6 @@ "name": { "str": "chitin ram" }, "item": "chitin_plate", "color": "yellow", - "broken_color": "light_gray", "looks_like": "ram_wood", "durability": 250, "breaks_into": [ { "item": "chitin_piece", "count": [ 5, 15 ] } ], @@ -207,7 +206,6 @@ "name": { "str": "tied mattress" }, "item": "mattress", "color": "white", - "broken_color": "light_gray", "damage_modifier": 50, "durability": 40, "description": "A mattress, strapped onto the vehicle. It could serve to blunt any impact.", diff --git a/data/json/vehicleparts/rotor.json b/data/json/vehicleparts/rotor.json index 0c966410fb042..8945d2b20a9ab 100644 --- a/data/json/vehicleparts/rotor.json +++ b/data/json/vehicleparts/rotor.json @@ -5,7 +5,6 @@ "categories": [ "movement" ], "location": "on_roof", "color": "light_blue", - "broken_color": "light_gray", "flags": [ "ROTOR", "NO_INSTALL_PLAYER", "NO_REPAIR", "SMASH_REMOVE" ], "description": "A set of aerofoil helicopter rotors, when spun at high speed, they generate thrust via lift.", "variants": [ { "symbols": "X", "symbols_broken": "O" } ] @@ -45,9 +44,7 @@ "copy-from": "heavy_duty_military_rotor", "type": "vehicle_part", "name": { "str": "heavy-duty military Blackhawk rotors" }, - "item": "heavy_duty_military_rotor", "//": "rotor diameter is in meters", - "description": "A set of four military-grade helicopter rotor blades, used to provide lift by rotation.", "rotor_diameter": 16 }, { @@ -55,7 +52,6 @@ "copy-from": "heavy_duty_military_rotor", "type": "vehicle_part", "name": { "str": "heavy-duty military Osprey rotors" }, - "item": "heavy_duty_military_rotor", "//": "rotor diameter is in meters", "description": "A set of three military-grade helicopter rotor blades, used to provide lift by rotation.", "rotor_diameter": 11 diff --git a/data/json/vehicleparts/tanks.json b/data/json/vehicleparts/tanks.json index b662594713f68..7024e76815652 100644 --- a/data/json/vehicleparts/tanks.json +++ b/data/json/vehicleparts/tanks.json @@ -147,7 +147,6 @@ "type": "vehicle_part", "name": { "str": "heated tank (60L)" }, "item": "heattank", - "location": "fuel_source", "copy-from": "fridgetank", "description": "A 60L heated tank. When turned on, it will prevent the contents from freezing.", "epower": "-60 W", @@ -184,7 +183,6 @@ "type": "vehicle_part", "name": { "str": "roof-mounted external tank (100L)" }, "looks_like": "afs_roof_external_tank", - "item": "30gal_drum", "location": "on_roof", "extend": { "flags": [ "ON_ROOF" ] } }, @@ -442,7 +440,6 @@ "copy-from": "external_tank_small_aluminum", "type": "vehicle_part", "name": { "str": "roof-mounted external aluminum tank (100L)" }, - "item": "30gal_drum_aluminum", "breaks_into": [ { "item": "scrap_aluminum", "count": [ 4, 13 ] } ], "requirements": { "install": { "skills": [ [ "mechanics", 1 ] ], "time": "60 m", "using": [ [ "welding_alloys", 50 ] ] }, diff --git a/data/json/vehicleparts/utilities.json b/data/json/vehicleparts/utilities.json index cbdabadc0ea17..90e4bb8ab2cdc 100644 --- a/data/json/vehicleparts/utilities.json +++ b/data/json/vehicleparts/utilities.json @@ -6,7 +6,6 @@ { "count": [ 4, 6 ], "item": "steel_chunk" }, { "count": [ 4, 6 ], "item": "scrap" } ], - "broken_color": "light_gray", "categories": [ "utility" ], "color": "red", "damage_modifier": 10, @@ -39,7 +38,6 @@ { "count": [ 4, 6 ], "item": "steel_chunk" }, { "count": [ 4, 6 ], "item": "scrap" } ], - "broken_color": "light_gray", "categories": [ "utility" ], "color": "red", "damage_modifier": 10, @@ -108,7 +106,6 @@ "looks_like": "binoculars", "categories": [ "passengers" ], "color": "dark_gray", - "broken_color": "light_gray", "damage_modifier": 1, "durability": 50, "description": "Binoculars secured near the seat.", diff --git a/data/json/vehicleparts/vehicle_parts.json b/data/json/vehicleparts/vehicle_parts.json index d185daad324a6..7daf83c7ecf64 100644 --- a/data/json/vehicleparts/vehicle_parts.json +++ b/data/json/vehicleparts/vehicle_parts.json @@ -105,7 +105,6 @@ "wheel_offroad_rating": 0.7, "wheel_terrain_modifiers": { "FLAT": [ 0, 3 ], "ROAD": [ 0, 1 ] }, "description": "Attach this part to a beast of burden to allow it to pull your vehicle.", - "power": "0 W", "location": "structure", "requirements": { "install": { "skills": [ [ "fabrication", 1 ] ], "time": "100 s", "using": [ [ "vehicle_screw", 1 ] ] }, @@ -135,7 +134,6 @@ "categories": [ "movement", "operations" ], "color": "dark_gray", "broken_color": "dark_gray", - "damage_modifier": 100, "noise_factor": 10, "fuel_type": "animal", "durability": 600, @@ -146,7 +144,6 @@ "wheel_offroad_rating": 0.7, "wheel_terrain_modifiers": { "FLAT": [ 0, 3 ], "ROAD": [ 0, 1 ] }, "description": "Attach this part to a beast of burden to allow it to pull your vehicle. This one is reinforced with heavy chains and steel.", - "power": "0 W", "location": "structure", "requirements": { "install": { "skills": [ [ "mechanics", 1 ] ], "time": "20 m", "using": [ [ "welding_standard", 10 ] ] }, @@ -177,13 +174,11 @@ "color": "white", "broken_color": "red", "damage_modifier": 10, - "noise_factor": 0, "fuel_type": "animal", "durability": 20, "item": "pipe", "m2c": 90, "description": "A metal handle, a creature with hands could use it to push a vehicle.", - "power": "0 W", "//": "10cm weld per damage quadrant to repair, 10cm weld to install", "location": "structure", "requirements": { @@ -301,7 +296,6 @@ "looks_like": "t_metal_floor", "categories": [ "hull", "passengers" ], "color": "white", - "broken_color": "light_gray", "durability": 400, "description": "An aisle.", "item": "sheet_metal", @@ -354,7 +348,6 @@ "description": "A collapsible aisle.", "folded_volume": "12500 ml", "item": "foldwoodframe", - "location": "center", "flags": [ "AISLE", "BOARDABLE" ] }, { @@ -364,7 +357,6 @@ "looks_like": "t_carpet_red", "categories": [ "cargo" ], "color": "white", - "broken_color": "light_gray", "durability": 400, "description": "An aisle. A hatch lets you access a cargo space beneath it.", "size": "87500 ml", @@ -394,7 +386,6 @@ "id": "roof_cloth", "name": { "str": "cloth roof" }, "categories": [ "hull" ], - "color": "light_gray", "broken_color": "dark_gray", "durability": 15, "description": "A cloth roof.", @@ -414,7 +405,6 @@ "id": "roof", "name": { "str": "roof" }, "categories": [ "hull" ], - "color": "light_gray", "broken_color": "dark_gray", "durability": 240, "description": "A metal roof.", @@ -505,7 +495,6 @@ "id": "storage_battery_mount", "name": { "str": "swappable storage battery case" }, "categories": [ "energy" ], - "color": "light_gray", "broken_color": "red", "damage_modifier": 80, "durability": 300, @@ -540,7 +529,6 @@ "id": "handheld_battery_mount", "name": { "str": "tool battery mount" }, "categories": [ "energy" ], - "color": "light_gray", "broken_color": "red", "damage_modifier": 80, "durability": 100, @@ -566,7 +554,6 @@ "description": "An armored black box, a device meant to record and preserve data of a military vehicle in the field in case it gets destroyed.", "durability": 400, "categories": [ "other" ], - "color": "light_gray", "broken_color": "dark_gray", "flags": [ "NO_REPAIR" ], "requirements": { @@ -905,7 +892,6 @@ "looks_like": "f_table", "categories": [ "utility" ], "color": "red", - "broken_color": "light_gray", "damage_modifier": 60, "durability": 145, "size": "20 L", @@ -933,7 +919,6 @@ "looks_like": "f_table", "categories": [ "utility" ], "color": "red", - "broken_color": "light_gray", "damage_modifier": 60, "durability": 145, "size": "20 L", @@ -961,7 +946,6 @@ "looks_like": "veh_table_wood", "categories": [ "utility" ], "color": "red", - "broken_color": "light_gray", "damage_modifier": 30, "durability": 70, "size": "20 L", @@ -989,7 +973,6 @@ "looks_like": "veh_table_wood", "categories": [ "utility" ], "color": "red", - "broken_color": "light_gray", "damage_modifier": 60, "durability": 300, "size": "30 L", @@ -1022,7 +1005,6 @@ "bonus": 15, "epower": "-50 W", "item": "workbench_with_recharger", - "location": "center", "//": "20cm weld per quadrant of damage", "requirements": { "install": { "skills": [ [ "mechanics", 1 ] ], "time": "15 m", "using": [ [ "vehicle_wrench_2", 1 ] ] }, @@ -1042,7 +1024,7 @@ { "item": "scrap", "count": [ 1, 3 ] } ], "size": "29500 ml", - "workbench": { "multiplier": 1.2, "mass": 300000, "volume": "29L" }, + "workbench": { "volume": "29L" }, "damage_reduction": { "all": 29 } }, { @@ -1053,7 +1035,6 @@ "looks_like": "t_wall_log", "categories": [ "hull" ], "color": "brown", - "broken_color": "light_gray", "damage_modifier": 50, "durability": 40, "item": "boat_board", @@ -1076,7 +1057,6 @@ "looks_like": "t_wall_log", "categories": [ "hull" ], "color": "brown", - "broken_color": "light_gray", "damage_modifier": 50, "durability": 30, "item": "raft_board", @@ -1099,7 +1079,6 @@ "categories": [ "hull" ], "color": "brown", "looks_like": "boat_board", - "broken_color": "light_gray", "damage_modifier": 50, "durability": 120, "item": "plastic_boat_hull", @@ -1122,7 +1101,6 @@ "categories": [ "hull" ], "color": "dark_gray", "looks_like": "boat_board", - "broken_color": "light_gray", "damage_modifier": 50, "durability": 240, "item": "sheet_metal", @@ -1154,7 +1132,6 @@ "categories": [ "hull" ], "color": "brown", "looks_like": "boat_board", - "broken_color": "light_gray", "damage_modifier": 50, "durability": 480, "item": "carbonfiber_boat_hull", @@ -1177,7 +1154,6 @@ "categories": [ "hull" ], "color": "green", "size": "15 L", - "broken_color": "light_gray", "durability": 50, "item": "inflatable_section", "location": "structure", @@ -1201,7 +1177,6 @@ "name": { "str": "inflatable airbag" }, "categories": [ "hull" ], "color": "green", - "broken_color": "light_gray", "damage_modifier": 50, "durability": 40, "item": "inflatable_airbag", @@ -1225,7 +1200,6 @@ "id": "sail", "name": { "str": "sail" }, "categories": [ "movement", "operations" ], - "color": "light_gray", "broken_color": "red", "damage_modifier": 50, "durability": 20, @@ -1251,7 +1225,6 @@ "id": "hand_paddles", "name": { "str": "hand paddles" }, "categories": [ "movement", "operations" ], - "color": "light_gray", "broken_color": "red", "damage_modifier": 50, "durability": 50, @@ -1279,7 +1252,6 @@ "id": "reins_tackle", "name": { "str": "reins and tackle" }, "categories": [ "operations" ], - "color": "light_gray", "broken_color": "red", "durability": 80, "description": "A set of leather bindings to control a creature pulling a vehicle, such as a cart.", @@ -1301,7 +1273,6 @@ "id": "controls", "name": { "str": "controls" }, "categories": [ "operations" ], - "color": "light_gray", "broken_color": "red", "damage_modifier": 10, "durability": 250, @@ -1390,7 +1361,6 @@ "item": "mountable_heater_small", "//": "going with half energy draw based on difference between small and large space heaters", "epower": "-350 W", - "bonus": 10, "folded_volume": "3750 ml", "requirements": { "install": { "skills": [ [ "mechanics", 1 ], [ "electronics", 1 ] ], "time": "2 m", "using": [ [ "vehicle_screw", 1 ] ] }, @@ -1454,8 +1424,6 @@ "id": "muffler", "name": { "str": "muffler" }, "categories": [ "other" ], - "color": "light_gray", - "broken_color": "light_gray", "damage_modifier": 10, "durability": 50, "description": "A metal pipe that somewhat reduces engine noise. Also vents heat from an installed vehicle cooler.", @@ -1489,7 +1457,6 @@ "id": "seatbelt", "name": { "str": "seatbelt" }, "categories": [ "operations", "passengers" ], - "color": "light_gray", "broken_color": "red", "damage_modifier": 10, "durability": 35, @@ -1543,7 +1510,6 @@ "id": "smart_engine_controller", "name": { "str": "smart engine controller" }, "categories": [ "other" ], - "color": "light_gray", "broken_color": "red", "damage_modifier": 10, "durability": 35, @@ -1572,7 +1538,6 @@ "id": "seatbelt_heavyduty", "name": { "str": "5-point harness" }, "categories": [ "operations", "passengers" ], - "color": "light_gray", "broken_color": "red", "damage_modifier": 10, "durability": 100, @@ -1597,7 +1562,6 @@ "looks_like": "t_door_curtain_c", "categories": [ "other" ], "color": "dark_gray", - "broken_color": "light_gray", "damage_modifier": 1, "durability": 200, "description": "A sheet over a window.", @@ -1620,7 +1584,6 @@ "looks_like": "v_curtain", "categories": [ "other" ], "color": "dark_gray", - "broken_color": "light_gray", "damage_modifier": 1, "durability": 200, "description": "A sheet across an aisle.", @@ -1922,8 +1885,6 @@ "name": { "str": "water faucet" }, "looks_like": "f_sink", "categories": [ "utility" ], - "color": "light_gray", - "broken_color": "light_gray", "damage_modifier": 10, "description": "A water faucet.", "durability": 45, @@ -2151,7 +2112,6 @@ "id": "horn_bicycle", "name": { "str": "bicycle horn" }, "categories": [ "other" ], - "color": "light_gray", "broken_color": "red", "damage_modifier": 10, "durability": 75, @@ -2173,7 +2133,6 @@ "id": "horn_car", "name": { "str": "car horn" }, "categories": [ "other" ], - "color": "light_gray", "broken_color": "red", "damage_modifier": 10, "durability": 100, @@ -2194,7 +2153,6 @@ "id": "horn_big", "name": { "str": "truck horn" }, "categories": [ "other" ], - "color": "light_gray", "broken_color": "red", "damage_modifier": 10, "durability": 125, @@ -2215,7 +2173,6 @@ "id": "beeper", "name": { "str": "back-up beeper" }, "categories": [ "other" ], - "color": "light_gray", "broken_color": "dark_gray", "damage_modifier": 10, "durability": 90, @@ -2238,7 +2195,6 @@ "name": { "str": "cargo space" }, "looks_like": "box", "categories": [ "cargo" ], - "color": "light_gray", "broken_color": "dark_gray", "durability": 250, "size": "500 L", @@ -2273,7 +2229,6 @@ "id": "livestock_stall", "name": { "str": "livestock stall" }, "categories": [ "passengers", "cargo" ], - "color": "light_gray", "looks_like": "cargo_space", "broken_color": "dark_gray", "durability": 250, @@ -2369,7 +2324,6 @@ "name": { "str": "stereo system" }, "categories": [ "other" ], "color": "red", - "broken_color": "light_gray", "damage_modifier": 0, "durability": 60, "damage_reduction": { "bash": 5 }, @@ -2392,7 +2346,6 @@ "name": { "str": "chimes" }, "categories": [ "other" ], "color": "red", - "broken_color": "light_gray", "damage_modifier": 0, "durability": 40, "description": "A collection of electronic bells. Use the vehicle's controls to turn it on or off. When turned on, it makes noise, attracting neighborhood children.", @@ -2509,7 +2462,6 @@ "categories": [ "other" ], "color": "yellow", "broken_color": "dark_gray", - "epower": "0 W", "//": "Epower for POWER_TRANSFER stuff is how much percentage-wise loss there is in transmission", "damage_modifier": 10, "durability": 120, @@ -2578,7 +2530,6 @@ "id": "roof_wood", "name": { "str": "wooden roof" }, "categories": [ "hull" ], - "color": "light_gray", "broken_color": "dark_gray", "durability": 130, "description": "A wooden roof.", @@ -2600,7 +2551,6 @@ "name": { "str": "chitin plating" }, "categories": [ "warfare" ], "color": "yellow", - "broken_color": "light_gray", "durability": 200, "item": "chitin_plate", "location": "armor", @@ -2630,7 +2580,6 @@ "name": { "str": "door motor" }, "categories": [ "other" ], "color": "light_green", - "broken_color": "light_gray", "damage_modifier": 10, "durability": 50, "description": "A small electric motor. Installed on the same frame as a door or curtain, it will allow you to remotely open the door or curtain from the vehicle controls.", @@ -2733,16 +2682,9 @@ "copy-from": "omnicam", "name": { "str": "reinforced security camera" }, "categories": [ "operations" ], - "color": "light_red", - "broken_color": "red", - "damage_modifier": 10, "durability": 300, "description": "A small camera encased in a protective metal cage. Will relay what it can see to a camera control station.", - "folded_volume": "2 L", - "bonus": 24, "item": "omnicamera_reinforced", - "epower": "-10 W", - "location": "on_roof", "requirements": { "install": { "skills": [ [ "mechanics", 4 ] ], "time": "60 m", "using": [ [ "vehicle_screw", 1 ] ] }, "removal": { "skills": [ [ "mechanics", 2 ] ], "time": "30 m", "using": [ [ "vehicle_screw", 1 ] ] }, @@ -2758,7 +2700,6 @@ "name": { "str": "robot controls" }, "categories": [ "operations" ], "color": "white", - "broken_color": "light_gray", "damage_modifier": 10, "durability": 300, "description": "A set of controls to allow a vehicle to drive itself, or you to drive it remotely using a controller.", @@ -2796,11 +2737,9 @@ "id": "vehicle_clock", "name": { "str": "makeshift clock" }, "categories": [ "other" ], - "color": "light_gray", "broken_color": "dark_gray", "durability": 20, "description": "A clock, so you know what time it is.", - "epower": "0 W", "folded_volume": "250 ml", "item": "wristwatch", "requirements": { @@ -2820,7 +2759,6 @@ "looks_like": "funnel", "categories": [ "other" ], "color": "brown", - "broken_color": "light_gray", "damage_modifier": 5, "durability": 80, "description": "A funnel that will collect rainwater into the tank beneath it.", @@ -2844,7 +2782,6 @@ "looks_like": "funnel", "categories": [ "other" ], "color": "white", - "broken_color": "light_gray", "damage_modifier": 5, "durability": 60, "description": "A funnel that will collect rainwater into the tank beneath it.", @@ -2868,7 +2805,6 @@ "looks_like": "funnel", "categories": [ "other" ], "color": "yellow", - "broken_color": "light_gray", "damage_modifier": 5, "durability": 80, "description": "A funnel that will collect rainwater into the tank beneath it.", @@ -2891,7 +2827,6 @@ "name": { "str": "funnel" }, "categories": [ "other" ], "color": "yellow", - "broken_color": "light_gray", "damage_modifier": 5, "durability": 200, "description": "A funnel that will collect rainwater into the tank beneath it.", @@ -2913,8 +2848,6 @@ "name": { "str": "metal funnel" }, "looks_like": "funnel", "categories": [ "other" ], - "color": "light_gray", - "broken_color": "light_gray", "damage_modifier": 30, "durability": 300, "description": "A funnel that will collect rainwater into the tank beneath it.", @@ -2936,7 +2869,6 @@ "id": "vehicle_scoop", "name": { "str": "scoop" }, "categories": [ "utility" ], - "color": "light_gray", "broken_color": "dark_gray", "durability": 100, "description": "A scoop. Use the vehicle controls to turn it on or off. When turned on, it will scoop up loose items that it travels over until it's full.", @@ -3096,7 +3028,6 @@ "id": "reaper", "name": { "str": "reaper" }, "categories": [ "utility" ], - "color": "light_gray", "broken_color": "light_blue", "damage_modifier": 120, "bonus": 7, @@ -3129,7 +3060,6 @@ "id": "reaper_advanced", "name": { "str": "advanced reaper" }, "categories": [ "utility" ], - "color": "light_gray", "broken_color": "light_blue", "damage_modifier": 120, "bonus": 7, @@ -3171,7 +3101,6 @@ "name": { "str": "cargo lock" }, "categories": [ "cargo" ], "color": "dark_gray", - "broken_color": "light_gray", "durability": 25, "description": "A set of locks. Attached to a suitable cargo space, it will prevent other people from accessing the cargo and taking your stuff.", "folded_volume": "250 ml", @@ -3192,8 +3121,6 @@ "id": "turret_mount", "name": { "str": "turret mount" }, "categories": [ "warfare" ], - "color": "light_gray", - "broken_color": "light_gray", "damage_modifier": 80, "durability": 320, "description": "A rotating, universal mount for a weapon. If your hands are empty, you can stand on the same tile as a turret mount and 'f'ire the weapon.", @@ -3248,7 +3175,6 @@ "categories": [ "hull" ], "color": "dark_gray", "looks_like": "boat_board", - "broken_color": "light_gray", "damage_modifier": 50, "durability": 200, "item": "aluminum_boat_hull", @@ -3298,7 +3224,6 @@ "name": { "str": "tied-down fridge" }, "categories": [ "other" ], "color": "white", - "broken_color": "light_gray", "damage_modifier": 5, "durability": 200, "description": "A fridge, secured to the roof for transportation. Not functional, but easier than carrying it with your hands.", @@ -3326,7 +3251,6 @@ "name": { "str": "tied-down freezer" }, "categories": [ "other" ], "color": "white", - "broken_color": "light_gray", "damage_modifier": 5, "durability": 200, "description": "A chest freezer, secured to the roof for transportation. Not functional, but easier than carrying it with your hands.", diff --git a/data/json/vehicleparts/wheel.json b/data/json/vehicleparts/wheel.json index f55b7d9c2dc8e..42dd07072f6ed 100644 --- a/data/json/vehicleparts/wheel.json +++ b/data/json/vehicleparts/wheel.json @@ -6,7 +6,6 @@ "categories": [ "movement" ], "color": "brown", "location": "axle", - "broken_color": "light_gray", "damage_modifier": 40, "folded_volume": "250 ml", "durability": 80, @@ -34,9 +33,7 @@ "id": "wheel_mount_light", "name": { "str": "light wheel mount" }, "categories": [ "movement" ], - "color": "light_gray", "location": "axle", - "broken_color": "light_gray", "damage_modifier": 80, "folded_volume": "250 ml", "durability": 120, @@ -65,9 +62,7 @@ "id": "wheel_mount_medium", "name": { "str": "wheel hub assembly" }, "categories": [ "movement" ], - "color": "light_gray", "location": "axle", - "broken_color": "light_gray", "damage_modifier": 80, "durability": 120, "description": "Connection where wheels can be connected on. This particular one is fit for normal car wheels.", @@ -103,9 +98,7 @@ "id": "wheel_mount_heavy", "name": { "str": "heavy wheel hub assembly" }, "categories": [ "movement" ], - "color": "light_gray", "location": "axle", - "broken_color": "light_gray", "damage_modifier": 80, "durability": 120, "description": "Connection where wheels can be connected on. This particular one is fit for large car wheels.", @@ -231,7 +224,6 @@ { "item": "steel_chunk", "count": [ 1, 2 ] }, { "item": "scrap", "count": [ 1, 2 ] } ], - "rolling_resistance": 1.0, "wheel_terrain_modifiers": { "FLAT": [ 0, 4 ], "ROAD": [ 0, 2 ] }, "contact_area": 153, "requirements": { @@ -640,7 +632,6 @@ "type": "vehicle_part", "name": { "str": "banded wooden cart wheel" }, "item": "wheel_wood_b", - "location": "under", "breaks_into": [ { "item": "2x4", "count": [ 0, 4 ] }, { "item": "nail", "charges": [ 5, 15 ] }, diff --git a/data/json/vehicleparts/windshields.json b/data/json/vehicleparts/windshields.json index c59cedac2dda0..9c20e431cac2d 100644 --- a/data/json/vehicleparts/windshields.json +++ b/data/json/vehicleparts/windshields.json @@ -3,7 +3,6 @@ "id": "windshield", "type": "vehicle_part", "breaks_into": [ { "count": [ 25, 50 ], "item": "glass_shard" } ], - "broken_color": "light_gray", "categories": [ "hull" ], "color": "light_cyan", "damage_modifier": 70, diff --git a/src/assign.cpp b/src/assign.cpp index 8ac19b1cfa988..e025ba64baed0 100644 --- a/src/assign.cpp +++ b/src/assign.cpp @@ -439,7 +439,7 @@ bool assign( const JsonObject &jo, const std::string_view name, units::power &va return true; } -bool assign( const JsonObject &jo, const std::string &name, nc_color &val ) +bool assign( const JsonObject &jo, const std::string &name, nc_color &val, bool strict ) { if( !jo.has_member( name ) ) { return false; @@ -448,6 +448,13 @@ bool assign( const JsonObject &jo, const std::string &name, nc_color &val ) if( out == c_unset ) { jo.throw_error_at( name, "invalid color name" ); } + + if( strict && out == val ) { + report_strict_violation( jo, + "cannot assign explicit value the same as default or inherited value", + name ); + } + val = out; return true; } diff --git a/src/assign.h b/src/assign.h index bd5aa0a61e456..9ec8077ec1998 100644 --- a/src/assign.h +++ b/src/assign.h @@ -234,7 +234,8 @@ bool assign( const JsonObject &jo, std::string_view name, units::power &val, units::power lo = units::power_min, units::power hi = units::power_max ); -bool assign( const JsonObject &jo, const std::string &name, nc_color &val ); +bool assign( const JsonObject &jo, const std::string &name, nc_color &val, + bool strict = false ); class time_duration; diff --git a/src/veh_type.cpp b/src/veh_type.cpp index 6e46d52e372e5..31bee2b6c613e 100644 --- a/src/veh_type.cpp +++ b/src/veh_type.cpp @@ -150,7 +150,7 @@ const vpart_info &string_id::obj() const return vpart_info_factory.obj( *this ); } -static void parse_vp_reqs( const JsonObject &obj, const std::string &id, const std::string &key, +static void parse_vp_reqs( const JsonObject &obj, const vpart_id &id, const std::string &key, std::vector> &reqs, std::map &skills, int &moves ) { @@ -163,9 +163,9 @@ static void parse_vp_reqs( const JsonObject &obj, const std::string &id, const s JsonArray sk = src.get_array( "skills" ); if( !sk.empty() ) { skills.clear(); - } - for( JsonArray cur : sk ) { - skills.emplace( skill_id( cur.get_string( 0 ) ), cur.size() >= 2 ? cur.get_int( 1 ) : 1 ); + for( JsonArray cur : sk ) { + skills.emplace( skill_id( cur.get_string( 0 ) ), cur.size() >= 2 ? cur.get_int( 1 ) : 1 ); + } } if( src.has_int( "time" ) ) { @@ -226,30 +226,30 @@ void vpart_info::load( const JsonObject &jo, const std::string &src ) { const bool strict = src == "dda"; - assign( jo, "name", name_ ); - assign( jo, "item", base_item ); - assign( jo, "location", location ); - assign( jo, "durability", durability ); - assign( jo, "damage_modifier", dmg_mod ); - assign( jo, "energy_consumption", energy_consumption ); - assign( jo, "power", power ); - assign( jo, "epower", epower ); - assign( jo, "emissions", emissions ); - assign( jo, "exhaust", exhaust ); - assign( jo, "fuel_type", fuel_type ); - assign( jo, "default_ammo", default_ammo ); - assign( jo, "folded_volume", folded_volume ); - assign( jo, "size", size ); - assign( jo, "bonus", bonus ); - assign( jo, "cargo_weight_modifier", cargo_weight_modifier ); - assign( jo, "categories", categories ); - assign( jo, "flags", flags ); - assign( jo, "description", description ); - assign( jo, "color", color ); - assign( jo, "broken_color", color_broken ); - assign( jo, "comfort", comfort ); - assign( jo, "floor_bedding_warmth", floor_bedding_warmth ); - assign( jo, "bonus_fire_warmth_feet", bonus_fire_warmth_feet ); + assign( jo, "name", name_, strict ); + assign( jo, "item", base_item, strict ); + assign( jo, "location", location, strict ); + assign( jo, "durability", durability, strict ); + assign( jo, "damage_modifier", dmg_mod, strict ); + assign( jo, "energy_consumption", energy_consumption, strict ); + assign( jo, "power", power, strict ); + assign( jo, "epower", epower, strict ); + assign( jo, "emissions", emissions, strict ); + assign( jo, "exhaust", exhaust, strict ); + assign( jo, "fuel_type", fuel_type, strict ); + assign( jo, "default_ammo", default_ammo, strict ); + assign( jo, "folded_volume", folded_volume, strict ); + assign( jo, "size", size, strict ); + assign( jo, "bonus", bonus, strict ); + assign( jo, "cargo_weight_modifier", cargo_weight_modifier, strict ); + assign( jo, "categories", categories, strict ); + assign( jo, "flags", flags, strict ); + assign( jo, "description", description, strict ); + assign( jo, "color", color, strict ); + assign( jo, "broken_color", color_broken, strict ); + assign( jo, "comfort", comfort, strict ); + assign( jo, "floor_bedding_warmth", floor_bedding_warmth, strict ); + assign( jo, "bonus_fire_warmth_feet", bonus_fire_warmth_feet, strict ); if( jo.has_array( "variants" ) ) { variants.clear(); @@ -293,9 +293,9 @@ void vpart_info::load( const JsonObject &jo, const std::string &src ) if( jo.has_member( "requirements" ) ) { JsonObject reqs = jo.get_object( "requirements" ); - parse_vp_reqs( reqs, id.str(), "install", install_reqs, install_skills, install_moves ); - parse_vp_reqs( reqs, id.str(), "removal", removal_reqs, removal_skills, removal_moves ); - parse_vp_reqs( reqs, id.str(), "repair", repair_reqs, repair_skills, repair_moves ); + parse_vp_reqs( reqs, id, "install", install_reqs, install_skills, install_moves ); + parse_vp_reqs( reqs, id, "removal", removal_reqs, removal_skills, removal_moves ); + parse_vp_reqs( reqs, id, "repair", repair_reqs, repair_skills, repair_moves ); } assign( jo, "looks_like", looks_like, strict ); @@ -326,10 +326,10 @@ void vpart_info::load( const JsonObject &jo, const std::string &src ) } } } - assign( jo, "folding_tools", folding_tools ); - assign( jo, "unfolding_tools", unfolding_tools ); - assign( jo, "folding_time", folding_time ); - assign( jo, "unfolding_time", unfolding_time ); + assign( jo, "folding_tools", folding_tools, strict ); + assign( jo, "unfolding_tools", unfolding_tools, strict ); + assign( jo, "folding_time", folding_time, strict ); + assign( jo, "unfolding_time", unfolding_time, strict ); if( jo.has_member( "damage_reduction" ) ) { JsonObject dred = jo.get_object( "damage_reduction" ); @@ -340,14 +340,14 @@ void vpart_info::load( const JsonObject &jo, const std::string &src ) if( !engine_info ) { engine_info.emplace(); } - assign( jo, "backfire_threshold", engine_info->backfire_threshold ); - assign( jo, "backfire_freq", engine_info->backfire_freq ); - assign( jo, "noise_factor", engine_info->noise_factor ); - assign( jo, "damaged_power_factor", engine_info->damaged_power_factor ); - assign( jo, "m2c", engine_info->m2c ); - assign( jo, "muscle_power_factor", engine_info->muscle_power_factor ); - assign( jo, "exclusions", engine_info->exclusions ); - assign( jo, "fuel_options", engine_info->fuel_opts ); + assign( jo, "backfire_threshold", engine_info->backfire_threshold, strict ); + assign( jo, "backfire_freq", engine_info->backfire_freq, strict ); + assign( jo, "noise_factor", engine_info->noise_factor, strict ); + assign( jo, "damaged_power_factor", engine_info->damaged_power_factor, strict ); + assign( jo, "m2c", engine_info->m2c, strict ); + assign( jo, "muscle_power_factor", engine_info->muscle_power_factor, strict ); + assign( jo, "exclusions", engine_info->exclusions, strict ); + assign( jo, "fuel_options", engine_info->fuel_opts, strict ); } if( has_flag( "WHEEL" ) ) { @@ -355,9 +355,9 @@ void vpart_info::load( const JsonObject &jo, const std::string &src ) wheel_info.emplace(); } - assign( jo, "rolling_resistance", wheel_info->rolling_resistance ); - assign( jo, "contact_area", wheel_info->contact_area ); - assign( jo, "wheel_offroad_rating", wheel_info->offroad_rating ); + assign( jo, "rolling_resistance", wheel_info->rolling_resistance, strict ); + assign( jo, "contact_area", wheel_info->contact_area, strict ); + assign( jo, "wheel_offroad_rating", wheel_info->offroad_rating, strict ); if( const std::optional jo_termod = jo.get_member_opt( "wheel_terrain_modifiers" ) ) { wheel_info->terrain_mod.clear(); for( const JsonMember jo_mod : static_cast( *jo_termod ) ) { @@ -372,7 +372,7 @@ void vpart_info::load( const JsonObject &jo, const std::string &src ) if( !rotor_info ) { rotor_info.emplace(); } - assign( jo, "rotor_diameter", rotor_info->rotor_diameter ); + assign( jo, "rotor_diameter", rotor_info->rotor_diameter, strict ); } if( has_flag( "WORKBENCH" ) ) { @@ -381,16 +381,16 @@ void vpart_info::load( const JsonObject &jo, const std::string &src ) } JsonObject wb_jo = jo.get_object( "workbench" ); - assign( wb_jo, "multiplier", workbench_info->multiplier ); - assign( wb_jo, "mass", workbench_info->allowed_mass ); - assign( wb_jo, "volume", workbench_info->allowed_volume ); + assign( wb_jo, "multiplier", workbench_info->multiplier, strict ); + assign( wb_jo, "mass", workbench_info->allowed_mass, strict ); + assign( wb_jo, "volume", workbench_info->allowed_volume, strict ); } if( has_flag( "VEH_TOOLS" ) ) { if( !toolkit_info ) { toolkit_info.emplace(); } - assign( jo, "allowed_tools", toolkit_info->allowed_types ); + assign( jo, "allowed_tools", toolkit_info->allowed_types, strict ); } }