Skip to content

Commit

Permalink
Fix condition & remove duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
olanti-p committed Apr 28, 2020
1 parent f9b3841 commit 5ac9488
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions src/ranged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,7 @@ std::vector<tripoint> target_handler::target_ui( player &pc, target_mode mode,
int line_number = 1;
Creature *critter = g->critter_at( dst, true );
const int relative_elevation = dst.z - pc.pos().z;
std::string label_range;
if( dst != src ) {
// Only draw those tiles which are on current z-level
auto ret_this_zlevel = ret;
Expand All @@ -1576,27 +1577,20 @@ std::vector<tripoint> target_handler::target_ui( player &pc, target_mode mode,
// Provides feedback to the player, and avoids leaking information
// about tiles they can't see.
g->draw_line( dst, center, ret_this_zlevel );
label_range = string_format( "%d/%d", rl_dist( src, dst ), range );
} else {
label_range = string_format( "%d", range );
}

// Print to target window
if( ( panel_type == "compact" || panel_type == "labels-narrow" )
&& display_type != "numbers" ) {
mvwprintw( w_target, point( 1, line_number++ ), _( "Range: %d/%d Elevation: %d" ),
rl_dist( src, dst ), range, relative_elevation );
mvwprintw( w_target, point( 1, line_number++ ), _( "Targets: %d" ), t.size() );
} else {
mvwprintw( w_target, point( 1, line_number++ ), _( "Range: %d Elevation: %d "
"Targets: %d" ), range, relative_elevation, t.size() );
}
// Print to target window
if( ( panel_type == "compact" || panel_type == "labels-narrow" )
&& display_type != "numbers" ) {
mvwprintw( w_target, point( 1, line_number++ ), _( "Range: %s Elevation: %d" ),
label_range, relative_elevation );
mvwprintw( w_target, point( 1, line_number++ ), _( "Targets: %d" ), t.size() );
} else {
if( ( panel_type == "compact" || panel_type == "labels-narrow" )
&& display_type != "numbers" ) {
mvwprintw( w_target, point( 1, line_number++ ), _( "Range: %d/%d Elevation: %d" ),
rl_dist( src, dst ), range, relative_elevation );
mvwprintw( w_target, point( 1, line_number++ ), _( "Targets: %d" ), t.size() );
} else {
mvwprintw( w_target, point( 1, line_number++ ), _( "Range: %d Elevation: %d "
"Targets: %d" ), range, relative_elevation, t.size() );
}
mvwprintw( w_target, point( 1, line_number++ ), _( "Range: %s Elevation: %d Targets: %d" ),
label_range, relative_elevation, t.size() );
}

// Skip blank lines if we're short on space.
Expand Down

0 comments on commit 5ac9488

Please sign in to comment.