Skip to content

Commit

Permalink
Trivial: minor speedup of monster->Character attitude calculation (#4…
Browse files Browse the repository at this point in the history
…5421)

* speedup monster::attitude( const Character *u )

Co-authored-by: anothersimulacrum <anothersimulacrum@gmail.com>
  • Loading branch information
Aivean and anothersimulacrum authored Nov 15, 2020
1 parent f620d01 commit 01d2bf5
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1132,19 +1132,20 @@ monster_attitude monster::attitude( const Character *u ) const
}

for( const trait_id &mut : u->get_mutations() ) {
for( const std::pair<const species_id, int> &elem : mut.obj().anger_relations ) {
if( type->in_species( elem.first ) ) {
effective_anger += elem.second;
}
const mutation_branch &branch = *mut;
if( branch.ignored_by.empty() && branch.anger_relations.empty() ) {
continue;
}
}

for( const trait_id &mut : u->get_mutations() ) {
for( const species_id &spe : mut.obj().ignored_by ) {
for( const species_id &spe : branch.ignored_by ) {
if( type->in_species( spe ) ) {
return MATT_IGNORE;
}
}
for( const std::pair<const species_id, int> &elem : branch.anger_relations ) {
if( type->in_species( elem.first ) ) {
effective_anger += elem.second;
}
}
}
}

Expand Down

0 comments on commit 01d2bf5

Please sign in to comment.