summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2015-04-02 10:49:24 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-04-02 09:46:10 -0700
commit61ff7c5f8b29cd94e1bc0941bcc1492b3f167ed9 (patch)
tree41b982ed4ab0e4290a96c758d7e5931a8d0a72e9 /dive.c
parentcc8d6014229dbca15373f6c3d888a6404c0775f1 (diff)
downloadsubsurface-61ff7c5f8b29cd94e1bc0941bcc1492b3f167ed9.tar.gz
Only do safety stop of dive has at least max depth of 10m
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/dive.c b/dive.c
index 4afb21f37..bdb6937d4 100644
--- a/dive.c
+++ b/dive.c
@@ -2838,15 +2838,14 @@ void set_userid(char *rUserId)
prefs.userid[30]='\0';
}
-int average_depth(struct diveplan *dive)
+void average_max_depth(struct diveplan *dive, int *avg_depth, int *max_depth)
{
int integral = 0;
int last_time = 0;
int last_depth = 0;
struct divedatapoint *dp = dive->dp;
- if (!dp)
- return 0;
+ *max_depth = 0;
while (dp) {
if (dp->time) {
@@ -2854,13 +2853,15 @@ int average_depth(struct diveplan *dive)
integral += (dp->depth + last_depth) * (dp->time - last_time) / 2;
last_time = dp->time;
last_depth = dp->depth;
+ if (dp->depth > *max_depth)
+ *max_depth = dp->depth;
}
dp = dp->next;
}
if (last_time)
- return integral / last_time;
+ *avg_depth = integral / last_time;
else
- return 0;
+ *avg_depth = *max_depth = 0;
}
struct picture *alloc_picture()