mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: move copy_cylinder_types() from dive.c to equipment.c
Thus, future callers will not have to include the monster dive.h include if they just want to copy cylinders. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
860807bf92
commit
4355ce3924
3 changed files with 23 additions and 23 deletions
23
core/dive.c
23
core/dive.c
|
@ -440,7 +440,6 @@ struct dive *move_dive(struct dive *s)
|
||||||
d->_component = copy_string(s->_component)
|
d->_component = copy_string(s->_component)
|
||||||
|
|
||||||
// copy elements, depending on bits in what that are set
|
// copy elements, depending on bits in what that are set
|
||||||
static void copy_cylinder_types(const struct dive *s, struct dive *d);
|
|
||||||
void selective_copy_dive(const struct dive *s, struct dive *d, struct dive_components what, bool clear)
|
void selective_copy_dive(const struct dive *s, struct dive *d, struct dive_components what, bool clear)
|
||||||
{
|
{
|
||||||
if (clear)
|
if (clear)
|
||||||
|
@ -517,28 +516,6 @@ int nr_weightsystems(const struct dive *dive)
|
||||||
return dive->weightsystems.nr;
|
return dive->weightsystems.nr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copy_cylinder_type(const cylinder_t *s, cylinder_t *d)
|
|
||||||
{
|
|
||||||
free(d->type.description);
|
|
||||||
d->type = s->type;
|
|
||||||
d->type.description = s->type.description ? strdup(s->type.description) : NULL;
|
|
||||||
d->gasmix = s->gasmix;
|
|
||||||
d->depth = s->depth;
|
|
||||||
d->cylinder_use = s->cylinder_use;
|
|
||||||
d->manually_added = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* copy the equipment data part of the cylinders but keep pressures */
|
|
||||||
static void copy_cylinder_types(const struct dive *s, struct dive *d)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
if (!s || !d)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (i = 0; i < MAX_CYLINDERS; i++)
|
|
||||||
copy_cylinder_type(s->cylinder + i, d->cylinder + i);
|
|
||||||
}
|
|
||||||
|
|
||||||
void copy_cylinders(const struct dive *s, struct dive *d, bool used_only)
|
void copy_cylinders(const struct dive *s, struct dive *d, bool used_only)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
|
@ -288,6 +288,28 @@ void reset_cylinders(struct dive *dive, bool track_gas)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void copy_cylinder_type(const cylinder_t *s, cylinder_t *d)
|
||||||
|
{
|
||||||
|
free(d->type.description);
|
||||||
|
d->type = s->type;
|
||||||
|
d->type.description = s->type.description ? strdup(s->type.description) : NULL;
|
||||||
|
d->gasmix = s->gasmix;
|
||||||
|
d->depth = s->depth;
|
||||||
|
d->cylinder_use = s->cylinder_use;
|
||||||
|
d->manually_added = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* copy the equipment data part of the cylinders but keep pressures */
|
||||||
|
void copy_cylinder_types(const struct dive *s, struct dive *d)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
if (!s || !d)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_CYLINDERS; i++)
|
||||||
|
copy_cylinder_type(s->cylinder + i, d->cylinder + i);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_CYL
|
#ifdef DEBUG_CYL
|
||||||
void dump_cylinders(struct dive *dive, bool verbose)
|
void dump_cylinders(struct dive *dive, bool verbose)
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,6 +57,7 @@ struct weightsystem_table {
|
||||||
|
|
||||||
extern int cylinderuse_from_text(const char *text);
|
extern int cylinderuse_from_text(const char *text);
|
||||||
extern void copy_weights(const struct weightsystem_table *s, struct weightsystem_table *d);
|
extern void copy_weights(const struct weightsystem_table *s, struct weightsystem_table *d);
|
||||||
|
extern void copy_cylinder_types(const struct dive *s, struct dive *d);
|
||||||
extern void add_cloned_weightsystem(struct weightsystem_table *t, weightsystem_t ws);
|
extern void add_cloned_weightsystem(struct weightsystem_table *t, weightsystem_t ws);
|
||||||
extern void add_cylinder_description(const cylinder_type_t *);
|
extern void add_cylinder_description(const cylinder_type_t *);
|
||||||
extern void add_weightsystem_description(const weightsystem_t *);
|
extern void add_weightsystem_description(const weightsystem_t *);
|
||||||
|
|
Loading…
Add table
Reference in a new issue