diff options
author | rubidium42 <rubidium@openttd.org> | 2021-05-30 12:47:50 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-06-10 20:09:44 +0200 |
commit | 9c424ab741218238205e8d1f2644a3912fda250a (patch) | |
tree | 3aa21fe1a71c5d7ed3ec69259b72aa40e1358b30 /src/network/network_content_gui.cpp | |
parent | dfb89f3891ec73b4d5a6f46092ad825dabec6bb7 (diff) | |
download | openttd-9c424ab741218238205e8d1f2644a3912fda250a.tar.xz |
Codechange: [ContentInfo] Use StringList for tags instead of custom allocations
Diffstat (limited to 'src/network/network_content_gui.cpp')
-rw-r--r-- | src/network/network_content_gui.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index a74d902a3..a617f4e49 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -443,9 +443,8 @@ class NetworkContentListWindow : public Window, ContentCallback { static bool CDECL TagNameFilter(const ContentInfo * const *a, ContentListFilterData &filter) { filter.string_filter.ResetState(); - for (int i = 0; i < (*a)->tag_count; i++) { - filter.string_filter.AddLine((*a)->tags[i]); - } + for (auto &tag : (*a)->tags) filter.string_filter.AddLine(tag.c_str()); + filter.string_filter.AddLine((*a)->name); return filter.string_filter.GetState(); } @@ -747,12 +746,12 @@ public: y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_DEPENDENCIES); } - if (this->selected->tag_count != 0) { + if (!this->selected->tags.empty()) { /* List all tags */ char buf[DRAW_STRING_BUFFER] = ""; char *p = buf; - for (uint i = 0; i < this->selected->tag_count; i++) { - p += seprintf(p, lastof(buf), i == 0 ? "%s" : ", %s", this->selected->tags[i]); + for (auto &tag : this->selected->tags) { + p += seprintf(p, lastof(buf), p == buf ? "%s" : ", %s", tag.c_str()); } SetDParamStr(0, buf); y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_TAGS); |