MCPcopy Create free account
hub / github.com/DFHack/dfhack / get_entry_tiles

Function get_entry_tiles

plugins/pathable.cpp:176–198  ·  view source on GitHub ↗

if entry_tiles is given, it is filled with the surface edge tiles that match one of the given depot pathability groups. If entry_tiles is NULL, just returns true if such a tile is found. returns false if no tiles are found

Source from the content-addressed store, hash-verified

174// depot pathability groups. If entry_tiles is NULL, just returns true if such a tile is found.
175// returns false if no tiles are found
176static bool get_entry_tiles(unordered_set<df::coord> * entry_tiles, const unordered_set<uint16_t> & depot_pathability_groups) {
177 auto & edge = plotinfo->map_edge;
178 size_t num_edge_tiles = edge.surface_x.size();
179 uint32_t count_x, count_y, count_z;
180 Maps::getTileSize(count_x, count_y, count_z);
181 if (!count_x || !count_y)
182 return false;
183 uint16_t max_x = count_x - 1;
184 uint16_t max_y = count_y - 1;
185 bool found = false;
186 for (size_t idx = 0; idx < num_edge_tiles; ++idx) {
187 df::coord pos(edge.surface_x[idx], edge.surface_y[idx], edge.surface_z[idx]);
188 auto wgroup = Maps::getWalkableGroup(pos);
189 if (depot_pathability_groups.contains(wgroup) &&
190 (pos.x == 0 || pos.y == 0 || pos.x == max_x || pos.y == max_y)) {
191 found = true;
192 if (!entry_tiles)
193 break;
194 entry_tiles->emplace(pos);
195 }
196 }
197 return found;
198}
199
200static bool getDepotAccessibleByAnimals(color_ostream &out) {
201 unordered_set<df::coord> depot_coords;

Callers 2

Calls 2

containsMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected