1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-25 05:04:07 +01:00

Codechange: Use unique_ptr to manage ContentInfo lifetime.

Removes manually managed new/delete.
This commit is contained in:
Peter Nelson
2025-04-10 08:34:59 +01:00
committed by Peter Nelson
parent 7b31f26611
commit 20d83677eb
5 changed files with 52 additions and 78 deletions

View File

@@ -410,9 +410,9 @@ class NetworkContentListWindow : public Window, ContentCallback {
bool all_available = true;
for (ConstContentIterator iter = _network_content_client.Begin(); iter != _network_content_client.End(); iter++) {
if ((*iter)->state == ContentInfo::DOES_NOT_EXIST) all_available = false;
this->content.push_back(*iter);
for (const ContentInfo &ci : _network_content_client.Info()) {
if (ci.state == ContentInfo::DOES_NOT_EXIST) all_available = false;
this->content.push_back(&ci);
}
this->SetWidgetDisabledState(WID_NCL_SEARCH_EXTERNAL, this->auto_select && all_available);
@@ -732,13 +732,11 @@ public:
std::string buf;
for (auto &cid : this->selected->dependencies) {
/* Try to find the dependency */
ConstContentIterator iter = _network_content_client.Begin();
for (; iter != _network_content_client.End(); iter++) {
const ContentInfo *ci = *iter;
if (ci->id != cid) continue;
for (const ContentInfo &ci : _network_content_client.Info()) {
if (ci.id != cid) continue;
if (!buf.empty()) buf += list_separator;
buf += (*iter)->name;
buf += ci.name;
break;
}
}
@@ -1138,9 +1136,5 @@ void ShowNetworkContentListWindow(ContentVector *cv, ContentType type1, ContentT
GetEncodedString(STR_CONTENT_NO_ZLIB),
GetEncodedString(STR_CONTENT_NO_ZLIB_SUB),
WL_ERROR);
/* Connection failed... clean up the mess */
if (cv != nullptr) {
for (ContentInfo *ci : *cv) delete ci;
}
#endif /* WITH_ZLIB */
}