From 0e609a48c5c3c199bf71271018128d34a3f08ad0 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Tue, 18 Feb 2020 22:58:05 +0300 Subject: [PATCH 1/7] Move activity_id and itype_id definition --- src/advanced_inv_listitem.h | 1 - src/ammo.h | 4 ++-- src/basecamp.h | 2 -- src/bionics.h | 2 -- src/cata_string_consts.h | 2 +- src/cata_tiles.h | 2 -- src/cata_variant.h | 2 -- src/character_martial_arts.cpp | 2 -- src/character_martial_arts.h | 2 -- src/event.h | 2 -- src/explosion.h | 2 +- src/game.h | 1 - src/gamemode_defense.h | 2 -- src/harvest.h | 1 - src/item.h | 1 - src/itype.h | 1 - src/iuse.h | 4 ++-- src/iuse_actor.h | 1 - src/map.h | 1 - src/mapdata.h | 2 -- src/material.h | 1 - src/mtype.h | 2 -- src/mutation.h | 1 - src/npc_favor.h | 1 - src/player.h | 1 - src/player_activity.cpp | 2 +- src/player_activity.h | 2 -- src/profession.h | 1 - src/recipe.h | 1 - src/recipe_dictionary.h | 2 -- src/requirements.h | 3 --- src/string_id.h | 2 -- src/trap.h | 3 --- src/type_id.h | 5 +++++ src/uistate.h | 2 -- src/veh_type.h | 2 -- 36 files changed, 12 insertions(+), 56 deletions(-) diff --git a/src/advanced_inv_listitem.h b/src/advanced_inv_listitem.h index 9fb1c2ff5b55e..50da1e4e3982a 100644 --- a/src/advanced_inv_listitem.h +++ b/src/advanced_inv_listitem.h @@ -25,7 +25,6 @@ class item_category; class advanced_inv_listitem { public: - using itype_id = std::string; /** * Index of the item in the itemstack. */ diff --git a/src/ammo.h b/src/ammo.h index 173ab6ff7c88d..f3e91f4f15b7c 100644 --- a/src/ammo.h +++ b/src/ammo.h @@ -5,9 +5,9 @@ #include #include -class JsonObject; +#include "type_id.h" -using itype_id = std::string; +class JsonObject; class ammunition_type { diff --git a/src/basecamp.h b/src/basecamp.h index 6347425b33b38..ea37bad461df3 100644 --- a/src/basecamp.h +++ b/src/basecamp.h @@ -42,8 +42,6 @@ struct expansion_data { using npc_ptr = shared_ptr_fast; using comp_list = std::vector; using Group_tag = std::string; -using itype_id = std::string; - namespace catacurses { class window; diff --git a/src/bionics.h b/src/bionics.h index c1da377933a68..b0c08f3892481 100644 --- a/src/bionics.h +++ b/src/bionics.h @@ -21,8 +21,6 @@ class player; class JsonObject; class JsonIn; class JsonOut; -using itype_id = std::string; - struct bionic_data { bionic_data(); diff --git a/src/cata_string_consts.h b/src/cata_string_consts.h index 17247944fe98f..b8990549bad58 100644 --- a/src/cata_string_consts.h +++ b/src/cata_string_consts.h @@ -3,8 +3,8 @@ #define STRING_CONSTS_H #include "type_id.h" -#include "player_activity.h" +#include "itype.h" static const activity_id ACT_ADV_INVENTORY( "ACT_ADV_INVENTORY" ); static const activity_id ACT_AIM( "ACT_AIM" ); diff --git a/src/cata_tiles.h b/src/cata_tiles.h index 45ec9194ce19c..a1692164f2c66 100644 --- a/src/cata_tiles.h +++ b/src/cata_tiles.h @@ -28,8 +28,6 @@ class player; class pixel_minimap; class JsonObject; -using itype_id = std::string; - extern void set_displaybuffer_rendertarget(); /** Structures */ diff --git a/src/cata_variant.h b/src/cata_variant.h index c02701cd6fc92..a59efee418d94 100644 --- a/src/cata_variant.h +++ b/src/cata_variant.h @@ -18,8 +18,6 @@ enum body_part : int; enum class mutagen_technique : int; enum hp_part : int; -using itype_id = std::string; - // cata_variant is a variant-like type that stores a variety of different cata // types. All types are stored by converting them to a string. diff --git a/src/character_martial_arts.cpp b/src/character_martial_arts.cpp index 4eee8bbf86462..755d946284928 100644 --- a/src/character_martial_arts.cpp +++ b/src/character_martial_arts.cpp @@ -6,8 +6,6 @@ #include "output.h" #include "cata_string_consts.h" -using itype_id = std::string; - character_martial_arts::character_martial_arts() { diff --git a/src/character_martial_arts.h b/src/character_martial_arts.h index bd47591dc3ee0..904837f6f4286 100644 --- a/src/character_martial_arts.h +++ b/src/character_martial_arts.h @@ -13,8 +13,6 @@ class item; class JsonOut; class JsonIn; -using itype_id = std::string; - class character_martial_arts { private: diff --git a/src/event.h b/src/event.h index 9720143303469..422f03ac9ae71 100644 --- a/src/event.h +++ b/src/event.h @@ -10,8 +10,6 @@ #include "enum_conversions.h" #include "type_id.h" -using itype_id = std::string; - // An event is something to be passed via the event_bus to subscribers // interested in being notified about events. // diff --git a/src/explosion.h b/src/explosion.h index 2010f8adc61a2..5ab28b0b11ce6 100644 --- a/src/explosion.h +++ b/src/explosion.h @@ -5,7 +5,7 @@ #include #include -using itype_id = std::string; +#include "type_id.h" struct tripoint; class JsonObject; diff --git a/src/game.h b/src/game.h index b267103adb732..faded5a8863ee 100644 --- a/src/game.h +++ b/src/game.h @@ -93,7 +93,6 @@ enum target_mode : int; struct special_game; -using itype_id = std::string; class avatar; class event_bus; class kill_tracker; diff --git a/src/gamemode_defense.h b/src/gamemode_defense.h index 0c787b346634c..19bb2012c4d48 100644 --- a/src/gamemode_defense.h +++ b/src/gamemode_defense.h @@ -11,8 +11,6 @@ #include "type_id.h" enum action_id : int; -using itype_id = std::string; - enum defense_style { DEFENSE_CUSTOM = 0, DEFENSE_EASY, diff --git a/src/harvest.h b/src/harvest.h index b55f6ce28d4bd..830d50d346314 100644 --- a/src/harvest.h +++ b/src/harvest.h @@ -13,7 +13,6 @@ #include "translations.h" #include "type_id.h" -using itype_id = std::string; class JsonObject; // Could be reused for butchery diff --git a/src/item.h b/src/item.h index fa349b8b2d05c..b4a92f57e0892 100644 --- a/src/item.h +++ b/src/item.h @@ -72,7 +72,6 @@ enum m_size : int; enum class side : int; class body_part_set; -using itype_id = std::string; struct fire_data; struct damage_instance; struct damage_unit; diff --git a/src/itype.h b/src/itype.h index ad43e6488c89b..417701c242414 100644 --- a/src/itype.h +++ b/src/itype.h @@ -36,7 +36,6 @@ enum art_effect_active : int; enum art_charge : int; enum art_charge_req : int; enum art_effect_passive : int; -using itype_id = std::string; class gun_modifier_data { diff --git a/src/iuse.h b/src/iuse.h index 8758cdfe881c6..d53f18e96f4d8 100644 --- a/src/iuse.h +++ b/src/iuse.h @@ -6,6 +6,7 @@ #include #include +#include "type_id.h" #include "clone_ptr.h" #include "units.h" @@ -17,7 +18,6 @@ class monster; template class ret_val; struct iteminfo; -using itype_id = std::string; struct tripoint; // iuse methods returning a bool indicating whether to consume a charge of the item being used. @@ -297,7 +297,7 @@ class iuse_actor /** * Finalizes the actor. Must be called after all items are loaded. */ - virtual void finalize( const itype_id &/*my_item_type*/ ) { } + virtual void finalize( const itype_id & ) { } }; struct use_function { diff --git a/src/iuse_actor.h b/src/iuse_actor.h index a2b80e28091cd..d405a114eb567 100644 --- a/src/iuse_actor.h +++ b/src/iuse_actor.h @@ -33,7 +33,6 @@ enum hp_part : int; enum body_part : int; class JsonObject; -using itype_id = std::string; struct furn_t; struct itype; class item_location; diff --git a/src/map.h b/src/map.h index cf7e4e7f0bc0d..eceef058560bc 100644 --- a/src/map.h +++ b/src/map.h @@ -70,7 +70,6 @@ struct trap; enum direction : unsigned; enum class special_item_type : int; -using itype_id = std::string; template class visitable; struct regional_settings; diff --git a/src/mapdata.h b/src/mapdata.h index bb1f1d138bad2..18fd3da733942 100644 --- a/src/mapdata.h +++ b/src/mapdata.h @@ -26,8 +26,6 @@ struct tripoint; using iexamine_function = void ( * )( player &, const tripoint & ); -using itype_id = std::string; - struct map_bash_info { int str_min; // min str(*) required to bash int str_max; // max str required: bash succeeds if str >= random # between str_min & str_max diff --git a/src/material.h b/src/material.h index 8907c816c05e7..db2d43a010581 100644 --- a/src/material.h +++ b/src/material.h @@ -17,7 +17,6 @@ class material_type; enum damage_type : int; -using itype_id = std::string; class JsonObject; using mat_burn_products = std::vector>; diff --git a/src/mtype.h b/src/mtype.h index d28bc9f100be2..dcbfb7d4b9b33 100644 --- a/src/mtype.h +++ b/src/mtype.h @@ -34,8 +34,6 @@ using bodytype_id = std::string; class JsonArray; class JsonObject; -using itype_id = std::string; - // These are triggers which may affect the monster's anger or morale. // They are handled in monster::check_triggers(), in monster.cpp enum class mon_trigger { diff --git a/src/mutation.h b/src/mutation.h index 363e751363194..8ace795b7801d 100644 --- a/src/mutation.h +++ b/src/mutation.h @@ -27,7 +27,6 @@ struct dream; class Trait_group; class item; -using itype_id = std::string; class JsonArray; extern std::vector dreams; diff --git a/src/npc_favor.h b/src/npc_favor.h index 6b285da89e270..0ba8d7b2b1661 100644 --- a/src/npc_favor.h +++ b/src/npc_favor.h @@ -6,7 +6,6 @@ #include "type_id.h" -using itype_id = std::string; class JsonIn; class JsonOut; diff --git a/src/player.h b/src/player.h index d3c2e13f3b96f..27f86ebb3c03c 100644 --- a/src/player.h +++ b/src/player.h @@ -65,7 +65,6 @@ class JsonOut; struct dealt_projectile_attack; class dispersion_sources; -using itype_id = std::string; using faction_id = string_id; struct trap; class profession; diff --git a/src/player_activity.cpp b/src/player_activity.cpp index 7de44edaaaa71..81c96a815a217 100644 --- a/src/player_activity.cpp +++ b/src/player_activity.cpp @@ -4,6 +4,7 @@ #include "activity_handlers.h" #include "activity_type.h" +#include "cata_string_consts.h" #include "construction.h" #include "map.h" #include "game.h" @@ -12,7 +13,6 @@ #include "avatar.h" #include "itype.h" #include "skill.h" -#include "cata_string_consts.h" player_activity::player_activity() : type( activity_id::NULL_ID() ) { } diff --git a/src/player_activity.h b/src/player_activity.h index 9c6ad33aaefe1..9efb7b0d47da7 100644 --- a/src/player_activity.h +++ b/src/player_activity.h @@ -25,8 +25,6 @@ class activity_type; class monster; class translation; -using activity_id = string_id; - class player_activity { private: diff --git a/src/profession.h b/src/profession.h index 8c3c5fb96340e..baa2f410f1141 100644 --- a/src/profession.h +++ b/src/profession.h @@ -20,7 +20,6 @@ class generic_factory; using Group_tag = std::string; class item; -using itype_id = std::string; class avatar; class player; class JsonObject; diff --git a/src/recipe.h b/src/recipe.h index cce16c8b2a82e..385acd21d9c1b 100644 --- a/src/recipe.h +++ b/src/recipe.h @@ -18,7 +18,6 @@ class item; class JsonObject; class time_duration; -using itype_id = std::string; // From itype.h class Character; enum class recipe_filter_flags : int { diff --git a/src/recipe_dictionary.h b/src/recipe_dictionary.h index 9e9ab4ee6d8f6..d93a54e33124b 100644 --- a/src/recipe_dictionary.h +++ b/src/recipe_dictionary.h @@ -18,8 +18,6 @@ class JsonIn; class JsonOut; class JsonObject; -using itype_id = std::string; - class recipe_dictionary { friend class Item_factory; // allow removal of blacklisted recipes diff --git a/src/requirements.h b/src/requirements.h index a9fccc5554c9e..bc5ed5f052978 100644 --- a/src/requirements.h +++ b/src/requirements.h @@ -23,9 +23,6 @@ class JsonOut; class inventory; class item; -// Denotes the id of an item type -using itype_id = std::string; - enum available_status { a_true = +1, // yes, it's available a_false = -1, // no, it's not available diff --git a/src/string_id.h b/src/string_id.h index 5b2a396f89ca9..b1a9ace6f67e3 100644 --- a/src/string_id.h +++ b/src/string_id.h @@ -25,8 +25,6 @@ class int_id; * * Example: * \code - * struct itype; - * using itype_id = string_id; * struct mtype; * using mtype_id = string_id; * \endcode diff --git a/src/trap.h b/src/trap.h index c8e61e96bf25e..990fb4e300a73 100644 --- a/src/trap.h +++ b/src/trap.h @@ -65,8 +65,6 @@ bool snake( const tripoint &p, Creature *c, item *i ); } // namespace trapfunc struct vehicle_handle_trap_data { - using itype_id = std::string; - bool remove_trap = false; bool do_explosion = false; bool is_falling = false; @@ -85,7 +83,6 @@ struct vehicle_handle_trap_data { using trap_function = std::function; struct trap { - using itype_id = std::string; trap_str_id id; trap_id loadid; diff --git a/src/type_id.h b/src/type_id.h index d3246ae43dc3c..69ae264e82f03 100644 --- a/src/type_id.h +++ b/src/type_id.h @@ -5,6 +5,11 @@ #include "int_id.h" #include "string_id.h" +using itype_id = std::string; + +class activity_type; +using activity_id = string_id; + class ammunition_type; using ammotype = string_id; diff --git a/src/uistate.h b/src/uistate.h index 1f172311d3f8c..6d68705be4c0b 100644 --- a/src/uistate.h +++ b/src/uistate.h @@ -25,8 +25,6 @@ class uistatedata { /**** this will set a default value on startup, however to save, see below ****/ private: - // not needed for compilation, but keeps syntax plugins happy - using itype_id = std::string; enum side { left = 0, right = 1, NUM_PANES = 2 }; public: int ags_pay_gas_selected_pump = 0; diff --git a/src/veh_type.h b/src/veh_type.h index 55cf3811e97ba..258fbdfb06c99 100644 --- a/src/veh_type.h +++ b/src/veh_type.h @@ -23,8 +23,6 @@ #include "point.h" #include "translations.h" -using itype_id = std::string; - class JsonObject; class Character; From cbac63b75d7c18f168434df387aaaaec09adc1c3 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Tue, 18 Feb 2020 23:22:03 +0300 Subject: [PATCH 2/7] Removed redundant empty lines --- src/cata_string_consts.h | 6 ------ src/character.cpp | 2 -- src/item.cpp | 2 -- src/item.h | 2 -- src/item_action.cpp | 1 - src/item_factory.cpp | 1 - src/itype.h | 1 - src/point.h | 1 - 8 files changed, 16 deletions(-) diff --git a/src/cata_string_consts.h b/src/cata_string_consts.h index b8990549bad58..25130766c525b 100644 --- a/src/cata_string_consts.h +++ b/src/cata_string_consts.h @@ -3,7 +3,6 @@ #define STRING_CONSTS_H #include "type_id.h" - #include "itype.h" static const activity_id ACT_ADV_INVENTORY( "ACT_ADV_INVENTORY" ); @@ -104,7 +103,6 @@ static const activity_id ACT_WAIT_WEATHER( "ACT_WAIT_WEATHER" ); static const activity_id ACT_WASH( "ACT_WASH" ); static const activity_id ACT_WEAR( "ACT_WEAR" ); - static const bionic_id bio_adrenaline( "bio_adrenaline" ); static const bionic_id bio_ads( "bio_ads" ); static const bionic_id bio_advreactor( "bio_advreactor" ); @@ -924,7 +922,6 @@ static const mtype_id mon_zombie_technician( "mon_zombie_technician" ); static const mtype_id mon_zombie_tough( "mon_zombie_tough" ); static const mtype_id mon_zombie_waif( "mon_zombie_waif" ); - static const std::string flag_ACID( "ACID" ); static const std::string flag_ACT_IN_FIRE( "ACT_IN_FIRE" ); static const std::string flag_ACTIVE_CLOAKING( "ACTIVE_CLOAKING" ); @@ -1249,7 +1246,6 @@ static const std::string flag_WIND_EXTINGUISH( "WIND_EXTINGUISH" ); static const std::string flag_WRITE_MESSAGE( "WRITE_MESSAGE" ); static const std::string flag_YOUNG( "YOUNG" ); - static const skill_id skill_archery( "archery" ); static const skill_id skill_barter( "barter" ); static const skill_id skill_bashing( "bashing" ); @@ -1279,7 +1275,6 @@ 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" ); @@ -1298,7 +1293,6 @@ 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 zone_type_id zone_investigate_only( "NPC_INVESTIGATE_ONLY" ); static const zone_type_id zone_no_investigate( "NPC_NO_INVESTIGATE" ); static const zone_type_id zone_type_CHOP_TREES( "CHOP_TREES" ); diff --git a/src/character.cpp b/src/character.cpp index c49a18314e3a5..c9507e067ba36 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -68,7 +68,6 @@ #include "vitamin.h" #include "vpart_position.h" - // *INDENT-OFF* Character::Character() : @@ -3951,7 +3950,6 @@ void Character::update_needs( int rate_multiplier ) mod_sleep_deprivation( fatigue_roll * 5 ); } - if( npc_no_food && get_fatigue() > TIRED ) { set_fatigue( TIRED ); set_sleep_deprivation( 0 ); diff --git a/src/item.cpp b/src/item.cpp index f4c867a691acb..62e6d74a76a3c 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -9416,8 +9416,6 @@ bool item::has_infinite_charges() const skill_id item::contextualize_skill( const skill_id &id ) const { if( id->is_contextual_skill() ) { - - if( id == skill_weapon ) { if( is_gun() ) { return gun_skill(); diff --git a/src/item.h b/src/item.h index b4a92f57e0892..fdb28fd834016 100644 --- a/src/item.h +++ b/src/item.h @@ -144,8 +144,6 @@ struct iteminfo { lower_is_better = 1 << 3, ///< Lower values are better for this stat no_name = 1 << 4, ///< Do not print the name show_plus = 1 << 5, ///< Use a + sign for positive values - - }; /** diff --git a/src/item_action.cpp b/src/item_action.cpp index a9c7dba5e1ade..2addbefcddc84 100644 --- a/src/item_action.cpp +++ b/src/item_action.cpp @@ -34,7 +34,6 @@ struct tripoint; static item_action nullaction; - static char key_bound_to( const input_context &ctxt, const item_action_id &act ) { auto keys = ctxt.keys_bound_to( act ); diff --git a/src/item_factory.cpp b/src/item_factory.cpp index 00c0515c8e1e3..08a1f57039988 100644 --- a/src/item_factory.cpp +++ b/src/item_factory.cpp @@ -2095,7 +2095,6 @@ void Item_factory::load_basic_info( const JsonObject &jo, itype &def, const std: assign( jo, "insulation", def.insulation_factor ); assign( jo, "ascii_picture", def.ascii_picture ); - if( jo.has_member( "thrown_damage" ) ) { def.thrown_damage = load_damage_instance( jo.get_array( "thrown_damage" ) ); } else { diff --git a/src/itype.h b/src/itype.h index 417701c242414..cdf62cb85c85b 100644 --- a/src/itype.h +++ b/src/itype.h @@ -36,7 +36,6 @@ enum art_effect_active : int; enum art_charge : int; enum art_charge_req : int; enum art_effect_passive : int; - class gun_modifier_data { private: diff --git a/src/point.h b/src/point.h index 75112d3782bfb..64c70f1821101 100644 --- a/src/point.h +++ b/src/point.h @@ -309,7 +309,6 @@ std::vector closest_tripoints_first( const tripoint ¢er, int min_d std::vector closest_points_first( const point ¢er, int max_dist ); std::vector closest_points_first( const point ¢er, int min_dist, int max_dist ); - inline point abs( const point &p ) { return point( abs( p.x ), abs( p.y ) ); From c652b96811103cc3bba4815a08bbc19351c6dc55 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Tue, 18 Feb 2020 23:29:51 +0300 Subject: [PATCH 3/7] Removed redundant empty statements --- src/safemode_ui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/safemode_ui.cpp b/src/safemode_ui.cpp index 131462730d031..97ec1b858794b 100644 --- a/src/safemode_ui.cpp +++ b/src/safemode_ui.cpp @@ -697,7 +697,7 @@ bool safemode::is_sound_safe( const std::string &sound_name_in, return false; } } - }; + } return sound_safe; } From 40e2c32efb4b12f621312cd5e35a907113e8eda7 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Tue, 18 Feb 2020 23:31:59 +0300 Subject: [PATCH 4/7] Removed non-implemented functions --- src/character.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/character.h b/src/character.h index be0bd5bc7f1c7..ee37495b04842 100644 --- a/src/character.h +++ b/src/character.h @@ -762,8 +762,6 @@ class Character : public Creature, public visitable std::array, num_bp> mut_drench; - void serialize_consumption_history( JsonOut jsout ) const; - void deserialize_consumption_history( JsonArray jarr ); public: // recalculates enchantment cache by iterating through all held, worn, and wielded items void recalculate_enchantment_cache(); From e9ad1c3e6a95238b39c46a5b7b8f3f241b20cbb7 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Tue, 18 Feb 2020 23:38:05 +0300 Subject: [PATCH 5/7] Removed unused declarator --- src/cata_string_consts.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cata_string_consts.h b/src/cata_string_consts.h index 25130766c525b..1eb89b8574d2b 100644 --- a/src/cata_string_consts.h +++ b/src/cata_string_consts.h @@ -1362,7 +1362,6 @@ static const matype_id style_tiger( "style_tiger" ); static const matype_id style_wingchun( "style_wingchun" ); static const matype_id style_zui_quan( "style_zui_quan" ); -static const species_id ABERRATION( "ABERRATION" ); static const species_id species_BLOB( "BLOB" ); static const species_id FISH( "FISH" ); static const species_id FUNGUS( "FUNGUS" ); From 801dcd746a252cf71c73eaaaa0999919b29b42ac Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Tue, 18 Feb 2020 23:43:00 +0300 Subject: [PATCH 6/7] Combined var declaration and assignment --- src/activity_item_handling.cpp | 3 +-- src/avatar_action.cpp | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index 42bbd87860690..9ab6989c13a38 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -1942,7 +1942,6 @@ static void fetch_activity( player &p, const tripoint &src_loc, src_veh = &vp->vehicle(); src_part = vp->part_index(); } - std::string picked_up; const units::volume volume_allowed = p.volume_capacity() - p.volume_carried(); const units::mass weight_allowed = p.weight_capacity() - p.weight_carried(); // TODO: vehicle_stack and map_stack into one loop. @@ -1992,12 +1991,12 @@ static void fetch_activity( player &p, const tripoint &src_loc, } it.set_var( "activity_var", p.name ); p.i_add( it ); - picked_up = it.tname(); items_there.erase( item_iter ); // If we didn't pick up a whole stack, put the remainder back where it came from. if( leftovers.charges > 0 ) { g->m.add_item_or_charges( src_loc, leftovers ); } + std::string picked_up = it.tname(); if( p.is_npc() && !picked_up.empty() ) { if( pickup_count == 1 ) { add_msg( _( "%1$s picks up a %2$s." ), p.disp_name(), picked_up ); diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index 13c1c5497c64e..3fbb612f360f2 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -1124,9 +1124,7 @@ void avatar_action::use_item( avatar &you, item_location &loc ) // If it's a gun, some gunmods can also be loaded void avatar_action::unload( avatar &you ) { - item_location loc; - - loc = g->inv_map_splice( [&you]( const item & it ) { + item_location loc = g->inv_map_splice( [&you]( const item & it ) { return you.rate_action_unload( it ) == HINT_GOOD; }, _( "Unload item" ), 1, _( "You have nothing to unload." ) ); From 5d4be2cbe416f3e87046b212c63240f774622c8d Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Wed, 19 Feb 2020 23:05:01 +0300 Subject: [PATCH 7/7] Apply suggestions from code review --- src/activity_item_handling.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index 9ab6989c13a38..38cf6f12711ab 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -1996,10 +1996,9 @@ static void fetch_activity( player &p, const tripoint &src_loc, if( leftovers.charges > 0 ) { g->m.add_item_or_charges( src_loc, leftovers ); } - std::string picked_up = it.tname(); - if( p.is_npc() && !picked_up.empty() ) { + if( p.is_npc() ) { if( pickup_count == 1 ) { - add_msg( _( "%1$s picks up a %2$s." ), p.disp_name(), picked_up ); + add_msg( _( "%1$s picks up a %2$s." ), p.disp_name(), it.tname() ); } else { add_msg( _( "%s picks up several items." ), p.disp_name() ); }