summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dive.c9
-rw-r--r--divelist.c12
-rw-r--r--profile.c2
3 files changed, 10 insertions, 13 deletions
diff --git a/dive.c b/dive.c
index aee09d53a..54784cdba 100644
--- a/dive.c
+++ b/dive.c
@@ -478,11 +478,12 @@ struct dive *fixup_dive(struct dive *dive)
int asc_desc_time = depth*60/9000;
int duration = dive->duration.seconds;
- /* Protect against insane dives - make mean be half of max */
- if (duration <= asc_desc_time) {
+ /* Some sanity checks against insane dives */
+ if (duration < 2)
duration = 2;
- asc_desc_time = 1;
- }
+ if (asc_desc_time * 2 >= duration)
+ asc_desc_time = duration/2;
+
dive->meandepth.mm = depth*(duration-asc_desc_time)/duration;
return dive;
}
diff --git a/divelist.c b/divelist.c
index a773b6017..1e1d1c921 100644
--- a/divelist.c
+++ b/divelist.c
@@ -328,8 +328,8 @@ static void date_data_func(GtkTreeViewColumn *col,
time_t when;
char buffer[40];
- gtk_tree_model_get(model, iter, DIVE_INDEX, &idx, DIVE_DATE, &val, DIVE_NR, &nr, -1);
-
+ gtk_tree_model_get(model, iter, DIVE_INDEX, &idx, DIVE_DATE, &val, -1);
+ nr = gtk_tree_model_iter_n_children(model, iter);
/* 2038 problem */
when = val;
@@ -904,7 +904,6 @@ static void fill_dive_list(void)
/* make sure we display the first date of the trip in previous summary */
if (dive_trip && parent_ptr) {
gtk_tree_store_set(treestore, parent_ptr,
- DIVE_NR, dive_trip->number,
DIVE_DATE, dive_trip->when,
DIVE_LOCATION, dive_trip->location,
-1);
@@ -947,15 +946,12 @@ static void fill_dive_list(void)
}
} else {
dive_trip = trip->data;
- dive_trip->number = 0;
}
}
}
- /* update dive_trip to include this dive, increase number of dives in
- the trip and update location if necessary */
+ /* update dive_trip time and (if necessary) location */
if (dive_trip) {
dive->tripflag = IN_TRIP;
- dive_trip->number++;
dive_trip->when = dive->when;
if (!dive_trip->location && dive->location)
dive_trip->location = dive->location;
@@ -967,7 +963,6 @@ static void fill_dive_list(void)
/* a duration of 0 (and negative index) identifies a group */
gtk_tree_store_set(treestore, parent_ptr,
DIVE_INDEX, -1,
- DIVE_NR, dive_trip->number,
DIVE_DATE, dive_trip->when,
DIVE_LOCATION, dive_trip->location,
DIVE_DURATION, 0,
@@ -1008,7 +1003,6 @@ static void fill_dive_list(void)
/* make sure we display the first date of the trip in previous summary */
if (parent_ptr && dive_trip)
gtk_tree_store_set(treestore, parent_ptr,
- DIVE_NR, dive_trip->number,
DIVE_DATE, dive_trip->when,
DIVE_LOCATION, dive_trip->location,
-1);
diff --git a/profile.c b/profile.c
index d4e88c02c..0039867ef 100644
--- a/profile.c
+++ b/profile.c
@@ -1387,6 +1387,8 @@ void plot(struct graphics_context *gc, cairo_rectangle_int_t *drawing_area, stru
int duration = dive->duration.seconds;
int maxdepth = dive->maxdepth.mm;
int asc_desc_time = dive->maxdepth.mm*60/9000;
+ if (asc_desc_time * 2 >= duration)
+ asc_desc_time = duration / 2;
sample = fake;
fake[1].time.seconds = asc_desc_time;
fake[1].depth.mm = maxdepth;