From 5340d46b804142386a5305e60eb8f907869897db Mon Sep 17 00:00:00 2001 From: KorGgenT Date: Fri, 18 Oct 2019 21:51:17 -0400 Subject: [PATCH] change scope of player::has_charges --- src/character.h | 12 ++++++++++++ src/iuse_actor.cpp | 3 ++- src/player.cpp | 10 +++++----- src/player.h | 11 ----------- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/character.h b/src/character.h index a49843035d8d9..ce9c03be8e3ba 100644 --- a/src/character.h +++ b/src/character.h @@ -1088,6 +1088,18 @@ class Character : public Creature, public visitable void stop_hauling(); bool is_hauling() const; + // Has a weapon, inventory item or worn item with flag + bool has_item_with_flag( const std::string &flag, bool need_charges = false ) const; + /** + * All items that have the given flag (@ref item::has_flag). + */ + std::vector all_items_with_flag( const std::string &flag ) const; + + bool has_fire( int quantity ) const; + + bool has_charges( const itype_id &it, int quantity, + const std::function &filter = return_true ) const; + /** Legacy activity assignment, should not be used where resuming is important. */ void assign_activity( const activity_id &type, int moves = calendar::INDEFINITELY_LONG, int index = -1, int pos = INT_MIN, diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 25d0f2cd57155..7cb127c834930 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -1962,7 +1962,8 @@ int enzlave_actor::use( player &p, item &it, bool t, const tripoint & ) const return cost >= 0 ? cost : it.ammo_required(); } -ret_val enzlave_actor::can_use( const Character &p, const item &, bool, const tripoint & ) const +ret_val enzlave_actor::can_use( const Character &p, const item &, bool, + const tripoint & ) const { /** @EFFECT_SURVIVAL >=1 allows enzlavement */ diff --git a/src/player.cpp b/src/player.cpp index 9b0d714fea04e..2f7080586d53c 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -6446,7 +6446,7 @@ bool player::use_charges_if_avail( const itype_id &it, int quantity ) return false; } -bool player::has_fire( const int quantity ) const +bool Character::has_fire( const int quantity ) const { // TODO: Replace this with a "tool produces fire" flag. @@ -6617,8 +6617,8 @@ int player::amount_worn( const itype_id &id ) const return amount; } -bool player::has_charges( const itype_id &it, int quantity, - const std::function &filter ) const +bool Character::has_charges( const itype_id &it, int quantity, + const std::function &filter ) const { if( it == "fire" || it == "apparatus" ) { return has_fire( quantity ); @@ -10595,7 +10595,7 @@ float player::speed_rating() const return ret; } -std::vector player::all_items_with_flag( const std::string &flag ) const +std::vector Character::all_items_with_flag( const std::string &flag ) const { return items_with( [&flag]( const item & it ) { return it.has_flag( flag ); @@ -10644,7 +10644,7 @@ bool player::crush_frozen_liquid( item_location loc ) return false; } -bool player::has_item_with_flag( const std::string &flag, bool need_charges ) const +bool Character::has_item_with_flag( const std::string &flag, bool need_charges ) const { return has_item_with( [&flag, &need_charges]( const item & it ) { if( it.is_tool() && need_charges ) { diff --git a/src/player.h b/src/player.h index 7a9d1d4fb7e2f..2a0aa62a4ca97 100644 --- a/src/player.h +++ b/src/player.h @@ -1138,10 +1138,6 @@ class player : public Character float power_rating() const override; float speed_rating() const override; - /** - * All items that have the given flag (@ref item::has_flag). - */ - std::vector all_items_with_flag( const std::string &flag ) const; void process_active_items(); /** * Remove charges from a specific item (given by its item position). @@ -1194,9 +1190,6 @@ class player : public Character std::list use_charges( const itype_id &what, int qty, const std::function &filter = return_true ); - bool has_charges( const itype_id &it, int quantity, - const std::function &filter = return_true ) const; - /** Returns the amount of item `type' that is currently worn */ int amount_worn( const itype_id &id ) const; @@ -1212,9 +1205,6 @@ class player : public Character */ bool crush_frozen_liquid( item_location loc ); - // Has a weapon, inventory item or worn item with flag - bool has_item_with_flag( const std::string &flag, bool need_charges = false ) const; - bool has_mission_item( int mission_id ) const; // Has item with mission_id /** * Check whether the player has a gun that uses the given type of ammo. @@ -1623,7 +1613,6 @@ class player : public Character // Trigger and disable mutations that can be so toggled. void activate_mutation( const trait_id &mutation ); void deactivate_mutation( const trait_id &mut ); - bool has_fire( int quantity ) const; void use_fire( int quantity ); /** Determine player's capability of recharging their CBMs. */