mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: move gasname() to struct gasmix
Also, turn it to use std::string instead of writing into a global(!) buffer. This was not reentrant. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
9c726d8d6f
commit
22a1120b30
14 changed files with 46 additions and 52 deletions
|
|
@ -178,26 +178,6 @@ bool weightsystem_t::operator==(const weightsystem_t &w2) const
|
|||
std::tie(w2.weight.grams, w2.description);
|
||||
}
|
||||
|
||||
void get_gas_string(struct gasmix gasmix, char *text, int len)
|
||||
{
|
||||
if (gasmix_is_air(gasmix))
|
||||
snprintf(text, len, "%s", translate("gettextFromC", "air"));
|
||||
else if (get_he(gasmix) == 0 && get_o2(gasmix) < 1000)
|
||||
snprintf(text, len, translate("gettextFromC", "EAN%d"), (get_o2(gasmix) + 5) / 10);
|
||||
else if (get_he(gasmix) == 0 && get_o2(gasmix) == 1000)
|
||||
snprintf(text, len, "%s", translate("gettextFromC", "oxygen"));
|
||||
else
|
||||
snprintf(text, len, "(%d/%d)", (get_o2(gasmix) + 5) / 10, (get_he(gasmix) + 5) / 10);
|
||||
}
|
||||
|
||||
/* Returns a static char buffer - only good for immediate use by printf etc */
|
||||
const char *gasname(struct gasmix gasmix)
|
||||
{
|
||||
static char gas[64];
|
||||
get_gas_string(gasmix, gas, sizeof(gas));
|
||||
return gas;
|
||||
}
|
||||
|
||||
volume_t cylinder_t::gas_volume(pressure_t p) const
|
||||
{
|
||||
double bar = p.mbar / 1000.0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue