MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ScriptTileList_IndustryAccepting

Method ScriptTileList_IndustryAccepting

src/script/api/script_tilelist.cpp:91–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91ScriptTileList_IndustryAccepting::ScriptTileList_IndustryAccepting(IndustryID industry_id, SQInteger radius)
92{
93 if (!ScriptIndustry::IsValidIndustry(industry_id) || radius <= 0) return;
94
95 const Industry *i = ::Industry::Get(industry_id);
96
97 /* Check if this industry is only served by its neutral station */
98 if (i->neutral_station != nullptr && !_settings_game.station.serve_neutral_industries) return;
99
100 /* Check if this industry accepts anything */
101 if (!i->IsCargoAccepted()) return;
102
103 if (!_settings_game.station.modified_catchment) radius = CA_UNMODIFIED;
104
105 BitmapTileArea bta(TileArea(i->location).Expand(radius));
106 FillIndustryCatchment(i, radius, bta);
107
108 BitmapTileIterator it(bta);
109 for (TileIndex cur_tile = it; cur_tile != INVALID_TILE; cur_tile = ++it) {
110 /* Only add the tile if it accepts the cargo (sometimes just 1 tile of an
111 * industry triggers the acceptance). */
112 CargoArray acceptance = ::GetAcceptanceAroundTiles(cur_tile, 1, 1, radius);
113 if (std::none_of(std::begin(i->accepted), std::end(i->accepted), [&acceptance](const auto &a) { return ::IsValidCargoType(a.cargo) && acceptance[a.cargo] != 0; })) continue;
114
115 this->AddTile(cur_tile);
116 }
117}
118
119ScriptTileList_IndustryProducing::ScriptTileList_IndustryProducing(IndustryID industry_id, SQInteger radius)
120{

Callers

nothing calls this directly

Calls 8

FillIndustryCatchmentFunction · 0.85
GetAcceptanceAroundTilesFunction · 0.85
IsValidCargoTypeFunction · 0.85
ExpandMethod · 0.80
AddTileMethod · 0.80
beginFunction · 0.50
endFunction · 0.50
IsCargoAcceptedMethod · 0.45

Tested by

no test coverage detected