mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-22 11:44:17 +01:00
Codechange: Use projection-based std::range::find where possible.
This simplifies matching by class members and avoids wordy lambdas.
This commit is contained in:
committed by
Peter Nelson
parent
876d53282e
commit
059a4b22f7
@@ -388,7 +388,7 @@ void Station::AddIndustryToDeliver(Industry *ind, TileIndex tile)
|
||||
uint distance = DistanceMax(this->xy, tile);
|
||||
|
||||
/* Don't check further if this industry is already in the list but update the distance if it's closer */
|
||||
auto pos = std::find_if(this->industries_near.begin(), this->industries_near.end(), [&](const IndustryListEntry &e) { return e.industry->index == ind->index; });
|
||||
auto pos = std::ranges::find(this->industries_near, ind, &IndustryListEntry::industry);
|
||||
if (pos != this->industries_near.end()) {
|
||||
if (pos->distance > distance) {
|
||||
auto node = this->industries_near.extract(pos);
|
||||
@@ -410,7 +410,7 @@ void Station::AddIndustryToDeliver(Industry *ind, TileIndex tile)
|
||||
*/
|
||||
void Station::RemoveIndustryToDeliver(Industry *ind)
|
||||
{
|
||||
auto pos = std::find_if(this->industries_near.begin(), this->industries_near.end(), [&](const IndustryListEntry &e) { return e.industry->index == ind->index; });
|
||||
auto pos = std::ranges::find(this->industries_near, ind, &IndustryListEntry::industry);
|
||||
if (pos != this->industries_near.end()) {
|
||||
this->industries_near.erase(pos);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user