Codechange: Use std::vector for GRFConfig lists. (#10835)

This replaces the C-style custom managed linked-list and allows use of iterators etc.
This commit is contained in:
Peter Nelson
2025-01-31 17:09:09 +00:00
committed by GitHub
parent 40aeedeade
commit 5664b1e2f6
23 changed files with 248 additions and 384 deletions

View File

@@ -579,8 +579,8 @@ void Gamelog::GRFAddList(const GRFConfigList &newg)
{
assert(this->action_type == GLAT_START || this->action_type == GLAT_LOAD);
for (GRFConfig *gc = newg; gc != nullptr; gc = gc->next) {
this->GRFAdd(*gc);
for (const auto &c : newg) {
this->GRFAdd(*c);
}
}
@@ -591,8 +591,8 @@ void Gamelog::GRFAddList(const GRFConfigList &newg)
static std::vector<const GRFConfig *> GenerateGRFList(const GRFConfigList &grfc)
{
std::vector<const GRFConfig *> list;
for (const GRFConfig *g = grfc; g != nullptr; g = g->next) {
if (IsLoggableGrfConfig(*g)) list.push_back(g);
for (const auto &g : grfc) {
if (IsLoggableGrfConfig(*g)) list.push_back(g.get());
}
return list;