From 3aaf8b1f5af275f3b1d26ff7c21c6b47448d76c0 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 30 Jul 2014 10:08:33 -0700 Subject: Make gas use statistics be coherent and more complete The gas use logic in the dive statistics page is confused. The SAC case had a special case for "unknown", but only for the first gas. Other gases had the normal empty case. Also, the logic was really odd - if you had gases that weren't used (or pressures not known) intermixed with gases you *did* have pressure for, the statistics got really confused. The list of gases showed all gases that we know about during the dive, but then the gas use and SAC-rate lists wouldn't necessarily match, because the loops that computed those stopped after the first gas that didn't have any pressure change. To make things worse, the first cylinder was special-cased again, so it all lined up for the single-cylinder case. This makes all the cylinders act the same way, leaving unknown gas use (and thus SAC) just empty for that gas. It also fixes the SAC calculation case where we don't have real samples, and the profile is a fake profile - possibly with gas changes in between the fake points. We now make the SAC calculations match what we show - which is admittedly not at all necessarily what the dive was, but at least we're consistent. Signed-off-by: Linus Torvalds Signed-off-by: Dirk Hohndel --- statistics.c | 27 --------------------------- 1 file changed, 27 deletions(-) (limited to 'statistics.c') diff --git a/statistics.c b/statistics.c index 21b386b21..01adf4f14 100644 --- a/statistics.c +++ b/statistics.c @@ -331,33 +331,6 @@ void get_gas_used(struct dive *dive, volume_t gases[MAX_CYLINDERS]) } } -#define MAXBUF 80 -/* for the O2/He readings just create a list of them */ -char *get_gaslist(struct dive *dive) -{ - int idx, offset = 0; - static char buf[MAXBUF]; - - buf[0] = '\0'; - for (idx = 0; idx < MAX_CYLINDERS; idx++) { - cylinder_t *cyl; - if (!is_cylinder_used(dive, idx)) - continue; - cyl = &dive->cylinder[idx]; - if (offset > 0) { - strncpy(buf + offset, "\n", MAXBUF - offset); - offset = strlen(buf); - } - strncpy(buf + offset, gasname(&cyl->gasmix), MAXBUF - offset); - offset = strlen(buf); - } - if (*buf == '\0') - strncpy(buf, translate("gettextFromC", "air"), MAXBUF); - - buf[MAXBUF - 1] = '\0'; - return buf; -} - /* Quite crude reverse-blender-function, but it produces a approx result */ static void get_gas_parts(struct gasmix mix, volume_t vol, int o2_in_topup, volume_t *o2, volume_t *he) { -- cgit v1.2.3-70-g09d2