diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-11-23 16:51:27 -1000 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-11-23 19:36:27 -0800 |
commit | 25b4fee655e847081031fffb60d0d4d04ab1a8ee (patch) | |
tree | 0217294aa7b15b55ea170294126ed86937eda271 /divelist.c | |
parent | a9786564c23fbf032f47096f543699c8c402785b (diff) | |
download | subsurface-25b4fee655e847081031fffb60d0d4d04ab1a8ee.tar.gz |
Move events and samples into a 'struct divecomputer'
For now we only have one fixed divecomputer associated with each dive,
so this doesn't really change any current semantics. But it will make
it easier for us to associate a dive with multiple dive computers.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divelist.c')
-rw-r--r-- | divelist.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/divelist.c b/divelist.c index 13eda68b5..cc301a8b0 100644 --- a/divelist.c +++ b/divelist.c @@ -697,15 +697,15 @@ static void otu_data_func(GtkTreeViewColumn *col, } /* calculate OTU for a dive */ -static int calculate_otu(struct dive *dive) +static int calculate_otu(struct dive *dive, struct divecomputer *dc) { int i; double otu = 0.0; - for (i = 1; i < dive->samples; i++) { + for (i = 1; i < dc->samples; i++) { int t; double po2; - struct sample *sample = dive->sample + i; + struct sample *sample = dc->sample + i; struct sample *psample = sample - 1; t = sample->time.seconds - psample->time.seconds; int o2 = dive->cylinder[sample->cylinderindex].gasmix.o2.permille; @@ -744,7 +744,7 @@ static double calculate_airuse(struct dive *dive) return airuse; } -static int calculate_sac(struct dive *dive) +static int calculate_sac(struct dive *dive, struct divecomputer *dc) { double airuse, pressure, sac; int duration, i; @@ -757,16 +757,16 @@ static int calculate_sac(struct dive *dive) /* find and eliminate long surface intervals */ duration = dive->duration.seconds; - for (i = 0; i < dive->samples; i++) { - if (dive->sample[i].depth.mm < 100) { /* less than 10cm */ + for (i = 0; i < dc->samples; i++) { + if (dc->sample[i].depth.mm < 100) { /* less than 10cm */ int end = i + 1; - while (end < dive->samples && dive->sample[end].depth.mm < 100) + while (end < dc->samples && dc->sample[end].depth.mm < 100) end++; /* we only want the actual surface time during a dive */ - if (end < dive->samples) { + if (end < dc->samples) { end--; - duration -= dive->sample[end].time.seconds - - dive->sample[i].time.seconds; + duration -= dc->sample[end].time.seconds - + dc->sample[i].time.seconds; i = end + 1; } } @@ -782,8 +782,8 @@ static int calculate_sac(struct dive *dive) void update_cylinder_related_info(struct dive *dive) { if (dive != NULL) { - dive->sac = calculate_sac(dive); - dive->otu = calculate_otu(dive); + dive->sac = calculate_sac(dive, &dive->dc); + dive->otu = calculate_otu(dive, &dive->dc); } } @@ -1931,7 +1931,7 @@ void delete_single_dive(int idx) dive_table.nr--; if (dive->selected) amount_selected--; - free(dive->sample); + free(dive->dc.sample); free(dive); } |