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
13
core/gas.cpp
13
core/gas.cpp
|
|
@ -2,6 +2,7 @@
|
|||
#include "gas.h"
|
||||
#include "pref.h"
|
||||
#include "errorhelper.h"
|
||||
#include "format.h"
|
||||
#include "gettext.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
|
@ -183,3 +184,15 @@ const char *gastype_name(enum gastype type)
|
|||
return "";
|
||||
return translate("gettextFromC", gastype_names[type]);
|
||||
}
|
||||
|
||||
std::string gasmix::name() const
|
||||
{
|
||||
if (gasmix_is_air(*this))
|
||||
return translate("gettextFromC", "air");
|
||||
else if (get_he(*this) == 0 && get_o2(*this) < 1000)
|
||||
return format_string_std(translate("gettextFromC", "EAN%d"), (get_o2(*this) + 5) / 10);
|
||||
else if (get_he(*this) == 0 && get_o2(*this) == 1000)
|
||||
return translate("gettextFromC", "oxygen");
|
||||
else
|
||||
return format_string_std("(%d/%d)", (get_o2(*this) + 5) / 10, (get_he(*this) + 5) / 10);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue