[Patch]Repair repetitive diving in planner

Dirk Hohndel dirk at hohndel.org
Mon Jul 7 09:19:20 PDT 2014


On Mon, Jul 07, 2014 at 02:03:37PM +0200, Robert Helling wrote:
> 
> this patch corrects the search for dives in the last 48h before a
> planned dive.

NAK

        tissue_tolerance = surface_pressure = get_surface_pressure_in_mbar(dive, true) / 1000.0;
-       divenr = get_divenr(dive);
+       divenr = get_divenr(dive) >= 0 ? get_divenr(dive) :

You get back -1 if your dive is not part of the dive_table (i.e., it's
most likely the displayed_dive). That does NOT mean that it is later than
the latest dive in your table. So instead you need to search backwards
through the table and find the first dive that comes BEFORE the dive in
question.

	i = divenr;
-       while (i && --i) {
+               ;

what's that lonely ';' doing there?

+       while (i >= 0 && --i >= 0) {

This is just silly. It is equivalent to 

	while (i > 0)

(please tell me a value for i where that is not the case)

> Furthermore it restricts depths in the divepointstable to non-negative
> values (negatives are easily reached with the scroll wheel). If someone
> could make the spinner appearing in the table not to accept negative
> values (via a setMinimium()) that would be great, I couldn’t find the
> correct place to do that.

I will take this part of your commit (I would want those to be two
commits, anyway).

/D


More information about the subsurface mailing list