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

Function CountMapSquareAround

src/station_cmd.cpp:157–169  ·  view source on GitHub ↗

* Counts the numbers of tiles matching a specific type in the area around * @param tile the center tile of the 'count area' * @param cmp the comparator/matcher (@see CMSAMatcher) * @return the number of matching tiles around */

Source from the content-addressed store, hash-verified

155 * @return the number of matching tiles around
156 */
157static int CountMapSquareAround(TileIndex tile, CMSAMatcher cmp)
158{
159 int num = 0;
160
161 for (int dx = -3; dx <= 3; dx++) {
162 for (int dy = -3; dy <= 3; dy++) {
163 TileIndex t = TileAddWrap(tile, dx, dy);
164 if (t != INVALID_TILE && cmp(t)) num++;
165 }
166 }
167
168 return num;
169}
170
171/**
172 * Check whether the tile is a mine.

Callers 1

GenerateStationNameFunction · 0.85

Calls 1

TileAddWrapFunction · 0.85

Tested by

no test coverage detected