From a9531ebcbec3d72819d1402b8cb22b3f74d66354 Mon Sep 17 00:00:00 2001
From: "Robert C. Helling" <helling@atdotde.de>
Date: Thu, 10 Jul 2014 22:29:00 +0200
Subject: [PATCH] Use user entered pO2 limits for high pO2 warnings.

Furthermore, replaced gasmix accessors instead of .permille directly (think: air!)

Signed-off-by: Robert C. Helling <helling@atdotde.de>
---
 planner.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/planner.c b/planner.c
index 16152b1..6721314 100644
--- a/planner.c
+++ b/planner.c
@@ -672,9 +672,9 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
 	dp = diveplan->dp;
 	while (dp) {
 		if (dp->time != 0) {
-			int pO2 = depth_to_atm(dp->depth, dive) * dp->gasmix.o2.permille;
+			int pO2 = depth_to_atm(dp->depth, dive) * get_o2(&dp->gasmix);
 
-			if (pO2 > 1600) {
+			if (pO2 > dp->entered ? prefs.bottompo2 : prefs.decopo2) {
 				const char *depth_unit;
 				int decimals;
 				double depth_value = get_depth_units(dp->depth, &decimals, &depth_unit);
@@ -795,7 +795,7 @@ void plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
 		gas = displayed_dive.cylinder[current_cylinder].gasmix;
 #if DEBUG_PLAN & 16
 		printf("switch to gas %d (%d/%d) @ %5.2lfm\n", best_first_ascend_cylinder,
-		       (gas.o2.permille + 5) / 10, (gas.he.permille + 5) / 10, gaschanges[best_first_ascend_cylinder].depth / 1000.0);
+		       (get_o2(&gas) + 5) / 10, (get_he(&gas) + 5) / 10, gaschanges[best_first_ascend_cylinder].depth / 1000.0);
 #endif
 	}
 	while (1) {
@@ -834,7 +834,7 @@ void plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
 			gas = displayed_dive.cylinder[current_cylinder].gasmix;
 #if DEBUG_PLAN & 16
 			printf("switch to gas %d (%d/%d) @ %5.2lfm\n", gaschanges[gi].gasidx,
-			       (gas.o2.permille + 5) / 10, (gas.he.permille + 5) / 10, gaschanges[gi].depth / 1000.0);
+			       (get_o2(&gas) + 5) / 10, (get_he(&gas) + 5) / 10, gaschanges[gi].depth / 1000.0);
 #endif
 			gi--;
 		}
-- 
1.8.5.2 (Apple Git-48)

