Skip to content

Commit

Permalink
Merge pull request #87 from Night-Sky-To/develop
Browse files Browse the repository at this point in the history
Cache a flag in Character::get_limb_score()  ------ from SurFlurer
  • Loading branch information
Night-Pryanik authored Jun 12, 2023
2 parents 7c02c3d + 7bb751d commit 321a558
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/character_modifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ float Character::get_limb_score( const limb_score_id &score, const body_part_typ
skill = get_skill_level( skill_swimming );
}
float total = 0.0f;
// Avoid call has_flag() in a loop to improve performance
bool cache_flag_EFFECT_LIMB_SCORE_MOD_LOCAL = has_flag( flag_EFFECT_LIMB_SCORE_MOD_LOCAL );
for( const std::pair<const bodypart_str_id, bodypart> &id : body ) {
float mod = 0.0f;
if( bp == body_part_type::type::num_types ) {
Expand All @@ -231,7 +233,7 @@ float Character::get_limb_score( const limb_score_id &score, const body_part_typ
mod = id.second.get_limb_score( score, skill, override_encumb,
override_wounds ) * id.first->limbtypes.at( bp );
}
if( has_flag( flag_EFFECT_LIMB_SCORE_MOD_LOCAL ) ) {
if( cache_flag_EFFECT_LIMB_SCORE_MOD_LOCAL ) {
for( const effect &local : get_effects_from_bp( id.first ) ) {
float local_mul = 1.0f;
// Second filter to only apply the local effects at this step (non-local modifiers are already calulated)
Expand Down

0 comments on commit 321a558

Please sign in to comment.