Codechange: Replace vehicle related FOR_ALL with range-based for loops

This commit is contained in:
glx
2019-12-17 03:37:43 +01:00
committed by Niels Martin Hansen
parent 9892d90b26
commit d8a1be48cd
39 changed files with 155 additions and 317 deletions

View File

@@ -1534,12 +1534,10 @@ void NetworkSocketHandler::SendCompanyInformation(Packet *p, const Company *c, c
*/
void NetworkPopulateCompanyStats(NetworkCompanyStats *stats)
{
const Vehicle *v;
memset(stats, 0, sizeof(*stats) * MAX_COMPANIES);
/* Go through all vehicles and count the type of vehicles */
FOR_ALL_VEHICLES(v) {
for (const Vehicle *v : Vehicle::Iterate()) {
if (!Company::IsValidID(v->owner) || !v->IsPrimaryVehicle()) continue;
byte type = 0;
switch (v->type) {
@@ -1623,8 +1621,7 @@ static void NetworkAutoCleanCompanies()
if (_settings_client.network.autoclean_novehicles != 0) {
memset(vehicles_in_company, 0, sizeof(vehicles_in_company));
const Vehicle *v;
FOR_ALL_VEHICLES(v) {
for (const Vehicle *v : Vehicle::Iterate()) {
if (!Company::IsValidID(v->owner) || !v->IsPrimaryVehicle()) continue;
vehicles_in_company[v->owner]++;
}