mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: move gas-functions to own translation unit
But only functions that operate only on gases. Functions concerning cylinders or dives remain in dive.c or are moved to equipment.c Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
8352274758
commit
619d3fb1fd
8 changed files with 174 additions and 149 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
#include <limits.h>
|
||||
#include "equipment.h"
|
||||
#include "gettext.h"
|
||||
#include "dive.h"
|
||||
|
@ -101,6 +102,36 @@ const char *gasname(struct gasmix gasmix)
|
|||
return gas;
|
||||
}
|
||||
|
||||
int gas_volume(const cylinder_t *cyl, pressure_t p)
|
||||
{
|
||||
double bar = p.mbar / 1000.0;
|
||||
double z_factor = gas_compressibility_factor(cyl->gasmix, bar);
|
||||
return lrint(cyl->type.size.mliter * bar_to_atm(bar) / z_factor);
|
||||
}
|
||||
|
||||
int find_best_gasmix_match(struct gasmix mix, const cylinder_t array[], unsigned int used)
|
||||
{
|
||||
int i;
|
||||
int best = -1, score = INT_MAX;
|
||||
|
||||
for (i = 0; i < MAX_CYLINDERS; i++) {
|
||||
const cylinder_t *match;
|
||||
int distance;
|
||||
|
||||
if (used & (1 << i))
|
||||
continue;
|
||||
match = array + i;
|
||||
if (cylinder_nodata(match))
|
||||
continue;
|
||||
distance = gasmix_distance(mix, match->gasmix);
|
||||
if (distance >= score)
|
||||
continue;
|
||||
best = i;
|
||||
score = distance;
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
bool weightsystem_none(const weightsystem_t *ws)
|
||||
{
|
||||
return !ws->weight.grams && !ws->description;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue