From 2504d97daa490ddb4d0071e219fc4efbff98343a Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Wed, 17 Nov 2021 08:52:08 -0700 Subject: [PATCH] Eliminiate redundant route_head data member (#764) eliminate redundant route_head data member rte_waypt_ct, replacing it with a member function rte_waypt_ct() that gets the count from the waypoint_list container. --- bcr.cc | 2 +- defs.h | 3 ++- garmin_txt.cc | 4 ++-- gdb.cc | 2 +- ggv_ovl.cc | 4 ++-- gtm.cc | 4 ++-- humminbird.cc | 4 ++-- igc.cc | 6 +++--- ignrando.cc | 2 +- kml.cc | 20 ++++++++++---------- lowranceusr.cc | 14 +++++++------- magproto.cc | 2 +- mapsend.cc | 2 +- mmo.cc | 20 ++++++++++---------- navilink.cc | 2 +- osm.cc | 2 +- ozi.cc | 2 +- position.cc | 2 +- raymarine.cc | 2 +- route.cc | 6 +----- saroute.cc | 2 +- shape.cc | 4 ++-- skyforce.cc | 2 +- smplrout.cc | 6 +++--- stmsdf.cc | 2 +- tpo.cc | 2 +- trackfilter.cc | 12 ++++++------ validate.cc | 6 +++--- xol.cc | 2 +- 29 files changed, 70 insertions(+), 73 deletions(-) diff --git a/bcr.cc b/bcr.cc index 1954ced34..1d744c8e7 100644 --- a/bcr.cc +++ b/bcr.cc @@ -297,7 +297,7 @@ bcr_data_read() } /* remove empty route */ - if (route->rte_waypt_ct == 0) { + if (route->rte_waypt_ct() == 0) { route_del_head(route); } else { bcr_create_waypts_from_route(route); diff --git a/defs.h b/defs.h index 68c14159d..a1dfa506a 100644 --- a/defs.h +++ b/defs.h @@ -702,7 +702,6 @@ class route_head QString rte_desc; UrlList rte_urls; int rte_num; - int rte_waypt_ct; /* # waypoints in waypoint list */ FormatSpecificDataList fs; gb_color line_color; /* Optional line color for rendering */ int line_width; /* in pixels (sigh). < 0 is unknown. */ @@ -716,6 +715,8 @@ class route_head route_head(const route_head& other) = delete; route_head& operator=(const route_head& rhs) = delete; ~route_head(); + + int rte_waypt_ct() const {return waypoint_list.count();} /* # waypoints in waypoint list */ }; using route_hdr = void (*)(const route_head*); diff --git a/garmin_txt.cc b/garmin_txt.cc index 485bf3c9e..f49984112 100644 --- a/garmin_txt.cc +++ b/garmin_txt.cc @@ -621,7 +621,7 @@ route_disp_hdr_cb(const route_head* rte) cur_info = &route_info[route_idx]; cur_info->prev_wpt = nullptr; cur_info->total = 0; - if (rte->rte_waypt_ct <= 0) { + if (rte->rte_waypt_ct() <= 0) { return; } @@ -675,7 +675,7 @@ track_disp_hdr_cb(const route_head* track) cur_info = &route_info[route_idx]; cur_info->prev_wpt = nullptr; cur_info->total = 0; - if (track->rte_waypt_ct <= 0) { + if (track->rte_waypt_ct() <= 0) { return; } diff --git a/gdb.cc b/gdb.cc index dd901bdf9..607505802 100644 --- a/gdb.cc +++ b/gdb.cc @@ -112,7 +112,7 @@ static int trk_ct; /* informational: total number of tracks in/out */ /*******************************************************************************/ -#define ELEMENTS(a) a->rte_waypt_ct +#define ELEMENTS(a) a->rte_waypt_ct() #define NOT_EMPTY(a) (a && *a) static void diff --git a/ggv_ovl.cc b/ggv_ovl.cc index 21f03e553..c862dce2b 100644 --- a/ggv_ovl.cc +++ b/ggv_ovl.cc @@ -266,7 +266,7 @@ waypt_disp_cb(const Waypoint* wpt) static void track_disp_cb(const route_head* trk) { - int waypt_ct = trk->rte_waypt_ct; + int waypt_ct = trk->rte_waypt_ct(); if (waypt_ct <= 0) { return; @@ -294,7 +294,7 @@ track_disp_cb(const route_head* trk) static void route_disp_cb(const route_head* rte) { - int waypt_ct = rte->rte_waypt_ct; + int waypt_ct = rte->rte_waypt_ct(); if (waypt_ct <= 0) { return; diff --git a/gtm.cc b/gtm.cc index 82c23766c..d0581d42f 100644 --- a/gtm.cc +++ b/gtm.cc @@ -416,7 +416,7 @@ gtm_rd_deinit() static void count_track_styles(const route_head* rte) { - if (rte->rte_waypt_ct > 0) { + if (rte->rte_waypt_ct() > 0) { ts_count++; } } @@ -670,7 +670,7 @@ static void write_trk_waypt(const Waypoint* wpt) static void write_trk_style(const route_head* trk) { - if (trk->rte_waypt_ct > 0) { + if (trk->rte_waypt_ct() > 0) { fwrite_string(file_out, trk->rte_name); fwrite_byte(file_out, 1); fwrite_long(file_out, 0); diff --git a/humminbird.cc b/humminbird.cc index 403393708..40765ec48 100644 --- a/humminbird.cc +++ b/humminbird.cc @@ -729,7 +729,7 @@ humminbird_track_head(const route_head* trk) trk_head = nullptr; last_time = 0; - if (trk->rte_waypt_ct > 0) { + if (trk->rte_waypt_ct() > 0) { trk_head = (humminbird_trk_header_t*) xcalloc(1, sizeof(humminbird_trk_header_t)); trk_points = (humminbird_trk_point_t*) xcalloc(max_points, sizeof(humminbird_trk_point_t)); @@ -852,7 +852,7 @@ static void humminbird_rte_head(const route_head* rte) { humrte = nullptr; - if (rte->rte_waypt_ct > 0) { + if (rte->rte_waypt_ct() > 0) { humrte = (humminbird_rte_t*) xcalloc(1, sizeof(*humrte)); } } diff --git a/igc.cc b/igc.cc index d728595d3..faa3065ba 100644 --- a/igc.cc +++ b/igc.cc @@ -499,12 +499,12 @@ static void detect_other_track(const route_head* rh) max_waypt_ct = 0; } // Find other track with the most waypoints - if (rh->rte_waypt_ct > max_waypt_ct && + if (rh->rte_waypt_ct() > max_waypt_ct && (rh->rte_name.isEmpty() || (!rh->rte_name.startsWith(PRESTRKNAME) && !rh->rte_name.startsWith(GNSSTRKNAME)))) { head = rh; - max_waypt_ct = rh->rte_waypt_ct; + max_waypt_ct = rh->rte_waypt_ct(); } } @@ -651,7 +651,7 @@ static void wr_task_hdr(const route_head* rte) unsigned char have_takeoff = 0; char flight_date[7] = "000000"; char task_desc[MAXRECLEN] = ""; - int num_tps = rte->rte_waypt_ct - 2; + int num_tps = rte->rte_waypt_ct() - 2; struct tm* tm; time_t rte_time; static unsigned int task_num = 1; diff --git a/ignrando.cc b/ignrando.cc index fdda2e7bd..5fe43a76e 100644 --- a/ignrando.cc +++ b/ignrando.cc @@ -219,7 +219,7 @@ ignr_write_track_hdr(const route_head* track_hdr) } gbfprintf(fout, "\t\n"); - gbfprintf(fout, "\t\t%d\n", track_hdr->rte_waypt_ct); + gbfprintf(fout, "\t\t%d\n", track_hdr->rte_waypt_ct()); if (!track_hdr->rte_desc.isEmpty()) { gbfprintf(fout, "\t\t%s\n", STRFROMUNICODE(track_hdr->rte_desc)); } diff --git a/kml.cc b/kml.cc index a548e5b85..695b30d65 100644 --- a/kml.cc +++ b/kml.cc @@ -251,12 +251,12 @@ void KmlFormat::trk_coord(xg_string args, const QXmlStreamAttributes* /*attrs*/) if (wpt_timespan_begin.isValid() && wpt_timespan_end.isValid()) { // If there are some Waypoints, then distribute the TimeSpan to all Waypoints - if (trk_head->rte_waypt_ct > 0) { + if (trk_head->rte_waypt_ct() > 0) { qint64 timespan_ms = wpt_timespan_begin.msecsTo(wpt_timespan_end); - if (trk_head->rte_waypt_ct < 2) { + if (trk_head->rte_waypt_ct() < 2) { fatal(MYNAME ": attempt to interpolate TimeSpan with too few points."); } - qint64 ms_per_waypoint = timespan_ms / (trk_head->rte_waypt_ct - 1); + qint64 ms_per_waypoint = timespan_ms / (trk_head->rte_waypt_ct() - 1); foreach (Waypoint* trackpoint, trk_head->waypoint_list) { trackpoint->SetCreationTime(wpt_timespan_begin); wpt_timespan_begin = wpt_timespan_begin.addMSecs(ms_per_waypoint); @@ -315,7 +315,7 @@ void KmlFormat::gx_trk_e(xg_string /*args*/, const QXmlStreamAttributes* /*attrs } } - if (!gx_trk_head->rte_waypt_ct) { + if (!gx_trk_head->rte_waypt_ct()) { track_del_head(gx_trk_head); } delete gx_trk_times; @@ -662,7 +662,7 @@ void KmlFormat::kml_output_header(const route_head* header, const computed_trkda writer->writeOptionalTextElement(QStringLiteral("name"), header->rte_name); kml_output_trkdescription(header, td); - if (export_points && header->rte_waypt_ct > 0) { + if (export_points && header->rte_waypt_ct() > 0) { // Put the points in a subfolder writer->writeStartElement(QStringLiteral("Folder")); writer->writeTextElement(QStringLiteral("name"), QStringLiteral("Points")); @@ -880,12 +880,12 @@ void KmlFormat::kml_output_point(const Waypoint* waypointp, kml_point_type pt_ty void KmlFormat::kml_output_tailer(const route_head* header) { - if (export_points && header->rte_waypt_ct > 0) { + if (export_points && header->rte_waypt_ct() > 0) { writer->writeEndElement(); // Close Folder tag } // Add a linestring for this track? - if (export_lines && header->rte_waypt_ct > 0) { + if (export_lines && header->rte_waypt_ct() > 0) { int needs_multigeometry = 0; foreach (const Waypoint* tpt, header->waypoint_list) { @@ -1459,7 +1459,7 @@ void KmlFormat::kml_waypt_pr(const Waypoint* waypointp) const void KmlFormat::kml_track_hdr(const route_head* header) const { computed_trkdata td = track_recompute(header); - if (header->rte_waypt_ct > 0 && (export_lines || export_points)) { + if (header->rte_waypt_ct() > 0 && (export_lines || export_points)) { kml_output_header(header, &td); } } @@ -1471,7 +1471,7 @@ void KmlFormat::kml_track_disp(const Waypoint* waypointp) const void KmlFormat::kml_track_tlr(const route_head* header) { - if (header->rte_waypt_ct > 0 && (export_lines || export_points)) { + if (header->rte_waypt_ct() > 0 && (export_lines || export_points)) { kml_output_tailer(header); } } @@ -2002,7 +2002,7 @@ void KmlFormat::wr_position(Waypoint* wpt) * head here. */ while (max_position_points && - (posn_trk_head->rte_waypt_ct >= max_position_points)) { + (posn_trk_head->rte_waypt_ct() >= max_position_points)) { Waypoint* tonuke = posn_trk_head->waypoint_list.front(); track_del_wpt(posn_trk_head, tonuke); } diff --git a/lowranceusr.cc b/lowranceusr.cc index b72ab47a4..6e51a0f42 100644 --- a/lowranceusr.cc +++ b/lowranceusr.cc @@ -1560,7 +1560,7 @@ LowranceusrFormat::lowranceusr_trail_hdr(const route_head* trk) gbfputint32(text_len, file_out); gbfwrite(CSTR(name), 1, text_len, file_out); - auto num_trail_points = (short) trk->rte_waypt_ct; + auto num_trail_points = (short) trk->rte_waypt_ct(); short max_trail_size = MAX_TRAIL_POINTS; if (num_trail_points > max_trail_size) { num_trail_points = max_trail_size; @@ -1602,7 +1602,7 @@ LowranceusrFormat::lowranceusr_route_hdr(const route_head* rte) gbfputs(name, file_out); /* num legs */ - auto num_legs = (short) rte->rte_waypt_ct; + auto num_legs = (short) rte->rte_waypt_ct(); gbfputint16(num_legs, file_out); char route_reversed=0; gbfwrite(&route_reversed, 1, 1, file_out); @@ -1617,7 +1617,7 @@ LowranceusrFormat::lowranceusr4_route_hdr(const route_head* rte) { if (global_opts.debug_level >= 1) { printf(MYNAME " writing route #%d (%s) with %d waypts\n", - route_uid, qPrintable(rte->rte_name), rte->rte_waypt_ct); + route_uid, qPrintable(rte->rte_name), rte->rte_waypt_ct()); } const auto* fs = reinterpret_cast(rte->fs.FsChainFind(kFsLowranceusr4)); @@ -1642,7 +1642,7 @@ LowranceusrFormat::lowranceusr4_route_hdr(const route_head* rte) lowranceusr4_writestr(rte->rte_name, file_out, 2); /* Num Legs */ - gbfputint32(rte->rte_waypt_ct, file_out); + gbfputint32(rte->rte_waypt_ct(), file_out); } void @@ -1720,7 +1720,7 @@ LowranceusrFormat::lowranceusr_merge_trail_hdr(const route_head* trk) } } - trail_point_count += (short) trk->rte_waypt_ct; + trail_point_count += (short) trk->rte_waypt_ct(); } void @@ -1756,7 +1756,7 @@ LowranceusrFormat::lowranceusr4_trail_hdr(const route_head* trail) { if (global_opts.debug_level >= 1) { printf(MYNAME " writing trail %d (%s) with %d trailpoints\n", - trail_uid, qPrintable(trail->rte_name), trail->rte_waypt_ct); + trail_uid, qPrintable(trail->rte_name), trail->rte_waypt_ct()); } /* UID unit number */ @@ -1803,7 +1803,7 @@ LowranceusrFormat::lowranceusr4_trail_hdr(const route_head* trail) // } /* Trackpoint count */ - gbfputint32(trail->rte_waypt_ct, file_out); + gbfputint32(trail->rte_waypt_ct(), file_out); } void diff --git a/magproto.cc b/magproto.cc index ed707aec1..ca9fb5adb 100644 --- a/magproto.cc +++ b/magproto.cc @@ -1471,7 +1471,7 @@ mag_route_trl(const route_head* rte) QString icon_token; /* count waypoints for this route */ - int i = rte->rte_waypt_ct; + int i = rte->rte_waypt_ct(); /* number of output PMGNRTE messages at 2 points per line */ int numlines = (i / 2) + (i % 2); diff --git a/mapsend.cc b/mapsend.cc index b920938f3..61c761dce 100644 --- a/mapsend.cc +++ b/mapsend.cc @@ -359,7 +359,7 @@ mapsend_route_hdr(const route_head* rte) gbfputint32(rte->rte_num, mapsend_file_out); /* # of waypoints to follow... */ - gbfputint32(rte->rte_waypt_ct, mapsend_file_out); + gbfputint32(rte->rte_waypt_ct(), mapsend_file_out); } static void diff --git a/mmo.cc b/mmo.cc index cb3641f19..ddf41b046 100644 --- a/mmo.cc +++ b/mmo.cc @@ -350,7 +350,7 @@ mmo_end_of_route(mmo_data_t* data) DBG((sobj, "for \"%s\" \n", data->name)); } - if (rte->rte_waypt_ct == 0) { /* don't keep empty routes */ + if (rte->rte_waypt_ct() == 0) { /* don't keep empty routes */ route_del_head(rte); data->data = nullptr; } @@ -721,7 +721,7 @@ mmo_read_CObjTrack(mmo_data_t* data) } } - if (trk->rte_waypt_ct == 0) { + if (trk->rte_waypt_ct() == 0) { track_del_head(trk); data->data = nullptr; } @@ -1127,7 +1127,7 @@ mmo_enum_waypt_cb(const Waypoint*) static void mmo_enum_route_cb(const route_head* rte) { - if (rte->rte_waypt_ct > 0) { + if (rte->rte_waypt_ct() > 0) { mmo_obj_ct++; } } @@ -1293,7 +1293,7 @@ mmo_write_rte_head_cb(const route_head* rte) { time_t time = 0x7FFFFFFF; - if (rte->rte_waypt_ct <= 0) { + if (rte->rte_waypt_ct() <= 0) { return; } @@ -1313,18 +1313,18 @@ mmo_write_rte_head_cb(const route_head* rte) mmo_register_object(objid, rte, rtedata); mmo_write_category("CCategory", "Route"); gbfputc(0, fout); /* unknown */ - gbfputuint16(rte->rte_waypt_ct, fout); + gbfputuint16(rte->rte_waypt_ct(), fout); } static void mmo_write_rte_tail_cb(const route_head* rte) { - if (rte->rte_waypt_ct <= 0) { + if (rte->rte_waypt_ct() <= 0) { return; } - DBG(("write", "route with %d point(s).\n", rte->rte_waypt_ct)); + DBG(("write", "route with %d point(s).\n", rte->rte_waypt_ct())); if (mmo_version >= 0x12) { if (rte->line_color.bbggrr < 0) { @@ -1350,14 +1350,14 @@ mmo_write_rte_tail_cb(const route_head* rte) static void mmo_write_trk_head_cb(const route_head* trk) { - if (trk->rte_waypt_ct <= 0) { + if (trk->rte_waypt_ct() <= 0) { return; } int objid = mmo_write_obj_head("CObjTrack", trk->rte_name.isEmpty() ? "Track" : CSTR(trk->rte_name), gpsbabel_time, obj_type_trk); mmo_write_category("CCategory", "Track"); - gbfputuint16(trk->rte_waypt_ct, fout); + gbfputuint16(trk->rte_waypt_ct(), fout); mmo_register_object(objid, trk, trkdata); } @@ -1366,7 +1366,7 @@ mmo_write_trk_head_cb(const route_head* trk) static void mmo_write_trk_tail_cb(const route_head* trk) { - if (trk->rte_waypt_ct <= 0) { + if (trk->rte_waypt_ct() <= 0) { return; } diff --git a/navilink.cc b/navilink.cc index 2c15b620a..6f92e2712 100644 --- a/navilink.cc +++ b/navilink.cc @@ -684,7 +684,7 @@ serial_read_routes(Waypoint** waypts) static void serial_write_route_start(const route_head* route) { - route_ids = (unsigned int*) xmalloc(route->rte_waypt_ct * sizeof(unsigned)); + route_ids = (unsigned int*) xmalloc(route->rte_waypt_ct() * sizeof(unsigned)); route_id_ptr = 0; } diff --git a/osm.cc b/osm.cc index 30b85a2b2..a34c5b9b2 100644 --- a/osm.cc +++ b/osm.cc @@ -803,7 +803,7 @@ OsmFormat::osm_waypt_disp(const Waypoint* waypoint) void OsmFormat::osm_rte_disp_head(const route_head* route) { - skip_rte = route->rte_waypt_ct <= 0; + skip_rte = route->rte_waypt_ct() <= 0; if (skip_rte) { return; diff --git a/ozi.cc b/ozi.cc index 4e218d3d1..228122f80 100644 --- a/ozi.cc +++ b/ozi.cc @@ -609,7 +609,7 @@ ozi_parse_track(int field, const QString& str, Waypoint* wpt_tmp, char* trk_name break; case 2: /* new track flag */ - if ((str.toInt() == 1) && (trk_head->rte_waypt_ct > 0)) { + if ((str.toInt() == 1) && (trk_head->rte_waypt_ct() > 0)) { trk_head = new route_head; track_add_head(trk_head); if (trk_name) { diff --git a/position.cc b/position.cc index bb372f956..23ccd3381 100644 --- a/position.cc +++ b/position.cc @@ -124,7 +124,7 @@ void PositionFilter::position_runqueue(WaypointList* waypt_list, int qtype) void PositionFilter::position_process_any_route(const route_head* rh, int type) { - if (rh->rte_waypt_ct != 0) { + if (rh->rte_waypt_ct() != 0) { cur_rte = const_cast(rh); position_runqueue(&cur_rte->waypoint_list, type); cur_rte = nullptr; diff --git a/raymarine.cc b/raymarine.cc index 75fc6ec7a..aaa1988dd 100644 --- a/raymarine.cc +++ b/raymarine.cc @@ -415,7 +415,7 @@ write_route_wpt_cb(const Waypoint* wpt) static void enum_route_hdr_cb(const route_head* rte) { - is_fatal(rte->rte_waypt_ct > 50, + is_fatal(rte->rte_waypt_ct() > 50, MYNAME ": Routes with more than 50 points are not supported by Raymarine!"); } diff --git a/route.cc b/route.cc index ee03684e7..115a119fe 100644 --- a/route.cc +++ b/route.cc @@ -358,7 +358,6 @@ computed_trkdata track_recompute(const route_head* trk) route_head::route_head() : rte_num(0), - rte_waypt_ct(0), // line_color(), line_width(-1), session(curr_session()) @@ -389,7 +388,7 @@ RouteList::add_head(route_head* rte) void RouteList::del_head(route_head* rte) { - waypt_ct -= rte->rte_waypt_ct; + waypt_ct -= rte->rte_waypt_ct(); const int idx = this->indexOf(rte); assert(idx >= 0); removeAt(idx); @@ -411,7 +410,6 @@ RouteList::insert_head(route_head* rte, route_head* predecessor) void RouteList::add_wpt(route_head* rte, Waypoint* wpt, bool synth, const QString& namepart, int number_digits) { - rte->rte_waypt_ct++; /* waypoints in this route */ ++waypt_ct; rte->waypoint_list.add_rte_waypt(waypt_ct, wpt, synth, namepart, number_digits); if ((this == global_route_list) || (this == global_track_list)) { @@ -423,7 +421,6 @@ void RouteList::del_wpt(route_head* rte, Waypoint* wpt) { rte->waypoint_list.del_rte_waypt(wpt); - rte->rte_waypt_ct--; --waypt_ct; } @@ -467,7 +464,6 @@ RouteList::copy(RouteList** dst) const rte_new->rte_desc = rte_old->rte_desc; rte_new->rte_urls = rte_old->rte_urls; rte_new->rte_num = rte_old->rte_num; - // rte_waypt_ct created below with add_wpt. rte_new->fs = rte_old->fs.FsChainCopy(); rte_new->line_color = rte_old->line_color; rte_new->line_width = rte_old->line_width; diff --git a/saroute.cc b/saroute.cc index eac684804..a02044f4b 100644 --- a/saroute.cc +++ b/saroute.cc @@ -285,7 +285,7 @@ my_read() record = ReadRecord(infile, recsize); stringlen = le_read16((uint16_t*)record); if (split && stringlen) { - if (track_head->rte_waypt_ct) { + if (track_head->rte_waypt_ct()) { old_track_head = track_head; track_head = new route_head; if (timesynth) { diff --git a/shape.cc b/shape.cc index 6bb81a499..874ddb0aa 100644 --- a/shape.cc +++ b/shape.cc @@ -422,7 +422,7 @@ ShapeFormat::write_wpt(const Waypoint* wpt) const void ShapeFormat::poly_init(const route_head* rte) { - const int ct = rte->rte_waypt_ct; + const int ct = rte->rte_waypt_ct(); poly_count = 0; polybufx = new double[ct]; polybufy = new double[ct]; @@ -446,7 +446,7 @@ ShapeFormat::poly_deinit(const route_head* rte) // to SHPT_ARC. // We could potentially write SHPT_ARCZ, but we would have // to address what to do when we don't have altitude data. - assert(rte->rte_waypt_ct == poly_count); + assert(rte->rte_waypt_ct() == poly_count); SHPObject* shpobject = SHPCreateSimpleObject(SHPT_ARC, poly_count, polybufx, polybufy, polybufz); int iShape = SHPWriteObject(ohandle, -1, shpobject); diff --git a/skyforce.cc b/skyforce.cc index 51bef2b5b..b5152f15e 100644 --- a/skyforce.cc +++ b/skyforce.cc @@ -123,7 +123,7 @@ static void skyforce_head_disp_cb(const route_head* head) { prev_wpt = nullptr; - if (head->rte_waypt_ct <= 0) { + if (head->rte_waypt_ct() <= 0) { return; } diff --git a/smplrout.cc b/smplrout.cc index eb67a2fa5..569213797 100644 --- a/smplrout.cc +++ b/smplrout.cc @@ -195,16 +195,16 @@ void SimplifyRouteFilter::routesimple_head(const route_head* rte) totalerror = 0; /* short-circuit if we already have fewer than the max points */ - if (countopt && count >= rte->rte_waypt_ct) { + if (countopt && count >= rte->rte_waypt_ct()) { return; } /* short-circuit if the route is impossible to simplify, too. */ - if (2 >= rte->rte_waypt_ct) { + if (2 >= rte->rte_waypt_ct()) { return; } - xte_recs = new struct xte[rte->rte_waypt_ct]; + xte_recs = new struct xte[rte->rte_waypt_ct()]; cur_rte = rte; } diff --git a/stmsdf.cc b/stmsdf.cc index a7e3e7c17..0787696cd 100644 --- a/stmsdf.cc +++ b/stmsdf.cc @@ -605,7 +605,7 @@ track_disp_wpt_cb(const Waypoint* wpt) calculate(wpt, &dist, &speed, &course, nullptr, nullptr); trkpt_dist = trkpt_dist + dist; - if (track_points == trk_out->rte_waypt_ct) { /* I'm the last in that list */ + if (track_points == trk_out->rte_waypt_ct()) { /* I'm the last in that list */ if (all_track_points != saved_track_points) { /* but not the overall latest */ flag = 1; } diff --git a/tpo.cc b/tpo.cc index c47741156..17729af63 100644 --- a/tpo.cc +++ b/tpo.cc @@ -1943,7 +1943,7 @@ tpo_track_hdr(const route_head* rte) gbfwrite(bounding_box, 1, sizeof(bounding_box), tpo_file_out); /* number of route points */ - gbfputint16(rte->rte_waypt_ct, tpo_file_out); + gbfputint16(rte->rte_waypt_ct(), tpo_file_out); /* initialize the track length computation */ track_length = 0; diff --git a/trackfilter.cc b/trackfilter.cc index 079bf36e7..39b82c276 100644 --- a/trackfilter.cc +++ b/trackfilter.cc @@ -179,7 +179,7 @@ QDateTime TrackFilter::trackfilter_get_last_time(const route_head* track) void TrackFilter::trackfilter_fill_track_list_cb(const route_head* track) /* callback for track_disp_all */ { - if (track->rte_waypt_ct == 0) { + if (track->rte_waypt_ct() == 0) { track_del_head(const_cast(track)); return; } @@ -223,7 +223,7 @@ void TrackFilter::trackfilter_fill_track_list_cb(const route_head* track) /* ca void TrackFilter::trackfilter_minpoint_list_cb(const route_head* track) { - if (track->rte_waypt_ct < minimum_points) { + if (track->rte_waypt_ct() < minimum_points) { track_del_head(const_cast(track)); return; } @@ -268,7 +268,7 @@ void TrackFilter::trackfilter_pack_init_rte_name(route_head* track, const gpsbab // Uggh. strftime format exposed to user. gpsbabel::DateTime dt; - if (track->rte_waypt_ct == 0) { + if (track->rte_waypt_ct() == 0) { dt = default_time; } else { auto* wpt = track->waypoint_list.front(); @@ -388,7 +388,7 @@ void TrackFilter::trackfilter_merge() } } - if (master->rte_waypt_ct == 0) { + if (master->rte_waypt_ct() == 0) { track_del_head(master); track_list.clear(); } @@ -412,7 +412,7 @@ void TrackFilter::trackfilter_split() fatal(MYNAME "-split: Cannot split more than one track, please pack (or merge) before!\n"); } else if (!track_list.isEmpty()) { route_head* master = track_list.first(); - int count = master->rte_waypt_ct; + int count = master->rte_waypt_ct(); int i, j; double interval = -1; /* seconds */ @@ -724,7 +724,7 @@ void TrackFilter::trackfilter_range() } } - if (track->rte_waypt_ct == 0) { + if (track->rte_waypt_ct() == 0) { track_del_head(track); it = track_list.erase(it); } else { diff --git a/validate.cc b/validate.cc index df7d2b8ee..50d4b0ef3 100644 --- a/validate.cc +++ b/validate.cc @@ -37,10 +37,10 @@ void ValidateFilter::validate_head_trl(const route_head* header) { int segment_waypt_ct = point_ct - segment_ct_start; if (debug) { - fprintf(stderr, "%s %d ct: %d, waypt_count: %d\n", segment_type, header->rte_num, segment_waypt_ct, header->rte_waypt_ct); + fprintf(stderr, "%s %d ct: %d, waypt_count: %d\n", segment_type, header->rte_num, segment_waypt_ct, header->rte_waypt_ct()); } - if (!debug && (segment_waypt_ct != header->rte_waypt_ct)) { - fatal(MYNAME ":%s %d count mismatch, expected %d, actual %d\n", segment_type, header->rte_num, header->rte_waypt_ct, segment_waypt_ct); + if (!debug && (segment_waypt_ct != header->rte_waypt_ct())) { + fatal(MYNAME ":%s %d count mismatch, expected %d, actual %d\n", segment_type, header->rte_num, header->rte_waypt_ct(), segment_waypt_ct); } } diff --git a/xol.cc b/xol.cc index 474a8f87f..b5cd7ea40 100644 --- a/xol.cc +++ b/xol.cc @@ -110,7 +110,7 @@ static void xol_shape_end(xg_string, const QXmlStreamAttributes*) { } wpt_ = nullptr; } else if (trk_) { - if (trk_->rte_waypt_ct == 0) { + if (trk_->rte_waypt_ct() == 0) { track_del_head(trk_); } trk_ = nullptr;