summaryrefslogtreecommitdiff
path: root/src/industry_cmd.cpp
diff options
context:
space:
mode:
authordP <dp@dpointer.org>2020-05-12 01:36:28 +0300
committerCharles Pigott <charlespigott@googlemail.com>2020-05-13 08:43:01 +0100
commit7bd52970a1e83cb88069e73e26479eb71bd17726 (patch)
tree88e6fca4b38b16333dd6f37c7fde50fd4464596d /src/industry_cmd.cpp
parent2d5869fc79a1f1f347ab31665148c806d54afcd9 (diff)
downloadopenttd-7bd52970a1e83cb88069e73e26479eb71bd17726.tar.xz
Codechange: Refactor FindStationsAroundTiles to avoid code duplication
Diffstat (limited to 'src/industry_cmd.cpp')
-rw-r--r--src/industry_cmd.cpp18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index dfc43500f..39fc0d6f1 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1697,20 +1697,10 @@ static void PopulateStationsNearby(Industry *ind)
return;
}
- /* Get our list of nearby stations. */
- FindStationsAroundTiles(ind->location, &ind->stations_near, false);
-
- /* Test if industry can accept cargo */
- uint cargo_index;
- for (cargo_index = 0; cargo_index < lengthof(ind->accepts_cargo); cargo_index++) {
- if (ind->accepts_cargo[cargo_index] != CT_INVALID) break;
- }
- if (cargo_index >= lengthof(ind->accepts_cargo)) return;
-
- /* Cargo is accepted, add industry to nearby stations nearby industry list. */
- for (Station *st : ind->stations_near) {
- st->industries_near.insert(ind);
- }
+ ForAllStationsAroundTiles(ind->location, [ind](Station *st) {
+ ind->stations_near.insert(st);
+ st->AddIndustryToDeliver(ind);
+ });
}
/**