diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/network/network_gui.cpp | 14 | ||||
-rw-r--r-- | src/strings.cpp | 8 | ||||
-rw-r--r-- | src/strings_func.h | 2 |
3 files changed, 12 insertions, 12 deletions
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 50678e8a6..29bc88959 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -63,18 +63,18 @@ static const StringID _lan_internet_types_dropdown[] = { INVALID_STRING_ID }; -static StringID _language_dropdown[NETLANG_COUNT + 1] = {STR_NULL}; +static std::vector<StringID> _language_dropdown; void SortNetworkLanguages() { /* Init the strings */ - if (_language_dropdown[0] == STR_NULL) { - for (int i = 0; i < NETLANG_COUNT; i++) _language_dropdown[i] = STR_NETWORK_LANG_ANY + i; - _language_dropdown[NETLANG_COUNT] = INVALID_STRING_ID; + if (_language_dropdown.empty()) { + for (int i = 0; i < NETLANG_COUNT; i++) _language_dropdown.emplace_back(STR_NETWORK_LANG_ANY + i); + _language_dropdown.emplace_back(INVALID_STRING_ID); } /* Sort the strings (we don't move 'any' and the 'invalid' one) */ - QSortT(_language_dropdown + 1, NETLANG_COUNT - 1, &StringIDSorter); + std::sort(_language_dropdown.begin() + 1, _language_dropdown.end() - 1, StringIDSorter); } /** @@ -1172,13 +1172,13 @@ struct NetworkStartServerWindow : public Window { case WID_NSS_LANGUAGE_BTN: { // Language uint sel = 0; - for (uint i = 0; i < lengthof(_language_dropdown) - 1; i++) { + for (uint i = 0; i < _language_dropdown.size() - 1; i++) { if (_language_dropdown[i] == STR_NETWORK_LANG_ANY + _settings_client.network.server_lang) { sel = i; break; } } - ShowDropDownMenu(this, _language_dropdown, sel, WID_NSS_LANGUAGE_BTN, 0, 0); + ShowDropDownMenu(this, _language_dropdown.data(), sel, WID_NSS_LANGUAGE_BTN, 0, 0); break; } diff --git a/src/strings.cpp b/src/strings.cpp index ed8d439b4..1ed679e27 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -1864,14 +1864,14 @@ const char *GetCurrentLocale(const char *param) const char *GetCurrentLocale(const char *param); #endif /* !(defined(_WIN32) || defined(__APPLE__)) */ -int CDECL StringIDSorter(const StringID *a, const StringID *b) +bool StringIDSorter(const StringID &a, const StringID &b) { char stra[512]; char strb[512]; - GetString(stra, *a, lastof(stra)); - GetString(strb, *b, lastof(strb)); + GetString(stra, a, lastof(stra)); + GetString(strb, b, lastof(strb)); - return strnatcmp(stra, strb); + return strnatcmp(stra, strb) < 0; } /** diff --git a/src/strings_func.h b/src/strings_func.h index a5e2e1ca2..d0fbde495 100644 --- a/src/strings_func.h +++ b/src/strings_func.h @@ -238,7 +238,7 @@ extern TextDirection _current_text_dir; ///< Text direction of the currently sel void InitializeLanguagePacks(); const char *GetCurrentLanguageIsoCode(); -int CDECL StringIDSorter(const StringID *a, const StringID *b); +bool StringIDSorter(const StringID &a, const StringID &b); /** * A searcher for missing glyphs. |