Skip to content

Commit

Permalink
Consolidate Creature::is_player() and is_avatar() (#50050)
Browse files Browse the repository at this point in the history
  • Loading branch information
eltank authored Jul 19, 2021
1 parent 9dc329c commit 7e05d34
Show file tree
Hide file tree
Showing 37 changed files with 151 additions and 157 deletions.
6 changes: 3 additions & 3 deletions src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3382,7 +3382,7 @@ void shearing_activity_actor::start( player_activity &act, Character &who )

const int shearing_quality = who.max_quality( qual_SHEAR );
if( !( shearing_quality > 0 ) ) {
if( who.is_player() ) {
if( who.is_avatar() ) {
add_msg( m_info, _( "%1$s don't have a shearing tool." ), who.disp_name( false, true ) );
} else { // who.is_npc
// npcs can't shear monsters yet, this is for when they are able to
Expand All @@ -3400,7 +3400,7 @@ void shearing_activity_actor::start( player_activity &act, Character &who )
add_msg_debug( debugmode::DF_ACT_SHEARING, "shearing_time time = %s",
to_string_writable( shearing_time ) );

if( who.is_player() ) {
if( who.is_avatar() ) {
add_msg( m_info,
_( "%1$s start shearing %2$s." ), who.disp_name( false, true ), mon->disp_name() );
} else { // who.is_npc
Expand All @@ -3416,7 +3416,7 @@ void shearing_activity_actor::start( player_activity &act, Character &who )
void shearing_activity_actor::do_turn( player_activity &, Character &who )
{
if( !who.has_quality( qual_SHEAR ) ) {
if( who.is_player() ) {
if( who.is_avatar() ) {
add_msg(
m_bad,
_( "%1$s don't have a shearing tool anymore." ),
Expand Down
4 changes: 2 additions & 2 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ static void set_up_butchery( player_activity &act, player &u, butcher_type actio
u.has_trait_flag( json_flag_PSYCHOPATH ) ||
u.has_trait_flag( json_flag_SAPIOVORE ) ) ) {

if( u.is_player() ) {
if( u.is_avatar() ) {
if( query_yn( _( "Would you dare desecrate the mortal remains of a fellow human being?" ) ) ) {
switch( rng( 1, 3 ) ) {
case 1:
Expand Down Expand Up @@ -3032,7 +3032,7 @@ void activity_handlers::wait_weather_finish( player_activity *act, player *p )
void activity_handlers::find_mount_do_turn( player_activity *act, player *p )
{
//npc only activity
if( p->is_player() ) {
if( p->is_avatar() ) {
act->set_to_null();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ void game::draw_hit_player( const Character &p, const int dam )
static const std::string npc_male {"npc_male"};
static const std::string npc_female {"npc_female"};

const std::string &type = p.is_player() ? ( p.male ? player_male : player_female )
const std::string &type = p.is_avatar() ? ( p.male ? player_male : player_female )
: p.male ? npc_male : npc_female;

shared_ptr_fast<draw_callback_t> hit_cb = make_shared_fast<draw_callback_t>( [&]() {
Expand Down
2 changes: 1 addition & 1 deletion src/armor_layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ void player::sort_armor()

bool exit = false;
while( !exit ) {
if( is_player() ) {
if( is_avatar() ) {
// Totally hoisted this from advanced_inv
if( player_character.moves < 0 ) {
do_return_entry();
Expand Down
2 changes: 1 addition & 1 deletion src/ballistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ dealt_projectile_attack projectile_attack( const projectile &proj_arg, const tri

if( critter != nullptr && cur_missed_by < 1.0 ) {
if( in_veh != nullptr && veh_pointer_or_null( here.veh_at( tp ) ) == in_veh &&
critter->is_player() ) {
critter->is_avatar() ) {
// Turret either was aimed by the player (who is now ducking) and shoots from above
// Or was just IFFing, giving lots of warnings and time to get out of the line of fire
continue;
Expand Down
10 changes: 5 additions & 5 deletions src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1903,7 +1903,7 @@ void Character::bionics_uninstall_failure( monster &installer, player &patient,

bool u_see = sees( patient );

if( u_see || patient.is_player() ) {
if( u_see || patient.is_avatar() ) {
if( fail_type <= 0 ) {
add_msg( m_neutral, _( "The removal fails without incident." ) );
return;
Expand Down Expand Up @@ -2296,7 +2296,7 @@ bool Character::uninstall_bionic( const bionic &target_cbm, monster &installer,
installer.add_effect( effect_operating, duration + 5_turns );
}

if( patient.is_player() ) {
if( patient.is_avatar() ) {
add_msg( m_bad,
_( "You feel a tiny pricking sensation in your right arm, and lose all sensation before abruptly blacking out." ) );
} else {
Expand All @@ -2310,7 +2310,7 @@ bool Character::uninstall_bionic( const bionic &target_cbm, monster &installer,
patient.add_effect( effect_narcosis, duration );
patient.add_effect( effect_sleep, duration );

if( patient.is_player() ) {
if( patient.is_avatar() ) {
add_msg( _( "You fall asleep and %1$s starts operating." ), installer.disp_name() );
} else {
add_msg_if_player_sees( patient, _( "%1$s falls asleep and %2$s starts operating." ),
Expand All @@ -2319,7 +2319,7 @@ bool Character::uninstall_bionic( const bionic &target_cbm, monster &installer,

if( success > 0 ) {

if( patient.is_player() ) {
if( patient.is_avatar() ) {
add_msg( m_neutral, _( "Your parts are jiggled back into their familiar places." ) );
add_msg( m_mixed, _( "Successfully removed %s." ), target_cbm.info().name );
} else if( patient.is_npc() && player_view.sees( patient ) ) {
Expand Down Expand Up @@ -2626,7 +2626,7 @@ void Character::bionics_install_failure( const bionic_id &bid, const std::string
add_msg( m_bad, _( "%s lose power capacity!" ), disp_name() );
set_max_power_level( units::from_kilojoule( rng( 0,
units::to_kilojoule( get_max_power_level() ) - 25 ) ) );
if( is_player() ) {
if( is_avatar() ) {
get_memorial().add(
pgettext( "memorial_male", "Lost %d units of power capacity." ),
pgettext( "memorial_female", "Lost %d units of power capacity." ),
Expand Down
2 changes: 1 addition & 1 deletion src/cata_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3087,7 +3087,7 @@ bool cata_tiles::draw_critter_at( const tripoint &p, lit_level ll, int &height_3
if( pl != nullptr ) {
draw_entity_with_overlays( *pl, p, ll, height_3d );
result = true;
if( pl->is_player() ) {
if( pl->is_avatar() ) {
is_player = true;
} else {
sees_player = pl->sees( you );
Expand Down
Loading

0 comments on commit 7e05d34

Please sign in to comment.