Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup_dc_sample_sensors() would make sure that any pressure sensor indexes were in range of the cylinders by just clearing the pressure data if the sensor index was larger than the number of cylinders in the dive. That certainly makes the sensor index data consistent, but at the cost of just dropping the sensor data entirely. Dirk had some cases of odd sensor data (probably because of an older version of subsurface, but possibly due to removing cylinders manually or because of oddities with the downloader for the Atomic Aquatics Cobalt dive computer he used), and when re-saving the dive, the pressure data would magically just get removed due to this. So rewrite the sensor data fixup to strive very hard to avoid throwing pressure sensor data away. We do this by: (a) generating a mask of sensor numbers seen (b) checking if that mask is a subset of the cylinders we have, in which case everything is fine. (c) if it's not a subset, "compress" the sensor indexes to the minimal range (ie if you had sensor indexes 3 and 6, rename 3 to 0, and 6 to 1). (d) if it now fits in the cylinder mask we have, everything is fine (e) if we still have more sensors than we have cylinders, leave the data alone, but complain about it with SSRF_INFO() so that the user is notified. That final (e) case might be for dive computers that allow reporting pressure data for your buddy's cylinder too. So it's odd, but not entirely crazy, and we now will keep the data. You may have to add a fake cylinder to your dive to make it all make sense and avoid the informational warning. This whole "we clear the pressure data" was at least partly hidden by two things: (1) in the git save format, we don't rewrite dives unless you've changed the dive some way, so old dives stay around with old data in the save until explicitly changed. (2) if you had multiple dive computers, and one dive computer does not have any pressure data but another one does, our profile will use that "other" dive computer pressure data (because often times you might have only one dive computer that is air integrated, but you still want to see the tank pressure when you look at other dive computers - or you have one dive computer give pressure data for your deco bottle, and another for your travel gas etc). So those two facts hid the reality that we had actually cleared the tank sensor data for Dirk's dive with the Atomic Aquatics dive computer, because we'd still see pressure data in the profile, and the git data would still be the old one. Until Dirk renumbered his dives, and the data was rewritten. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
- Loading branch information