Skip to content

Commit

Permalink
Change create_class macro to a template
Browse files Browse the repository at this point in the history
Make absorb_t always stateless ( everything is already migrated to it )

Make raid_event_t more of a abstract base class for custom raid events.

Remove some virtual keywords on functions which should not be
polymorphic.

Change some helper classes with only static functions to namespaces.

Fix error with absorb buffs not having a valid stats pointer.

git-svn-id: https://simulationcraft.googlecode.com/svn/branches/mop@11725 3b4652a1-8050-0410-ac47-3d40261b0f8b
  • Loading branch information
philoptik committed Apr 26, 2012
1 parent 8ecd6bc commit 1b9e869
Show file tree
Hide file tree
Showing 66 changed files with 2,041 additions and 2,061 deletions.
30 changes: 15 additions & 15 deletions engine/class_modules/sc_death_knight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3473,9 +3473,9 @@ action_t* death_knight_t::create_action( const std::string& name, const std::str
expr_t* death_knight_t::create_expression( action_t* a, const std::string& name_str )
{
std::vector<std::string> splits;
int num_splits = util_t::string_split( splits, name_str, "." );
int num_splits = util::string_split( splits, name_str, "." );

if ( util_t::str_compare_ci( splits[ 0 ], "rune" ) )
if ( util::str_compare_ci( splits[ 0 ], "rune" ) )
{
rune_type rt = RUNE_TYPE_NONE;
bool include_death = true; // whether to include death runes
Expand All @@ -3498,11 +3498,11 @@ expr_t* death_knight_t::create_expression( action_t* a, const std::string& name_
}

int act = 0;
if ( num_splits == 3 && util_t::str_compare_ci( splits[ 2 ], "cooldown_remains" ) )
if ( num_splits == 3 && util::str_compare_ci( splits[ 2 ], "cooldown_remains" ) )
act = 1;
else if ( num_splits == 3 && util_t::str_compare_ci( splits[ 2 ], "cooldown_remains_all" ) )
else if ( num_splits == 3 && util::str_compare_ci( splits[ 2 ], "cooldown_remains_all" ) )
act = 2;
else if ( num_splits == 3 && util_t::str_compare_ci( splits[ 2 ], "depleted" ) )
else if ( num_splits == 3 && util::str_compare_ci( splits[ 2 ], "depleted" ) )
act = 3;

struct rune_inspection_expr_t : public expr_t
Expand Down Expand Up @@ -3535,16 +3535,16 @@ expr_t* death_knight_t::create_expression( action_t* a, const std::string& name_
else if ( num_splits == 2 )
{
rune_type rt = RUNE_TYPE_NONE;
if ( util_t::str_compare_ci( splits[ 0 ], "blood" ) || util_t::str_compare_ci( splits[ 0 ], "b" ) )
if ( util::str_compare_ci( splits[ 0 ], "blood" ) || util::str_compare_ci( splits[ 0 ], "b" ) )
rt = RUNE_TYPE_BLOOD;
else if ( util_t::str_compare_ci( splits[ 0 ], "frost" ) || util_t::str_compare_ci( splits[ 0 ], "f" ) )
else if ( util::str_compare_ci( splits[ 0 ], "frost" ) || util::str_compare_ci( splits[ 0 ], "f" ) )
rt = RUNE_TYPE_FROST;
else if ( util_t::str_compare_ci( splits[ 0 ], "unholy" ) || util_t::str_compare_ci( splits[ 0 ], "u" ) )
else if ( util::str_compare_ci( splits[ 0 ], "unholy" ) || util::str_compare_ci( splits[ 0 ], "u" ) )
rt = RUNE_TYPE_UNHOLY;
else if ( util_t::str_compare_ci( splits[ 0 ], "death" ) || util_t::str_compare_ci( splits[ 0 ], "d" ) )
else if ( util::str_compare_ci( splits[ 0 ], "death" ) || util::str_compare_ci( splits[ 0 ], "d" ) )
rt = RUNE_TYPE_DEATH;

if ( rt != RUNE_TYPE_NONE && util_t::str_compare_ci( splits[ 1 ], "cooldown_remains" ) )
if ( rt != RUNE_TYPE_NONE && util::str_compare_ci( splits[ 1 ], "cooldown_remains" ) )
{
struct rune_cooldown_expr_t : public expr_t
{
Expand All @@ -3564,13 +3564,13 @@ expr_t* death_knight_t::create_expression( action_t* a, const std::string& name_
else
{
rune_type rt = RUNE_TYPE_NONE;
if ( util_t::str_compare_ci( splits[ 0 ], "blood" ) || util_t::str_compare_ci( splits[ 0 ], "b" ) )
if ( util::str_compare_ci( splits[ 0 ], "blood" ) || util::str_compare_ci( splits[ 0 ], "b" ) )
rt = RUNE_TYPE_BLOOD;
else if ( util_t::str_compare_ci( splits[ 0 ], "frost" ) || util_t::str_compare_ci( splits[ 0 ], "f" ) )
else if ( util::str_compare_ci( splits[ 0 ], "frost" ) || util::str_compare_ci( splits[ 0 ], "f" ) )
rt = RUNE_TYPE_FROST;
else if ( util_t::str_compare_ci( splits[ 0 ], "unholy" ) || util_t::str_compare_ci( splits[ 0 ], "u" ) )
else if ( util::str_compare_ci( splits[ 0 ], "unholy" ) || util::str_compare_ci( splits[ 0 ], "u" ) )
rt = RUNE_TYPE_UNHOLY;
else if ( util_t::str_compare_ci( splits[ 0 ], "death" ) || util_t::str_compare_ci( splits[ 0 ], "d" ) )
else if ( util::str_compare_ci( splits[ 0 ], "death" ) || util::str_compare_ci( splits[ 0 ], "d" ) )
rt = RUNE_TYPE_DEATH;

struct rune_expr_t : public expr_t
Expand Down Expand Up @@ -4631,7 +4631,7 @@ void death_knight_t::arise()

player_t* player_t::create_death_knight( sim_t* sim, const std::string& name, race_type_e r )
{
SC_CREATE_DEATH_KNIGHT( sim, name, r );
return sc_create_class<death_knight_t,SC_DEATH_KNIGHT>()( "Death Knight", sim, name, r );
}

// player_t::death_knight_init ==============================================
Expand Down
6 changes: 3 additions & 3 deletions engine/class_modules/sc_druid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,7 @@ struct ferocious_bite_t : public druid_cat_attack_t
// Let the additional energy consumption create it's own debug log entries.
if ( sim -> debug )
log_t::output( sim, "%s consumes an additional %.1f %s for %s", player -> name(),
excess_energy, util_t::resource_type_string( current_resource() ), name() );
excess_energy, util::resource_type_string( current_resource() ), name() );

player -> resource_loss( current_resource(), excess_energy );
stats -> consume_resource( current_resource(), excess_energy );
Expand Down Expand Up @@ -4971,7 +4971,7 @@ player_t* player_t::create_druid( sim_t* sim,
const std::string& name,
race_type_e r )
{
SC_CREATE_DRUID( sim, name, r );
return sc_create_class<druid_t,SC_DRUID>()( "Druid", sim, name, r );
}

// player_t::druid_init =====================================================
Expand All @@ -4995,4 +4995,4 @@ void player_t::druid_init( sim_t* sim )

void player_t::druid_combat_begin( sim_t* )
{
}
}
16 changes: 8 additions & 8 deletions engine/class_modules/sc_hunter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ struct hunter_ranged_attack_t : public ranged_attack_t
{
if ( player -> items[ weapon -> slot ].encoded_enchant_str == "scope" )
{
double scope_damage = util_t::ability_rank( player -> level, 15.0,72, 12.0,67, 7.0,0 );
double scope_damage = util::ability_rank( player -> level, 15.0,72, 12.0,67, 7.0,0 );

base_dd_min += scope_damage;
base_dd_max += scope_damage;
Expand Down Expand Up @@ -2434,7 +2434,7 @@ struct explosive_shot_t : public hunter_ranged_attack_t

virtual void execute()
{
base_td = sim -> range( base_td_min, base_td_max );
base_td = sim -> averaged_range( base_td_min, base_td_max );
hunter_ranged_attack_t::execute();

hunter_t* p = player -> cast_hunter();
Expand Down Expand Up @@ -3436,7 +3436,7 @@ pet_t* hunter_t::create_pet( const std::string& pet_name,
if ( p )
return p;

pet_type_e type = util_t::parse_pet_type( pet_type );
pet_type_e type = util::parse_pet_type( pet_type );

if ( type > PET_NONE && type < PET_HUNTER )
{
Expand Down Expand Up @@ -3686,12 +3686,12 @@ void hunter_t::init_position()
if ( position == POSITION_FRONT )
{
position = POSITION_RANGED_FRONT;
position_str = util_t::position_type_string( position );
position_str = util::position_type_string( position );
}
else if ( position == POSITION_BACK )
{
position = POSITION_RANGED_BACK;
position_str = util_t::position_type_string( position );
position_str = util::position_type_string( position );
}
}

Expand Down Expand Up @@ -4046,7 +4046,7 @@ bool hunter_t::create_profile( std::string& profile_str, save_type_e stype, bool
}

profile_str += "pet=";
profile_str += util_t::pet_type_string( p -> pet_type );
profile_str += util::pet_type_string( p -> pet_type );
profile_str += ",";
profile_str += p -> name_str + "\n";
profile_str += "talents=" + p -> talents_str + "\n";
Expand Down Expand Up @@ -4232,7 +4232,7 @@ void hunter_t::armory_extensions( const std::string& region,
if ( ! xml_t::get_value( summoned_pet_name, xml_t::get_node( pet_nodes[ i ], "span", "class", "name" ), "." ) )
continue;

util_t::html_special_char_decode( summoned_pet_name );
util::html_special_char_decode( summoned_pet_name );
if ( ! summoned_pet_name.empty() )
{
summon_pet_str = summoned_pet_name;
Expand Down Expand Up @@ -4292,7 +4292,7 @@ void hunter_t::moving()

player_t* player_t::create_hunter( sim_t* sim, const std::string& name, race_type_e r )
{
SC_CREATE_HUNTER( sim, name, r );
return sc_create_class<hunter_t,SC_HUNTER>()( "Hunter", sim, name, r );
}

// player_t::hunter_init ====================================================
Expand Down
2 changes: 1 addition & 1 deletion engine/class_modules/sc_mage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3537,7 +3537,7 @@ int mage_t::decode_set( const item_t& item ) const

player_t* player_t::create_mage( sim_t* sim, const std::string& name, race_type_e r )
{
SC_CREATE_MAGE( sim, name, r );
return sc_create_class<mage_t,SC_MAGE>()( "Mage", sim, name, r );
}

// player_t::mage_init ======================================================
Expand Down
2 changes: 1 addition & 1 deletion engine/class_modules/sc_monk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ role_type_e monk_t::primary_role() const

player_t* player_t::create_monk( sim_t* sim, const std::string& name, race_type_e r )
{
SC_CREATE_MONK( sim, name, r );
return sc_create_class<monk_t,SC_MONK>()( "Monk", sim, name, r );
}

// player_t::monk_init ======================================================
Expand Down
10 changes: 5 additions & 5 deletions engine/class_modules/sc_paladin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ struct guardian_of_ancient_kings_ret_t : public pet_t
{
main_hand_weapon.type = WEAPON_BEAST;
main_hand_weapon.swing_time = timespan_t::from_seconds( 2.0 );
main_hand_weapon.min_dmg = util_t::ability_rank( p -> level, 5840.0,85, 1.0,0 ); // TODO
main_hand_weapon.max_dmg = util_t::ability_rank( p -> level, 7557.0,85, 1.0,0 ); // TODO
main_hand_weapon.min_dmg = util::ability_rank( p -> level, 5840.0,85, 1.0,0 ); // TODO
main_hand_weapon.max_dmg = util::ability_rank( p -> level, 7557.0,85, 1.0,0 ); // TODO
}

virtual void init_base()
Expand Down Expand Up @@ -2930,7 +2930,7 @@ double paladin_t::assess_damage( double amount,

if ( buffs.divine_protection -> up() )
{
if ( util_t::school_type_component( school, SCHOOL_MAGIC ) )
if ( util::school_type_component( school, SCHOOL_MAGIC ) )
{
amount *= 1.0 + buffs.divine_protection -> data().effect1().percent() * ( 1.0 + glyphs.divine_protection -> effectN( 1 ).percent() );
}
Expand Down Expand Up @@ -3094,7 +3094,7 @@ expr_t* paladin_t::create_expression( action_t* a,
};

std::vector<std::string> splits;
int num_splits = util_t::string_split( splits, name_str, "." );
int num_splits = util::string_split( splits, name_str, "." );

if ( ( num_splits == 2 ) && ( splits[ 0 ] == "seal" ) )
{
Expand All @@ -3120,7 +3120,7 @@ expr_t* paladin_t::create_expression( action_t* a,

player_t* player_t::create_paladin( sim_t* sim, const std::string& name, race_type_e r )
{
SC_CREATE_PALADIN( sim, name, r );
return sc_create_class<paladin_t,SC_PALADIN>()( "Paladin", sim, name, r );
}

// player_t::paladin_init ===================================================
Expand Down
61 changes: 46 additions & 15 deletions engine/class_modules/sc_priest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@

namespace {
struct remove_dots_event_t;

struct spirit_shell_buff_t : public absorb_buff_t
{
spirit_shell_buff_t( actor_pair_t p ) :
absorb_buff_t( absorb_buff_creator_t( buff_creator_t( p, "spirit_shell", p.source -> find_spell( 114908 ) ) ) )
{ }

virtual void expire()
{
absorb_buff_t::expire();

}
};

}

struct priest_targetdata_t : public targetdata_t
Expand All @@ -20,6 +34,7 @@ struct priest_targetdata_t : public targetdata_t

buff_t* buffs_power_word_shield;
buff_t* buffs_divine_aegis;
buff_t* buffs_spirit_shell;

remove_dots_event_t* remove_dots_event;

Expand All @@ -38,6 +53,7 @@ void register_priest_targetdata( sim_t* sim )

REGISTER_BUFF( power_word_shield );
REGISTER_BUFF( divine_aegis );
REGISTER_BUFF( spirit_shell );
}

// ==========================================================================
Expand Down Expand Up @@ -321,6 +337,11 @@ priest_targetdata_t::priest_targetdata_t( priest_t* p, player_t* target ) :
.source( source -> get_stats( "divine_aegis" ) );
buffs_divine_aegis = add_aura( new_da );
target -> absorb_buffs.push_back( new_da );

absorb_buff_t* new_ss = new spirit_shell_buff_t( this );

buffs_spirit_shell = add_aura( new_ss );
target -> absorb_buffs.push_back( new_ss );
}

namespace // ANONYMOUS NAMESPACE ============================================
Expand Down Expand Up @@ -822,13 +843,6 @@ struct atonement_heal_t : public priest_heal_t
// Priest Spell
// ==========================================================================

struct priest_spell_state_t : public action_state_t
{
priest_spell_state_t( action_t* a, priest_t* t ) :
action_state_t( a, t )
{ }
};

struct priest_spell_t : public spell_t
{
atonement_heal_t* atonement;
Expand Down Expand Up @@ -1006,8 +1020,8 @@ struct shadow_fiend_pet_t : public pet_t
direct_power_mod = 0.0063928 * p -> o() -> level;
if ( harmful ) base_spell_power_multiplier = 1.0;
base_attack_power_multiplier = 0.0;
base_dd_min = util_t::ability_rank( player -> level, 290.0,85, 197.0,82, 175.0,80, 1.0,0 );
base_dd_max = util_t::ability_rank( player -> level, 373.0,85, 245.0,82, 222.0,80, 2.0,0 );
base_dd_min = util::ability_rank( player -> level, 290.0,85, 197.0,82, 175.0,80, 1.0,0 );
base_dd_max = util::ability_rank( player -> level, 373.0,85, 245.0,82, 222.0,80, 2.0,0 );
background = true;
repeating = true;
may_dodge = true;
Expand Down Expand Up @@ -1067,7 +1081,7 @@ struct shadow_fiend_pet_t : public pet_t

shadow_fiend_pet_t( sim_t* sim, priest_t* owner ) :
pet_t( sim, owner, "shadow_fiend" ),
bad_spell_power( util_t::ability_rank( owner -> level, 370.0,85, 358.0,82, 352.0,80, 0.0,0 ) ),
bad_spell_power( util::ability_rank( owner -> level, 370.0,85, 358.0,82, 352.0,80, 0.0,0 ) ),
shadowcrawl( spell_data_t::nil() ), mana_leech( spell_data_t::nil() ),
bad_swing( false ), extra_tick( false )
{
Expand Down Expand Up @@ -1111,8 +1125,8 @@ struct shadow_fiend_pet_t : public pet_t
stats_base.attribute[ ATTR_AGILITY ] = 0; // Unknown
stats_base.attribute[ ATTR_STAMINA ] = 0; // Unknown
stats_base.attribute[ ATTR_INTELLECT ] = 0; // Unknown
resources.base[ RESOURCE_HEALTH ] = util_t::ability_rank( owner -> level, 18480.0,85, 7475.0,82, 6747.0,80, 100.0,0 );
resources.base[ RESOURCE_MANA ] = util_t::ability_rank( owner -> level, 16828.0,85, 9824.0,82, 7679.0,80, 100.0,0 );
resources.base[ RESOURCE_HEALTH ] = util::ability_rank( owner -> level, 18480.0,85, 7475.0,82, 6747.0,80, 100.0,0 );
resources.base[ RESOURCE_MANA ] = util::ability_rank( owner -> level, 16828.0,85, 9824.0,82, 7679.0,80, 100.0,0 );
stats_base.attack_power = 0; // Unknown
stats_base.attack_crit = 0.07; // Needs more testing
stats_initial.attack_power_per_strength = 0; // Unknown
Expand Down Expand Up @@ -3358,6 +3372,23 @@ struct renew_t : public priest_heal_t
return am;
}
};

struct spirit_shell_t : priest_heal_t
{
spirit_shell_t( priest_t* p, const std::string& options_str ) :
priest_heal_t( "spirit_shell", p, p -> find_class_spell( "Spirit Shell" ) )
{
parse_options( NULL, options_str );

// Parse values from buff spell effect
action_t::parse_effect_data( p -> find_spell( 114908 ) -> effectN( 1 ) );
}

virtual void impact_s( action_state_t* s )
{
td( s -> target ) -> buffs_spirit_shell -> trigger();
}
};
} // ANONYMOUS NAMESPACE ====================================================

// ==========================================================================
Expand Down Expand Up @@ -3645,7 +3676,7 @@ void priest_t::init_benefits()
player_t::init_benefits();

for ( size_t i = 0; i < 4; ++i )
benefits.mind_spike[ i ] = get_benefit( "Mind Spike " + util_t::to_string( i ) );
benefits.mind_spike[ i ] = get_benefit( "Mind Spike " + util::to_string( i ) );
}

// priest_t::init_rng =======================================================
Expand Down Expand Up @@ -4220,7 +4251,7 @@ bool priest_t::create_profile( std::string& profile_str, save_type_e type, bool
if ( initial_shadow_orbs != 0 )
{
profile_str += "initial_shadow_orbs=";
profile_str += util_t::to_string( initial_shadow_orbs );
profile_str += util::to_string( initial_shadow_orbs );
profile_str += "\n";
}
}
Expand Down Expand Up @@ -4300,7 +4331,7 @@ int priest_t::decode_set( const item_t& item ) const

player_t* player_t::create_priest( sim_t* sim, const std::string& name, race_type_e r )
{
SC_CREATE_PRIEST( sim, name, r );
return sc_create_class<priest_t,SC_PRIEST>()( "Priest", sim, name, r );
}

// player_t::priest_init ====================================================
Expand Down
2 changes: 1 addition & 1 deletion engine/class_modules/sc_rogue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4033,7 +4033,7 @@ int rogue_t::decode_set( const item_t& item ) const

player_t* player_t::create_rogue( sim_t* sim, const std::string& name, race_type_e r )
{
SC_CREATE_ROGUE( sim, name, r );
return sc_create_class<rogue_t,SC_ROGUE>()( "Rogue", sim, name, r );
}

// player_t::rogue_init =====================================================
Expand Down
Loading

0 comments on commit 1b9e869

Please sign in to comment.