summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2019-04-13 22:53:18 +0200
committerglx22 <glx22@users.noreply.github.com>2019-04-18 21:49:34 +0200
commit889927261452da616c5289f016e84b6f201141e8 (patch)
tree63942e5a7267bd23c61e81818c8969164629db79 /src/network
parent9195f2337a7c4f9154058877093bbb74db33cf32 (diff)
downloadopenttd-889927261452da616c5289f016e84b6f201141e8.tar.xz
Codechange: use std::vector for _language_dropdown
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network_gui.cpp14
1 files changed, 7 insertions, 7 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;
}