1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-30 10:15:36 +01:00

Use iterators again for removing empty headings

Improving on f00aa15096, continue to use iterator and just set it to the result of erase.
This commit is contained in:
Ted John
2018-03-10 13:58:49 +00:00
parent f00aa15096
commit 74228ed35f

View File

@@ -681,16 +681,16 @@ static void initialise_list_items(rct_window *w)
_listItems.pop_back();
// Remove empty headings
for (size_t i = 0; i < _listItems.size(); i++)
for (auto it = _listItems.begin(); it != _listItems.end(); it++)
{
const auto &listItem = _listItems[i];
const auto &listItem = *it;
if (listItem.type == LIST_ITEM_TYPE::HEADING)
{
if (i + 1 == _listItems.size() ||
_listItems[i + 1].type == LIST_ITEM_TYPE::HEADING)
if ((it + 1) == _listItems.end() ||
(it + 1)->type == LIST_ITEM_TYPE::HEADING)
{
_listItems.erase(_listItems.begin() + i);
i--;
it = _listItems.erase(it);
it--;
}
}
}