From b1b48badff60f3c3ba85d4a3683ac2f38fa2b4ed Mon Sep 17 00:00:00 2001 From: Eric <52087122+Ramza13@users.noreply.github.com> Date: Fri, 21 Feb 2020 01:09:53 -0500 Subject: [PATCH] Move string consts into single file (#38195) --- src/artifact.cpp | 41 +++++++++++++++-------------- src/bionics.cpp | 2 +- src/cata_string_consts.h | 49 ++++++++++++++++++++++++++++++++++ src/character.cpp | 28 ++++++++++---------- src/consumption.cpp | 6 ++--- src/creature.cpp | 14 +++++----- src/game.cpp | 2 +- src/handle_action.cpp | 2 +- src/iexamine.cpp | 6 ++--- src/inventory.cpp | 2 +- src/item.cpp | 4 +-- src/item_factory.cpp | 57 ++++++++++++++++++++-------------------- src/iuse_actor.cpp | 2 +- src/iuse_actor.h | 51 +++++++++++++++++------------------ src/map.cpp | 2 +- src/map_field.cpp | 12 ++++----- src/melee.cpp | 6 ++--- src/monattack.cpp | 18 ++++++------- src/monster.cpp | 28 ++++++++++---------- src/mtype.cpp | 30 ++++++++++----------- src/ranged.cpp | 4 +-- src/sounds.cpp | 14 +++++----- src/trapfunc.cpp | 6 ++--- 23 files changed, 219 insertions(+), 167 deletions(-) diff --git a/src/artifact.cpp b/src/artifact.cpp index 2c8fa5da7c1da..9cc1f8c6b1066 100644 --- a/src/artifact.cpp +++ b/src/artifact.cpp @@ -24,6 +24,7 @@ #include "units.h" #include "type_id.h" #include "value_ptr.h" +#include "cata_string_consts.h" template inline units::quantity rng( const units::quantity &min, @@ -417,27 +418,27 @@ static const std::array artifact_property_ }; static const std::array artifact_tool_form_data = { { { - translate_marker( "Harp" ), ';', def_c_yellow, material_id( "wood" ), 5_liter, 7500_ml, 1150_gram, 2100_gram, ARTWEAP_BULK, + translate_marker( "Harp" ), ';', def_c_yellow, material_wood, 5_liter, 7500_ml, 1150_gram, 2100_gram, ARTWEAP_BULK, {{ARTWEAP_SPEAR, ARTWEAP_SWORD, ARTWEAP_KNIFE}} }, { - translate_marker( "Staff" ), '/', def_c_brown, material_id( "wood" ), 1500_ml, 3_liter, 450_gram, 1150_gram, ARTWEAP_CLUB, + translate_marker( "Staff" ), '/', def_c_brown, material_wood, 1500_ml, 3_liter, 450_gram, 1150_gram, ARTWEAP_CLUB, {{ARTWEAP_BULK, ARTWEAP_SPEAR, ARTWEAP_KNIFE}} }, { - translate_marker( "Sword" ), '/', def_c_light_blue, material_id( "steel" ), 2_liter, 3500_ml, 900_gram, 3259_gram, ARTWEAP_SWORD, + translate_marker( "Sword" ), '/', def_c_light_blue, material_steel, 2_liter, 3500_ml, 900_gram, 3259_gram, ARTWEAP_SWORD, {{ARTWEAP_BULK, NUM_ARTWEAPS, NUM_ARTWEAPS}} }, { - translate_marker( "Dagger" ), ';', def_c_light_blue, material_id( "steel" ), 250_ml, 1_liter, 100_gram, 700_gram, ARTWEAP_KNIFE, + translate_marker( "Dagger" ), ';', def_c_light_blue, material_steel, 250_ml, 1_liter, 100_gram, 700_gram, ARTWEAP_KNIFE, {{NUM_ARTWEAPS, NUM_ARTWEAPS, NUM_ARTWEAPS}} }, { - translate_marker( "Cube" ), '*', def_c_white, material_id( "steel" ), 250_ml, 750_ml, 100_gram, 2300_gram, ARTWEAP_BULK, + translate_marker( "Cube" ), '*', def_c_white, material_steel, 250_ml, 750_ml, 100_gram, 2300_gram, ARTWEAP_BULK, {{ARTWEAP_SPEAR, NUM_ARTWEAPS, NUM_ARTWEAPS}} } } @@ -454,7 +455,7 @@ static const std::array artifact_weapon_dat static const std::array artifact_armor_form_data = { { // Name color Material Vol Wgt Enc MaxEnc Cov Thk Env Wrm Sto Bsh Cut Hit { - translate_marker( "Robe" ), def_c_red, material_id( "wool" ), 1500_ml, 700_gram, 1, 1, 90, 3, 0, 2, 0_ml, -8, 0, -3, + translate_marker( "Robe" ), def_c_red, material_wool, 1500_ml, 700_gram, 1, 1, 90, 3, 0, 2, 0_ml, -8, 0, -3, { { bp_torso, bp_leg_l, bp_leg_r } }, false, {{ ARMORMOD_LIGHT, ARMORMOD_BULKY, ARMORMOD_POCKETED, ARMORMOD_FURRED, @@ -464,7 +465,7 @@ static const std::array artifact_arm }, { - translate_marker( "Coat" ), def_c_brown, material_id( "leather" ), 3500_ml, 1600_gram, 2, 2, 80, 2, 1, 4, 1_liter, -6, 0, -3, + translate_marker( "Coat" ), def_c_brown, material_leather, 3500_ml, 1600_gram, 2, 2, 80, 2, 1, 4, 1_liter, -6, 0, -3, { bp_torso }, false, {{ ARMORMOD_LIGHT, ARMORMOD_POCKETED, ARMORMOD_FURRED, ARMORMOD_PADDED, @@ -474,7 +475,7 @@ static const std::array artifact_arm }, { - translate_marker( "Mask" ), def_c_white, material_id( "wood" ), 1_liter, 100_gram, 2, 2, 50, 2, 1, 2, 0_ml, 2, 0, -2, + translate_marker( "Mask" ), def_c_white, material_wood, 1_liter, 100_gram, 2, 2, 50, 2, 1, 2, 0_ml, 2, 0, -2, { { bp_eyes, bp_mouth } }, false, {{ ARMORMOD_FURRED, ARMORMOD_FURRED, ARMORMOD_NULL, ARMORMOD_NULL, @@ -485,7 +486,7 @@ static const std::array artifact_arm // Name color Materials Vol Wgt Enc MaxEnc Cov Thk Env Wrm Sto Bsh Cut Hit { - translate_marker( "Helm" ), def_c_dark_gray, material_id( "silver" ), 1500_ml, 700_gram, 2, 2, 85, 3, 0, 1, 0_ml, 8, 0, -2, + translate_marker( "Helm" ), def_c_dark_gray, material_silver, 1500_ml, 700_gram, 2, 2, 85, 3, 0, 1, 0_ml, 8, 0, -2, { bp_head }, false, {{ ARMORMOD_BULKY, ARMORMOD_FURRED, ARMORMOD_PADDED, ARMORMOD_PLATED, @@ -495,7 +496,7 @@ static const std::array artifact_arm }, { - translate_marker( "Gloves" ), def_c_light_blue, material_id( "leather" ), 500_ml, 100_gram, 1, 1, 90, 3, 1, 2, 0_ml, -4, 0, -2, + translate_marker( "Gloves" ), def_c_light_blue, material_leather, 500_ml, 100_gram, 1, 1, 90, 3, 1, 2, 0_ml, -4, 0, -2, { { bp_hand_l, bp_hand_r } }, true, {{ ARMORMOD_BULKY, ARMORMOD_FURRED, ARMORMOD_PADDED, ARMORMOD_PLATED, @@ -506,7 +507,7 @@ static const std::array artifact_arm // Name color Materials Vol Wgt Enc MaxEnc Cov Thk Env Wrm Sto Bsh Cut Hit { - translate_marker( "Boots" ), def_c_blue, material_id( "leather" ), 1500_ml, 250_gram, 1, 1, 75, 3, 1, 3, 0_ml, 4, 0, -1, + translate_marker( "Boots" ), def_c_blue, material_leather, 1500_ml, 250_gram, 1, 1, 75, 3, 1, 3, 0_ml, 4, 0, -1, { { bp_foot_l, bp_foot_r } }, true, {{ ARMORMOD_LIGHT, ARMORMOD_BULKY, ARMORMOD_PADDED, ARMORMOD_PLATED, @@ -516,7 +517,7 @@ static const std::array artifact_arm }, { - translate_marker( "Ring" ), def_c_light_green, material_id( "silver" ), 0_ml, 4_gram, 0, 0, 0, 0, 0, 0, 0_ml, 0, 0, 0, + translate_marker( "Ring" ), def_c_light_green, material_silver, 0_ml, 4_gram, 0, 0, 0, 0, 0, 0, 0_ml, 0, 0, 0, {}, false, {{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}} } @@ -529,44 +530,44 @@ static const std::array artifact_arm */ static const std::array artifact_armor_mod_data = { { { - "", def_c_white, material_id( "null" ), 0_ml, 0_gram, 0, 0, 0, 0, 0, 0, 0_ml, 0, 0, 0, {}, false, + "", def_c_white, material_null, 0_ml, 0_gram, 0, 0, 0, 0, 0, 0, 0_ml, 0, 0, 0, {}, false, {{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}} }, // Description; "It is ..." or "They are ..." { - translate_marker( "very thin and light." ), def_c_white, material_id( "null" ), + translate_marker( "very thin and light." ), def_c_white, material_null, // Vol Wgt Enc MaxEnc Cov Thk Env Wrm Sto -1_liter, -950_gram, -2, -2, -1, -1, -1, -1, 0_ml, 0, 0, 0, {}, false, {{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}} }, { - translate_marker( "extremely bulky." ), def_c_white, material_id( "null" ), + translate_marker( "extremely bulky." ), def_c_white, material_null, 2_liter, 1150_gram, 2, 2, 1, 1, 0, 1, 0_ml, 0, 0, 0, {}, false, {{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}} }, { - translate_marker( "covered in pockets." ), def_c_white, material_id( "null" ), + translate_marker( "covered in pockets." ), def_c_white, material_null, 250_ml, 150_gram, 1, 1, 0, 0, 0, 0, 4_liter, 0, 0, 0, {}, false, {{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}} }, { - translate_marker( "disgustingly furry." ), def_c_white, material_id( "wool" ), + translate_marker( "disgustingly furry." ), def_c_white, material_wool, // Vol Wgt Enc MaxEnc Dmg Cut Env Wrm Sto 1_liter, 250_gram, 1, 1, 1, 1, 1, 3, 0_ml, 0, 0, 0, {}, false, {{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}} }, { - translate_marker( "leather-padded." ), def_c_white, material_id( "leather" ), + translate_marker( "leather-padded." ), def_c_white, material_leather, 1_liter, 450_gram, 1, 1, 1, 1, 0, 1, -750_ml, 0, 0, 0, {}, false, {{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}} }, { - translate_marker( "plated in iron." ), def_c_white, material_id( "iron" ), + translate_marker( "plated in iron." ), def_c_white, material_iron, 1_liter, 1400_gram, 3, 3, 2, 2, 0, 1, -1_liter, 0, 0, 0, {}, false, {{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}} }, @@ -941,7 +942,7 @@ std::string new_natural_artifact( artifact_natural_property prop ) def.sym = ":"; def.color = c_yellow; - def.materials.push_back( material_id( "stone" ) ); + def.materials.push_back( material_stone ); def.volume = rng( shape_data.volume_min, shape_data.volume_max ); def.weight = rng( shape_data.weight_min, shape_data.weight_max ); def.melee[DT_BASH] = 0; diff --git a/src/bionics.cpp b/src/bionics.cpp index 4f27c2ed3d613..3af1b992c8cdf 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -539,7 +539,7 @@ bool Character::activate_bionic( int b, bool eff_only ) } } else if( bio.id == bio_magnet ) { static const std::set affected_materials = - { material_id( "iron" ), material_id( "steel" ) }; + { material_iron, material_steel }; // Remember all items that will be affected, then affect them // Don't "snowball" by affecting some items multiple times std::vector> affected; diff --git a/src/cata_string_consts.h b/src/cata_string_consts.h index 4b5e990b6aba6..63a92e22da6ca 100644 --- a/src/cata_string_consts.h +++ b/src/cata_string_consts.h @@ -936,6 +936,7 @@ static const std::string flag_ALLERGEN_MEAT( "ALLERGEN_MEAT" ); static const std::string flag_ALLERGEN_MILK( "ALLERGEN_MILK" ); static const std::string flag_ALLERGEN_VEGGY( "ALLERGEN_VEGGY" ); static const std::string flag_ALLERGEN_WHEAT( "ALLERGEN_WHEAT" ); +static const std::string flag_ALLERGEN_WOOL( "ALLERGEN_WOOL" ); static const std::string flag_ALLOW_OUTSIDE( "ALLOW_OUTSIDE" ); static const std::string flag_ALLOW_ROTTEN( "ALLOW_ROTTEN" ); static const std::string flag_ALLOWS_NATURAL_ATTACKS( "ALLOWS_NATURAL_ATTACKS" ); @@ -1001,6 +1002,7 @@ static const std::string flag_COLD( "COLD" ); static const std::string flag_COLD_IMMUNE( "COLD_IMMUNE" ); static const std::string flag_COLLAPSES( "COLLAPSES" ); static const std::string flag_COLLAPSIBLE_STOCK( "COLLAPSIBLE_STOCK" ); +static const std::string flag_COLLAR( "COLLAR" ); static const std::string flag_CONDUCTIVE( "CONDUCTIVE" ); static const std::string flag_CONSOLE( "CONSOLE" ); static const std::string flag_CONSUMABLE( "CONSUMABLE" ); @@ -1651,6 +1653,53 @@ static const ter_str_id ter_water_moving_sh( "t_water_moving_sh" ); static const ter_str_id ter_water_pool( "t_water_pool" ); static const ter_str_id ter_water_sh( "t_water_sh" ); +static const material_id material_acidchitin( "acidchitin" ); +static const material_id material_alien_resin( "alien_resin" ); +static const material_id material_all( "all" ); +static const material_id material_bean( "bean" ); +static const material_id material_bone( "bone" ); +static const material_id material_budget_steel( "budget_steel" ); +static const material_id material_cac2powder( "cac2powder" ); +static const material_id material_chitin( "chitin" ); +static const material_id material_cotton( "cotton" ); +static const material_id material_egg( "egg" ); +static const material_id material_faux_fur( "faux_fur" ); +static const material_id material_flesh( "flesh" ); +static const material_id material_fruit( "fruit" ); +static const material_id material_fur( "fur" ); +static const material_id material_garlic( "garlic" ); +static const material_id material_glass( "glass" ); +static const material_id material_hardsteel( "hardsteel" ); +static const material_id material_hflesh( "hflesh" ); +static const material_id material_honey( "honey" ); +static const material_id material_hydrocarbons( "hydrocarbons" ); +static const material_id material_iflesh( "iflesh" ); +static const material_id material_iron( "iron" ); +static const material_id material_junk( "junk" ); +static const material_id material_kevlar( "kevlar" ); +static const material_id material_kevlar_rigid( "kevlar_rigid" ); +static const material_id material_leather( "leather" ); +static const material_id material_lycra( "lycra" ); +static const material_id material_milk( "milk" ); +static const material_id material_mushroom( "mushroom" ); +static const material_id material_neoprene( "neoprene" ); +static const material_id material_nomex( "nomex" ); +static const material_id material_null( "null" ); +static const material_id material_nut( "nut" ); +static const material_id material_nylon( "nylon" ); +static const material_id material_oil( "oil" ); +static const material_id material_paper( "paper" ); +static const material_id material_plastic( "plastic" ); +static const material_id material_powder( "powder" ); +static const material_id material_silver( "silver" ); +static const material_id material_steel( "steel" ); +static const material_id material_stone( "stone" ); +static const material_id material_tomato( "tomato" ); +static const material_id material_veggy( "veggy" ); +static const material_id material_wheat( "wheat" ); +static const material_id material_wood( "wood" ); +static const material_id material_wool( "wool" ); + static const oter_str_id oter_forest( "forest" ); static const oter_str_id oter_forest_thick( "forest_thick" ); diff --git a/src/character.cpp b/src/character.cpp index 66503eebcfee2..574d220401d1b 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -2138,7 +2138,7 @@ ret_val Character::can_wear( const item &it, bool with_equip_change ) cons return ret_val::make_failure( _( "Putting on a %s would be tricky." ), it.tname() ); } - if( has_trait( trait_WOOLALLERGY ) && ( it.made_of( material_id( "wool" ) ) || + if( has_trait( trait_WOOLALLERGY ) && ( it.made_of( material_wool ) || it.item_tags.count( flag_wooled ) ) ) { return ret_val::make_failure( _( "Can't wear that, it's made of wool!" ) ); } @@ -2158,8 +2158,8 @@ ret_val Character::can_wear( const item &it, bool with_equip_change ) cons } } if( it.covers( bp_head ) && !it.has_flag( flag_SEMITANGIBLE ) && - !it.made_of( material_id( "wool" ) ) && !it.made_of( material_id( "cotton" ) ) && - !it.made_of( material_id( "nomex" ) ) && !it.made_of( material_id( "leather" ) ) && + !it.made_of( material_wool ) && !it.made_of( material_cotton ) && + !it.made_of( material_nomex ) && !it.made_of( material_leather ) && ( has_trait( trait_HORNS_POINTED ) || has_trait( trait_ANTENNAE ) || has_trait( trait_ANTLERS ) ) ) { return ret_val::make_failure( _( "Cannot wear a helmet over %s." ), @@ -2963,13 +2963,13 @@ int Character::get_wind_resistance( body_part bp ) const for( auto &i : worn ) { if( i.covers( bp ) ) { - if( i.made_of( material_id( "leather" ) ) || i.made_of( material_id( "plastic" ) ) || - i.made_of( material_id( "bone" ) ) || - i.made_of( material_id( "chitin" ) ) || i.made_of( material_id( "nomex" ) ) ) { + if( i.made_of( material_leather ) || i.made_of( material_plastic ) || + i.made_of( material_bone ) || + i.made_of( material_chitin ) || i.made_of( material_nomex ) ) { penalty = 10; // 90% effective - } else if( i.made_of( material_id( "cotton" ) ) ) { + } else if( i.made_of( material_cotton ) ) { penalty = 30; - } else if( i.made_of( material_id( "wool" ) ) ) { + } else if( i.made_of( material_wool ) ) { penalty = 40; } else { penalty = 1; // 99% effective @@ -5509,7 +5509,7 @@ int Character::throw_range( const item &it ) const static_cast( tmp.weight() / 15_gram ) ); ret -= tmp.volume() / 1_liter; - static const std::set affected_materials = { material_id( "iron" ), material_id( "steel" ) }; + static const std::set affected_materials = { material_iron, material_steel }; if( has_active_bionic( bio_railgun ) && tmp.made_of_any( affected_materials ) ) { ret *= 2; } @@ -5527,7 +5527,7 @@ int Character::throw_range( const item &it ) const return ret; } -const std::vector Character::fleshy = { material_id( "flesh" ), material_id( "hflesh" ) }; +const std::vector Character::fleshy = { material_flesh, material_hflesh }; bool Character::made_of( const material_id &m ) const { // TODO: check for mutations that change this. @@ -8259,7 +8259,7 @@ int Character::warmth( body_part bp ) const warmth = i.get_warmth(); // Wool items do not lose their warmth due to being wet. // Warmth is reduced by 0 - 66% based on wetness. - if( !i.made_of( material_id( "wool" ) ) ) { + if( !i.made_of( material_wool ) ) { warmth *= 1.0 - 0.66 * body_wetness[bp] / drench_capacity[bp]; } ret += warmth; @@ -8286,17 +8286,17 @@ int Character::bonus_item_warmth( body_part bp ) const // If the player is not wielding anything big, check if hands can be put in pockets if( ( bp == bp_hand_l || bp == bp_hand_r ) && weapon.volume() < 500_ml ) { - ret += bestwarmth( worn, "POCKETS" ); + ret += bestwarmth( worn, flag_POCKETS ); } // If the player's head is not encumbered, check if hood can be put up if( bp == bp_head && encumb( bp_head ) < 10 ) { - ret += bestwarmth( worn, "HOOD" ); + ret += bestwarmth( worn, flag_HOOD ); } // If the player's mouth is not encumbered, check if collar can be put up if( bp == bp_mouth && encumb( bp_mouth ) < 10 ) { - ret += bestwarmth( worn, "COLLAR" ); + ret += bestwarmth( worn, flag_COLLAR ); } return ret; diff --git a/src/consumption.cpp b/src/consumption.cpp index 2c8b8902f7382..06efa585df865 100644 --- a/src/consumption.cpp +++ b/src/consumption.cpp @@ -135,7 +135,7 @@ static std::map compute_default_effective_vitamins( // TODO: put this loop into a function and utilize it again for bionics for( const auto &mat : mut.vitamin_absorb_multi ) { // this is where we are able to check if the food actually is changed by the trait - if( mat.first == material_id( "all" ) || it.made_of( mat.first ) ) { + if( mat.first == material_all || it.made_of( mat.first ) ) { const std::map &mat_vit_map = mat.second; for( auto &vit : res ) { auto vit_factor = mat_vit_map.find( vit.first ); @@ -1441,10 +1441,10 @@ int Character::get_acquirable_energy( const item &it, rechargeable_cbm cbm ) con int amount = ( consumed_vol / 250_ml + consumed_mass / 1_gram ) / 9; // TODO: JSONize. - if( it.made_of( material_id( "leather" ) ) ) { + if( it.made_of( material_leather ) ) { amount /= 4; } - if( it.made_of( material_id( "wood" ) ) ) { + if( it.made_of( material_wood ) ) { amount /= 2; } diff --git a/src/creature.cpp b/src/creature.cpp index 06a64e2e8f3f4..af653b025360a 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -48,17 +48,17 @@ const std::map Creature::size_map = { }; const std::set Creature::cmat_flesh{ - material_id( "flesh" ), material_id( "iflesh" ) + material_flesh, material_iflesh }; const std::set Creature::cmat_fleshnveg{ - material_id( "flesh" ), material_id( "iflesh" ), material_id( "veggy" ) + material_flesh, material_iflesh, material_veggy }; const std::set Creature::cmat_flammable{ - material_id( "paper" ), material_id( "powder" ), material_id( "wood" ), - material_id( "cotton" ), material_id( "wool" ) + material_paper, material_powder, material_wood, + material_cotton, material_wool }; const std::set Creature::cmat_flameres{ - material_id( "stone" ), material_id( "kevlar" ), material_id( "steel" ) + material_stone, material_kevlar, material_steel }; Creature::Creature() @@ -684,13 +684,13 @@ void Creature::deal_projectile_attack( Creature *source, dealt_projectile_attack } } if( proj.proj_effects.count( "INCENDIARY" ) ) { - if( made_of( material_id( "veggy" ) ) || made_of_any( cmat_flammable ) ) { + if( made_of( material_veggy ) || made_of_any( cmat_flammable ) ) { add_effect( effect_onfire, rng( 2_turns, 6_turns ), bp_hit ); } else if( made_of_any( cmat_flesh ) && one_in( 4 ) ) { add_effect( effect_onfire, rng( 1_turns, 4_turns ), bp_hit ); } } else if( proj.proj_effects.count( "IGNITE" ) ) { - if( made_of( material_id( "veggy" ) ) || made_of_any( cmat_flammable ) ) { + if( made_of( material_veggy ) || made_of_any( cmat_flammable ) ) { add_effect( effect_onfire, 6_turns, bp_hit ); } else if( made_of_any( cmat_flesh ) ) { add_effect( effect_onfire, 10_turns, bp_hit ); diff --git a/src/game.cpp b/src/game.cpp index 494e201ebb1af..578ec4787364b 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -4996,7 +4996,7 @@ bool game::forced_door_closing( const tripoint &p, const ter_id &door_type, int it = items.erase( it ); continue; } - if( it->made_of( material_id( "glass" ) ) && one_in( 2 ) ) { + if( it->made_of( material_glass ) && one_in( 2 ) ) { if( can_see ) { add_msg( m_warning, _( "A %s shatters!" ), it->tname() ); } else { diff --git a/src/handle_action.cpp b/src/handle_action.cpp index b653887465643..958c2bcf6869b 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -709,7 +709,7 @@ static void smash() u.practice( skill_melee, rng( 0, 1 ) * rng( 0, 1 ) ); } const int vol = u.weapon.volume() / units::legacy_volume_factor; - if( u.weapon.made_of( material_id( "glass" ) ) && + if( u.weapon.made_of( material_glass ) && rng( 0, vol + 3 ) < vol ) { add_msg( m_bad, _( "Your %s shatters!" ), u.weapon.tname() ); for( auto &elem : u.weapon.contents ) { diff --git a/src/iexamine.cpp b/src/iexamine.cpp index 1810a05c606e7..f86cb3b4a1484 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -108,7 +108,7 @@ void iexamine::cvdmachine( player &p, const tripoint & ) { // Select an item to which it is possible to apply a diamond coating auto loc = g->inv_map_splice( []( const item & e ) { - return ( e.is_melee( DT_CUT ) || e.is_melee( DT_STAB ) ) && e.made_of( material_id( "steel" ) ) && + return ( e.is_melee( DT_CUT ) || e.is_melee( DT_STAB ) ) && e.made_of( material_steel ) && !e.has_flag( flag_DIAMOND ) && !e.has_flag( flag_NO_CVD ); }, _( "Apply diamond coating" ), 1, _( "You don't have a suitable item to coat with diamond" ) ); @@ -2267,7 +2267,7 @@ void iexamine::kiln_empty( player &p, const tripoint &examp ) return; } - static const std::set kilnable{ material_id( "wood" ), material_id( "bone" ) }; + static const std::set kilnable{ material_wood, material_bone }; bool fuel_present = false; auto items = g->m.i_at( examp ); for( const item &i : items ) { @@ -2396,7 +2396,7 @@ void iexamine::arcfurnace_empty( player &p, const tripoint &examp ) return; } - static const std::set arcfurnaceable{ material_id( "cac2powder" ) }; + static const std::set arcfurnaceable{ material_cac2powder }; bool fuel_present = false; auto items = g->m.i_at( examp ); for( const item &i : items ) { diff --git a/src/inventory.cpp b/src/inventory.cpp index 46115a784fe4f..b18b315df1c44 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -876,7 +876,7 @@ void inventory::rust_iron_items() { for( auto &elem : items ) { for( auto &elem_stack_iter : elem ) { - if( elem_stack_iter.made_of( material_id( "iron" ) ) && + if( elem_stack_iter.made_of( material_iron ) && !elem_stack_iter.has_flag( flag_WATERPROOF_GUN ) && !elem_stack_iter.has_flag( flag_WATERPROOF ) && elem_stack_iter.damage() < elem_stack_iter.max_damage() / 2 && diff --git a/src/item.cpp b/src/item.cpp index dd01fb0c9a240..011b476b67ef8 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -2736,7 +2736,7 @@ void item::final_info( std::vector &info, const iteminfo_query *parts, } if( is_armor() && g->u.has_trait( trait_WOOLALLERGY ) && - ( made_of( material_id( "wool" ) ) || item_tags.count( "wooled" ) ) ) { + ( made_of( material_wool ) || item_tags.count( flag_wooled ) ) ) { info.push_back( iteminfo( "DESCRIPTION", _( "* This clothing will give you an allergic " "reaction." ) ) ); @@ -3460,7 +3460,7 @@ nc_color item::color_in_inventory() const } else if( has_flag( flag_LITCIG ) ) { ret = c_red; } else if( is_armor() && u.has_trait( trait_WOOLALLERGY ) && - ( made_of( material_id( "wool" ) ) || item_tags.count( "wooled" ) ) ) { + ( made_of( material_wool ) || item_tags.count( flag_wooled ) ) ) { ret = c_red; } else if( is_filthy() || item_tags.count( "DIRTY" ) ) { ret = c_brown; diff --git a/src/item_factory.cpp b/src/item_factory.cpp index 86bf535b24b7a..2b8cc1f1aa0ff 100644 --- a/src/item_factory.cpp +++ b/src/item_factory.cpp @@ -47,6 +47,7 @@ #include "units.h" #include "cata_utility.h" #include "flat_set.h" +#include "cata_string_consts.h" class player; struct tripoint; @@ -226,8 +227,8 @@ void Item_factory::finalize_pre( itype &obj ) } const auto &mats = obj.materials; - if( std::find( mats.begin(), mats.end(), material_id( "hydrocarbons" ) ) == mats.end() && - std::find( mats.begin(), mats.end(), material_id( "oil" ) ) == mats.end() ) { + if( std::find( mats.begin(), mats.end(), material_hydrocarbons ) == mats.end() && + std::find( mats.begin(), mats.end(), material_oil ) == mats.end() ) { const auto &ammo_effects = obj.ammo->ammo_effects; obj.ammo->cookoff = ammo_effects.count( "INCENDIARY" ) > 0 || ammo_effects.count( "COOKOFF" ) > 0; @@ -2112,31 +2113,31 @@ static void set_allergy_flags( itype &item_template ) static const std::vector all_pairs = {{ // First allergens: // An item is an allergen even if it has trace amounts of allergenic material - std::make_pair( material_id( "hflesh" ), "CANNIBALISM" ), - - std::make_pair( material_id( "hflesh" ), "ALLERGEN_MEAT" ), - std::make_pair( material_id( "iflesh" ), "ALLERGEN_MEAT" ), - std::make_pair( material_id( "flesh" ), "ALLERGEN_MEAT" ), - std::make_pair( material_id( "wheat" ), "ALLERGEN_WHEAT" ), - std::make_pair( material_id( "fruit" ), "ALLERGEN_FRUIT" ), - std::make_pair( material_id( "veggy" ), "ALLERGEN_VEGGY" ), - std::make_pair( material_id( "bean" ), "ALLERGEN_VEGGY" ), - std::make_pair( material_id( "tomato" ), "ALLERGEN_VEGGY" ), - std::make_pair( material_id( "garlic" ), "ALLERGEN_VEGGY" ), - std::make_pair( material_id( "nut" ), "ALLERGEN_VEGGY" ), - std::make_pair( material_id( "mushroom" ), "ALLERGEN_VEGGY" ), - std::make_pair( material_id( "milk" ), "ALLERGEN_MILK" ), - std::make_pair( material_id( "egg" ), "ALLERGEN_EGG" ), - std::make_pair( material_id( "junk" ), "ALLERGEN_JUNK" ), + std::make_pair( material_hflesh, flag_CANNIBALISM ), + + std::make_pair( material_hflesh, flag_ALLERGEN_MEAT ), + std::make_pair( material_iflesh, flag_ALLERGEN_MEAT ), + std::make_pair( material_flesh, flag_ALLERGEN_MEAT ), + std::make_pair( material_wheat, flag_ALLERGEN_WHEAT ), + std::make_pair( material_fruit, flag_ALLERGEN_FRUIT ), + std::make_pair( material_veggy, flag_ALLERGEN_VEGGY ), + std::make_pair( material_bean, flag_ALLERGEN_VEGGY ), + std::make_pair( material_tomato, flag_ALLERGEN_VEGGY ), + std::make_pair( material_garlic, flag_ALLERGEN_VEGGY ), + std::make_pair( material_nut, flag_ALLERGEN_VEGGY ), + std::make_pair( material_mushroom, flag_ALLERGEN_VEGGY ), + std::make_pair( material_milk, flag_ALLERGEN_MILK ), + std::make_pair( material_egg, flag_ALLERGEN_EGG ), + std::make_pair( material_junk, flag_ALLERGEN_JUNK ), // Not food, but we can keep it here - std::make_pair( material_id( "wool" ), "ALLERGEN_WOOL" ), + std::make_pair( material_wool, flag_ALLERGEN_WOOL ), // Now "made of". Those flags should not be passed - std::make_pair( material_id( "flesh" ), "CARNIVORE_OK" ), - std::make_pair( material_id( "hflesh" ), "CARNIVORE_OK" ), - std::make_pair( material_id( "iflesh" ), "CARNIVORE_OK" ), - std::make_pair( material_id( "milk" ), "CARNIVORE_OK" ), - std::make_pair( material_id( "egg" ), "CARNIVORE_OK" ), - std::make_pair( material_id( "honey" ), "URSINE_HONEY" ), + std::make_pair( material_flesh, flag_CARNIVORE_OK ), + std::make_pair( material_hflesh, flag_CARNIVORE_OK ), + std::make_pair( material_iflesh, flag_CARNIVORE_OK ), + std::make_pair( material_milk, flag_CARNIVORE_OK ), + std::make_pair( material_egg, flag_CARNIVORE_OK ), + std::make_pair( material_honey, flag_URSINE_HONEY ), } }; @@ -2154,11 +2155,11 @@ void hflesh_to_flesh( itype &item_template ) { auto &mats = item_template.materials; const auto old_size = mats.size(); - mats.erase( std::remove( mats.begin(), mats.end(), material_id( "hflesh" ) ), mats.end() ); + mats.erase( std::remove( mats.begin(), mats.end(), material_hflesh ), mats.end() ); // Only add "flesh" material if not already present if( old_size != mats.size() && - std::find( mats.begin(), mats.end(), material_id( "flesh" ) ) == mats.end() ) { - mats.push_back( material_id( "flesh" ) ); + std::find( mats.begin(), mats.end(), material_flesh ) == mats.end() ) { + mats.push_back( material_flesh ); } } diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 9b2dc8c99cf22..d1b6c1142c9a1 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -1864,7 +1864,7 @@ int enzlave_actor::use( player &p, item &it, bool t, const tripoint & ) const for( auto &it : items ) { const auto mt = it.get_mtype(); - if( it.is_corpse() && mt->in_species( species_ZOMBIE ) && mt->made_of( material_id( "flesh" ) ) && + if( it.is_corpse() && mt->in_species( species_ZOMBIE ) && mt->made_of( material_flesh ) && mt->in_species( species_HUMAN ) && it.active && !it.has_var( "zlave" ) ) { corpses.push_back( &it ); } diff --git a/src/iuse_actor.h b/src/iuse_actor.h index d405a114eb567..0cc1c1fff1d96 100644 --- a/src/iuse_actor.h +++ b/src/iuse_actor.h @@ -22,6 +22,7 @@ class npc_template; #include "type_id.h" #include "units.h" #include "optional.h" +#include "cata_string_consts.h" class Character; class item; @@ -501,23 +502,23 @@ class salvage_actor : public iuse_actor /** Materials it can cut */ std::set material_whitelist = { - material_id( "acidchitin" ), - material_id( "alien_resin" ), - material_id( "bone" ), - material_id( "chitin" ), - material_id( "cotton" ), - material_id( "faux_fur" ), - material_id( "fur" ), - material_id( "kevlar" ), - material_id( "kevlar_rigid" ), - material_id( "leather" ), - material_id( "lycra" ), - material_id( "neoprene" ), - material_id( "nomex" ), - material_id( "nylon" ), - material_id( "plastic" ), - material_id( "wood" ), - material_id( "wool" ) + material_acidchitin, + material_alien_resin, + material_bone, + material_chitin, + material_cotton, + material_faux_fur, + material_fur, + material_kevlar, + material_kevlar_rigid, + material_leather, + material_lycra, + material_neoprene, + material_nomex, + material_nylon, + material_plastic, + material_wood, + material_wool }; bool try_to_cut_up( player &p, item &it ) const; @@ -548,14 +549,14 @@ class inscribe_actor : public iuse_actor // Materials it can write on std::set material_whitelist = { - material_id( "wood" ), - material_id( "plastic" ), - material_id( "glass" ), - material_id( "chitin" ), - material_id( "iron" ), - material_id( "steel" ), - material_id( "silver" ), - material_id( "bone" ) + material_wood, + material_plastic, + material_glass, + material_chitin, + material_iron, + material_steel, + material_silver, + material_bone }; // How will the inscription be described diff --git a/src/map.cpp b/src/map.cpp index dc80728128db2..5d33e7616b0fc 100755 --- a/src/map.cpp +++ b/src/map.cpp @@ -3251,7 +3251,7 @@ void map::bash_items( const tripoint &p, bash_params ¶ms ) bool smashed_glass = false; for( auto bashed_item = bashed_items.begin(); bashed_item != bashed_items.end(); ) { // the check for active suppresses Molotovs smashing themselves with their own explosion - if( bashed_item->made_of( material_id( "glass" ) ) && !bashed_item->active && one_in( 2 ) ) { + if( bashed_item->made_of( material_glass ) && !bashed_item->active && one_in( 2 ) ) { params.did_bash = true; smashed_glass = true; for( const item &bashed_content : bashed_item->contents ) { diff --git a/src/map_field.cpp b/src/map_field.cpp index 2c04603c6639f..e2cb4c7eea861 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -1765,7 +1765,7 @@ void map::monster_in_field( monster &z ) if( z.made_of_any( Creature::cmat_flesh ) ) { dam += 3; } - if( z.made_of( material_id( "veggy" ) ) ) { + if( z.made_of( material_veggy ) ) { dam += 12; } if( z.made_of( LIQUID ) || z.made_of_any( Creature::cmat_flammable ) ) { @@ -1805,7 +1805,7 @@ void map::monster_in_field( monster &z ) z.moves -= rng( 10, 20 ); } // Plants suffer from smoke even worse - if( z.made_of( material_id( "veggy" ) ) ) { + if( z.made_of( material_veggy ) ) { z.moves -= rng( 1, cur.get_field_intensity() * 12 ); } } @@ -1822,7 +1822,7 @@ void map::monster_in_field( monster &z ) } else { z.add_effect( effect_stunned, rng( 1_turns, 5_turns ) ); } - if( z.made_of( material_id( "veggy" ) ) ) { + if( z.made_of( material_veggy ) ) { z.moves -= rng( cur.get_field_intensity() * 5, cur.get_field_intensity() * 12 ); dam += cur.get_field_intensity() * rng( 8, 14 ); } @@ -1864,7 +1864,7 @@ void map::monster_in_field( monster &z ) z.moves -= rng( 0, 15 ); dam += rng( 0, 12 ); } - if( z.made_of( material_id( "veggy" ) ) ) { + if( z.made_of( material_veggy ) ) { z.moves -= rng( cur.get_field_intensity() * 5, cur.get_field_intensity() * 12 ); dam *= cur.get_field_intensity(); } @@ -1879,7 +1879,7 @@ void map::monster_in_field( monster &z ) if( z.made_of_any( Creature::cmat_flesh ) ) { dam += 3; } - if( z.made_of( material_id( "veggy" ) ) ) { + if( z.made_of( material_veggy ) ) { dam += 12; } if( z.made_of( LIQUID ) || z.made_of_any( Creature::cmat_flammable ) ) { @@ -1910,7 +1910,7 @@ void map::monster_in_field( monster &z ) if( z.made_of_any( Creature::cmat_flesh ) ) { dam += 3; } - if( z.made_of( material_id( "veggy" ) ) ) { + if( z.made_of( material_veggy ) ) { dam += 12; } if( z.made_of( LIQUID ) || z.made_of_any( Creature::cmat_flammable ) ) { diff --git a/src/melee.cpp b/src/melee.cpp index f8e254621ecf8..b477c88540951 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -484,7 +484,7 @@ void player::melee_attack( Creature &t, bool allow_special, const matec_id &forc std::string material = "flesh"; if( t.is_monster() ) { const monster *m = dynamic_cast( &t ); - if( m->made_of( material_id( "steel" ) ) ) { + if( m->made_of( material_steel ) ) { material = "steel"; } } @@ -1641,7 +1641,7 @@ bool player::block_hit( Creature *source, body_part &bp_hit, damage_instance &da if( tec != matec_tec_none && !is_dead_state() ) { if( get_stamina() < get_stamina_max() / 3 ) { add_msg( m_bad, _( "You try to counterattack but you are too exhausted!" ) ); - } else if( weapon.made_of( material_id( "glass" ) ) ) { + } else if( weapon.made_of( material_glass ) ) { add_msg( m_bad, _( "The item you are wielding is too fragile to counterattack with!" ) ); } else { melee_attack( *source, false, tec ); @@ -1727,7 +1727,7 @@ std::string player::melee_special_effects( Creature &t, damage_instance &d, item const int vol = weap.volume() / 250_ml; // Glass weapons shatter sometimes - if( weap.made_of( material_id( "glass" ) ) && + if( weap.made_of( material_glass ) && /** @EFFECT_STR increases chance of breaking glass weapons (NEGATIVE) */ rng( 0, vol + 8 ) < vol + str_cur ) { if( is_player() ) { diff --git a/src/monattack.cpp b/src/monattack.cpp index 03b7ea4855bcb..a3aca740be2d4 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -673,10 +673,10 @@ bool mattack::pull_metal_weapon( monster *z ) if( foe != nullptr ) { // Wielded steel or iron items except for built-in things like bionic claws or monomolecular blade if( !foe->weapon.has_flag( flag_NO_UNWIELD ) && - ( foe->weapon.made_of( material_id( "iron" ) ) || - foe->weapon.made_of( material_id( "hardsteel" ) ) || - foe->weapon.made_of( material_id( "steel" ) ) || - foe->weapon.made_of( material_id( "budget_steel" ) ) ) ) { + ( foe->weapon.made_of( material_iron ) || + foe->weapon.made_of( material_hardsteel ) || + foe->weapon.made_of( material_steel ) || + foe->weapon.made_of( material_budget_steel ) ) ) { int wp_skill = foe->get_skill_level( skill_melee ); // It takes a while z->moves -= att_cost_pull; @@ -2240,9 +2240,9 @@ bool mattack::formblob( monster *z ) } else if( othermon.type->id == mon_blob && othermon.get_speed_base() >= 80 ) { poly_keep_speed( othermon, mon_blob_large ); } - } else if( ( othermon.made_of( material_id( "flesh" ) ) || - othermon.made_of( material_id( "veggy" ) ) || - othermon.made_of( material_id( "iflesh" ) ) ) && + } else if( ( othermon.made_of( material_flesh ) || + othermon.made_of( material_veggy ) || + othermon.made_of( material_iflesh ) ) && rng( 0, z->get_hp() ) > rng( othermon.get_hp() / 2, othermon.get_hp() ) ) { didit = blobify( *z, othermon ); } @@ -4100,8 +4100,8 @@ bool mattack::absorb_meat( monster *z ) auto items = g->m.i_at( p ); for( auto ¤t_item : items ) { const material_id current_item_material = current_item.get_base_material().ident(); - if( current_item_material == material_id( "flesh" ) || - current_item_material == material_id( "hflesh" ) ) { + if( current_item_material == material_flesh || + current_item_material == material_hflesh ) { //We have something meaty! Calculate how much it will heal the monster const int ml_of_meat = units::to_milliliter( current_item.volume() ); const int total_charges = current_item.count(); diff --git a/src/monster.cpp b/src/monster.cpp index 0e92744679069..9fccb53f8a3f8 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -436,14 +436,14 @@ std::string monster::name_with_armor() const std::string ret; if( type->in_species( species_INSECT ) ) { ret = _( "carapace" ); - } else if( made_of( material_id( "veggy" ) ) ) { + } else if( made_of( material_veggy ) ) { ret = _( "thick bark" ); - } else if( made_of( material_id( "bone" ) ) ) { + } else if( made_of( material_bone ) ) { ret = _( "exoskeleton" ); - } else if( made_of( material_id( "flesh" ) ) || made_of( material_id( "hflesh" ) ) || - made_of( material_id( "iflesh" ) ) ) { + } else if( made_of( material_flesh ) || made_of( material_hflesh ) || + made_of( material_iflesh ) ) { ret = _( "thick hide" ); - } else if( made_of( material_id( "iron" ) ) || made_of( material_id( "steel" ) ) ) { + } else if( made_of( material_iron ) || made_of( material_steel ) ) { ret = _( "armor plating" ); } else if( made_of( LIQUID ) ) { ret = _( "dense jelly mass" ); @@ -1147,14 +1147,14 @@ bool monster::is_immune_effect( const efftype_id &effect ) const if( effect == effect_bleed ) { return !has_flag( MF_WARM ) || - !made_of( material_id( "flesh" ) ); + !made_of( material_flesh ); } if( effect == effect_paralyzepoison || effect == effect_badpoison || effect == effect_poison ) { return !has_flag( MF_WARM ) || - ( !made_of( material_id( "flesh" ) ) && !made_of( material_id( "iflesh" ) ) ); + ( !made_of( material_flesh ) && !made_of( material_iflesh ) ); } if( effect == effect_stunned ) { @@ -1184,7 +1184,7 @@ bool monster::is_immune_damage( const damage_type dt ) const return false; case DT_HEAT: // Ugly hardcode - remove later - return made_of( material_id( "steel" ) ) || made_of( material_id( "stone" ) ); + return made_of( material_steel ) || made_of( material_stone ); case DT_COLD: return false; case DT_ELECTRIC: @@ -2279,9 +2279,9 @@ void monster::process_one_effect( effect &it, bool is_new ) effect_cache[MOVEMENT_IMPAIRED] = true; } else if( id == effect_onfire ) { int dam = 0; - if( made_of( material_id( "veggy" ) ) ) { + if( made_of( material_veggy ) ) { dam = rng( 10, 20 ); - } else if( made_of( material_id( "flesh" ) ) || made_of( material_id( "iflesh" ) ) ) { + } else if( made_of( material_flesh ) || made_of( material_iflesh ) ) { dam = rng( 5, 10 ); } @@ -2381,9 +2381,9 @@ bool monster::make_fungus() if( type->in_species( species_FUNGUS ) ) { // No friendly-fungalizing ;-) return true; } - if( !made_of( material_id( "flesh" ) ) && !made_of( material_id( "hflesh" ) ) && - !made_of( material_id( "veggy" ) ) && !made_of( material_id( "iflesh" ) ) && - !made_of( material_id( "bone" ) ) ) { + if( !made_of( material_flesh ) && !made_of( material_hflesh ) && + !made_of( material_veggy ) && !made_of( material_iflesh ) && + !made_of( material_bone ) ) { // No fungalizing robots or weird stuff (mi-gos are technically fungi, blobs are goo) return true; } @@ -2827,7 +2827,7 @@ void monster::on_load() if( regen <= 0 ) { if( has_flag( MF_REVIVES ) ) { regen = 1.0f / to_turns( 1_hours ); - } else if( made_of( material_id( "flesh" ) ) || made_of( material_id( "veggy" ) ) ) { + } else if( made_of( material_flesh ) || made_of( material_veggy ) ) { // Most living stuff here regen = 0.25f / to_turns( 1_hours ); } diff --git a/src/mtype.cpp b/src/mtype.cpp index b351624e2f2e9..d9b608349c3b6 100644 --- a/src/mtype.cpp +++ b/src/mtype.cpp @@ -22,7 +22,7 @@ mtype::mtype() size = MS_MEDIUM; volume = 62499_ml; weight = 81499_gram; - mat = { material_id( "flesh" ) }; + mat = { material_flesh }; phase = SOLID; def_chance = 0; upgrades = false; @@ -152,13 +152,13 @@ field_type_id mtype::bloodType() const if( has_flag( MF_LARVA ) || has_flag( MF_ARTHROPOD_BLOOD ) ) { return fd_blood_invertebrate; } - if( made_of( material_id( "veggy" ) ) ) { + if( made_of( material_veggy ) ) { return fd_blood_veggy; } - if( made_of( material_id( "iflesh" ) ) ) { + if( made_of( material_iflesh ) ) { return fd_blood_insect; } - if( has_flag( MF_WARM ) && made_of( material_id( "flesh" ) ) ) { + if( has_flag( MF_WARM ) && made_of( material_flesh ) ) { return fd_blood; } return fd_null; @@ -169,13 +169,13 @@ field_type_id mtype::gibType() const if( has_flag( MF_LARVA ) || in_species( species_MOLLUSK ) ) { return fd_gibs_invertebrate; } - if( made_of( material_id( "veggy" ) ) ) { + if( made_of( material_veggy ) ) { return fd_gibs_veggy; } - if( made_of( material_id( "iflesh" ) ) ) { + if( made_of( material_iflesh ) ) { return fd_gibs_insect; } - if( made_of( material_id( "flesh" ) ) ) { + if( made_of( material_flesh ) ) { return fd_gibs_flesh; } // There are other materials not listed here like steel, protoplasmic, powder, null, stone, bone @@ -185,18 +185,18 @@ field_type_id mtype::gibType() const itype_id mtype::get_meat_itype() const { if( has_flag( MF_POISON ) ) { - if( made_of( material_id( "flesh" ) ) || made_of( material_id( "hflesh" ) ) ) { + if( made_of( material_flesh ) || made_of( material_hflesh ) ) { return "meat_tainted"; - } else if( made_of( material_id( "iflesh" ) ) ) { + } else if( made_of( material_iflesh ) ) { //In the future, insects could drop insect flesh rather than plain ol' meat. return "meat_tainted"; - } else if( made_of( material_id( "veggy" ) ) ) { + } else if( made_of( material_veggy ) ) { return "veggy_tainted"; - } else if( made_of( material_id( "bone" ) ) ) { + } else if( made_of( material_bone ) ) { return "bone_tainted"; } } else { - if( made_of( material_id( "flesh" ) ) || made_of( material_id( "hflesh" ) ) ) { + if( made_of( material_flesh ) || made_of( material_hflesh ) ) { if( has_flag( MF_HUMAN ) ) { return "human_flesh"; } else if( has_flag( MF_AQUATIC ) ) { @@ -204,12 +204,12 @@ itype_id mtype::get_meat_itype() const } else { return "meat"; } - } else if( made_of( material_id( "iflesh" ) ) ) { + } else if( made_of( material_iflesh ) ) { //In the future, insects could drop insect flesh rather than plain ol' meat. return "meat"; - } else if( made_of( material_id( "veggy" ) ) ) { + } else if( made_of( material_veggy ) ) { return "veggy"; - } else if( made_of( material_id( "bone" ) ) ) { + } else if( made_of( material_bone ) ) { return "bone"; } } diff --git a/src/ranged.cpp b/src/ranged.cpp index 0aa63e36328eb..c1d31187e249a 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -593,7 +593,7 @@ dealt_projectile_attack player::throw_item( const tripoint &target, const item & auto &impact = proj.impact; auto &proj_effects = proj.proj_effects; - static const std::set ferric = { material_id( "iron" ), material_id( "steel" ) }; + static const std::set ferric = { material_iron, material_steel }; bool do_railgun = has_active_bionic( bio_railgun ) && thrown.made_of_any( ferric ) && !throw_assist; @@ -618,7 +618,7 @@ dealt_projectile_attack player::throw_item( const tripoint &target, const item & // Item will shatter upon landing, destroying the item, dealing damage, and making noise /** @EFFECT_STR increases chance of shattering thrown glass items (NEGATIVE) */ - const bool shatter = !thrown.active && thrown.made_of( material_id( "glass" ) ) && + const bool shatter = !thrown.active && thrown.made_of( material_glass ) && rng( 0, units::to_milliliter( 2_liter - volume ) ) < get_str() * 100; // Item will burst upon landing, destroying the item, and spilling its contents diff --git a/src/sounds.cpp b/src/sounds.cpp index 376e658b623ba..1bce93d3eaf07 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -1075,11 +1075,11 @@ void sfx::do_projectile_hit( const Creature &target ) if( target.is_monster() ) { const monster &mon = dynamic_cast( target ); static const std::set fleshy = { - material_id( "flesh" ), - material_id( "hflesh" ), - material_id( "iflesh" ), - material_id( "veggy" ), - material_id( "bone" ), + material_flesh, + material_hflesh, + material_iflesh, + material_veggy, + material_bone, }; const bool is_fleshy = std::any_of( fleshy.begin(), fleshy.end(), [&mon]( const material_id & m ) { return mon.made_of( m ); @@ -1088,10 +1088,10 @@ void sfx::do_projectile_hit( const Creature &target ) if( is_fleshy ) { play_variant_sound( "bullet_hit", "hit_flesh", heard_volume, angle, 0.8, 1.2 ); return; - } else if( mon.made_of( material_id( "stone" ) ) ) { + } else if( mon.made_of( material_stone ) ) { play_variant_sound( "bullet_hit", "hit_wall", heard_volume, angle, 0.8, 1.2 ); return; - } else if( mon.made_of( material_id( "steel" ) ) ) { + } else if( mon.made_of( material_steel ) ) { play_variant_sound( "bullet_hit", "hit_metal", heard_volume, angle, 0.8, 1.2 ); return; } else { diff --git a/src/trapfunc.cpp b/src/trapfunc.cpp index 2ea837e72f813..ccb9c38e6448e 100644 --- a/src/trapfunc.cpp +++ b/src/trapfunc.cpp @@ -966,16 +966,16 @@ bool trapfunc::lava( const tripoint &p, Creature *c, item * ) if( z->made_of_any( Creature::cmat_flesh ) ) { dam = 50; } - if( z->made_of( material_id( "veggy" ) ) ) { + if( z->made_of( material_veggy ) ) { dam = 80; } if( z->made_of( LIQUID ) || z->made_of_any( Creature::cmat_flammable ) ) { dam = 200; } - if( z->made_of( material_id( "stone" ) ) ) { + if( z->made_of( material_stone ) ) { dam = 15; } - if( z->made_of( material_id( "kevlar" ) ) || z->made_of( material_id( "steel" ) ) ) { + if( z->made_of( material_kevlar ) || z->made_of( material_steel ) ) { dam = 5; } z->deal_damage( nullptr, bp_torso, damage_instance( DT_HEAT, dam ) );