From 99ced28227f0d7cf52a45256a60c8f948aab92aa Mon Sep 17 00:00:00 2001 From: LordZanos Date: Tue, 5 Mar 2024 15:34:43 -0500 Subject: [PATCH 1/3] fix: fix crashing when viewing armor item with undefined resitances --- src/item.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/item.cpp b/src/item.cpp index 5af56fe994a1..c9edd8a47bee 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -6170,7 +6170,7 @@ int item::acid_resist( bool to_self, int base_env_resist ) const float mod = get_clothing_mod_val( clothing_mod_type_acid ); std::optional overriden_resistance = damage_resistance_override(); - if( overriden_resistance->flat.count( DT_ACID ) ) { + if( overriden_resistance && overriden_resistance->flat.count( DT_ACID ) ) { return std::lround( overriden_resistance->flat[DT_ACID] + mod ); } @@ -6209,7 +6209,7 @@ int item::fire_resist( bool to_self, int base_env_resist ) const float mod = get_clothing_mod_val( clothing_mod_type_fire ); std::optional overriden_resistance = damage_resistance_override(); - if( overriden_resistance->flat.count( DT_HEAT ) ) { + if (overriden_resistance && overriden_resistance->flat.count(DT_ACID)) { return std::lround( overriden_resistance->flat[DT_HEAT] + mod ); } From 71defe9b73b528a35dc0471d6a78085fb7466804 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 5 Mar 2024 20:42:05 +0000 Subject: [PATCH 2/3] style(autofix.ci): automated formatting --- src/item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/item.cpp b/src/item.cpp index c9edd8a47bee..b0dd7fe660d2 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -6209,7 +6209,7 @@ int item::fire_resist( bool to_self, int base_env_resist ) const float mod = get_clothing_mod_val( clothing_mod_type_fire ); std::optional overriden_resistance = damage_resistance_override(); - if (overriden_resistance && overriden_resistance->flat.count(DT_ACID)) { + if( overriden_resistance && overriden_resistance->flat.count( DT_ACID ) ) { return std::lround( overriden_resistance->flat[DT_HEAT] + mod ); } From 79dbb2250a5808d09ab1489a02426deea46b2deb Mon Sep 17 00:00:00 2001 From: LordZanos Date: Tue, 5 Mar 2024 16:27:29 -0500 Subject: [PATCH 3/3] typo fix --- src/item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/item.cpp b/src/item.cpp index b0dd7fe660d2..d3239d3883be 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -6209,7 +6209,7 @@ int item::fire_resist( bool to_self, int base_env_resist ) const float mod = get_clothing_mod_val( clothing_mod_type_fire ); std::optional overriden_resistance = damage_resistance_override(); - if( overriden_resistance && overriden_resistance->flat.count( DT_ACID ) ) { + if( overriden_resistance && overriden_resistance->flat.count( DT_HEAT ) ) { return std::lround( overriden_resistance->flat[DT_HEAT] + mod ); }