aboutsummaryrefslogtreecommitdiffstats
path: root/core/dive.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-05-19 18:40:04 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-05-20 21:23:16 -0700
commit4fe9b39cdbb5839830281820621059cefc26a03a (patch)
tree952d4b3449c32c644140e94f8da38cf389135955 /core/dive.c
parentac590235c94fc2feb1f35a5cd290ea87f1a92044 (diff)
downloadsubsurface-4fe9b39cdbb5839830281820621059cefc26a03a.tar.gz
Core: let count_divecomputers() operate on an arbitrary dive
Currently, count_divecomputers only works on the current_dive. Instead, let it take a pointer to an arbitrary dive. This is in preparation for being smarter in the undo code concerning which dive computer to show on deletion. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/dive.c')
-rw-r--r--core/dive.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/core/dive.c b/core/dive.c
index 2b3b7ef62..5ddaded9e 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -4189,11 +4189,10 @@ struct dive *make_first_dc(const struct dive *d, int dc_number)
return res;
}
-/* always acts on the current dive */
-unsigned int count_divecomputers(void)
+int count_divecomputers(const struct dive *d)
{
int ret = 1;
- struct divecomputer *dc = current_dive->dc.next;
+ struct divecomputer *dc = d->dc.next;
while (dc) {
ret++;
dc = dc->next;
@@ -4229,7 +4228,7 @@ static void delete_divecomputer(struct dive *d, int num)
/* If this is the currently displayed dive, we might have to adjust
* the currently displayed dive computer. */
- if (d == current_dive && dc_number >= count_divecomputers())
+ if (d == current_dive && dc_number >= count_divecomputers(d))
dc_number--;
invalidate_dive_cache(d);
}