From be68b0caf4438ffb2a01234c6ef3575d26fa8a1b Mon Sep 17 00:00:00 2001 From: Kevin Granade Date: Sun, 23 Feb 2020 19:24:04 +0000 Subject: [PATCH] Revert "Merge pull request #38141 from ZhilkinSerg/sa-2020-02-18" This reverts commit 142295b1dcec10d738326341dcbdabe0fb9fc81e, reversing changes made to f98c67d3c3dd5b19196938a4d8516f5faf069a28. --- src/activity_item_handling.cpp | 6 ++++-- src/advanced_inv_listitem.h | 1 + src/ammo.h | 4 ++-- src/avatar_action.cpp | 4 +++- src/basecamp.h | 2 ++ src/bionics.h | 2 ++ src/cata_string_consts.h | 9 ++++++++- src/cata_tiles.h | 2 ++ src/cata_variant.h | 2 ++ src/character.cpp | 2 ++ src/character.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.cpp | 2 ++ src/item.h | 3 +++ src/item_action.cpp | 1 + src/item_factory.cpp | 1 + src/itype.h | 2 ++ 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/point.h | 1 + src/profession.h | 1 + src/recipe.h | 1 + src/recipe_dictionary.h | 2 ++ src/requirements.h | 3 +++ src/safemode_ui.cpp | 2 +- src/string_id.h | 2 ++ src/trap.h | 3 +++ src/type_id.h | 5 ----- src/uistate.h | 2 ++ src/veh_type.h | 2 ++ 45 files changed, 83 insertions(+), 16 deletions(-) diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index 38cf6f12711ab..42bbd87860690 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -1942,6 +1942,7 @@ 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. @@ -1991,14 +1992,15 @@ 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 ); } - if( p.is_npc() ) { + if( p.is_npc() && !picked_up.empty() ) { if( pickup_count == 1 ) { - add_msg( _( "%1$s picks up a %2$s." ), p.disp_name(), it.tname() ); + add_msg( _( "%1$s picks up a %2$s." ), p.disp_name(), picked_up ); } else { add_msg( _( "%s picks up several items." ), p.disp_name() ); } diff --git a/src/advanced_inv_listitem.h b/src/advanced_inv_listitem.h index 50da1e4e3982a..9fb1c2ff5b55e 100644 --- a/src/advanced_inv_listitem.h +++ b/src/advanced_inv_listitem.h @@ -25,6 +25,7 @@ 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 f3e91f4f15b7c..173ab6ff7c88d 100644 --- a/src/ammo.h +++ b/src/ammo.h @@ -5,10 +5,10 @@ #include #include -#include "type_id.h" - class JsonObject; +using itype_id = std::string; + class ammunition_type { friend class DynamicDataLoader; diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index 3fbb612f360f2..13c1c5497c64e 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -1124,7 +1124,9 @@ 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 = g->inv_map_splice( [&you]( const item & it ) { + item_location loc; + + 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." ) ); diff --git a/src/basecamp.h b/src/basecamp.h index ea37bad461df3..6347425b33b38 100644 --- a/src/basecamp.h +++ b/src/basecamp.h @@ -42,6 +42,8 @@ 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 b0c08f3892481..c1da377933a68 100644 --- a/src/bionics.h +++ b/src/bionics.h @@ -21,6 +21,8 @@ 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 541e1e971a2df..e854936d76d86 100644 --- a/src/cata_string_consts.h +++ b/src/cata_string_consts.h @@ -3,7 +3,8 @@ #define STRING_CONSTS_H #include "type_id.h" -#include "itype.h" +#include "player_activity.h" + static const activity_id ACT_ADV_INVENTORY( "ACT_ADV_INVENTORY" ); static const activity_id ACT_AIM( "ACT_AIM" ); @@ -103,6 +104,7 @@ 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" ); @@ -918,6 +920,7 @@ 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_ACT_ON_RANGED_HIT( "ACT_ON_RANGED_HIT" ); @@ -1271,6 +1274,7 @@ 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" ); @@ -1300,6 +1304,7 @@ 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" ); @@ -1318,6 +1323,7 @@ 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" ); @@ -1389,6 +1395,7 @@ 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" ); diff --git a/src/cata_tiles.h b/src/cata_tiles.h index a1692164f2c66..45ec9194ce19c 100644 --- a/src/cata_tiles.h +++ b/src/cata_tiles.h @@ -28,6 +28,8 @@ 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 a59efee418d94..c02701cd6fc92 100644 --- a/src/cata_variant.h +++ b/src/cata_variant.h @@ -18,6 +18,8 @@ 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.cpp b/src/character.cpp index ddd2005ae38da..70f7b62fef0f0 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -68,6 +68,7 @@ #include "vitamin.h" #include "vpart_position.h" + // *INDENT-OFF* Character::Character() : @@ -4004,6 +4005,7 @@ 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/character.h b/src/character.h index 75e8e37f4bc52..b1647013c340c 100644 --- a/src/character.h +++ b/src/character.h @@ -764,6 +764,8 @@ 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(); diff --git a/src/character_martial_arts.cpp b/src/character_martial_arts.cpp index 755d946284928..4eee8bbf86462 100644 --- a/src/character_martial_arts.cpp +++ b/src/character_martial_arts.cpp @@ -6,6 +6,8 @@ #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 904837f6f4286..bd47591dc3ee0 100644 --- a/src/character_martial_arts.h +++ b/src/character_martial_arts.h @@ -13,6 +13,8 @@ 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 422f03ac9ae71..9720143303469 100644 --- a/src/event.h +++ b/src/event.h @@ -10,6 +10,8 @@ #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 5ab28b0b11ce6..2010f8adc61a2 100644 --- a/src/explosion.h +++ b/src/explosion.h @@ -5,7 +5,7 @@ #include #include -#include "type_id.h" +using itype_id = std::string; struct tripoint; class JsonObject; diff --git a/src/game.h b/src/game.h index faded5a8863ee..b267103adb732 100644 --- a/src/game.h +++ b/src/game.h @@ -93,6 +93,7 @@ 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 19bb2012c4d48..0c787b346634c 100644 --- a/src/gamemode_defense.h +++ b/src/gamemode_defense.h @@ -11,6 +11,8 @@ #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 830d50d346314..b55f6ce28d4bd 100644 --- a/src/harvest.h +++ b/src/harvest.h @@ -13,6 +13,7 @@ #include "translations.h" #include "type_id.h" +using itype_id = std::string; class JsonObject; // Could be reused for butchery diff --git a/src/item.cpp b/src/item.cpp index 69e9c3fbd357c..2a70523001b8f 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -9419,6 +9419,8 @@ 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 47eb4085e896f..4773a2434761d 100644 --- a/src/item.h +++ b/src/item.h @@ -72,6 +72,7 @@ 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; @@ -144,6 +145,8 @@ 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 2addbefcddc84..a9c7dba5e1ade 100644 --- a/src/item_action.cpp +++ b/src/item_action.cpp @@ -34,6 +34,7 @@ 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 28915f185e7ff..1dee5c57fde0a 100644 --- a/src/item_factory.cpp +++ b/src/item_factory.cpp @@ -2219,6 +2219,7 @@ 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 563bbba6812ce..976c9de821cd2 100644 --- a/src/itype.h +++ b/src/itype.h @@ -36,6 +36,8 @@ 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 { private: diff --git a/src/iuse.h b/src/iuse.h index d53f18e96f4d8..8758cdfe881c6 100644 --- a/src/iuse.h +++ b/src/iuse.h @@ -6,7 +6,6 @@ #include #include -#include "type_id.h" #include "clone_ptr.h" #include "units.h" @@ -18,6 +17,7 @@ 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 & ) { } + virtual void finalize( const itype_id &/*my_item_type*/ ) { } }; struct use_function { diff --git a/src/iuse_actor.h b/src/iuse_actor.h index d405a114eb567..a2b80e28091cd 100644 --- a/src/iuse_actor.h +++ b/src/iuse_actor.h @@ -33,6 +33,7 @@ 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 782e442c66e6c..81a73a900987f 100644 --- a/src/map.h +++ b/src/map.h @@ -70,6 +70,7 @@ 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 18fd3da733942..bb1f1d138bad2 100644 --- a/src/mapdata.h +++ b/src/mapdata.h @@ -26,6 +26,8 @@ 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 ba110253a9642..60f81f51010ed 100644 --- a/src/material.h +++ b/src/material.h @@ -17,6 +17,7 @@ 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 dcbfb7d4b9b33..d28bc9f100be2 100644 --- a/src/mtype.h +++ b/src/mtype.h @@ -34,6 +34,8 @@ 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 8ace795b7801d..363e751363194 100644 --- a/src/mutation.h +++ b/src/mutation.h @@ -27,6 +27,7 @@ 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 0ba8d7b2b1661..6b285da89e270 100644 --- a/src/npc_favor.h +++ b/src/npc_favor.h @@ -6,6 +6,7 @@ #include "type_id.h" +using itype_id = std::string; class JsonIn; class JsonOut; diff --git a/src/player.h b/src/player.h index 99be20fa30579..05164077e6ec4 100644 --- a/src/player.h +++ b/src/player.h @@ -65,6 +65,7 @@ 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 5c7b46bc5c969..6571685f02a3e 100644 --- a/src/player_activity.cpp +++ b/src/player_activity.cpp @@ -4,7 +4,6 @@ #include "activity_handlers.h" #include "activity_type.h" -#include "cata_string_consts.h" #include "construction.h" #include "map.h" #include "game.h" @@ -13,6 +12,7 @@ #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 9efb7b0d47da7..9c6ad33aaefe1 100644 --- a/src/player_activity.h +++ b/src/player_activity.h @@ -25,6 +25,8 @@ class activity_type; class monster; class translation; +using activity_id = string_id; + class player_activity { private: diff --git a/src/point.h b/src/point.h index 64c70f1821101..75112d3782bfb 100644 --- a/src/point.h +++ b/src/point.h @@ -309,6 +309,7 @@ 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 ) ); diff --git a/src/profession.h b/src/profession.h index baa2f410f1141..8c3c5fb96340e 100644 --- a/src/profession.h +++ b/src/profession.h @@ -20,6 +20,7 @@ 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 385acd21d9c1b..cce16c8b2a82e 100644 --- a/src/recipe.h +++ b/src/recipe.h @@ -18,6 +18,7 @@ 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 d93a54e33124b..9e9ab4ee6d8f6 100644 --- a/src/recipe_dictionary.h +++ b/src/recipe_dictionary.h @@ -18,6 +18,8 @@ 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 bc5ed5f052978..a9fccc5554c9e 100644 --- a/src/requirements.h +++ b/src/requirements.h @@ -23,6 +23,9 @@ 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/safemode_ui.cpp b/src/safemode_ui.cpp index 97ec1b858794b..131462730d031 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; } diff --git a/src/string_id.h b/src/string_id.h index b1a9ace6f67e3..5b2a396f89ca9 100644 --- a/src/string_id.h +++ b/src/string_id.h @@ -25,6 +25,8 @@ 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 990fb4e300a73..c8e61e96bf25e 100644 --- a/src/trap.h +++ b/src/trap.h @@ -65,6 +65,8 @@ 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; @@ -83,6 +85,7 @@ 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 69ae264e82f03..d3246ae43dc3c 100644 --- a/src/type_id.h +++ b/src/type_id.h @@ -5,11 +5,6 @@ #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 6d68705be4c0b..1f172311d3f8c 100644 --- a/src/uistate.h +++ b/src/uistate.h @@ -25,6 +25,8 @@ 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 258fbdfb06c99..55cf3811e97ba 100644 --- a/src/veh_type.h +++ b/src/veh_type.h @@ -23,6 +23,8 @@ #include "point.h" #include "translations.h" +using itype_id = std::string; + class JsonObject; class Character;