Skip to content

Commit

Permalink
Rename empty_traits to clear_mutations
Browse files Browse the repository at this point in the history
In common C++ libraries, empty is an adjective, not a verb.
  • Loading branch information
jbytheway committed Apr 13, 2020
1 parent 235e772 commit dc9fb28
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -1449,8 +1449,8 @@ class Character : public Creature, public visitable<Character>
const std::bitset<NUM_VISION_MODES> &get_vision_modes() const {
return vision_mode_cache;
}
/** Empties the trait list */
void empty_traits();
/** Empties the trait and mutations lists */
void clear_mutations();
/**
* Adds mandatory scenario and profession traits unless you already have them
* And if you do already have them, refunds the points for the trait
Expand Down
4 changes: 2 additions & 2 deletions src/newcharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2709,7 +2709,7 @@ std::vector<trait_id> Character::get_mutations( bool include_hidden ) const
return result;
}

void Character::empty_traits()
void Character::clear_mutations()
{
while( !my_traits.empty() ) {
toggle_trait( *my_traits.begin() );
Expand Down Expand Up @@ -2916,7 +2916,7 @@ void reset_scenario( avatar &u, const scenario *scen )
u.toggle_trait( t );
}
}
u.empty_traits();
u.clear_mutations();
u.recalc_hp();
u.empty_skills();
u.add_traits();
Expand Down
2 changes: 1 addition & 1 deletion src/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ void npc::randomize( const npc_class_id &type )
starting_clothes( *this, myclass, male );
starting_inv( *this, myclass );
has_new_items = true;
empty_traits();
clear_mutations();

// Add fixed traits
for( const auto &tid : trait_group::traits_from( myclass->traits ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ player::player()
next_expected_position = cata::nullopt;
death_drops = true;

empty_traits();
clear_mutations();

nv_cached = false;
volume = 0;
Expand Down
4 changes: 2 additions & 2 deletions tests/char_biometrics_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static float bodyweight_kg_at_bmi( player &dummy, float bmi )
// Clear player traits and give them a single trait by name
static void set_single_trait( player &dummy, std::string trait_name )
{
dummy.empty_traits();
dummy.clear_mutations();
dummy.toggle_trait( trait_id( trait_name ) );
REQUIRE( dummy.has_trait( trait_id( trait_name ) ) );
}
Expand Down Expand Up @@ -363,7 +363,7 @@ TEST_CASE( "mutations may affect character metabolic rate", "[biometrics][metabo
// Metabolic base rate uses PLAYER_HUNGER_RATE from game_balance.json, described as "base hunger
// rate per 5 minutes". With no metabolism-affecting mutations, metabolism should be this value.
const float normal_metabolic_rate = get_option<float>( "PLAYER_HUNGER_RATE" );
dummy.empty_traits();
dummy.clear_mutations();
CHECK( dummy.metabolic_rate_base() == normal_metabolic_rate );

// The remaining checks assume the configured base rate is 1.0; if this is ever changed in the
Expand Down
4 changes: 2 additions & 2 deletions tests/char_healing_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
static void give_one_trait( player &dummy, const std::string trait_name )
{
const trait_id trait( trait_name );
dummy.empty_traits();
dummy.clear_mutations();
dummy.toggle_trait( trait );
REQUIRE( dummy.has_trait( trait ) );
}
Expand All @@ -29,7 +29,7 @@ TEST_CASE( "traits and mutations affecting healing rate", "[heal][trait][mutatio
REQUIRE( dummy.get_healthy() == 0 );

GIVEN( "no traits" ) {
dummy.empty_traits();
dummy.clear_mutations();

THEN( "there are no healing modifiers from mutations" ) {
CHECK( dummy.mutation_value( "healing_resting" ) == 0.0f );
Expand Down
2 changes: 1 addition & 1 deletion tests/encumbrance_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static void test_encumbrance_on(
)
{
CAPTURE( body_part );
p.empty_traits();
p.clear_mutations();
p.worn.clear();
if( tweak_player ) {
tweak_player( p );
Expand Down
4 changes: 2 additions & 2 deletions tests/item_tname_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static const skill_id skill_survival( "survival" );

TEST_CASE( "food with hidden effects", "[item][tname][hidden]" )
{
g->u.empty_traits();
g->u.clear_mutations();

GIVEN( "food with hidden poison" ) {
item coffee = item( "coffee_pod" );
Expand Down Expand Up @@ -386,7 +386,7 @@ TEST_CASE( "weapon fouling", "[item][tname][fouling][dirt]" )
item gun( "hk_mp5" );

// Ensure the player and gun are normal size to prevent "too big" or "too small" suffix in tname
g->u.empty_traits();
g->u.clear_mutations();
REQUIRE( gun.get_sizing( g-> u, true ) == item::sizing::human_sized_human_char );
REQUIRE_FALSE( gun.has_flag( "OVERSIZE" ) );
REQUIRE_FALSE( gun.has_flag( "UNDERSIZE" ) );
Expand Down
6 changes: 3 additions & 3 deletions tests/iteminfo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
static void test_info_equals( const item &i, const iteminfo_query &q,
const std::string &reference )
{
g->u.empty_traits();
g->u.clear_mutations();
std::vector<iteminfo> info_v;
std::string info = i.info( info_v, &q, 1 );
CHECK( info == reference );
Expand All @@ -26,7 +26,7 @@ static void test_info_equals( const item &i, const iteminfo_query &q,
static void test_info_contains( const item &i, const iteminfo_query &q,
const std::string &reference )
{
g->u.empty_traits();
g->u.clear_mutations();
std::vector<iteminfo> info_v;
std::string info = i.info( info_v, &q, 1 );
using Catch::Matchers::Contains;
Expand Down Expand Up @@ -515,7 +515,7 @@ TEST_CASE( "show available recipes with item as an ingredient", "[item][iteminfo
{
iteminfo_query q = q_vec( { iteminfo_parts::DESCRIPTION_APPLICABLE_RECIPES } );
const recipe *purtab = &recipe_id( "pur_tablets" ).obj();
g->u.empty_traits();
g->u.clear_mutations();

GIVEN( "character has a potassium iodide tablet and no skill" ) {
item &iodine = g->u.i_add( item( "iodine" ) );
Expand Down
6 changes: 3 additions & 3 deletions tests/itemname_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
TEST_CASE( "item sizing display", "[item][iteminfo][display_name][sizing]" )
{
GIVEN( "player is a normal size" ) {
g->u.empty_traits();
g->u.clear_mutations();

WHEN( "the item is a normal size" ) {
std::string name = item( "bookplate" ).display_name();
Expand Down Expand Up @@ -46,7 +46,7 @@ TEST_CASE( "item sizing display", "[item][iteminfo][display_name][sizing]" )
}

GIVEN( "player is a huge size" ) {
g->u.empty_traits();
g->u.clear_mutations();
g->u.toggle_trait( trait_id( "HUGE_OK" ) );

WHEN( "the item is a normal size" ) {
Expand Down Expand Up @@ -82,7 +82,7 @@ TEST_CASE( "item sizing display", "[item][iteminfo][display_name][sizing]" )
}

GIVEN( "player is a small size" ) {
g->u.empty_traits();
g->u.clear_mutations();
g->u.toggle_trait( trait_id( "SMALL_OK" ) );

WHEN( "the item is a normal size" ) {
Expand Down
2 changes: 1 addition & 1 deletion tests/new_character_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static std::vector<trait_id> next_subset( const std::vector<trait_id> &set )

static bool try_set_traits( const std::vector<trait_id> &traits )
{
g->u.empty_traits();
g->u.clear_mutations();
g->u.add_traits(); // mandatory prof/scen traits
for( const trait_id &tr : traits ) {
if( g->u.has_conflicting_trait( tr ) || !g->scen->traitquery( tr ) ) {
Expand Down
2 changes: 1 addition & 1 deletion tests/player_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void clear_character( player &dummy, bool debug_storage )
while( dummy.takeoff( dummy.i_at( -2 ), &temp ) );
dummy.inv.clear();
dummy.remove_weapon();
dummy.empty_traits();
dummy.clear_mutations();

// Prevent spilling, but don't cause encumbrance
if( debug_storage && !dummy.has_trait( trait_id( "DEBUG_STORAGE" ) ) ) {
Expand Down

0 comments on commit dc9fb28

Please sign in to comment.