Fix a bug on Shearwater cloud gas changes

Gas change is done to the cylinder we just found and not the last
cylinder. Also switching the variable name to index as we are actually
using that value outside the loop.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
This commit is contained in:
Miika Turkia 2020-09-12 21:17:18 +03:00 committed by Dirk Hohndel
parent b5c00c89e6
commit 23efcef58a

View file

@ -58,10 +58,10 @@ static int shearwater_changes(void *param, int columns, char **data, char **colu
o2 = 1000;
// Find the cylinder index
int i;
int index;
bool found = false;
for (i = 0; i < state->cur_dive->cylinders.nr; ++i) {
const cylinder_t *cyl = get_cylinder(state->cur_dive, i);
for (index = 0; index < state->cur_dive->cylinders.nr; ++index) {
const cylinder_t *cyl = get_cylinder(state->cur_dive, index);
if (cyl->gasmix.o2.permille == o2 && cyl->gasmix.he.permille == he) {
found = true;
break;
@ -75,7 +75,7 @@ static int shearwater_changes(void *param, int columns, char **data, char **colu
cylinder_end(state);
}
add_gas_switch_event(state->cur_dive, get_dc(state), state->sample_rate ? atoi(data[0]) / state->sample_rate * 10 : atoi(data[0]), state->cur_dive->cylinders.nr - 1);
add_gas_switch_event(state->cur_dive, get_dc(state), state->sample_rate ? atoi(data[0]) / state->sample_rate * 10 : atoi(data[0]), index);
return 0;
}