From b128ba4b588d7f2f16b85f64e4ae001f2bff7450 Mon Sep 17 00:00:00 2001 From: osuphobia Date: Sat, 23 Nov 2024 14:32:03 +0800 Subject: [PATCH 1/5] Remove unused `mods` in mutation. --- src/mutation.cpp | 32 -------------------------------- src/mutation.h | 3 --- 2 files changed, 35 deletions(-) diff --git a/src/mutation.cpp b/src/mutation.cpp index a6fef23a36699..95c9fb27d9492 100644 --- a/src/mutation.cpp +++ b/src/mutation.cpp @@ -444,32 +444,6 @@ bool reflex_activation_data::is_trigger_true( Character &guy ) const return trigger( d ); } -int Character::get_mod( const trait_id &mut, const std::string &arg ) const -{ - const auto &mod_data = mut->mods; - int ret = 0; - auto found = mod_data.find( std::make_pair( false, arg ) ); - if( found != mod_data.end() ) { - ret += found->second; - } - return ret; -} - -void Character::apply_mods( const trait_id &mut, bool add_remove ) -{ - int sign = add_remove ? 1 : -1; - int str_change = get_mod( mut, "STR" ); - str_max += sign * str_change; - per_max += sign * get_mod( mut, "PER" ); - dex_max += sign * get_mod( mut, "DEX" ); - int_max += sign * get_mod( mut, "INT" ); - - reset_stats(); - if( str_change != 0 ) { - recalc_hp(); - } -} - bool mutation_branch::conflicts_with_item( const item &it ) const { if( allow_soft_gear && it.is_soft() ) { @@ -575,8 +549,6 @@ void Character::mutation_effect( const trait_id &mut, const bool worn_destroyed_ { if( mut == trait_GLASSJAW ) { recalc_hp(); - } else { - apply_mods( mut, true ); } recalculate_size(); @@ -655,8 +627,6 @@ void Character::mutation_loss_effect( const trait_id &mut ) { if( mut == trait_GLASSJAW ) { recalc_hp(); - } else { - apply_mods( mut, false ); } recalculate_size(); @@ -997,8 +967,6 @@ void Character::deactivate_mutation( const trait_id &mut ) my_mutations[mut].powered = false; trait_flag_cache.clear(); - // Handle stat changes from deactivation - apply_mods( mut, false ); recalc_sight_limits(); const mutation_branch &mdata = mut.obj(); if( mdata.transform ) { diff --git a/src/mutation.h b/src/mutation.h index 7f83978484377..cc1690037dab1 100644 --- a/src/mutation.h +++ b/src/mutation.h @@ -351,9 +351,6 @@ struct mutation_branch { std::set remove_rigid_subparts; // item flags that allow wearing gear even if its body part is restricted std::set allowed_items; - // Mutation stat mods - /** Key pair is */ - std::unordered_map, int, cata::tuple_hash> mods; std::map armor; // Modifiers to protection values std::vector integrated_armor; // Armor pseudo-items that are put on by this mutation std::vector From f6245502bc4555d0d0b3a05ad8e4f5ad02c05e42 Mon Sep 17 00:00:00 2001 From: osuphobia Date: Sat, 23 Nov 2024 14:33:33 +0800 Subject: [PATCH 2/5] Not to immediately reset stats when toggling cbms. --- src/bionics.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/bionics.cpp b/src/bionics.cpp index cb66c7d45e9b8..af85e799b811f 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -1176,7 +1176,6 @@ bool Character::activate_bionic( bionic &bio, bool eff_only, bool *close_bionics bio_flag_cache.clear(); // Recalculate stats (strength, mods from pain etc.) that could have been affected calc_encumbrance(); - reset(); // Also reset crafting inventory cache if this bionic spawned a fake item if( bio.has_weapon() || !bio.info().passive_pseudo_items.empty() || @@ -1274,7 +1273,6 @@ bool Character::deactivate_bionic( bionic &bio, bool eff_only ) // Recalculate stats (strength, mods from pain etc.) that could have been affected calc_encumbrance(); - reset(); if( !bio.id->enchantments.empty() ) { recalculate_enchantment_cache(); } From 85c68877b944449e102b96dbc92cf20834df107c Mon Sep 17 00:00:00 2001 From: osuphobia Date: Sat, 23 Nov 2024 18:44:29 +0800 Subject: [PATCH 3/5] Clear `get_mod` and `apply_mods` in character.h --- src/character.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/character.h b/src/character.h index 2e0c6ffc232a3..0ef70a84cb1d9 100644 --- a/src/character.h +++ b/src/character.h @@ -1541,16 +1541,12 @@ class Character : public Creature, public visitable bool made_of_any( const std::set &ms ) const override; private: - /** Retrieves a stat mod of a mutation. */ - int get_mod( const trait_id &mut, const std::string &arg ) const; /** Applies skill-based boosts to stats **/ void apply_skill_boost(); protected: void on_move( const tripoint_abs_ms &old_pos ) override; void do_skill_rust(); - /** Applies stat mods to character. */ - void apply_mods( const trait_id &mut, bool add_remove ); /** Applies encumbrance from mutations and bionics only */ void mut_cbm_encumb( std::map &vals ) const; From dd12c43ee858719e3c8dfcdffddf11bd62e502c0 Mon Sep 17 00:00:00 2001 From: osuphobia Date: Sat, 23 Nov 2024 18:53:27 +0800 Subject: [PATCH 4/5] Change comments in bionics.cpp --- src/bionics.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/bionics.cpp b/src/bionics.cpp index af85e799b811f..26c312a4c2ac9 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -1174,7 +1174,6 @@ bool Character::activate_bionic( bionic &bio, bool eff_only, bool *close_bionics } } bio_flag_cache.clear(); - // Recalculate stats (strength, mods from pain etc.) that could have been affected calc_encumbrance(); // Also reset crafting inventory cache if this bionic spawned a fake item @@ -1271,7 +1270,6 @@ bool Character::deactivate_bionic( bionic &bio, bool eff_only ) } } - // Recalculate stats (strength, mods from pain etc.) that could have been affected calc_encumbrance(); if( !bio.id->enchantments.empty() ) { recalculate_enchantment_cache(); From 356b58e0e64fef3df139ab6260b40bc1503fdbbc Mon Sep 17 00:00:00 2001 From: osuphobia Date: Sat, 23 Nov 2024 19:32:13 +0800 Subject: [PATCH 5/5] Add Character::reset --- src/mutation.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mutation.cpp b/src/mutation.cpp index 95c9fb27d9492..086b41cffadd1 100644 --- a/src/mutation.cpp +++ b/src/mutation.cpp @@ -550,6 +550,7 @@ void Character::mutation_effect( const trait_id &mut, const bool worn_destroyed_ if( mut == trait_GLASSJAW ) { recalc_hp(); } + reset(); recalculate_size(); @@ -628,6 +629,7 @@ void Character::mutation_loss_effect( const trait_id &mut ) if( mut == trait_GLASSJAW ) { recalc_hp(); } + reset(); recalculate_size();