Skip to content

Commit

Permalink
Fix target UI regressions caused by #39785 (#40221)
Browse files Browse the repository at this point in the history
  • Loading branch information
olanti-p authored May 6, 2020
1 parent ec79781 commit 09e6310
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ enum safe_mode_type {
enum body_part : int;
enum weather_type : int;
enum action_id : int;
enum target_mode : int;

struct special_game;

Expand Down
12 changes: 8 additions & 4 deletions src/ranged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2003,7 +2003,8 @@ target_handler::trajectory target_ui::run( player &pc, ExitCode *exit_code )
break;
}
case ExitCode::Fire: {
on_target_accepted( pc, true );
bool harmful = !( mode == TargetMode::Spell && casting->damage() <= 0 );
on_target_accepted( pc, harmful );
break;
}
case ExitCode::Timeout: {
Expand Down Expand Up @@ -2199,6 +2200,8 @@ bool target_ui::set_cursor_pos( player &pc, const tripoint &new_pos )
clamp( delta.z, -range, range )
);
}
} else {
new_traj.push_back( src );
}

if( valid_pos == dst ) {
Expand Down Expand Up @@ -2361,8 +2364,9 @@ void target_ui::update_status()
} else if( ( mode == TargetMode::Fire || mode == TargetMode::TurretManual ) && range == 0 ) {
// Selected gun mode is empty
status = Status::OutOfAmmo;
} else if( src == dst ) {
// TODO: consider allowing targeting yourself with spells/turrets
} else if( ( src == dst ) && !( mode == TargetMode::Spell &&
casting->is_valid_target( target_self ) ) ) {
// TODO: consider allowing targeting yourself with turrets
status = Status::BadTarget;
} else if( dist_fn( dst ) > range ) {
// We're out of range. This can happen if we switch from long-ranged
Expand All @@ -2376,7 +2380,7 @@ void target_ui::update_status()

int target_ui::dist_fn( const tripoint &p )
{
return static_cast<int>( std::round( trig_dist( src, p ) ) );
return static_cast<int>( std::round( rl_dist_exact( src, p ) ) );
}

bool target_ui::pl_can_target( const player &pc, const Creature *cr )
Expand Down

0 comments on commit 09e6310

Please sign in to comment.