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

Function FillIndustryCatchment

src/script/api/script_tilelist.cpp:71–89  ·  view source on GitHub ↗

* Helper to get list of tiles that will cover an industry's production or acceptance. * @param i Industry in question * @param radius Catchment radius to test * @param bta BitmapTileArea to fill */

Source from the content-addressed store, hash-verified

69 * @param bta BitmapTileArea to fill
70 */
71static void FillIndustryCatchment(const Industry *i, SQInteger radius, BitmapTileArea &bta)
72{
73 for (TileIndex cur_tile : i->location) {
74 if (!::IsTileType(cur_tile, MP_INDUSTRY) || ::GetIndustryIndex(cur_tile) != i->index) continue;
75
76 int tx = TileX(cur_tile);
77 int ty = TileY(cur_tile);
78 for (int y = -radius; y <= radius; y++) {
79 if (ty + y < 0 || ty + y > (int)Map::MaxY()) continue;
80 for (int x = -radius; x <= radius; x++) {
81 if (tx + x < 0 || tx + x > (int)Map::MaxX()) continue;
82 TileIndex tile = TileXY(tx + x, ty + y);
83 if (!IsValidTile(tile)) continue;
84 if (::IsTileType(tile, MP_INDUSTRY) && ::GetIndustryIndex(tile) == i->index) continue;
85 bta.SetTile(tile);
86 }
87 }
88 }
89}
90
91ScriptTileList_IndustryAccepting::ScriptTileList_IndustryAccepting(IndustryID industry_id, SQInteger radius)
92{

Calls 7

IsTileTypeFunction · 0.85
GetIndustryIndexFunction · 0.85
TileXFunction · 0.85
TileYFunction · 0.85
TileXYFunction · 0.85
IsValidTileFunction · 0.85
SetTileMethod · 0.80

Tested by

no test coverage detected