From addb94b1bb8cd5e6118212d5a741c762187fa0a5 Mon Sep 17 00:00:00 2001 From: Karl Lehenbauer Date: Wed, 19 Mar 2014 22:06:10 +0000 Subject: [PATCH] Add a rollback capability to showFlightsFATSV where it will not issue an update for a hexid that doesn't contain anything update-worthy. --- net_io.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/net_io.c b/net_io.c index c00ea36..f85afc0 100644 --- a/net_io.c +++ b/net_io.c @@ -948,6 +948,8 @@ void showFlightsFATSV(void) { int groundValid = 0; int ground = 0; int latlonValid = 0; + int useful = 0; + char *rollback = p; if (0 && a->modeACflags & MODEAC_MSG_FLAG) { // skip any fudged ICAO records Mode A/C a = a->next; @@ -1017,7 +1019,6 @@ void showFlightsFATSV(void) { } } - p += sprintf(p, "clock\t%ld\thexid\t%06X", a->seen, a->addr); // if ((a->bFlags & MODES_ACFLAGS_CALLSIGN_VALID) && *a->flight != '\0') { @@ -1031,10 +1032,12 @@ void showFlightsFATSV(void) { if (altValid) { p += sprintf(p, "\talt\t%d", alt); + useful = 1; } if (a->bFlags & MODES_ACFLAGS_SPEED_VALID) { p += sprintf(p, "\tspeed\t%d", a->speed); + useful = 1; } if (groundValid) { @@ -1047,10 +1050,21 @@ void showFlightsFATSV(void) { if (a->lat != 0.0 || a->lon != 0.0) { p += sprintf(p, "\tlat\t%.5f\tlon\t%.5f", a->lat, a->lon); + useful = 1; } if (a->bFlags & MODES_ACFLAGS_HEADING_VALID) { p += sprintf(p, "\theading\t%d", a->track); + useful = 1; + } + + // if we didn't get at least an alt or a speed or a latlon or + // a heading, undo this message we've been prepping by setting + // the p pointer back to what it was when we started generating + // the message for this aircraft + if (!useful) { + p = rollback; + continue; } // if there's a verbatim string and it's not null, append it to the