From bea20938467fa4b479caf7786fa108a39ec48664 Mon Sep 17 00:00:00 2001 From: gastank <42421688+gastank@users.noreply.github.com> Date: Tue, 24 Sep 2024 21:58:53 -0700 Subject: [PATCH] [Player] use range( vector ) helper --- engine/player/pet_spawner_impl.hpp | 3 +-- engine/player/player.cpp | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/engine/player/pet_spawner_impl.hpp b/engine/player/pet_spawner_impl.hpp index 973faec4bca..e40dbaaa800 100644 --- a/engine/player/pet_spawner_impl.hpp +++ b/engine/player/pet_spawner_impl.hpp @@ -705,8 +705,7 @@ T* pet_spawner_t::replacement_pet() case pet_replacement_strategy::REPLACE_OLDEST: return active_pet_min_remains(); case pet_replacement_strategy::REPLACE_RANDOM: - return m_active_pets[ static_cast( - m_owner->rng().range( 0.0, as( m_active_pets.size() ) ) ) ]; + return m_owner->rng().range( m_active_pets ); default: return nullptr; } diff --git a/engine/player/player.cpp b/engine/player/player.cpp index 19d7aaa889f..ab1d236ba16 100644 --- a/engine/player/player.cpp +++ b/engine/player/player.cpp @@ -8840,8 +8840,7 @@ struct ancestral_call_t : public racial_spell_t { racial_spell_t::execute(); - auto& buffs = player->buffs.ancestral_call; - buffs[ rng().range( buffs.size() ) ] -> trigger(); + rng().range( player->buffs.ancestral_call )->trigger(); } }; @@ -13701,8 +13700,7 @@ action_t* player_t::select_action( const action_priority_list_t& list, if ( list.random == 1 ) { - size_t random = rng().range( a_list.size() ); - a = a_list[ random ]; + a = rng().range( a_list ); } else { @@ -13710,8 +13708,7 @@ action_t* player_t::select_action( const action_priority_list_t& list, if ( skill != 1 && rng().roll( ( 1 - skill ) * 0.5 ) ) { size_t max_random_attempts = static_cast( a_list.size() * ( skill * 0.5 ) ); - size_t random = rng().range( a_list.size() ); - a = a_list[ random ]; + a = rng().range( a_list ); attempted_random++; // Limit the amount of attempts to select a random action based on skill, then bail out and try again in 100 // ms.