Skip to content

Commit

Permalink
Move string consts into single file (#38195)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramza13 authored Feb 21, 2020
1 parent 4fffd96 commit b1b48ba
Show file tree
Hide file tree
Showing 23 changed files with 219 additions and 167 deletions.
41 changes: 21 additions & 20 deletions src/artifact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "units.h"
#include "type_id.h"
#include "value_ptr.h"
#include "cata_string_consts.h"

template<typename V, typename B>
inline units::quantity<V, B> rng( const units::quantity<V, B> &min,
Expand Down Expand Up @@ -417,27 +418,27 @@ static const std::array<artifact_property_datum, ARTPROP_MAX> artifact_property_
};
static const std::array<artifact_tool_form_datum, NUM_ARTTOOLFORMS> 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}}
}
}
Expand All @@ -454,7 +455,7 @@ static const std::array<artifact_weapon_datum, NUM_ARTWEAPS> artifact_weapon_dat
static const std::array<artifact_armor_form_datum, NUM_ARTARMFORMS> 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,
Expand All @@ -464,7 +465,7 @@ static const std::array<artifact_armor_form_datum, NUM_ARTARMFORMS> 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,
Expand All @@ -474,7 +475,7 @@ static const std::array<artifact_armor_form_datum, NUM_ARTARMFORMS> 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,
Expand All @@ -485,7 +486,7 @@ static const std::array<artifact_armor_form_datum, NUM_ARTARMFORMS> 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,
Expand All @@ -495,7 +496,7 @@ static const std::array<artifact_armor_form_datum, NUM_ARTARMFORMS> 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,
Expand All @@ -506,7 +507,7 @@ static const std::array<artifact_armor_form_datum, NUM_ARTARMFORMS> 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,
Expand All @@ -516,7 +517,7 @@ static const std::array<artifact_armor_form_datum, NUM_ARTARMFORMS> 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}}
}
Expand All @@ -529,44 +530,44 @@ static const std::array<artifact_armor_form_datum, NUM_ARTARMFORMS> artifact_arm
*/
static const std::array<artifact_armor_form_datum, NUM_ARMORMODS> 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}}
},
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ bool Character::activate_bionic( int b, bool eff_only )
}
} else if( bio.id == bio_magnet ) {
static const std::set<material_id> 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<std::pair<item, tripoint>> affected;
Expand Down
49 changes: 49 additions & 0 deletions src/cata_string_consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down Expand Up @@ -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" );
Expand Down Expand Up @@ -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" );

Expand Down
28 changes: 14 additions & 14 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2138,7 +2138,7 @@ ret_val<bool> Character::can_wear( const item &it, bool with_equip_change ) cons
return ret_val<bool>::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<bool>::make_failure( _( "Can't wear that, it's made of wool!" ) );
}
Expand All @@ -2158,8 +2158,8 @@ ret_val<bool> 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<bool>::make_failure( _( "Cannot wear a helmet over %s." ),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -5509,7 +5509,7 @@ int Character::throw_range( const item &it ) const
static_cast<int>(
tmp.weight() / 15_gram ) );
ret -= tmp.volume() / 1_liter;
static const std::set<material_id> affected_materials = { material_id( "iron" ), material_id( "steel" ) };
static const std::set<material_id> affected_materials = { material_iron, material_steel };
if( has_active_bionic( bio_railgun ) && tmp.made_of_any( affected_materials ) ) {
ret *= 2;
}
Expand All @@ -5527,7 +5527,7 @@ int Character::throw_range( const item &it ) const
return ret;
}

const std::vector<material_id> Character::fleshy = { material_id( "flesh" ), material_id( "hflesh" ) };
const std::vector<material_id> Character::fleshy = { material_flesh, material_hflesh };
bool Character::made_of( const material_id &m ) const
{
// TODO: check for mutations that change this.
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/consumption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static std::map<vitamin_id, int> 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<vitamin_id, double> &mat_vit_map = mat.second;
for( auto &vit : res ) {
auto vit_factor = mat_vit_map.find( vit.first );
Expand Down Expand Up @@ -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;
}

Expand Down
Loading

0 comments on commit b1b48ba

Please sign in to comment.