diff options
Diffstat (limited to 'subsurface-core/planner.c')
-rw-r--r-- | subsurface-core/planner.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/subsurface-core/planner.c b/subsurface-core/planner.c index 1828d5a11..705aad1cb 100644 --- a/subsurface-core/planner.c +++ b/subsurface-core/planner.c @@ -9,6 +9,7 @@ #include <ctype.h> #include <string.h> #include "dive.h" +#include "deco.h" #include "divelist.h" #include "planner.h" #include "gettext.h" @@ -103,7 +104,7 @@ int get_gasidx(struct dive *dive, struct gasmix *mix) void interpolate_transition(struct dive *dive, duration_t t0, duration_t t1, depth_t d0, depth_t d1, const struct gasmix *gasmix, o2pressure_t po2) { - int j; + uint32_t j; for (j = t0.seconds; j < t1.seconds; j++) { int depth = interpolate(d0.mm, d1.mm, j - t0.seconds, t1.seconds - t0.seconds); @@ -476,11 +477,11 @@ static struct gaschanges *analyze_gaslist(struct diveplan *diveplan, int *gascha } /* sort all the stops into one ordered list */ -static unsigned int *sort_stops(int *dstops, int dnr, struct gaschanges *gstops, int gnr) +static int *sort_stops(int *dstops, int dnr, struct gaschanges *gstops, int gnr) { int i, gi, di; int total = dnr + gnr; - unsigned int *stoplevels = malloc(total * sizeof(int)); + int *stoplevels = malloc(total * sizeof(int)); /* no gaschanges */ if (gnr == 0) { @@ -534,7 +535,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool const unsigned int sz_temp = 100000; char *buffer = (char *)malloc(sz_buffer); char *temp = (char *)malloc(sz_temp); - char *deco; + char *deco, *segmentsymbol; static char buf[1000]; int len, lastdepth = 0, lasttime = 0, lastsetpoint = -1, newdepth = 0, lastprintdepth = 0, lastprintsetpoint = -1; struct gasmix lastprintgasmix = {{ -1 }, { -1 }}; @@ -596,7 +597,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool translate("gettextFromC", "Subsurface dive plan"), temp); if (!plan_verbatim) { - len += snprintf(buffer + len, sz_buffer - len, "<div><table><thead><tr><th>%s</th>", + len += snprintf(buffer + len, sz_buffer - len, "<div><table><thead><tr><th></th><th>%s</th>", translate("gettextFromC", "depth")); if (plan_display_duration) len += snprintf(buffer + len, sz_buffer - len, "<th style='padding-left: 10px;'>%s</th>", @@ -710,8 +711,20 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool (!isascent && gaschange_before && nextdp && dp->depth != nextdp->depth) || (gaschange_after && lastentered) || (gaschange_after && !isascent) || (isascent && gaschange_after && nextdp && dp->depth != nextdp->depth )) { + // Print a symbol to indicate whether segment is an ascent, descent, constant depth (user entered) or deco stop + if (isascent) + segmentsymbol = "➚"; // up-right arrow for ascent + else if (dp->depth > lastdepth) + segmentsymbol = "➘"; // down-right arrow for descent + else if (dp->entered) + segmentsymbol = "➙"; // right arrow for entered entered segment at constant depth + else + segmentsymbol = "➖"; // heavey minus sign for deco stop + + len += snprintf(buffer + len, sz_buffer - len, "<tr><td style='padding-left: 10px; float: right;'>%s</td>", segmentsymbol); + snprintf(temp, sz_temp, translate("gettextFromC", "%3.0f%s"), depthvalue, depth_unit); - len += snprintf(buffer + len, sz_buffer - len, "<tr><td style='padding-left: 10px; float: right;'>%s</td>", temp); + len += snprintf(buffer + len, sz_buffer - len, "<td style='padding-left: 10px; float: right;'>%s</td>", temp); if (plan_display_duration) { snprintf(temp, sz_temp, translate("gettextFromC", "%3dmin"), (dp->time - lasttime + 30) / 60); len += snprintf(buffer + len, sz_buffer - len, "<td style='padding-left: 10px; float: right;'>%s</td>", temp); @@ -969,13 +982,13 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool int po2; int transitiontime, gi; int current_cylinder; - unsigned int stopidx; + int stopidx; int depth; struct gaschanges *gaschanges = NULL; int gaschangenr; int *decostoplevels; int decostoplevelcount; - unsigned int *stoplevels = NULL; + int *stoplevels = NULL; bool stopping = false; bool pendinggaschange = false; int clock, previous_point_time; |