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

@@ -591,7 +591,6 @@ void DrawRailCatenary(const TileInfo *ti)
bool SettingsDisableElrail(int32 p1)
{
Train *t;
bool disable = (p1 != 0);
/* we will now walk through all electric train engines and change their railtypes if it is the wrong one*/
@@ -611,7 +610,7 @@ bool SettingsDisableElrail(int32 p1)
/* when disabling elrails, make sure that all existing trains can run on
* normal rail too */
if (disable) {
FOR_ALL_TRAINS(t) {
for (Train *t : Train::Iterate()) {
if (t->railtype == RAILTYPE_ELECTRIC) {
/* this railroad vehicle is now compatible only with elrail,
* so add there also normal rail compatibility */
@@ -623,7 +622,7 @@ bool SettingsDisableElrail(int32 p1)
}
/* Fix the total power and acceleration for trains */
FOR_ALL_TRAINS(t) {
for (Train *t : Train::Iterate()) {
/* power and acceleration is cached only for front engines */
if (t->IsFrontEngine()) {
t->ConsistChanged(CCF_TRACK);