diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-02-23 11:38:53 +0100 |
---|---|---|
committer | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-04-07 00:13:34 +0200 |
commit | f1e08fd470502e5703a7338d6b5a5130a5f41c14 (patch) | |
tree | fb8b8550d28f33bf9e9ad0d5799463478d3b47a5 /core | |
parent | 1ca25ec03950cea052fd151c41e7d6535cfb1381 (diff) | |
download | subsurface-f1e08fd470502e5703a7338d6b5a5130a5f41c14.tar.gz |
core: introduce set_cylinder() function
We have a set_weightsystem() function. For symmetry, introduce
a set_cylinder() function so that we can more-or-less copy&paste
the weightsystem undo code for cylinder undo.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r-- | core/equipment.c | 9 | ||||
-rw-r--r-- | core/equipment.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/core/equipment.c b/core/equipment.c index 4672cbe00..3d169a338 100644 --- a/core/equipment.c +++ b/core/equipment.c @@ -291,6 +291,15 @@ void remove_cylinder(struct dive *dive, int idx) remove_from_cylinder_table(&dive->cylinders, idx); } +// cyl is cloned. +void set_cylinder(struct dive *dive, int idx, cylinder_t cyl) +{ + if (idx < 0 || idx >= dive->cylinders.nr) + return; + free_cylinder(dive->cylinders.cylinders[idx]); + dive->cylinders.cylinders[idx] = clone_cylinder(cyl); +} + void remove_weightsystem(struct dive *dive, int idx) { remove_from_weightsystem_table(&dive->weightsystems, idx); diff --git a/core/equipment.h b/core/equipment.h index 8bc752022..4ed809eff 100644 --- a/core/equipment.h +++ b/core/equipment.h @@ -86,6 +86,7 @@ extern void add_weightsystem_description(const weightsystem_t *); extern bool same_weightsystem(weightsystem_t w1, weightsystem_t w2); extern bool same_cylinder(cylinder_t cyl1, cylinder_t cyl2); extern void remove_cylinder(struct dive *dive, int idx); +extern void set_cylinder(struct dive *dive, int idx, cylinder_t ws); extern void remove_weightsystem(struct dive *dive, int idx); extern void set_weightsystem(struct dive *dive, int idx, weightsystem_t ws); extern void reset_cylinders(struct dive *dive, bool track_gas); |