Skip to content

[player] Deduplicate expressions that resolve identically. #10313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions engine/player/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3515,6 +3515,9 @@ parsed_assisted_combat_rule_t player_t::parse_assisted_combat_rule( const assist
std::string expr_str_2;
std::string expr_str_3;
bool has_or;
bool is_duplicate_2;
bool is_duplicate_3;
bool is_modified;
// TODO: verify < vs <= and > vs >= on all condition types
switch ( rule.condition_type )
{
Expand Down Expand Up @@ -3563,13 +3566,15 @@ parsed_assisted_combat_rule_t player_t::parse_assisted_combat_rule( const assist
expr_str = v1 ? aura_expr_from_spell_id( v1, true ) : "";
expr_str_2 = v2 ? aura_expr_from_spell_id( v2, true ) : "";
expr_str_3 = v3 ? aura_expr_from_spell_id( v3, true ) : "";
if ( v1 && !expr_str.find( "talent." ) == 0 )
if ( v1 && !( expr_str.find( "talent." ) == 0 ) )
expr_str += ".up";
if ( v2 && !expr_str_2.find( "talent." ) == 0 )
if ( v2 && !( expr_str_2.find( "talent." ) == 0 ) )
expr_str_2 += ".up";
if ( v3 && !expr_str_3.find( "talent." ) == 0 )
if ( v3 && !( expr_str_3.find( "talent." ) == 0 ) )
expr_str_3 += ".up";
if ( v2 )
is_duplicate_2 = v2 && expr_str_2 == expr_str;
is_duplicate_3 = v3 && ( expr_str_3 == expr_str || expr_str_3 == expr_str_2 );
if ( v2 && !is_duplicate_2 )
{
if ( !expr_str.empty() )
{
Expand All @@ -3578,7 +3583,7 @@ parsed_assisted_combat_rule_t player_t::parse_assisted_combat_rule( const assist
}
expr_str += expr_str_2;
}
if ( v3 )
if ( v3 && !is_duplicate_3 )
{
if ( !expr_str.empty() )
{
Expand All @@ -3587,9 +3592,10 @@ parsed_assisted_combat_rule_t player_t::parse_assisted_combat_rule( const assist
}
expr_str += expr_str_3;
}
is_modified = is_duplicate_2 || is_duplicate_3;
if ( has_or )
return fmt::format( "({})", expr_str );
return expr_str;
return { fmt::format( "({})", expr_str ), is_modified };
return { expr_str, is_modified };
case AURA_ON_TARGET:
assert( v2 == 0 && v3 == 0 );
expr_str = aura_expr_from_spell_id( v1, false );
Expand Down