summaryrefslogtreecommitdiffstats
path: root/core/cochran.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-08-06 11:19:32 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-08-08 16:26:31 -0700
commit00944f7a02c98bd281778218bccc592896386f14 (patch)
treeff0ac130a72c9e1be48d28aafc9afa5a21b022ab /core/cochran.c
parent6ce4aeb04ee4a01af43f18ef8b76224402cb5c3b (diff)
downloadsubsurface-00944f7a02c98bd281778218bccc592896386f14.tar.gz
Core: pass dive, cylinder-id to fill_default_cylinder
The fill_default_cylinder() function calculated the MOD based on the currently displayed dive. This does not seem to make sense: - When importing dives, why would we care about the altitude and salinity of the currently displayed dive, possibly from a different trip. - The planner is supposed to be thread-safe and should not touch global variables. Of course this means that the importing-functions have to fill out altitude and salinity before creating the default cylinder, but this is their problem. For a freshly created dive they will get the default values, which still seems less random than the values from the displayed dive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/cochran.c')
-rw-r--r--core/cochran.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/core/cochran.c b/core/cochran.c
index 14ee65fcb..9cbc51113 100644
--- a/core/cochran.c
+++ b/core/cochran.c
@@ -677,7 +677,7 @@ static void cochran_parse_dive(const unsigned char *decode, unsigned mod,
if (config.type == TYPE_GEMINI) {
dc->model = "Gemini";
dc->deviceid = buf[0x18c] * 256 + buf[0x18d]; // serial no
- fill_default_cylinder(&dive->cylinder[0]);
+ fill_default_cylinder(dive, 0);
dive->cylinder[0].gasmix.o2.permille = (log[CMD_O2_PERCENT] / 256
+ log[CMD_O2_PERCENT + 1]) * 10;
dive->cylinder[0].gasmix.he.permille = 0;
@@ -685,7 +685,7 @@ static void cochran_parse_dive(const unsigned char *decode, unsigned mod,
dc->model = "Commander";
dc->deviceid = array_uint32_le(buf + 0x31e); // serial no
for (g = 0; g < 2; g++) {
- fill_default_cylinder(&dive->cylinder[g]);
+ fill_default_cylinder(dive, g);
dive->cylinder[g].gasmix.o2.permille = (log[CMD_O2_PERCENT + g * 2] / 256
+ log[CMD_O2_PERCENT + g * 2 + 1]) * 10;
dive->cylinder[g].gasmix.he.permille = 0;
@@ -727,7 +727,7 @@ static void cochran_parse_dive(const unsigned char *decode, unsigned mod,
dc->model = "EMC";
dc->deviceid = array_uint32_le(buf + 0x31e); // serial no
for (g = 0; g < 4; g++) {
- fill_default_cylinder(&dive->cylinder[g]);
+ fill_default_cylinder(dive , g);
dive->cylinder[g].gasmix.o2.permille =
(log[EMC_O2_PERCENT + g * 2] / 256
+ log[EMC_O2_PERCENT + g * 2 + 1]) * 10;