mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
1ca25ec039
commit
f1e08fd470
2 changed files with 10 additions and 0 deletions
|
@ -291,6 +291,15 @@ void remove_cylinder(struct dive *dive, int idx)
|
||||||
remove_from_cylinder_table(&dive->cylinders, 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)
|
void remove_weightsystem(struct dive *dive, int idx)
|
||||||
{
|
{
|
||||||
remove_from_weightsystem_table(&dive->weightsystems, idx);
|
remove_from_weightsystem_table(&dive->weightsystems, idx);
|
||||||
|
|
|
@ -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_weightsystem(weightsystem_t w1, weightsystem_t w2);
|
||||||
extern bool same_cylinder(cylinder_t cyl1, cylinder_t cyl2);
|
extern bool same_cylinder(cylinder_t cyl1, cylinder_t cyl2);
|
||||||
extern void remove_cylinder(struct dive *dive, int idx);
|
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 remove_weightsystem(struct dive *dive, int idx);
|
||||||
extern void set_weightsystem(struct dive *dive, int idx, weightsystem_t ws);
|
extern void set_weightsystem(struct dive *dive, int idx, weightsystem_t ws);
|
||||||
extern void reset_cylinders(struct dive *dive, bool track_gas);
|
extern void reset_cylinders(struct dive *dive, bool track_gas);
|
||||||
|
|
Loading…
Add table
Reference in a new issue