* Get a C-string from a GRFText-list. If there is a translation for the * current language it is returned, otherwise the default translation * is returned. If there is neither a default nor a translation for the * current language nullptr is returned. * @param text_list The GRFTextList to get the string from. */
| 597 | * @param text_list The GRFTextList to get the string from. |
| 598 | */ |
| 599 | std::optional<std::string_view> GetGRFStringFromGRFText(const GRFTextList &text_list) |
| 600 | { |
| 601 | std::optional<std::string_view> default_text; |
| 602 | |
| 603 | /* Search the list of lang-strings of this stringid for current lang */ |
| 604 | for (const auto &text : text_list) { |
| 605 | if (text.langid == _current_lang_id) return text.text; |
| 606 | |
| 607 | /* If the current string is English or American, set it as the |
| 608 | * fallback language if the specific language isn't available. */ |
| 609 | if (text.langid == GRFLX_UNSPECIFIED || (!default_text.has_value() && (text.langid == GRFLX_ENGLISH || text.langid == GRFLX_AMERICAN))) { |
| 610 | default_text = text.text; |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | return default_text; |
| 615 | } |
| 616 | |
| 617 | /** |
| 618 | * Get a C-string from a GRFText-list. If there is a translation for the |
no outgoing calls
no test coverage detected