diff options
author | glx <glx@openttd.org> | 2019-12-14 17:22:38 +0100 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2019-12-21 20:13:03 +0100 |
commit | 3a14cea068d130e11b5d9dde11d4451dd7dec453 (patch) | |
tree | 7afd5a1160872aeba8a630c2915a8168cbc483dd /src/network/network_admin.cpp | |
parent | 68f22134cb35267d6fa01134a385d3854fda1787 (diff) | |
download | openttd-3a14cea068d130e11b5d9dde11d4451dd7dec453.tar.xz |
Codechange: Replace FOR_ALL_COMPANIES with range-based for loops
Diffstat (limited to 'src/network/network_admin.cpp')
-rw-r--r-- | src/network/network_admin.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/network/network_admin.cpp b/src/network/network_admin.cpp index 25481da93..037307627 100644 --- a/src/network/network_admin.cpp +++ b/src/network/network_admin.cpp @@ -399,8 +399,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyRemove(CompanyID c /** Send economic information of all companies. */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyEconomy() { - const Company *company; - FOR_ALL_COMPANIES(company) { + for (const Company *company : Company::Iterate()) { /* Get the income. */ Money income = 0; for (uint i = 0; i < lengthof(company->yearly_expenses[0]); i++) { @@ -438,10 +437,8 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyStats() NetworkCompanyStats company_stats[MAX_COMPANIES]; NetworkPopulateCompanyStats(company_stats); - const Company *company; - /* Go through all the companies. */ - FOR_ALL_COMPANIES(company) { + for (const Company *company : Company::Iterate()) { Packet *p = new Packet(ADMIN_PACKET_SERVER_COMPANY_STATS); /* Send the information. */ @@ -748,13 +745,12 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_POLL(Packet *p) case ADMIN_UPDATE_COMPANY_INFO: /* The admin is asking for company info. */ - const Company *company; if (d1 == UINT32_MAX) { - FOR_ALL_COMPANIES(company) { + for (const Company *company : Company::Iterate()) { this->SendCompanyInfo(company); } } else { - company = Company::GetIfValid(d1); + const Company *company = Company::GetIfValid(d1); if (company != nullptr) this->SendCompanyInfo(company); } break; |