diff options
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/network_admin.cpp | 12 | ||||
-rw-r--r-- | src/network/network_server.cpp | 6 | ||||
-rw-r--r-- | src/network/network_udp.cpp | 6 |
3 files changed, 8 insertions, 16 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; diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 7505bff87..a8322ff90 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -380,10 +380,9 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendCompanyInfo() /* Now send the data */ - Company *company; Packet *p; - FOR_ALL_COMPANIES(company) { + for (const Company *company : Company::Iterate()) { p = new Packet(PACKET_SERVER_COMPANY_INFO); p->Send_uint8 (NETWORK_COMPANY_INFO_VERSION); @@ -1619,7 +1618,6 @@ static void NetworkCheckRestartMap() static void NetworkAutoCleanCompanies() { const NetworkClientInfo *ci; - const Company *c; bool clients_in_company[MAX_COMPANIES]; int vehicles_in_company[MAX_COMPANIES]; @@ -1648,7 +1646,7 @@ static void NetworkAutoCleanCompanies() } /* Go through all the companies */ - FOR_ALL_COMPANIES(c) { + for (const Company *c : Company::Iterate()) { /* Skip the non-active once */ if (c->is_ai) continue; diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp index ddf2e9518..90b99ec44 100644 --- a/src/network/network_udp.cpp +++ b/src/network/network_udp.cpp @@ -198,8 +198,7 @@ void ServerNetworkUDPSocketHandler::Receive_CLIENT_DETAIL_INFO(Packet *p, Networ for (;;) { int free = SEND_MTU - packet.size; - Company *company; - FOR_ALL_COMPANIES(company) { + for (const Company *company : Company::Iterate()) { char company_name[NETWORK_COMPANY_NAME_LENGTH]; SetDParam(0, company->index); GetString(company_name, STR_COMPANY_NAME, company_name + max_cname_length - 1); @@ -214,9 +213,8 @@ void ServerNetworkUDPSocketHandler::Receive_CLIENT_DETAIL_INFO(Packet *p, Networ } } - Company *company; /* Go through all the companies */ - FOR_ALL_COMPANIES(company) { + for (const Company *company : Company::Iterate()) { /* Send the information */ this->SendCompanyInformation(&packet, company, &company_stats[company->index], max_cname_length); } |