diff options
author | Anton Lundin <glance@acc.umu.se> | 2013-11-27 23:05:51 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-11-27 14:15:12 -0800 |
commit | 9b5c7c2bbeaf5b4b17258f2549b08e34bcb42045 (patch) | |
tree | ba6e26f6c65692593aa49fd8526c57fbe1c65c11 | |
parent | 57fb878b41bb803aa9418f84e82aa489b5d542d3 (diff) | |
download | subsurface-9b5c7c2bbeaf5b4b17258f2549b08e34bcb42045.tar.gz |
Only return gas volumes for gases used
We check in get_gaslist is_gas_used, so if were going to be consistent
about what we return from get_gaslist and in get_gas_used, only return
gas volumes that we actually consumed during the dive.
The problem now this fixes can be seen in dives/test10.xml
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | statistics.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/statistics.c b/statistics.c index 51b8d60e2..c4beba3b2 100644 --- a/statistics.c +++ b/statistics.c @@ -293,20 +293,6 @@ void get_selected_dives_text(char *buffer, int size) } } -void get_gas_used(struct dive *dive, volume_t gases[MAX_CYLINDERS]) -{ - int idx; - for (idx = 0; idx < MAX_CYLINDERS; idx++) { - cylinder_t *cyl = &dive->cylinder[idx]; - pressure_t start, end; - - start = cyl->start.mbar ? cyl->start : cyl->sample_start; - end = cyl->end.mbar ? cyl->end : cyl->sample_end; - if (start.mbar && end.mbar) - gases[idx].mliter = gas_volume(cyl, start) - gas_volume(cyl, end); - } -} - bool is_gas_used(struct dive *dive, int idx) { cylinder_t *cyl = &dive->cylinder[idx]; @@ -354,6 +340,23 @@ bool is_gas_used(struct dive *dive, int idx) return used; } +void get_gas_used(struct dive *dive, volume_t gases[MAX_CYLINDERS]) +{ + int idx; + for (idx = 0; idx < MAX_CYLINDERS; idx++) { + cylinder_t *cyl = &dive->cylinder[idx]; + pressure_t start, end; + + if (!is_gas_used(dive, idx)) + continue; + + start = cyl->start.mbar ? cyl->start : cyl->sample_start; + end = cyl->end.mbar ? cyl->end : cyl->sample_end; + if (start.mbar && end.mbar) + gases[idx].mliter = gas_volume(cyl, start) - gas_volume(cyl, end); + } +} + #define MAXBUF 80 /* for the O2/He readings just create a list of them */ char *get_gaslist(struct dive *dive) |