Skip to content

Commit

Permalink
change iuse::can_use parameter to Character
Browse files Browse the repository at this point in the history
  • Loading branch information
KorGgenT committed Oct 19, 2019
1 parent d861a43 commit 8e6d238
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/item_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ std::string use_function::get_type() const
}
}

ret_val<bool> iuse_actor::can_use( const player &, const item &, bool, const tripoint & ) const
ret_val<bool> iuse_actor::can_use( const Character &, const item &, bool, const tripoint & ) const
{
return ret_val<bool>::make_success();
}
Expand Down
2 changes: 1 addition & 1 deletion src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9745,7 +9745,7 @@ void use_function::dump_info( const item &it, std::vector<iteminfo> &dump ) cons
}
}

ret_val<bool> use_function::can_call( const player &p, const item &it, bool t,
ret_val<bool> use_function::can_call( const Character &p, const item &it, bool t,
const tripoint &pos ) const
{
if( actor == nullptr ) {
Expand Down
5 changes: 3 additions & 2 deletions src/iuse.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "clone_ptr.h"
#include "units.h"

class Character;
class item;
class player;
class JsonObject;
Expand Down Expand Up @@ -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<bool> can_use( const player &, const item &, bool, const tripoint & ) const;
virtual ret_val<bool> can_use( const Character &, const item &, bool, const tripoint & ) const;
virtual void info( const item &, std::vector<iteminfo> & ) const {}
/**
* Returns a deep copy of this object. Example implementation:
Expand Down Expand Up @@ -308,7 +309,7 @@ struct use_function {
use_function( std::unique_ptr<iuse_actor> f ) : actor( std::move( f ) ) {}

int call( player &, item &, bool, const tripoint & ) const;
ret_val<bool> can_call( const player &, const item &, bool t, const tripoint &pos ) const;
ret_val<bool> can_call( const Character &, const item &, bool t, const tripoint &pos ) const;

iuse_actor *get_actor_ptr() {
return actor.get();
Expand Down
20 changes: 10 additions & 10 deletions src/iuse_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ int iuse_transform::use( player &p, item &it, bool t, const tripoint &pos ) cons
return 0;
}

ret_val<bool> iuse_transform::can_use( const player &p, const item &, bool,
ret_val<bool> iuse_transform::can_use( const Character &p, const item &, bool,
const tripoint & ) const
{
std::map<quality_id, int> unmet_reqs;
Expand Down Expand Up @@ -356,7 +356,7 @@ int countdown_actor::use( player &p, item &it, bool t, const tripoint &pos ) con
return 0;
}

ret_val<bool> countdown_actor::can_use( const player &, const item &it, bool,
ret_val<bool> countdown_actor::can_use( const Character &, const item &it, bool,
const tripoint & ) const
{
if( it.active ) {
Expand Down Expand Up @@ -1269,7 +1269,7 @@ void firestarter_actor::resolve_firestarter_use( player &p, const tripoint &pos
}
}

ret_val<bool> firestarter_actor::can_use( const player &p, const item &it, bool,
ret_val<bool> firestarter_actor::can_use( const Character &p, const item &it, bool,
const tripoint & ) const
{
if( p.is_underwater() ) {
Expand Down Expand Up @@ -1802,7 +1802,7 @@ int cauterize_actor::use( player &p, item &it, bool t, const tripoint & ) const
}
}

ret_val<bool> cauterize_actor::can_use( const player &p, const item &it, bool,
ret_val<bool> cauterize_actor::can_use( const Character &p, const item &it, bool,
const tripoint & ) const
{
if( !p.has_effect( effect_bite ) &&
Expand Down Expand Up @@ -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<bool> enzlave_actor::can_use( const player &p, const item &, bool, const tripoint & ) const
ret_val<bool> enzlave_actor::can_use( const Character &p, const item &, bool, const tripoint & ) const
{
/** @EFFECT_SURVIVAL >=1 allows enzlavement */

Expand Down Expand Up @@ -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<bool> fireweapon_off_actor::can_use( const player &p, const item &it, bool,
ret_val<bool> fireweapon_off_actor::can_use( const Character &p, const item &it, bool,
const tripoint & ) const
{
if( it.charges < it.type->charges_to_use() ) {
Expand Down Expand Up @@ -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<bool> manualnoise_actor::can_use( const player &, const item &it, bool,
ret_val<bool> manualnoise_actor::can_use( const Character &, const item &it, bool,
const tripoint & ) const
{
if( it.charges < it.type->charges_to_use() ) {
Expand Down Expand Up @@ -2268,7 +2268,7 @@ int musical_instrument_actor::use( player &p, item &it, bool t, const tripoint &
return 0;
}

ret_val<bool> musical_instrument_actor::can_use( const player &p, const item &, bool,
ret_val<bool> musical_instrument_actor::can_use( const Character &p, const item &, bool,
const tripoint & ) const
{
// TODO: (maybe): Mouth encumbrance? Smoke? Lack of arms? Hand encumbrance?
Expand Down Expand Up @@ -4088,7 +4088,7 @@ int install_bionic_actor::use( player &p, item &it, bool, const tripoint & ) con
}
}

ret_val<bool> install_bionic_actor::can_use( const player &p, const item &it, bool,
ret_val<bool> install_bionic_actor::can_use( const Character &p, const item &it, bool,
const tripoint & ) const
{
if( !it.is_bionic() ) {
Expand Down Expand Up @@ -4168,7 +4168,7 @@ int detach_gunmods_actor::use( player &p, item &it, bool, const tripoint & ) con
return 0;
}

ret_val<bool> detach_gunmods_actor::can_use( const player &p, const item &it, bool,
ret_val<bool> detach_gunmods_actor::can_use( const Character &p, const item &it, bool,
const tripoint & ) const
{
const auto mods = it.gunmods();
Expand Down
21 changes: 11 additions & 10 deletions src/iuse_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "units.h"
#include "optional.h"

class Character;
class item;
class player;
struct iteminfo;
Expand Down Expand Up @@ -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<bool> can_use( const player &, const item &, bool, const tripoint & ) const override;
ret_val<bool> can_use( const Character &, const item &, bool, const tripoint & ) const override;
std::unique_ptr<iuse_actor> clone() const override;
std::string get_name() const override;
void finalize( const itype_id &my_item_type ) override;
Expand All @@ -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<iuse_actor> clone() const override;
ret_val<bool> can_use( const player &, const item &it, bool, const tripoint & ) const override;
ret_val<bool> can_use( const Character &, const item &it, bool, const tripoint & ) const override;
std::string get_name() const override;
void info( const item &, std::vector<iteminfo> & ) const override;
};
Expand Down Expand Up @@ -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<bool> can_use( const player &, const item &, bool, const tripoint & ) const override;
ret_val<bool> can_use( const Character &, const item &, bool, const tripoint & ) const override;
std::unique_ptr<iuse_actor> clone() const override;
};

Expand Down Expand Up @@ -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<bool> can_use( const player &, const item &, bool, const tripoint & ) const override;
ret_val<bool> can_use( const Character &, const item &, bool, const tripoint & ) const override;
std::unique_ptr<iuse_actor> clone() const override;
};

Expand All @@ -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<bool> can_use( const player &, const item &, bool, const tripoint & ) const override;
ret_val<bool> can_use( const Character &, const item &, bool, const tripoint & ) const override;
std::unique_ptr<iuse_actor> clone() const override;
};

Expand All @@ -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<bool> can_use( const player &, const item &, bool, const tripoint & ) const override;
ret_val<bool> can_use( const Character &, const item &, bool, const tripoint & ) const override;
std::unique_ptr<iuse_actor> clone() const override;
};

Expand Down Expand Up @@ -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<bool> can_use( const player &, const item &, bool, const tripoint & ) const override;
ret_val<bool> can_use( const Character &, const item &, bool, const tripoint & ) const override;
std::unique_ptr<iuse_actor> clone() const override;
};

Expand Down Expand Up @@ -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<bool> can_use( const player &, const item &, bool, const tripoint & ) const override;
ret_val<bool> can_use( const Character &, const item &, bool, const tripoint & ) const override;
std::unique_ptr<iuse_actor> clone() const override;
};

Expand Down Expand Up @@ -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<bool> can_use( const player &, const item &it, bool, const tripoint & ) const override;
ret_val<bool> can_use( const Character &, const item &it, bool, const tripoint & ) const override;
std::unique_ptr<iuse_actor> clone() const override;
void finalize( const itype_id &my_item_type ) override;
};
Expand All @@ -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<bool> can_use( const player &, const item &it, bool, const tripoint & ) const override;
ret_val<bool> can_use( const Character &, const item &it, bool, const tripoint & ) const override;
std::unique_ptr<iuse_actor> clone() const override;
void finalize( const itype_id &my_item_type ) override;
};
Expand Down

0 comments on commit 8e6d238

Please sign in to comment.