]> git.tdb.fi Git - ext/subsurface.git/blobdiff - divelist.c
Display OTU for dives using air
[ext/subsurface.git] / divelist.c
index f664cde49cf6f0c8f725a8d3f681402a277a7abc..32dc92b9980dc7bf75573c0880a84e069927b871 100644 (file)
@@ -292,6 +292,8 @@ static gint nitrox_sort_func(GtkTreeModel *model,
        return a_he - b_he;
 }
 
+#define UTF8_ELLIPSIS "\xE2\x80\xA6"
+
 static void nitrox_data_func(GtkTreeViewColumn *col,
                             GtkCellRenderer *renderer,
                             GtkTreeModel *model,
@@ -315,7 +317,7 @@ static void nitrox_data_func(GtkTreeViewColumn *col,
                if (o2 == o2low)
                        snprintf(buffer, sizeof(buffer), "%d", o2);
                else
-                       snprintf(buffer, sizeof(buffer), "%d-%d", o2low, o2);
+                       snprintf(buffer, sizeof(buffer), "%d" UTF8_ELLIPSIS "%d", o2low, o2);
        else
                strcpy(buffer, "air");
 
@@ -390,8 +392,10 @@ static int calculate_otu(struct dive *dive)
                struct sample *sample = dive->sample + i;
                struct sample *psample = sample - 1;
                t = sample->time.seconds - psample->time.seconds;
-               po2 = dive->cylinder[sample->cylinderindex].gasmix.o2.permille / 1000.0 *
-                       (sample->depth.mm + 10000) / 10000.0;
+               int o2 = dive->cylinder[sample->cylinderindex].gasmix.o2.permille;
+               if (!o2)
+                       o2 = 209;
+               po2 = o2 / 1000.0 * (sample->depth.mm + 10000) / 10000.0;
                if (po2 >= 0.5)
                        otu += pow(po2 - 0.5, 0.83) * t / 30.0;
        }