Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix target UI regressions caused by #39785 #40221

Merged
merged 4 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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