Skip to content

Commit

Permalink
Merge pull request #38176 from Ramza13/string_consts_and_more
Browse files Browse the repository at this point in the history
Move string consts/rename string consts
  • Loading branch information
ZhilkinSerg authored Feb 20, 2020
2 parents 07995cd + e6cb983 commit 9c9835f
Show file tree
Hide file tree
Showing 20 changed files with 108 additions and 104 deletions.
4 changes: 2 additions & 2 deletions src/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,8 @@ int hotkey_for_action( action_id action, const bool restrict_to_printable )
bool can_butcher_at( const tripoint &p )
{
// TODO: unify this with game::butcher
const int factor = g->u.max_quality( qual_BUTCHER );
const int factorD = g->u.max_quality( qual_CUT_FINE );
const int factor = g->u.max_quality( quality_BUTCHER );
const int factorD = g->u.max_quality( quality_CUT_FINE );
auto items = g->m.i_at( p );
bool has_item = false;
bool has_corpse = false;
Expand Down
14 changes: 7 additions & 7 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ static void butcher_cbm_group( const std::string &group, const tripoint &pos,

static void set_up_butchery( player_activity &act, player &u, butcher_type action )
{
const int factor = u.max_quality( action == DISSECT ? qual_CUT_FINE : qual_BUTCHER );
const int factor = u.max_quality( action == DISSECT ? quality_CUT_FINE : quality_BUTCHER );

const item &corpse_item = *act.targets.back();
const mtype &corpse = *corpse_item.get_mtype();
Expand Down Expand Up @@ -446,7 +446,7 @@ static void set_up_butchery( player_activity &act, player &u, butcher_type actio
act.targets.pop_back();
return;
}
if( !( u.has_quality( qual_SAW_W ) || u.has_quality( qual_SAW_M ) ) ) {
if( !( u.has_quality( quality_SAW_W ) || u.has_quality( quality_SAW_M ) ) ) {
u.add_msg_if_player( m_info,
_( "For a corpse this big you need a saw to perform a full butchery." ) );
act.targets.pop_back();
Expand Down Expand Up @@ -539,7 +539,7 @@ static void set_up_butchery( player_activity &act, player &u, butcher_type actio
int butcher_time_to_cut( const player &u, const item &corpse_item, const butcher_type action )
{
const mtype &corpse = *corpse_item.get_mtype();
const int factor = u.max_quality( action == DISSECT ? qual_CUT_FINE : qual_BUTCHER );
const int factor = u.max_quality( action == DISSECT ? quality_CUT_FINE : quality_BUTCHER );

int time_to_cut = 0;
switch( corpse.size ) {
Expand Down Expand Up @@ -1038,13 +1038,13 @@ void activity_handlers::butcher_finish( player_activity *act, player *p )
}

int skill_level = p->get_skill_level( skill_survival );
int factor = p->max_quality( action == DISSECT ? qual_CUT_FINE :
qual_BUTCHER );
int factor = p->max_quality( action == DISSECT ? quality_CUT_FINE :
quality_BUTCHER );

// DISSECT has special case factor calculation and results.
if( action == DISSECT ) {
skill_level = p->get_skill_level( skill_firstaid );
skill_level += p->max_quality( qual_CUT_FINE );
skill_level += p->max_quality( quality_CUT_FINE );
skill_level += p->get_skill_level( skill_electronics ) / 2;
add_msg( m_debug, _( "Skill: %s" ), skill_level );
}
Expand Down Expand Up @@ -2854,7 +2854,7 @@ static void rod_fish( player *p, std::vector<monster *> &fishables )
//if the vector is empty (no fish around) the player is still given a small chance to get a (let us say it was hidden) fish
if( fishables.empty() ) {
const std::vector<mtype_id> fish_group = MonsterGroupManager::GetMonstersFromGroup(
mongroup_id( "GROUP_FISH" ) );
GROUP_FISH );
const mtype_id fish_mon = random_entry_ref( fish_group );
g->m.add_item_or_charges( p->pos(), item::make_corpse( fish_mon, calendar::turn + rng( 0_turns,
3_hours ) ) );
Expand Down
40 changes: 20 additions & 20 deletions src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ static bool are_requirements_nearby( const std::vector<tripoint> &loot_spots,
activity_to_restore == ACT_MULTIPLE_FISH;
bool found_welder = false;
for( item *elem : p.inv_dump() ) {
if( elem->has_quality( qual_WELD ) ) {
if( elem->has_quality( quality_WELD ) ) {
found_welder = true;
}
temp_inv += *elem;
Expand Down Expand Up @@ -1400,7 +1400,7 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe
if( act == ACT_MULTIPLE_CHOP_TREES ) {
if( g->m.has_flag( flag_TREE, src_loc ) || g->m.ter( src_loc ) == t_trunk ||
g->m.ter( src_loc ) == t_stump ) {
if( p.has_quality( qual_AXE ) ) {
if( p.has_quality( quality_AXE ) ) {
return activity_reason_info::ok( NEEDS_TREE_CHOPPING );
} else {
return activity_reason_info::fail( NEEDS_TREE_CHOPPING );
Expand Down Expand Up @@ -1436,16 +1436,16 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe
if( !b_rack_present || !g->m.has_nearby_table( src_loc, 2 ) ) {
return activity_reason_info::fail( NO_ZONE );
}
if( p.has_quality( quality_id( qual_BUTCHER ), 1 ) && ( p.has_quality( qual_SAW_W ) ||
p.has_quality( qual_SAW_M ) ) ) {
if( p.has_quality( quality_id( quality_BUTCHER ), 1 ) && ( p.has_quality( quality_SAW_W ) ||
p.has_quality( quality_SAW_M ) ) ) {
return activity_reason_info::ok( NEEDS_BIG_BUTCHERING );
} else {
return activity_reason_info::fail( NEEDS_BIG_BUTCHERING );
}
}
if( ( big_count > 0 && small_count > 0 ) || ( big_count == 0 ) ) {
// there are small corpses here, so we can ignore any big corpses here for the moment.
if( p.has_quality( qual_BUTCHER, 1 ) ) {
if( p.has_quality( quality_BUTCHER, 1 ) ) {
return activity_reason_info::ok( NEEDS_BUTCHERING );
} else {
return activity_reason_info::fail( NEEDS_BUTCHERING );
Expand All @@ -1459,7 +1459,7 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe
for( auto &i : g->m.i_at( src_loc ) ) {
if( i.typeId() == "log" ) {
// do we have an axe?
if( p.has_quality( qual_AXE, 1 ) ) {
if( p.has_quality( quality_AXE, 1 ) ) {
return activity_reason_info::ok( NEEDS_CHOPPING );
} else {
return activity_reason_info::fail( NEEDS_CHOPPING );
Expand Down Expand Up @@ -1506,7 +1506,7 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe
// simple work, pulling up plants, nothing else required.
return activity_reason_info::ok( NEEDS_HARVESTING );
} else if( g->m.has_flag( flag_PLOWABLE, src_loc ) && !g->m.has_furn( src_loc ) ) {
if( p.has_quality( qual_DIG, 1 ) ) {
if( p.has_quality( quality_DIG, 1 ) ) {
// we have a shovel/hoe already, great
return activity_reason_info::ok( NEEDS_TILLING );
} else {
Expand Down Expand Up @@ -2046,7 +2046,7 @@ static item *best_quality_item( player &p, const quality_id &qual )

static bool chop_plank_activity( player &p, const tripoint &src_loc )
{
item *best_qual = best_quality_item( p, qual_AXE );
item *best_qual = best_quality_item( p, quality_AXE );
if( !best_qual ) {
return false;
}
Expand Down Expand Up @@ -2314,7 +2314,7 @@ void activity_on_turn_move_loot( player_activity &act, player &p )
static int chop_moves( player &p, item *it )
{
// quality of tool
const int quality = it->get_quality( qual_AXE );
const int quality = it->get_quality( quality_AXE );

// attribute; regular tools - based on STR, powered tools - based on DEX
const int attr = it->has_flag( flag_POWERED ) ? p.dex_cur : p.str_cur;
Expand All @@ -2327,7 +2327,7 @@ static int chop_moves( player &p, item *it )

static bool chop_tree_activity( player &p, const tripoint &src_loc )
{
item *best_qual = best_quality_item( p, qual_AXE );
item *best_qual = best_quality_item( p, quality_AXE );
if( !best_qual ) {
return false;
}
Expand Down Expand Up @@ -2589,21 +2589,21 @@ static bool generic_multi_activity_check_requirement( player &p, const activity_
std::vector<std::vector<quality_requirement>> quality_comp_vector;
std::vector<std::vector<tool_comp>> tool_comp_vector;
if( reason == NEEDS_TILLING ) {
quality_comp_vector.push_back( std::vector<quality_requirement> { quality_requirement( qual_DIG, 1, 1 ) } );
quality_comp_vector.push_back( std::vector<quality_requirement> { quality_requirement( quality_DIG, 1, 1 ) } );
} else if( reason == NEEDS_CHOPPING || reason == NEEDS_TREE_CHOPPING ) {
quality_comp_vector.push_back( std::vector<quality_requirement> { quality_requirement( qual_AXE, 1, 1 ) } );
quality_comp_vector.push_back( std::vector<quality_requirement> { quality_requirement( quality_AXE, 1, 1 ) } );
} else if( reason == NEEDS_PLANTING ) {
requirement_comp_vector.push_back( std::vector<item_comp> { item_comp( itype_id( dynamic_cast<const plot_options &>
( zone->get_options() ).get_seed() ), 1 )
} );
} else if( reason == NEEDS_BUTCHERING || reason == NEEDS_BIG_BUTCHERING ) {
quality_comp_vector.push_back( std::vector<quality_requirement> { quality_requirement( qual_BUTCHER, 1, 1 ) } );
quality_comp_vector.push_back( std::vector<quality_requirement> { quality_requirement( quality_BUTCHER, 1, 1 ) } );
if( reason == NEEDS_BIG_BUTCHERING ) {
quality_comp_vector.push_back( std::vector<quality_requirement> { quality_requirement( qual_SAW_M, 1, 1 ), quality_requirement( qual_SAW_W, 1, 1 ) } );
quality_comp_vector.push_back( std::vector<quality_requirement> { quality_requirement( quality_SAW_M, 1, 1 ), quality_requirement( quality_SAW_W, 1, 1 ) } );
}

} else if( reason == NEEDS_FISHING ) {
quality_comp_vector.push_back( std::vector<quality_requirement> {quality_requirement( qual_FISHING, 1, 1 )} );
quality_comp_vector.push_back( std::vector<quality_requirement> {quality_requirement( quality_FISHING, 1, 1 )} );
}
// ok, we need a shovel/hoe/axe/etc
// this is an activity that only requires this one tool, so we will fetch and wield it.
Expand Down Expand Up @@ -2679,7 +2679,7 @@ static bool generic_multi_activity_do( player &p, const activity_id &act_id,
if( reason == NEEDS_HARVESTING && g->m.has_flag_furn( flag_GROWTH_HARVEST, src_loc ) ) {
iexamine::harvest_plant( p, src_loc, true );
} else if( reason == NEEDS_TILLING && g->m.has_flag( flag_PLOWABLE, src_loc ) &&
p.has_quality( qual_DIG, 1 ) && !g->m.has_furn( src_loc ) ) {
p.has_quality( quality_DIG, 1 ) && !g->m.has_furn( src_loc ) ) {
p.assign_activity( ACT_CHURN, 18000, -1 );
p.backlog.push_front( act_id );
p.activity.placement = src;
Expand All @@ -2700,7 +2700,7 @@ static bool generic_multi_activity_do( player &p, const activity_id &act_id,
iexamine::plant_seed( p, src_loc, itype_id( seed ) );
break;
}
} else if( reason == NEEDS_CHOPPING && p.has_quality( qual_AXE, 1 ) ) {
} else if( reason == NEEDS_CHOPPING && p.has_quality( quality_AXE, 1 ) ) {
if( chop_plank_activity( p, src_loc ) ) {
p.backlog.push_front( act_id );
return false;
Expand Down Expand Up @@ -2729,16 +2729,16 @@ static bool generic_multi_activity_do( player &p, const activity_id &act_id,
// Because some player activities are necessarily not marked as auto-resume.
activity_handlers::resume_for_multi_activities( p );
return false;
} else if( reason == NEEDS_TREE_CHOPPING && p.has_quality( qual_AXE, 1 ) ) {
} else if( reason == NEEDS_TREE_CHOPPING && p.has_quality( quality_AXE, 1 ) ) {
p.backlog.push_front( act_id );
if( chop_tree_activity( p, src_loc ) ) {
return false;
}
} else if( reason == NEEDS_FISHING && p.has_quality( qual_FISHING, 1 ) ) {
} else if( reason == NEEDS_FISHING && p.has_quality( quality_FISHING, 1 ) ) {
p.backlog.push_front( act_id );
// we dont want to keep repeating the fishing activity, just piggybacking on this functions structure to find requirements.
p.activity = player_activity();
item *best_rod = best_quality_item( p, qual_FISHING );
item *best_rod = best_quality_item( p, quality_FISHING );
p.assign_activity( ACT_FISH, to_moves<int>( 5_hours ), 0,
p.get_item_position( best_rod ), best_rod->tname() );
p.activity.coord_set = g->get_fishable_locations( ACTIVITY_SEARCH_DISTANCE, src_loc );
Expand Down
39 changes: 21 additions & 18 deletions src/cata_string_consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,8 @@ static const trait_id trait_WOOLALLERGY( "WOOLALLERGY" );
static const trait_id trait_XS( "XS" );
static const trait_id trait_XXXL( "XXXL" );


static const mongroup_id GROUP_ANT( "GROUP_ANT" );
static const mongroup_id GROUP_ANT_ACID( "GROUP_ANT_ACID" );
static const mongroup_id GROUP_BLOB( "GROUP_BLOB" );
static const mongroup_id GROUP_BREATHER( "GROUP_BREATHER" );
static const mongroup_id GROUP_BREATHER_HUB( "GROUP_BREATHER_HUB" );
Expand Down Expand Up @@ -757,6 +758,7 @@ static const mongroup_id GROUP_WORM( "GROUP_WORM" );
static const mongroup_id GROUP_ZOMBIE( "GROUP_ZOMBIE" );
static const mongroup_id GROUP_ZOMBIE_COP( "GROUP_ZOMBIE_COP" );


static const mtype_id mon_amigara_horror( "mon_amigara_horror" );
static const mtype_id mon_ant( "mon_ant" );
static const mtype_id mon_ant_acid_larva( "mon_ant_acid_larva" );
Expand Down Expand Up @@ -898,6 +900,7 @@ static const mtype_id mon_zombie_hazmat( "mon_zombie_hazmat" );
static const mtype_id mon_zombie_hulk( "mon_zombie_hulk" );
static const mtype_id mon_zombie_hunter( "mon_zombie_hunter" );
static const mtype_id mon_zombie_jackson( "mon_zombie_jackson" );
static const mtype_id mon_zombie_kevlar_2( "mon_zombie_kevlar_2" );
static const mtype_id mon_zombie_master( "mon_zombie_master" );
static const mtype_id mon_zombie_military_pilot( "mon_zombie_military_pilot" );
static const mtype_id mon_zombie_necro( "mon_zombie_necro" );
Expand Down Expand Up @@ -1314,23 +1317,23 @@ static const skill_id skill_traps( "traps" );
static const skill_id skill_unarmed( "unarmed" );
static const skill_id skill_weapon( "weapon" );

static const quality_id qual_ANESTHESIA( "ANESTHESIA" );
static const quality_id qual_AXE( "AXE" );
static const quality_id qual_BUTCHER( "BUTCHER" );
static const quality_id qual_CUT( "CUT" );
static const quality_id qual_CUT_FINE( "CUT_FINE" );
static const quality_id qual_DIG( "DIG" );
static const quality_id qual_DRILL( "DRILL" );
static const quality_id qual_FISHING( "FISHING" );
static const quality_id qual_HAMMER( "HAMMER" );
static const quality_id qual_JACK( "JACK" );
static const quality_id qual_LIFT( "LIFT" );
static const quality_id qual_PRY( "PRY" );
static const quality_id qual_SAW_M( "SAW_M" );
static const quality_id qual_SAW_W( "SAW_W" );
static const quality_id qual_SCREW_FINE( "SCREW_FINE" );
static const quality_id qual_SELF_JACK( "SELF_JACK" );
static const quality_id qual_WELD( "WELD" );
static const quality_id quality_ANESTHESIA( "ANESTHESIA" );
static const quality_id quality_AXE( "AXE" );
static const quality_id quality_BUTCHER( "BUTCHER" );
static const quality_id quality_CUT( "CUT" );
static const quality_id quality_CUT_FINE( "CUT_FINE" );
static const quality_id quality_DIG( "DIG" );
static const quality_id quality_DRILL( "DRILL" );
static const quality_id quality_FISHING( "FISHING" );
static const quality_id quality_HAMMER( "HAMMER" );
static const quality_id quality_JACK( "JACK" );
static const quality_id quality_LIFT( "LIFT" );
static const quality_id quality_PRY( "PRY" );
static const quality_id quality_SAW_M( "SAW_M" );
static const quality_id quality_SAW_W( "SAW_W" );
static const quality_id quality_SCREW_FINE( "SCREW_FINE" );
static const quality_id quality_SELF_JACK( "SELF_JACK" );
static const quality_id quality_WELD( "WELD" );

static const zone_type_id zone_investigate_only( "NPC_INVESTIGATE_ONLY" );
static const zone_type_id zone_no_investigate( "NPC_NO_INVESTIGATE" );
Expand Down
7 changes: 3 additions & 4 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1939,17 +1939,16 @@ int Character::best_nearby_lifting_assist() const

int Character::best_nearby_lifting_assist( const tripoint &world_pos ) const
{
const quality_id LIFT( "LIFT" );
int mech_lift = 0;
if( is_mounted() ) {
auto mons = mounted_creature.get();
if( mons->has_flag( MF_RIDEABLE_MECH ) ) {
mech_lift = mons->mech_str_addition() + 10;
}
}
return std::max( { this->max_quality( LIFT ), mech_lift,
map_selector( this->pos(), PICKUP_RANGE ).max_quality( LIFT ),
vehicle_selector( world_pos, 4, true, true ).max_quality( LIFT )
return std::max( { this->max_quality( quality_LIFT ), mech_lift,
map_selector( this->pos(), PICKUP_RANGE ).max_quality( quality_LIFT ),
vehicle_selector( world_pos, 4, true, true ).max_quality( quality_LIFT )
} );
}

Expand Down
2 changes: 1 addition & 1 deletion src/construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ void construct::done_grave( const tripoint &p )
g->u.getID(), it.get_mtype()->id, it.get_corpse_name() );
}
}
if( g->u.has_quality( qual_CUT ) ) {
if( g->u.has_quality( quality_CUT ) ) {
iuse::handle_ground_graffiti( g->u, nullptr, _( "Inscribe something on the grave?" ), p );
} else {
add_msg( m_neutral,
Expand Down
12 changes: 6 additions & 6 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4426,7 +4426,7 @@ void game::use_computer( const tripoint &p )
return;
}
if( u.has_trait( trait_HYPEROPIC ) && !u.worn_with_flag( flag_FIX_FARSIGHT ) &&
!u.has_effect( effect_contacts ) && !u.has_bionic( bionic_id( "bio_eye_optic" ) ) ) {
!u.has_effect( effect_contacts ) && !u.has_bionic( bio_eye_optic ) ) {
add_msg( m_info, _( "You'll need to put on reading glasses before you can see the screen." ) );
return;
}
Expand Down Expand Up @@ -7813,12 +7813,12 @@ static void butcher_submenu( const std::vector<map_stack::iterator> &corpses, in
};
const bool enough_light = g->u.fine_detail_vision_mod() <= 4;

const int factor = g->u.max_quality( qual_BUTCHER );
const int factor = g->u.max_quality( quality_BUTCHER );
const std::string msgFactor = factor > INT_MIN
? string_format( _( "Your best tool has %d butchering." ), factor )
: _( "You have no butchering tool." );

const int factorD = g->u.max_quality( qual_CUT_FINE );
const int factorD = g->u.max_quality( quality_CUT_FINE );
const std::string msgFactorD = factorD > INT_MIN
? string_format( _( "Your best tool has %d fine cutting." ), factorD )
: _( "You have no fine cutting tool." );
Expand Down Expand Up @@ -7945,8 +7945,8 @@ void game::butcher()
return;
}

const int factor = u.max_quality( qual_BUTCHER );
const int factorD = u.max_quality( qual_CUT_FINE );
const int factor = u.max_quality( quality_BUTCHER );
const int factorD = u.max_quality( quality_CUT_FINE );
const std::string no_knife_msg = _( "You don't have a butchering tool." );
const std::string no_corpse_msg = _( "There are no corpses here to butcher." );

Expand Down Expand Up @@ -9178,7 +9178,7 @@ point game::place_player( const tripoint &dest_loc )
}

const std::string pulp_butcher = get_option<std::string>( "AUTO_PULP_BUTCHER" );
if( pulp_butcher == "butcher" && u.max_quality( qual_BUTCHER ) > INT_MIN ) {
if( pulp_butcher == "butcher" && u.max_quality( quality_BUTCHER ) > INT_MIN ) {
std::vector<item *> corpses;

for( item &it : m.i_at( u.pos() ) ) {
Expand Down
Loading

0 comments on commit 9c9835f

Please sign in to comment.