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

armor data resetting material_thickness and environmental_protection #53130

Closed
Saicchi opened this issue Nov 30, 2021 · 2 comments · Fixed by #54801
Closed

armor data resetting material_thickness and environmental_protection #53130

Saicchi opened this issue Nov 30, 2021 · 2 comments · Fixed by #54801
Labels
<Bug> This needs to be fixed Items / Item Actions / Item Qualities Items and how they work and interact

Comments

@Saicchi
Copy link
Contributor

Saicchi commented Nov 30, 2021

Describe the bug

The armor fields material_thickness and environmental_protection are not copied / reset when using copy-from. Using proportional and relative on those fields cause the error: Member material_thickness of type cata::optional<float> does not support relative

After some testing I found out that if the item that is copying from the base item defines armor field, it resets / deletes the material_thickness and environmental_protection.

Steps to reproduce

  1. Load up a game with Magiclysm enabled.
  2. Spawn XL black dragonscale armor
  3. Spawn black dragonscale armor
  4. Compare both armors.

Expected behavior

material_thickness and environmental_protection being able to use copy-from, proportional and relative when armor data is defined.

Screenshots

201219

Versions and configuration

  • OS: Linux
    • OS Version: LSB Version: 1.4; Distributor ID: Arch; Description: Arch Linux; Release: rolling; Codename: n/a;
  • Game Version: 0.F-2728-g98649ca0c9-dirty [64-bit]
  • Graphics Version: Tiles
  • Game Language: English [en]
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    No Fungal Growth [no_fungal_growth],
    Bionic Professions [package_bionic_professions],
    Magiclysm [magiclysm],
    Sacchi's Debug Mod [sacchitesting]
    ]

Additional context

Though I show items from Magiclysm, this is not a Magiclysm specific bug, it occurs with other items in vanilla too.
For example, add "armor": [ { "encumbrance": 10, "coverage": 90, "covers": [ "torso", "leg_l", "leg_r" ] } ] to xl_armor_chitin which uses the same value as the item it's copying from armor_chitin, its values will be reset.

@wapcaplet wapcaplet added <Bug> This needs to be fixed Items / Item Actions / Item Qualities Items and how they work and interact labels Dec 1, 2021
@dseguin
Copy link
Member

dseguin commented Dec 1, 2021

Possible fix (untested, but I have a hunch): Edit: Nope, I'm a dummy. Didn't work.

diff --git a/src/item_factory.cpp b/src/item_factory.cpp
index 7c39bb2db7..cd1151b6d7 100644
--- a/src/item_factory.cpp
+++ b/src/item_factory.cpp
@@ -2321,9 +2321,9 @@ void islot_armor::load( const JsonObject &jo )
     cata::optional<body_part_set> covers;
 
     assign_coverage_from_json( jo, "covers", covers );
-    optional( jo, false, "material_thickness", thickness, cata::nullopt );
-    optional( jo, false, "environmental_protection", env_resist, cata::nullopt );
-    optional( jo, false, "environmental_protection_with_filter", env_resist_w_filter, cata::nullopt );
+    optional( jo, was_loaded, "material_thickness", thickness, cata::nullopt );
+    optional( jo, was_loaded, "environmental_protection", env_resist, cata::nullopt );
+    optional( jo, was_loaded, "environmental_protection_with_filter", env_resist_w_filter, cata::nullopt );
 
     for( armor_portion_data &armor : sub_data ) {
         apply_optional( armor.avg_thickness, thickness );

@Saicchi
Copy link
Contributor Author

Saicchi commented Dec 4, 2021

Related or duplicate of #48364 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bug> This needs to be fixed Items / Item Actions / Item Qualities Items and how they work and interact
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants