From 8e6d238e7d2155ff59cae5d28f1e4ada12778f41 Mon Sep 17 00:00:00 2001 From: KorGgenT Date: Fri, 18 Oct 2019 21:47:09 -0400 Subject: [PATCH] change iuse::can_use parameter to Character --- src/item_action.cpp | 2 +- src/iuse.cpp | 2 +- src/iuse.h | 5 +++-- src/iuse_actor.cpp | 20 ++++++++++---------- src/iuse_actor.h | 21 +++++++++++---------- 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/item_action.cpp b/src/item_action.cpp index 8395dbfa71abf..6047af047d56b 100644 --- a/src/item_action.cpp +++ b/src/item_action.cpp @@ -331,7 +331,7 @@ std::string use_function::get_type() const } } -ret_val iuse_actor::can_use( const player &, const item &, bool, const tripoint & ) const +ret_val iuse_actor::can_use( const Character &, const item &, bool, const tripoint & ) const { return ret_val::make_success(); } diff --git a/src/iuse.cpp b/src/iuse.cpp index 1e6a9a25509c3..ef6b612e3b7e6 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -9745,7 +9745,7 @@ void use_function::dump_info( const item &it, std::vector &dump ) cons } } -ret_val use_function::can_call( const player &p, const item &it, bool t, +ret_val use_function::can_call( const Character &p, const item &it, bool t, const tripoint &pos ) const { if( actor == nullptr ) { diff --git a/src/iuse.h b/src/iuse.h index 099a364f6e2df..65da0dd735278 100644 --- a/src/iuse.h +++ b/src/iuse.h @@ -9,6 +9,7 @@ #include "clone_ptr.h" #include "units.h" +class Character; class item; class player; class JsonObject; @@ -270,7 +271,7 @@ class iuse_actor virtual ~iuse_actor() = default; virtual void load( JsonObject &jo ) = 0; virtual int use( player &, item &, bool, const tripoint & ) const = 0; - virtual ret_val can_use( const player &, const item &, bool, const tripoint & ) const; + virtual ret_val can_use( const Character &, const item &, bool, const tripoint & ) const; virtual void info( const item &, std::vector & ) const {} /** * Returns a deep copy of this object. Example implementation: @@ -308,7 +309,7 @@ struct use_function { use_function( std::unique_ptr f ) : actor( std::move( f ) ) {} int call( player &, item &, bool, const tripoint & ) const; - ret_val can_call( const player &, const item &, bool t, const tripoint &pos ) const; + ret_val can_call( const Character &, const item &, bool t, const tripoint &pos ) const; iuse_actor *get_actor_ptr() { return actor.get(); diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 1dde63366c69c..25d0f2cd57155 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -257,7 +257,7 @@ int iuse_transform::use( player &p, item &it, bool t, const tripoint &pos ) cons return 0; } -ret_val iuse_transform::can_use( const player &p, const item &, bool, +ret_val iuse_transform::can_use( const Character &p, const item &, bool, const tripoint & ) const { std::map unmet_reqs; @@ -356,7 +356,7 @@ int countdown_actor::use( player &p, item &it, bool t, const tripoint &pos ) con return 0; } -ret_val countdown_actor::can_use( const player &, const item &it, bool, +ret_val countdown_actor::can_use( const Character &, const item &it, bool, const tripoint & ) const { if( it.active ) { @@ -1269,7 +1269,7 @@ void firestarter_actor::resolve_firestarter_use( player &p, const tripoint &pos } } -ret_val firestarter_actor::can_use( const player &p, const item &it, bool, +ret_val firestarter_actor::can_use( const Character &p, const item &it, bool, const tripoint & ) const { if( p.is_underwater() ) { @@ -1802,7 +1802,7 @@ int cauterize_actor::use( player &p, item &it, bool t, const tripoint & ) const } } -ret_val cauterize_actor::can_use( const player &p, const item &it, bool, +ret_val cauterize_actor::can_use( const Character &p, const item &it, bool, const tripoint & ) const { if( !p.has_effect( effect_bite ) && @@ -1962,7 +1962,7 @@ 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 player &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 */ @@ -2030,7 +2030,7 @@ int fireweapon_off_actor::use( player &p, item &it, bool t, const tripoint & ) c return it.type->charges_to_use(); } -ret_val fireweapon_off_actor::can_use( const player &p, const item &it, bool, +ret_val fireweapon_off_actor::can_use( const Character &p, const item &it, bool, const tripoint & ) const { if( it.charges < it.type->charges_to_use() ) { @@ -2128,7 +2128,7 @@ int manualnoise_actor::use( player &p, item &it, bool t, const tripoint & ) cons return it.type->charges_to_use(); } -ret_val manualnoise_actor::can_use( const player &, const item &it, bool, +ret_val manualnoise_actor::can_use( const Character &, const item &it, bool, const tripoint & ) const { if( it.charges < it.type->charges_to_use() ) { @@ -2268,7 +2268,7 @@ int musical_instrument_actor::use( player &p, item &it, bool t, const tripoint & return 0; } -ret_val musical_instrument_actor::can_use( const player &p, const item &, bool, +ret_val musical_instrument_actor::can_use( const Character &p, const item &, bool, const tripoint & ) const { // TODO: (maybe): Mouth encumbrance? Smoke? Lack of arms? Hand encumbrance? @@ -4088,7 +4088,7 @@ int install_bionic_actor::use( player &p, item &it, bool, const tripoint & ) con } } -ret_val install_bionic_actor::can_use( const player &p, const item &it, bool, +ret_val install_bionic_actor::can_use( const Character &p, const item &it, bool, const tripoint & ) const { if( !it.is_bionic() ) { @@ -4168,7 +4168,7 @@ int detach_gunmods_actor::use( player &p, item &it, bool, const tripoint & ) con return 0; } -ret_val detach_gunmods_actor::can_use( const player &p, const item &it, bool, +ret_val detach_gunmods_actor::can_use( const Character &p, const item &it, bool, const tripoint & ) const { const auto mods = it.gunmods(); diff --git a/src/iuse_actor.h b/src/iuse_actor.h index 9e11df593237a..4201bfcab45b0 100644 --- a/src/iuse_actor.h +++ b/src/iuse_actor.h @@ -22,6 +22,7 @@ #include "units.h" #include "optional.h" +class Character; class item; class player; struct iteminfo; @@ -104,7 +105,7 @@ class iuse_transform : public iuse_actor ~iuse_transform() override = default; void load( JsonObject &obj ) override; int use( player &, item &, bool, const tripoint & ) const override; - ret_val can_use( const player &, const item &, bool, const tripoint & ) const override; + ret_val can_use( const Character &, const item &, bool, const tripoint & ) const override; std::unique_ptr clone() const override; std::string get_name() const override; void finalize( const itype_id &my_item_type ) override; @@ -129,7 +130,7 @@ class countdown_actor : public iuse_actor void load( JsonObject &obj ) override; int use( player &, item &, bool, const tripoint & ) const override; std::unique_ptr clone() const override; - ret_val can_use( const player &, const item &it, bool, const tripoint & ) const override; + ret_val can_use( const Character &, const item &it, bool, const tripoint & ) const override; std::string get_name() const override; void info( const item &, std::vector & ) const override; }; @@ -439,7 +440,7 @@ class firestarter_actor : public iuse_actor ~firestarter_actor() override = default; void load( JsonObject &obj ) override; int use( player &, item &, bool, const tripoint & ) const override; - ret_val can_use( const player &, const item &, bool, const tripoint & ) const override; + ret_val can_use( const Character &, const item &, bool, const tripoint & ) const override; std::unique_ptr clone() const override; }; @@ -534,7 +535,7 @@ class cauterize_actor : public iuse_actor ~cauterize_actor() override = default; void load( JsonObject &obj ) override; int use( player &, item &, bool, const tripoint & ) const override; - ret_val can_use( const player &, const item &, bool, const tripoint & ) const override; + ret_val can_use( const Character &, const item &, bool, const tripoint & ) const override; std::unique_ptr clone() const override; }; @@ -549,7 +550,7 @@ class enzlave_actor : public iuse_actor ~enzlave_actor() override = default; void load( JsonObject &obj ) override; int use( player &, item &, bool, const tripoint & ) const override; - ret_val can_use( const player &, const item &, bool, const tripoint & ) const override; + ret_val can_use( const Character &, const item &, bool, const tripoint & ) const override; std::unique_ptr clone() const override; }; @@ -574,7 +575,7 @@ class fireweapon_off_actor : public iuse_actor ~fireweapon_off_actor() override = default; void load( JsonObject &obj ) override; int use( player &, item &, bool, const tripoint & ) const override; - ret_val can_use( const player &, const item &, bool, const tripoint & ) const override; + ret_val can_use( const Character &, const item &, bool, const tripoint & ) const override; std::unique_ptr clone() const override; }; @@ -620,7 +621,7 @@ class manualnoise_actor : public iuse_actor ~manualnoise_actor() override = default; void load( JsonObject &obj ) override; int use( player &, item &, bool, const tripoint & ) const override; - ret_val can_use( const player &, const item &, bool, const tripoint & ) const override; + ret_val can_use( const Character &, const item &, bool, const tripoint & ) const override; std::unique_ptr clone() const override; }; @@ -664,7 +665,7 @@ class musical_instrument_actor : public iuse_actor ~musical_instrument_actor() override = default; void load( JsonObject &obj ) override; int use( player &, item &, bool, const tripoint & ) const override; - ret_val can_use( const player &, const item &, bool, const tripoint & ) const override; + ret_val can_use( const Character &, const item &, bool, const tripoint & ) const override; std::unique_ptr clone() const override; }; @@ -1024,7 +1025,7 @@ class install_bionic_actor : public iuse_actor void load( JsonObject & ) override {} int use( player &p, item &it, bool t, const tripoint &pnt ) const override; - ret_val can_use( const player &, const item &it, bool, const tripoint & ) const override; + ret_val can_use( const Character &, const item &it, bool, const tripoint & ) const override; std::unique_ptr clone() const override; void finalize( const itype_id &my_item_type ) override; }; @@ -1036,7 +1037,7 @@ class detach_gunmods_actor : public iuse_actor void load( JsonObject & ) override {} int use( player &p, item &it, bool t, const tripoint &pnt ) const override; - ret_val can_use( const player &, const item &it, bool, const tripoint & ) const override; + ret_val can_use( const Character &, const item &it, bool, const tripoint & ) const override; std::unique_ptr clone() const override; void finalize( const itype_id &my_item_type ) override; };