From 8a30fc656b0ec2c0d5dee92c42bee1df4a300a6a Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 9 Jan 2016 16:38:12 +0000 Subject: [PATCH] Factor out editor special segment drawing --- similar/editor/meddraw.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/similar/editor/meddraw.cpp b/similar/editor/meddraw.cpp index 4cd1f499b..4e6241898 100644 --- a/similar/editor/meddraw.cpp +++ b/similar/editor/meddraw.cpp @@ -584,37 +584,39 @@ static void draw_mine_all(int automap_flag) } +static void draw_listed_segments(count_segment_array_t &s) +{ + range_for (const auto &ss, s) + { + const auto &&segp = vcsegptr(ss); + if (segp->segnum != segment_none) + draw_segment(segp); + } +} + static void draw_selected_segments(void) { gr_setcolor(SELECT_COLOR); - range_for (const auto &ss, Selected_segs) - if (Segments[ss].segnum != segment_none) - draw_segment(&Segments[ss]); + draw_listed_segments(Selected_segs); } static void draw_found_segments(void) { gr_setcolor(FOUND_COLOR); - range_for (const auto &fs, Found_segs) - if (Segments[fs].segnum != segment_none) - draw_segment(&Segments[fs]); + draw_listed_segments(Found_segs); } static void draw_warning_segments(void) { gr_setcolor(WARNING_COLOR); - range_for (const auto &ws, Warning_segs) - if (Segments[ws].segnum != segment_none) - draw_segment(&Segments[ws]); + draw_listed_segments(Warning_segs); } static void draw_group_segments(void) { if (current_group > -1) { gr_setcolor(GROUP_COLOR); - range_for (const auto &gs, GroupList[current_group].segments) - if (Segments[gs].segnum != segment_none) - draw_segment(&Segments[gs]); + draw_listed_segments(GroupList[current_group].segments); } }