Skip to content

Commit 2c65586

Browse files
authored
[Bugfixes] Fix mutating resetting stats and stamina (#80325)
* Fix statistic + stamina issues * astyle * test with github cause I'm too lazy to figure out how to run them locally * water move tbd * Fix swim test values since they were based off of a bug
1 parent d114680 commit 2c65586

File tree

3 files changed

+86
-82
lines changed

3 files changed

+86
-82
lines changed

src/character.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -7821,6 +7821,11 @@ void Character::recalculate_enchantment_cache()
78217821
if( enchantment_cache->modifies_bodyparts() ) {
78227822
recalculate_bodyparts();
78237823
}
7824+
7825+
// do final statistic recalculations
7826+
if( get_stamina() > get_stamina_max() ) {
7827+
set_stamina( get_stamina_max() );
7828+
}
78247829
recalc_hp();
78257830
}
78267831

src/mutation.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -327,17 +327,14 @@ void Character::set_mutation_unsafe( const trait_id &trait, const mutation_varia
327327
} else {
328328
update_cached_mutations();
329329
}
330+
reset();
331+
enchantment_cache->activate_passive( *this );
330332
}
331333

332334
void Character::do_mutation_updates()
333335
{
334336
recalc_sight_limits();
335337
calc_encumbrance();
336-
337-
// If the stamina is higher than the max (Languorous), set it back to max
338-
if( get_stamina() > get_stamina_max() ) {
339-
set_stamina( get_stamina_max() );
340-
}
341338
}
342339

343340
void Character::set_mutations( const std::vector<trait_id> &traits )
@@ -385,8 +382,12 @@ void Character::unset_mutation( const trait_id &trait_ )
385382
cached_mutations.erase( trait_ );
386383
if( !mut.enchantments.empty() ) {
387384
recalculate_enchantment_cache();
385+
} else {
386+
update_cached_mutations();
388387
}
389388
mutation_loss_effect( trait );
389+
reset();
390+
enchantment_cache->activate_passive( *this );
390391
}
391392
}
392393

@@ -572,7 +573,6 @@ void Character::mutation_effect( const trait_id &mut, const bool worn_destroyed_
572573
if( mut == trait_GLASSJAW ) {
573574
recalc_hp();
574575
}
575-
reset();
576576
trait_flag_cache.clear();
577577
recalculate_size();
578578

@@ -658,7 +658,6 @@ void Character::mutation_loss_effect( const trait_id &mut )
658658
if( mut == trait_GLASSJAW ) {
659659
recalc_hp();
660660
}
661-
reset();
662661
trait_flag_cache.clear();
663662
recalculate_size();
664663

0 commit comments

Comments
 (0)