From 4e744b47a5e19744863af3daacf2cd7c11628cee Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Tue, 14 Apr 2020 15:08:27 +0300 Subject: [PATCH 1/3] Make do_activity_reason a class enum --- src/activity_handlers.h | 2 +- src/activity_item_handling.cpp | 230 ++++++++++++++++++--------------- 2 files changed, 130 insertions(+), 102 deletions(-) diff --git a/src/activity_handlers.h b/src/activity_handlers.h index 5fc2f76233015..fcc46e16f138d 100644 --- a/src/activity_handlers.h +++ b/src/activity_handlers.h @@ -37,7 +37,7 @@ enum butcher_type : int { DISSECT // dissect a corpse for CBMs }; -enum do_activity_reason : int { +enum class do_activity_reason : int { CAN_DO_CONSTRUCTION, // Can do construction. CAN_DO_FETCH, // Can do fetch - this is usually the default result for fetch task CAN_DO_PREREQ, // for constructions - can't build the main construction, but can build the pre-req diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index 7125c222d5958..769f81af0e6b7 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -1027,11 +1027,11 @@ static activity_reason_info find_base_construction( if( !build.post_terrain.empty() ) { if( build.post_is_furniture ) { if( furn_id( build.post_terrain ) == furn ) { - return activity_reason_info::build( ALREADY_DONE, false, idx ); + return activity_reason_info::build( do_activity_reason::ALREADY_DONE, false, idx ); } } else { if( ter_id( build.post_terrain ) == ter ) { - return activity_reason_info::build( ALREADY_DONE, false, idx ); + return activity_reason_info::build( do_activity_reason::ALREADY_DONE, false, idx ); } } } @@ -1039,30 +1039,30 @@ static activity_reason_info find_base_construction( const bool has_skill = p.meets_skill_requirements( build ); if( part_con_idx && *part_con_idx == idx ) { if( !has_skill ) { - return activity_reason_info::build( DONT_HAVE_SKILL, false, idx ); + return activity_reason_info::build( do_activity_reason::DONT_HAVE_SKILL, false, idx ); } - return activity_reason_info::build( CAN_DO_CONSTRUCTION, true, idx ); + return activity_reason_info::build( do_activity_reason::CAN_DO_CONSTRUCTION, true, idx ); } //can build? const bool cc = can_construct( build, loc ); const bool pcb = player_can_build( p, inv, build ); if( !has_skill ) { - return activity_reason_info::build( DONT_HAVE_SKILL, false, idx ); + return activity_reason_info::build( do_activity_reason::DONT_HAVE_SKILL, false, idx ); } if( cc ) { if( pcb ) { - return activity_reason_info::build( CAN_DO_CONSTRUCTION, true, idx ); + return activity_reason_info::build( do_activity_reason::CAN_DO_CONSTRUCTION, true, idx ); } //can't build with current inventory, do not look for pre-req - return activity_reason_info::build( NO_COMPONENTS, false, idx ); + return activity_reason_info::build( do_activity_reason::NO_COMPONENTS, false, idx ); } // there are no pre-requisites. // so we need to potentially fetch components if( build.pre_terrain.empty() && build.pre_special( loc ) ) { - return activity_reason_info::build( NO_COMPONENTS, false, idx ); + return activity_reason_info::build( do_activity_reason::NO_COMPONENTS, false, idx ); } else if( !build.pre_special( loc ) ) { - return activity_reason_info::build( BLOCKING_TILE, false, idx ); + return activity_reason_info::build( do_activity_reason::BLOCKING_TILE, false, idx ); } // can't build it @@ -1074,7 +1074,7 @@ static activity_reason_info find_base_construction( ( !build.pre_is_furniture && ter_id( build.pre_terrain ) == ter ) ) ) { // the pre-req is already built, so the reason is due to lack of tools/components - return activity_reason_info::build( NO_COMPONENTS, false, idx ); + return activity_reason_info::build( do_activity_reason::NO_COMPONENTS, false, idx ); } //we can't immediately build it, looking for pre-req @@ -1106,14 +1106,15 @@ static activity_reason_info find_base_construction( activity_reason_info act_info_pre = find_base_construction( list_constructions, p, inv, loc, part_con_idx, pre_build.id, used ); if( act_info_pre.can_do ) { - return activity_reason_info::build( CAN_DO_PREREQ, true, *act_info_pre.con_idx ); + return activity_reason_info::build( do_activity_reason::CAN_DO_PREREQ, true, + *act_info_pre.con_idx ); } //find first pre-req failed reason if( !reason ) { reason = act_info_pre.reason; pre_req_idx = *act_info_pre.con_idx; } - if( act_info_pre.reason == ALREADY_DONE ) { + if( act_info_pre.reason == do_activity_reason::ALREADY_DONE ) { //pre-req is already here, but we still can't build over it reason.reset(); break; @@ -1122,20 +1123,20 @@ static activity_reason_info find_base_construction( } //have a partial construction which is not leading to the required construction if( part_con_idx ) { - return activity_reason_info::build( BLOCKING_TILE, false, idx ); + return activity_reason_info::build( do_activity_reason::BLOCKING_TILE, false, idx ); } //pre-req failed? if( reason ) { - if( *reason == NO_COMPONENTS ) { - return activity_reason_info::build( NO_COMPONENTS_PREREQ, false, pre_req_idx ); + if( *reason == do_activity_reason::NO_COMPONENTS ) { + return activity_reason_info::build( do_activity_reason::NO_COMPONENTS_PREREQ, false, pre_req_idx ); } return activity_reason_info::build( *reason, false, pre_req_idx ); } if( !pcb ) { - return activity_reason_info::build( NO_COMPONENTS, false, idx ); + return activity_reason_info::build( do_activity_reason::NO_COMPONENTS, false, idx ); } //only cc failed, no pre-req - return activity_reason_info::build( BLOCKING_TILE, false, idx ); + return activity_reason_info::build( do_activity_reason::BLOCKING_TILE, false, idx ); } static std::string random_string( size_t length ) @@ -1266,11 +1267,11 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe std::vector already_working_indexes; vehicle *veh = veh_pointer_or_null( g->m.veh_at( src_loc ) ); if( !veh ) { - return activity_reason_info::fail( NO_ZONE ); + return activity_reason_info::fail( do_activity_reason::NO_ZONE ); } // if the vehicle is moving or player is controlling it. if( std::abs( veh->velocity ) > 100 || veh->player_in_control( g->u ) ) { - return activity_reason_info::fail( NO_ZONE ); + return activity_reason_info::fail( do_activity_reason::NO_ZONE ); } for( const npc &guy : g->all_npcs() ) { if( &guy == &p ) { @@ -1285,7 +1286,7 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe // then discount, don't need to move each other out of the way. if( g->m.getlocal( g->u.activity.placement ) == src_loc || guy_work_spot == src_loc || guy.pos() == src_loc || ( p.is_npc() && g->u.pos() == src_loc ) ) { - return activity_reason_info::fail( ALREADY_WORKING ); + return activity_reason_info::fail( do_activity_reason::ALREADY_WORKING ); } if( guy_work_spot != tripoint_zero ) { vehicle *other_veh = veh_pointer_or_null( g->m.veh_at( guy_work_spot ) ); @@ -1338,9 +1339,9 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe // temporarily store the intended index, we do this so two NPCs don't try and work on the same part at same time. p.activity_vehicle_part_index = vpindex; if( !can_make ) { - return activity_reason_info::fail( NEEDS_VEH_DECONST ); + return activity_reason_info::fail( do_activity_reason::NEEDS_VEH_DECONST ); } else { - return activity_reason_info::ok( NEEDS_VEH_DECONST ); + return activity_reason_info::ok( do_activity_reason::NEEDS_VEH_DECONST ); } } } else if( act == ACT_VEHICLE_REPAIR ) { @@ -1369,52 +1370,52 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe // temporarily store the intended index, we do this so two NPCs don't try and work on the same part at same time. p.activity_vehicle_part_index = vpindex; if( !can_make ) { - return activity_reason_info::fail( NEEDS_VEH_REPAIR ); + return activity_reason_info::fail( do_activity_reason::NEEDS_VEH_REPAIR ); } else { - return activity_reason_info::ok( NEEDS_VEH_REPAIR ); + return activity_reason_info::ok( do_activity_reason::NEEDS_VEH_REPAIR ); } } } p.activity_vehicle_part_index = -1; - return activity_reason_info::fail( NO_ZONE ); + return activity_reason_info::fail( do_activity_reason::NO_ZONE ); } if( act == ACT_MULTIPLE_MINE ) { if( !g->m.has_flag( "MINEABLE", src_loc ) ) { - return activity_reason_info::fail( NO_ZONE ); + return activity_reason_info::fail( do_activity_reason::NO_ZONE ); } std::vector mining_inv = p.items_with( []( const item & itm ) { return ( itm.has_flag( flag_DIG_TOOL ) && !itm.type->can_use( "JACKHAMMER" ) ) || ( itm.type->can_use( "JACKHAMMER" ) && itm.ammo_sufficient() ); } ); if( mining_inv.empty() ) { - return activity_reason_info::fail( NEEDS_MINING ); + return activity_reason_info::fail( do_activity_reason::NEEDS_MINING ); } else { - return activity_reason_info::ok( NEEDS_MINING ); + return activity_reason_info::ok( do_activity_reason::NEEDS_MINING ); } } if( act == ACT_MULTIPLE_FISH ) { if( !g->m.has_flag( flag_FISHABLE, src_loc ) ) { - return activity_reason_info::fail( NO_ZONE ); + return activity_reason_info::fail( do_activity_reason::NO_ZONE ); } std::vector rod_inv = p.items_with( []( const item & itm ) { return itm.has_flag( flag_FISH_POOR ) || itm.has_flag( flag_FISH_GOOD ); } ); if( rod_inv.empty() ) { - return activity_reason_info::fail( NEEDS_FISHING ); + return activity_reason_info::fail( do_activity_reason::NEEDS_FISHING ); } else { - return activity_reason_info::ok( NEEDS_FISHING ); + return activity_reason_info::ok( do_activity_reason::NEEDS_FISHING ); } } 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 ) ) { - return activity_reason_info::ok( NEEDS_TREE_CHOPPING ); + return activity_reason_info::ok( do_activity_reason::NEEDS_TREE_CHOPPING ); } else { - return activity_reason_info::fail( NEEDS_TREE_CHOPPING ); + return activity_reason_info::fail( do_activity_reason::NEEDS_TREE_CHOPPING ); } } else { - return activity_reason_info::fail( NO_ZONE ); + return activity_reason_info::fail( do_activity_reason::NO_ZONE ); } } if( act == ACT_MULTIPLE_BUTCHER ) { @@ -1442,25 +1443,25 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe if( !corpses.empty() ) { if( big_count > 0 && small_count == 0 ) { if( !b_rack_present || !g->m.has_nearby_table( src_loc, 2 ) ) { - return activity_reason_info::fail( NO_ZONE ); + return activity_reason_info::fail( do_activity_reason::NO_ZONE ); } if( p.has_quality( quality_id( qual_BUTCHER ), 1 ) && ( p.has_quality( qual_SAW_W ) || p.has_quality( qual_SAW_M ) ) ) { - return activity_reason_info::ok( NEEDS_BIG_BUTCHERING ); + return activity_reason_info::ok( do_activity_reason::NEEDS_BIG_BUTCHERING ); } else { - return activity_reason_info::fail( NEEDS_BIG_BUTCHERING ); + return activity_reason_info::fail( do_activity_reason::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 ) ) { - return activity_reason_info::ok( NEEDS_BUTCHERING ); + return activity_reason_info::ok( do_activity_reason::NEEDS_BUTCHERING ); } else { - return activity_reason_info::fail( NEEDS_BUTCHERING ); + return activity_reason_info::fail( do_activity_reason::NEEDS_BUTCHERING ); } } } - return activity_reason_info::fail( NO_ZONE ); + return activity_reason_info::fail( do_activity_reason::NO_ZONE ); } if( act == ACT_MULTIPLE_CHOP_PLANKS ) { //are there even any logs there? @@ -1468,20 +1469,20 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe if( i.typeId() == "log" ) { // do we have an axe? if( p.has_quality( qual_AXE, 1 ) ) { - return activity_reason_info::ok( NEEDS_CHOPPING ); + return activity_reason_info::ok( do_activity_reason::NEEDS_CHOPPING ); } else { - return activity_reason_info::fail( NEEDS_CHOPPING ); + return activity_reason_info::fail( do_activity_reason::NEEDS_CHOPPING ); } } } - return activity_reason_info::fail( NO_ZONE ); + return activity_reason_info::fail( do_activity_reason::NO_ZONE ); } if( act == ACT_TIDY_UP ) { if( mgr.has_near( zone_type_LOOT_UNSORTED, g->m.getabs( src_loc ), distance ) || mgr.has_near( z_camp_storage, g->m.getabs( src_loc ), distance ) ) { - return activity_reason_info::ok( CAN_DO_FETCH ); + return activity_reason_info::ok( do_activity_reason::CAN_DO_FETCH ); } - return activity_reason_info::fail( NO_ZONE ); + return activity_reason_info::fail( do_activity_reason::NO_ZONE ); } if( act == ACT_MULTIPLE_CONSTRUCTION ) { const std::vector &list_constructions = get_constructions(); @@ -1500,7 +1501,7 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe const blueprint_options &options = dynamic_cast( zone.get_options() ); const construction_id index = options.get_index(); if( !stuff_there.empty() ) { - return activity_reason_info::build( BLOCKING_TILE, false, index ); + return activity_reason_info::build( do_activity_reason::BLOCKING_TILE, false, index ); } std::set used_idx; const activity_reason_info act_info = find_base_construction( list_constructions, p, pre_inv, @@ -1513,19 +1514,19 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe for( const zone_data &zone : zones ) { if( g->m.has_flag_furn( flag_GROWTH_HARVEST, src_loc ) ) { // simple work, pulling up plants, nothing else required. - return activity_reason_info::ok( NEEDS_HARVESTING ); + return activity_reason_info::ok( do_activity_reason::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 ) ) { // we have a shovel/hoe already, great - return activity_reason_info::ok( NEEDS_TILLING ); + return activity_reason_info::ok( do_activity_reason::NEEDS_TILLING ); } else { // we need a shovel/hoe - return activity_reason_info::fail( NEEDS_TILLING ); + return activity_reason_info::fail( do_activity_reason::NEEDS_TILLING ); } } else if( g->m.has_flag_ter_or_furn( flag_PLANTABLE, src_loc ) && warm_enough_to_plant( src_loc ) ) { if( g->m.has_items( src_loc ) ) { - return activity_reason_info::fail( BLOCKING_TILE ); + return activity_reason_info::fail( do_activity_reason::BLOCKING_TILE ); } else { // do we have the required seed on our person? const plot_options &options = dynamic_cast( zone.get_options() ); @@ -1533,14 +1534,14 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe // If its a farm zone with no specified seed, and we've checked for tilling and harvesting. // then it means no further work can be done here if( seed.empty() ) { - return activity_reason_info::fail( ALREADY_DONE ); + return activity_reason_info::fail( do_activity_reason::ALREADY_DONE ); } std::vector seed_inv = p.items_with( []( const item & itm ) { return itm.is_seed(); } ); for( const auto elem : seed_inv ) { if( elem->typeId() == itype_id( seed ) ) { - return activity_reason_info::ok( NEEDS_PLANTING ); + return activity_reason_info::ok( do_activity_reason::NEEDS_PLANTING ); } } // didn't find the seed, but maybe there are overlapping farm zones @@ -1550,20 +1551,20 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe } else { // can't plant, till or harvest - return activity_reason_info::fail( ALREADY_DONE ); + return activity_reason_info::fail( do_activity_reason::ALREADY_DONE ); } } // looped through all zones, and only got here if its plantable, but have no seeds. - return activity_reason_info::fail( NEEDS_PLANTING ); + return activity_reason_info::fail( do_activity_reason::NEEDS_PLANTING ); } else if( act == ACT_FETCH_REQUIRED ) { // we check if its possible to get all the requirements for fetching at two other places. // 1. before we even assign the fetch activity and; // 2. when we form the src_set to loop through at the beginning of the fetch activity. - return activity_reason_info::ok( CAN_DO_FETCH ); + return activity_reason_info::ok( do_activity_reason::CAN_DO_FETCH ); } // Shouldn't get here because the zones were checked previously. if it does, set enum reason as "no zone" - return activity_reason_info::fail( NO_ZONE ); + return activity_reason_info::fail( do_activity_reason::NO_ZONE ); } static void add_basecamp_storage_to_loot_zone_list( zone_manager &mgr, const tripoint &src_loc, @@ -2052,7 +2053,7 @@ static bool butcher_corpse_activity( player &p, const tripoint &src_loc, for( auto &elem : items ) { if( elem.is_corpse() && !elem.has_var( "activity_var" ) ) { const mtype corpse = *elem.get_mtype(); - if( corpse.size >= MS_MEDIUM && reason != NEEDS_BIG_BUTCHERING ) { + if( corpse.size >= MS_MEDIUM && reason != do_activity_reason::NEEDS_BIG_BUTCHERING ) { continue; } elem.set_var( "activity_var", p.name ); @@ -2615,21 +2616,30 @@ static requirement_check_result generic_multi_activity_check_requirement( player if( can_do_it ) { return CAN_DO_LOCATION; } - if( reason == DONT_HAVE_SKILL || reason == NO_ZONE || reason == ALREADY_DONE || - reason == BLOCKING_TILE || reason == UNKNOWN_ACTIVITY ) { + if( reason == do_activity_reason::DONT_HAVE_SKILL || + reason == do_activity_reason::NO_ZONE || + reason == do_activity_reason::ALREADY_DONE || + reason == do_activity_reason::BLOCKING_TILE || + reason == do_activity_reason::UNKNOWN_ACTIVITY ) { // we can discount this tile, the work can't be done. - if( reason == DONT_HAVE_SKILL ) { + if( reason == do_activity_reason::DONT_HAVE_SKILL ) { p.add_msg_if_player( m_info, _( "You don't have the skill for this task." ) ); - } else if( reason == BLOCKING_TILE ) { + } else if( reason == do_activity_reason::BLOCKING_TILE ) { p.add_msg_if_player( m_info, _( "There is something blocking the location for this task." ) ); } return SKIP_LOCATION; - } else if( reason == NO_COMPONENTS || reason == NO_COMPONENTS_PREREQ || - reason == NO_COMPONENTS_PREREQ_2 || reason == NEEDS_PLANTING || - reason == NEEDS_TILLING || reason == NEEDS_CHOPPING || reason == NEEDS_BUTCHERING || - reason == NEEDS_BIG_BUTCHERING || reason == NEEDS_VEH_DECONST || reason == NEEDS_VEH_REPAIR || - reason == NEEDS_TREE_CHOPPING || - reason == NEEDS_FISHING || reason == NEEDS_MINING ) { + } else if( reason == do_activity_reason::NO_COMPONENTS || + reason == do_activity_reason::NO_COMPONENTS_PREREQ || + reason == do_activity_reason::NO_COMPONENTS_PREREQ_2 || + reason == do_activity_reason::NEEDS_PLANTING || + reason == do_activity_reason::NEEDS_TILLING || + reason == do_activity_reason::NEEDS_CHOPPING || + reason == do_activity_reason::NEEDS_BUTCHERING || + reason == do_activity_reason::NEEDS_BIG_BUTCHERING || + reason == do_activity_reason::NEEDS_VEH_DECONST || + reason == do_activity_reason::NEEDS_VEH_REPAIR || + reason == do_activity_reason::NEEDS_TREE_CHOPPING || + reason == do_activity_reason::NEEDS_FISHING || reason == do_activity_reason::NEEDS_MINING ) { // we can do it, but we need to fetch some stuff first // before we set the task to fetch components - is it even worth it? are the components anywhere? requirement_id what_we_need; @@ -2645,8 +2655,9 @@ static requirement_check_result generic_multi_activity_check_requirement( player } add_basecamp_storage_to_loot_zone_list( mgr, src_loc, p, loot_zone_spots, combined_spots ); - if( ( reason == NO_COMPONENTS || reason == NO_COMPONENTS_PREREQ || - reason == NO_COMPONENTS_PREREQ_2 ) && + if( ( reason == do_activity_reason::NO_COMPONENTS || + reason == do_activity_reason::NO_COMPONENTS_PREREQ || + reason == do_activity_reason::NO_COMPONENTS_PREREQ_2 ) && act_id == ACT_MULTIPLE_CONSTRUCTION ) { if( !act_info.con_idx ) { debugmsg( "no construction selected" ); @@ -2655,7 +2666,8 @@ static requirement_check_result generic_multi_activity_check_requirement( player // its a construction and we need the components. const construction &built_chosen = act_info.con_idx->obj(); what_we_need = built_chosen.requirements; - } else if( reason == NEEDS_VEH_DECONST || reason == NEEDS_VEH_REPAIR ) { + } else if( reason == do_activity_reason::NEEDS_VEH_DECONST || + reason == do_activity_reason::NEEDS_VEH_REPAIR ) { const vehicle *veh = veh_pointer_or_null( g->m.veh_at( src_loc ) ); // we already checked this in can_do_activity() but check again just incase. if( !veh ) { @@ -2664,38 +2676,44 @@ static requirement_check_result generic_multi_activity_check_requirement( player } const vpart_info &vpinfo = veh->part_info( p.activity_vehicle_part_index ); requirement_data reqs; - if( reason == NEEDS_VEH_DECONST ) { + if( reason == do_activity_reason::NEEDS_VEH_DECONST ) { reqs = vpinfo.removal_requirements(); - } else if( reason == NEEDS_VEH_REPAIR ) { + } else if( reason == do_activity_reason::NEEDS_VEH_REPAIR ) { reqs = vpinfo.repair_requirements(); } const std::string ran_str = random_string( 10 ); const requirement_id req_id( ran_str ); requirement_data::save_requirement( reqs, req_id ); what_we_need = req_id; - } else if( reason == NEEDS_MINING ) { + } else if( reason == do_activity_reason::NEEDS_MINING ) { what_we_need = requirement_id( "mining_standard" ); - } else if( reason == NEEDS_TILLING || reason == NEEDS_PLANTING || reason == NEEDS_CHOPPING || - reason == NEEDS_BUTCHERING || reason == NEEDS_BIG_BUTCHERING || reason == NEEDS_TREE_CHOPPING || - reason == NEEDS_FISHING ) { + } else if( reason == do_activity_reason::NEEDS_TILLING || + reason == do_activity_reason::NEEDS_PLANTING || + reason == do_activity_reason::NEEDS_CHOPPING || + reason == do_activity_reason::NEEDS_BUTCHERING || + reason == do_activity_reason::NEEDS_BIG_BUTCHERING || + reason == do_activity_reason::NEEDS_TREE_CHOPPING || + reason == do_activity_reason::NEEDS_FISHING ) { std::vector> requirement_comp_vector; std::vector> quality_comp_vector; std::vector> tool_comp_vector; - if( reason == NEEDS_TILLING ) { + if( reason == do_activity_reason::NEEDS_TILLING ) { quality_comp_vector.push_back( std::vector { quality_requirement( qual_DIG, 1, 1 ) } ); - } else if( reason == NEEDS_CHOPPING || reason == NEEDS_TREE_CHOPPING ) { + } else if( reason == do_activity_reason::NEEDS_CHOPPING || + reason == do_activity_reason::NEEDS_TREE_CHOPPING ) { quality_comp_vector.push_back( std::vector { quality_requirement( qual_AXE, 1, 1 ) } ); - } else if( reason == NEEDS_PLANTING ) { + } else if( reason == do_activity_reason::NEEDS_PLANTING ) { requirement_comp_vector.push_back( std::vector { item_comp( itype_id( dynamic_cast ( zone->get_options() ).get_seed() ), 1 ) } ); - } else if( reason == NEEDS_BUTCHERING || reason == NEEDS_BIG_BUTCHERING ) { + } else if( reason == do_activity_reason::NEEDS_BUTCHERING || + reason == do_activity_reason::NEEDS_BIG_BUTCHERING ) { quality_comp_vector.push_back( std::vector { quality_requirement( qual_BUTCHER, 1, 1 ) } ); - if( reason == NEEDS_BIG_BUTCHERING ) { + if( reason == do_activity_reason::NEEDS_BIG_BUTCHERING ) { quality_comp_vector.push_back( std::vector { quality_requirement( qual_SAW_M, 1, 1 ), quality_requirement( qual_SAW_W, 1, 1 ) } ); } - } else if( reason == NEEDS_FISHING ) { + } else if( reason == do_activity_reason::NEEDS_FISHING ) { quality_comp_vector.push_back( std::vector {quality_requirement( qual_FISHING, 1, 1 )} ); } // ok, we need a shovel/hoe/axe/etc. @@ -2707,15 +2725,21 @@ static requirement_check_result generic_multi_activity_check_requirement( player requirement_data::save_requirement( reqs_data, req_id ); what_we_need = req_id; } - bool tool_pickup = reason == NEEDS_TILLING || reason == NEEDS_PLANTING || - reason == NEEDS_CHOPPING || reason == NEEDS_BUTCHERING || reason == NEEDS_BIG_BUTCHERING || - reason == NEEDS_TREE_CHOPPING || reason == NEEDS_VEH_DECONST || reason == NEEDS_VEH_REPAIR || - reason == NEEDS_MINING; + bool tool_pickup = reason == do_activity_reason::NEEDS_TILLING || + reason == do_activity_reason::NEEDS_PLANTING || + reason == do_activity_reason::NEEDS_CHOPPING || + reason == do_activity_reason::NEEDS_BUTCHERING || + reason == do_activity_reason::NEEDS_BIG_BUTCHERING || + reason == do_activity_reason::NEEDS_TREE_CHOPPING || + reason == do_activity_reason::NEEDS_VEH_DECONST || + reason == do_activity_reason::NEEDS_VEH_REPAIR || + reason == do_activity_reason::NEEDS_MINING; // is it even worth fetching anything if there isn't enough nearby? if( !are_requirements_nearby( tool_pickup ? loot_zone_spots : combined_spots, what_we_need, p, act_id, tool_pickup, src_loc ) ) { p.add_msg_if_player( m_info, _( "The required items are not available to complete this task." ) ); - if( reason == NEEDS_VEH_DECONST || reason == NEEDS_VEH_REPAIR ) { + if( reason == do_activity_reason::NEEDS_VEH_DECONST || + reason == do_activity_reason::NEEDS_VEH_REPAIR ) { p.activity_vehicle_part_index = -1; } return SKIP_LOCATION; @@ -2725,7 +2749,7 @@ static requirement_check_result generic_multi_activity_check_requirement( player p.assign_activity( ACT_FETCH_REQUIRED ); player_activity &act_prev = p.backlog.front(); act_prev.str_values.push_back( what_we_need.str() ); - act_prev.values.push_back( reason ); + act_prev.values.push_back( static_cast( reason ) ); // come back here after successfully fetching your stuff if( act_prev.coords.empty() ) { std::vector local_src_set; @@ -2772,15 +2796,17 @@ static bool generic_multi_activity_do( player &p, const activity_id &act_id, const zone_data *zone = mgr.get_zone_at( src, get_zone_for_act( src_loc, mgr, act_id ) ); // something needs to be done, now we are there. // it was here earlier, in the space of one turn, maybe it got harvested by someone else. - if( reason == NEEDS_HARVESTING && g->m.has_flag_furn( flag_GROWTH_HARVEST, src_loc ) ) { + if( reason == do_activity_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 ) && + } else if( reason == do_activity_reason::NEEDS_TILLING && g->m.has_flag( flag_PLOWABLE, src_loc ) && p.has_quality( qual_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; return false; - } else if( reason == NEEDS_PLANTING && g->m.has_flag_ter_or_furn( flag_PLANTABLE, src_loc ) ) { + } else if( reason == do_activity_reason::NEEDS_PLANTING && + g->m.has_flag_ter_or_furn( flag_PLANTABLE, src_loc ) ) { std::vector zones = mgr.get_zones( zone_type_FARM_PLOT, g->m.getabs( src_loc ) ); for( const zone_data &zone : zones ) { @@ -2797,17 +2823,19 @@ static bool generic_multi_activity_do( player &p, const activity_id &act_id, p.backlog.push_front( act_id ); return false; } - } else if( reason == NEEDS_CHOPPING && p.has_quality( qual_AXE, 1 ) ) { + } else if( reason == do_activity_reason::NEEDS_CHOPPING && p.has_quality( qual_AXE, 1 ) ) { if( chop_plank_activity( p, src_loc ) ) { p.backlog.push_front( act_id ); return false; } - } else if( reason == NEEDS_BUTCHERING || reason == NEEDS_BIG_BUTCHERING ) { + } else if( reason == do_activity_reason::NEEDS_BUTCHERING || + reason == do_activity_reason::NEEDS_BIG_BUTCHERING ) { if( butcher_corpse_activity( p, src_loc, reason ) ) { p.backlog.push_front( act_id ); return false; } - } else if( reason == CAN_DO_CONSTRUCTION || reason == CAN_DO_PREREQ ) { + } else if( reason == do_activity_reason::CAN_DO_CONSTRUCTION || + reason == do_activity_reason::CAN_DO_PREREQ ) { if( g->m.partial_con_at( src_loc ) ) { p.backlog.push_front( act_id ); p.assign_activity( ACT_BUILD ); @@ -2817,11 +2845,11 @@ static bool generic_multi_activity_do( player &p, const activity_id &act_id, if( construction_activity( p, zone, src_loc, act_info, act_id ) ) { return false; } - } else if( reason == CAN_DO_FETCH && act_id == ACT_TIDY_UP ) { + } else if( reason == do_activity_reason::CAN_DO_FETCH && act_id == ACT_TIDY_UP ) { if( !tidy_activity( p, src_loc, act_id, ACTIVITY_SEARCH_DISTANCE ) ) { return false; } - } else if( reason == CAN_DO_FETCH && act_id == ACT_FETCH_REQUIRED ) { + } else if( reason == do_activity_reason::CAN_DO_FETCH && act_id == ACT_FETCH_REQUIRED ) { if( fetch_activity( p, src_loc, act_id, ACTIVITY_SEARCH_DISTANCE ) ) { if( !p.is_npc() ) { // Npcs will automatically start the next thing in the backlog, players need to be manually prompted @@ -2830,12 +2858,12 @@ static bool generic_multi_activity_do( player &p, const activity_id &act_id, } return false; } - } else if( reason == NEEDS_TREE_CHOPPING && p.has_quality( qual_AXE, 1 ) ) { + } else if( reason == do_activity_reason::NEEDS_TREE_CHOPPING && p.has_quality( qual_AXE, 1 ) ) { if( chop_tree_activity( p, src_loc ) ) { p.backlog.push_front( act_id ); return false; } - } else if( reason == NEEDS_FISHING && p.has_quality( qual_FISHING, 1 ) ) { + } else if( reason == do_activity_reason::NEEDS_FISHING && p.has_quality( qual_FISHING, 1 ) ) { p.backlog.push_front( act_id ); // we don't want to keep repeating the fishing activity, just piggybacking on this functions structure to find requirements. p.activity = player_activity(); @@ -2845,19 +2873,19 @@ static bool generic_multi_activity_do( player &p, const activity_id &act_id, p.activity.targets.push_back( item_location( p, best_rod ) ); p.activity.coord_set = g->get_fishable_locations( ACTIVITY_SEARCH_DISTANCE, src_loc ); return false; - } else if( reason == NEEDS_MINING ) { + } else if( reason == do_activity_reason::NEEDS_MINING ) { // if have enough batteries to continue etc. p.backlog.push_front( act_id ); if( mine_activity( p, src_loc ) ) { return false; } - } else if( reason == NEEDS_VEH_DECONST ) { + } else if( reason == do_activity_reason::NEEDS_VEH_DECONST ) { if( vehicle_activity( p, src_loc, p.activity_vehicle_part_index, 'o' ) ) { p.backlog.push_front( act_id ); return false; } p.activity_vehicle_part_index = -1; - } else if( reason == NEEDS_VEH_REPAIR ) { + } else if( reason == do_activity_reason::NEEDS_VEH_REPAIR ) { if( vehicle_activity( p, src_loc, p.activity_vehicle_part_index, 'r' ) ) { p.backlog.push_front( act_id ); return false; From f1de090b69b62a585dcb77136991bde9997ab6a0 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Tue, 14 Apr 2020 23:17:22 +0300 Subject: [PATCH 2/3] Make text_alignment a class enum --- src/cata_tiles.cpp | 6 +++--- src/cata_tiles.h | 8 ++++---- src/sdltiles.cpp | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index dbbff49c8c372..1f082ade9bbdf 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -165,15 +165,15 @@ formatted_text::formatted_text( const std::string &text, const int color, case direction::NORTHWEST: case direction::WEST: case direction::SOUTHWEST: - alignment = TEXT_ALIGNMENT_RIGHT; + alignment = text_alignment::right; break; case direction::NORTH: case direction::CENTER: case direction::SOUTH: - alignment = TEXT_ALIGNMENT_CENTER; + alignment = text_alignment::center; break; default: - alignment = TEXT_ALIGNMENT_LEFT; + alignment = text_alignment::left; break; } } diff --git a/src/cata_tiles.h b/src/cata_tiles.h index 800daabb1582a..2049e20b4fa91 100644 --- a/src/cata_tiles.h +++ b/src/cata_tiles.h @@ -238,10 +238,10 @@ class tileset_loader void load( const std::string &tileset_id, bool precheck ); }; -enum text_alignment { - TEXT_ALIGNMENT_LEFT, - TEXT_ALIGNMENT_CENTER, - TEXT_ALIGNMENT_RIGHT, +enum class text_alignment : int { + left, + center, + right, }; struct formatted_text { diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index 6d4f3e64b0f9d..34d467094207c 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -1151,9 +1151,9 @@ void cata_cursesport::curses_drawwindow( const catacurses::window &w ) } alignment_offset = 0; - if( ft.alignment == TEXT_ALIGNMENT_CENTER ) { + if( ft.alignment == text_alignment::center ) { alignment_offset = full_text_length / 2; - } else if( ft.alignment == TEXT_ALIGNMENT_RIGHT ) { + } else if( ft.alignment == text_alignment::right ) { alignment_offset = full_text_length - 1; } } From fdad1f1e9a3e8c84f50057b1352e9987cc815db4 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Tue, 14 Apr 2020 23:21:11 +0300 Subject: [PATCH 3/3] Make hint_rating a class enum --- src/avatar.cpp | 4 +-- src/avatar_action.cpp | 2 +- src/character.cpp | 6 ++-- src/consumption.cpp | 8 +++--- src/game.cpp | 31 +++++++++++---------- src/item.h | 8 +++--- src/iuse_actor.cpp | 4 +-- src/player.cpp | 64 +++++++++++++++++++++---------------------- 8 files changed, 64 insertions(+), 63 deletions(-) diff --git a/src/avatar.cpp b/src/avatar.cpp index d403f81730361..143bac24ca22b 100644 --- a/src/avatar.cpp +++ b/src/avatar.cpp @@ -928,11 +928,11 @@ bool avatar::has_identified( const std::string &item_id ) const hint_rating avatar::rate_action_read( const item &it ) const { if( !it.is_book() ) { - return HINT_CANT; + return hint_rating::cant; } std::vector dummy; - return get_book_reader( it, dummy ) == nullptr ? HINT_IFFY : HINT_GOOD; + return get_book_reader( it, dummy ) == nullptr ? hint_rating::iffy : hint_rating::good; } void avatar::wake_up() diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index b5d2665fb31cb..b58f2bd2bd4f7 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -1290,7 +1290,7 @@ void avatar_action::use_item( avatar &you, item_location &loc ) void avatar_action::unload( avatar &you ) { item_location loc = g->inv_map_splice( [&you]( const item & it ) { - return you.rate_action_unload( it ) == HINT_GOOD; + return you.rate_action_unload( it ) == hint_rating::good; }, _( "Unload item" ), 1, _( "You have nothing to unload." ) ); if( !loc ) { diff --git a/src/character.cpp b/src/character.cpp index f89f747ec67f0..3e30d432084fe 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -3422,14 +3422,14 @@ int Character::extraEncumbrance( const layer_level level, const int bp ) const hint_rating Character::rate_action_change_side( const item &it ) const { if( !is_worn( it ) ) { - return HINT_IFFY; + return hint_rating::iffy; } if( !it.is_sided() ) { - return HINT_CANT; + return hint_rating::cant; } - return HINT_GOOD; + return hint_rating::good; } bool Character::change_side( item &it, bool interactive ) diff --git a/src/consumption.cpp b/src/consumption.cpp index 0921b6080e723..877a045b127bb 100644 --- a/src/consumption.cpp +++ b/src/consumption.cpp @@ -1356,17 +1356,17 @@ bool Character::consume_effects( item &food ) hint_rating Character::rate_action_eat( const item &it ) const { if( !can_consume( it ) ) { - return HINT_CANT; + return hint_rating::cant; } const auto rating = will_eat( it ); if( rating.success() ) { - return HINT_GOOD; + return hint_rating::good; } else if( rating.value() == INEDIBLE || rating.value() == INEDIBLE_MUTATION ) { - return HINT_CANT; + return hint_rating::cant; } - return HINT_IFFY; + return hint_rating::iffy; } bool Character::can_feed_reactor_with( const item &it ) const diff --git a/src/game.cpp b/src/game.cpp index d666df11a42a7..748f29c91bf8e 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2064,7 +2064,8 @@ int game::inventory_item_menu( item_location locThisItem, int iStartX, int iWidt std::vector vDummy; const bool bHPR = get_auto_pickup().has_rule( &oThisItem ); - const hint_rating rate_drop_item = u.weapon.has_flag( "NO_UNWIELD" ) ? HINT_CANT : HINT_GOOD; + const hint_rating rate_drop_item = u.weapon.has_flag( "NO_UNWIELD" ) ? hint_rating::cant : + hint_rating::good; int max_text_length = 0; uilist action_menu; @@ -2074,13 +2075,13 @@ int game::inventory_item_menu( item_location locThisItem, int iStartX, int iWidt action_menu.addentry( key, true, key, text ); auto &entry = action_menu.entries.back(); switch( hint ) { - case HINT_CANT: + case hint_rating::cant: entry.text_color = c_light_gray; break; - case HINT_IFFY: + case hint_rating::iffy: entry.text_color = c_light_red; break; - case HINT_GOOD: + case hint_rating::good: entry.text_color = c_light_green; break; } @@ -2090,8 +2091,8 @@ int game::inventory_item_menu( item_location locThisItem, int iStartX, int iWidt addentry( 'R', pgettext( "action", "read" ), u.rate_action_read( oThisItem ) ); addentry( 'E', pgettext( "action", "eat" ), u.rate_action_eat( oThisItem ) ); addentry( 'W', pgettext( "action", "wear" ), u.rate_action_wear( oThisItem ) ); - addentry( 'w', pgettext( "action", "wield" ), HINT_GOOD ); - addentry( 't', pgettext( "action", "throw" ), HINT_GOOD ); + addentry( 'w', pgettext( "action", "wield" ), hint_rating::good ); + addentry( 't', pgettext( "action", "throw" ), hint_rating::good ); addentry( 'c', pgettext( "action", "change side" ), u.rate_action_change_side( oThisItem ) ); addentry( 'T', pgettext( "action", "take off" ), u.rate_action_takeoff( oThisItem ) ); addentry( 'd', pgettext( "action", "drop" ), rate_drop_item ); @@ -2102,17 +2103,17 @@ int game::inventory_item_menu( item_location locThisItem, int iStartX, int iWidt addentry( 'D', pgettext( "action", "disassemble" ), u.rate_action_disassemble( oThisItem ) ); if( oThisItem.is_favorite ) { - addentry( 'f', pgettext( "action", "unfavorite" ), HINT_GOOD ); + addentry( 'f', pgettext( "action", "unfavorite" ), hint_rating::good ); } else { - addentry( 'f', pgettext( "action", "favorite" ), HINT_GOOD ); + addentry( 'f', pgettext( "action", "favorite" ), hint_rating::good ); } - addentry( '=', pgettext( "action", "reassign" ), HINT_GOOD ); + addentry( '=', pgettext( "action", "reassign" ), hint_rating::good ); if( bHPR ) { - addentry( '-', _( "Autopickup" ), HINT_IFFY ); + addentry( '-', _( "Autopickup" ), hint_rating::iffy ); } else { - addentry( '+', _( "Autopickup" ), HINT_GOOD ); + addentry( '+', _( "Autopickup" ), hint_rating::good ); } int iScrollPos = 0; @@ -8406,7 +8407,7 @@ void game::reload( item_location &loc, bool prompt, bool empty ) } switch( u.rate_action_reload( *it ) ) { - case HINT_IFFY: + case hint_rating::iffy: if( ( it->is_ammo_container() || it->is_magazine() ) && it->ammo_remaining() > 0 && it->ammo_remaining() == it->ammo_capacity() ) { add_msg( m_info, _( "The %s is already fully loaded!" ), it->tname() ); @@ -8427,11 +8428,11 @@ void game::reload( item_location &loc, bool prompt, bool empty ) // intentional fall-through - case HINT_CANT: + case hint_rating::cant: add_msg( m_info, _( "You can't reload a %s!" ), it->tname() ); return; - case HINT_GOOD: + case hint_rating::good: break; } @@ -8486,7 +8487,7 @@ void game::reload( item_location &loc, bool prompt, bool empty ) void game::reload_item() { item_location item_loc = inv_map_splice( [&]( const item & it ) { - return u.rate_action_reload( it ) == HINT_GOOD; + return u.rate_action_reload( it ) == hint_rating::good; }, _( "Reload item" ), 1, _( "You have nothing to reload." ) ); if( !item_loc ) { diff --git a/src/item.h b/src/item.h index bebf429e1f0dd..f11d800e1e04c 100644 --- a/src/item.h +++ b/src/item.h @@ -2234,13 +2234,13 @@ bool item_ptr_compare_by_charges( const item *left, const item *right ); * This is assigned as a result of some legacy logic in @ref draw_item_info(). This * will eventually be rewritten to eliminate the need for this hack. */ -enum hint_rating { +enum class hint_rating : int { /** Item should display as gray */ - HINT_CANT = 0, + cant = 0, /** Item should display as red */ - HINT_IFFY = 1, + iffy = 1, /** Item should display as green */ - HINT_GOOD = -999 + good = -999 }; /** diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 0b3ebaf4be601..ea393f857a95b 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -1552,7 +1552,7 @@ bool salvage_actor::try_to_cut_up( player &p, item &it ) const // There must be some historical significance to these items. if( !it.is_salvageable() ) { add_msg( m_info, _( "Can't salvage anything from %s." ), it.tname() ); - if( p.rate_action_disassemble( it ) != HINT_CANT ) { + if( p.rate_action_disassemble( it ) != hint_rating::cant ) { add_msg( m_info, _( "Try disassembling the %s instead." ), it.tname() ); } return false; @@ -2944,7 +2944,7 @@ int ammobelt_actor::use( player &p, item &, bool, const tripoint & ) const item mag( belt ); mag.ammo_unset(); - if( p.rate_action_reload( mag ) != HINT_GOOD ) { + if( p.rate_action_reload( mag ) != hint_rating::good ) { p.add_msg_if_player( _( "Insufficient ammunition to assemble %s" ), mag.tname() ); return 0; } diff --git a/src/player.cpp b/src/player.cpp index fa2491e380a82..f591520024947 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -3097,13 +3097,13 @@ bool character_martial_arts::pick_style( const avatar &you ) // Style selection hint_rating player::rate_action_wear( const item &it ) const { - // TODO: flag already-worn items as HINT_IFFY + // TODO: flag already-worn items as hint_rating::iffy if( !it.is_armor() ) { - return HINT_CANT; + return hint_rating::cant; } - return can_wear( it ).success() ? HINT_GOOD : HINT_IFFY; + return can_wear( it ).success() ? hint_rating::good : hint_rating::iffy; } bool player::can_reload( const item &it, const itype_id &ammo ) const @@ -3383,14 +3383,14 @@ player::wear( item &to_wear, bool interactive ) hint_rating player::rate_action_takeoff( const item &it ) const { if( !it.is_armor() ) { - return HINT_CANT; + return hint_rating::cant; } if( is_worn( it ) ) { - return HINT_GOOD; + return hint_rating::good; } - return HINT_IFFY; + return hint_rating::iffy; } ret_val player::can_takeoff( const item &it, const std::list *res ) @@ -3659,19 +3659,19 @@ void player::use_wielded() hint_rating player::rate_action_reload( const item &it ) const { - hint_rating res = HINT_CANT; + hint_rating res = hint_rating::cant; // Guns may contain additional reloadable mods so check these first for( const auto mod : it.gunmods() ) { switch( rate_action_reload( *mod ) ) { - case HINT_GOOD: - return HINT_GOOD; + case hint_rating::good: + return hint_rating::good; - case HINT_CANT: + case hint_rating::cant: continue; - case HINT_IFFY: - res = HINT_IFFY; + case hint_rating::iffy: + res = hint_rating::iffy; } } @@ -3679,89 +3679,89 @@ hint_rating player::rate_action_reload( const item &it ) const return res; } - return can_reload( it ) ? HINT_GOOD : HINT_IFFY; + return can_reload( it ) ? hint_rating::good : hint_rating::iffy; } hint_rating player::rate_action_unload( const item &it ) const { if( ( it.is_container() || it.is_bandolier() ) && !it.contents.empty() && it.can_unload_liquid() ) { - return HINT_GOOD; + return hint_rating::good; } if( it.has_flag( "NO_UNLOAD" ) ) { - return HINT_CANT; + return hint_rating::cant; } if( it.magazine_current() ) { - return HINT_GOOD; + return hint_rating::good; } for( auto e : it.gunmods() ) { if( e->is_gun() && !e->has_flag( "NO_UNLOAD" ) && ( e->magazine_current() || e->ammo_remaining() > 0 || e->casings_count() > 0 ) ) { - return HINT_GOOD; + return hint_rating::good; } } if( it.ammo_types().empty() ) { - return HINT_CANT; + return hint_rating::cant; } if( it.ammo_remaining() > 0 || it.casings_count() > 0 ) { - return HINT_GOOD; + return hint_rating::good; } if( it.ammo_capacity() > 0 ) { - return HINT_IFFY; + return hint_rating::iffy; } - return HINT_CANT; + return hint_rating::cant; } hint_rating player::rate_action_mend( const item &it ) const { // TODO: check also if item damage could be repaired via a tool if( !it.faults.empty() ) { - return HINT_GOOD; + return hint_rating::good; } - return it.faults_potential().empty() ? HINT_CANT : HINT_IFFY; + return it.faults_potential().empty() ? hint_rating::cant : hint_rating::iffy; } hint_rating player::rate_action_disassemble( const item &it ) { if( can_disassemble( it, crafting_inventory() ).success() ) { - return HINT_GOOD; // possible + return hint_rating::good; // possible } else if( recipe_dictionary::get_uncraft( it.typeId() ) ) { - return HINT_IFFY; // potentially possible but we currently lack requirements + return hint_rating::iffy; // potentially possible but we currently lack requirements } else { - return HINT_CANT; // never possible + return hint_rating::cant; // never possible } } hint_rating player::rate_action_use( const item &it ) const { if( it.is_tool() ) { - return it.ammo_sufficient() ? HINT_GOOD : HINT_IFFY; + return it.ammo_sufficient() ? hint_rating::good : hint_rating::iffy; } else if( it.is_gunmod() ) { /** @EFFECT_GUN >0 allows rating estimates for gun modifications */ if( get_skill_level( skill_gun ) == 0 ) { - return HINT_IFFY; + return hint_rating::iffy; } else { - return HINT_GOOD; + return hint_rating::good; } } else if( it.is_food() || it.is_medication() || it.is_book() || it.is_armor() ) { - return HINT_IFFY; //the rating is subjective, could be argued as HINT_CANT or HINT_GOOD as well + return hint_rating::iffy; //the rating is subjective, could be argued as hint_rating::cant or hint_rating::good as well } else if( it.type->has_use() ) { - return HINT_GOOD; + return hint_rating::good; } else if( !it.is_container_empty() ) { return rate_action_use( it.get_contained() ); } - return HINT_CANT; + return hint_rating::cant; } void player::use( int inventory_position )