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

Function get_tile_zone

plugins/blueprint.cpp:1323–1369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1321}
1322
1323static const char * get_tile_zone(color_ostream &out, const df::coord &pos, const tile_context &ctx) {
1324 vector<df::building_civzonest*> civzones;
1325 if (!Buildings::findCivzonesAt(&civzones, pos))
1326 return NULL;
1327
1328 // we can handle overlapping zones in a single blueprint, but only if one of
1329 // the following is true:
1330 // -- they exactly overlap (even if they aren't rectangular)
1331 // -- no two non-rectangular zones overlap
1332
1333 // for a first implementation, we will only handle overlapping zones if they
1334 // are rectangular and have different upper-left corners. if this is the upper
1335 // left corner of a rectangular zone, we will output for that zone. otherwise,
1336 // if this pos is interior to all zones, then it doesn't matter which we choose.
1337
1338 df::building_civzonest * primary_zone = civzones[0];
1339 df::coord upper_left_corner;
1340
1341 if (civzones.size() == 1) {
1342 upper_left_corner = get_first_tile(primary_zone);
1343 } else if (civzones.size() > 1) {
1344 for (auto zone : civzones) {
1345 if (!is_rectangular(zone))
1346 continue;
1347 primary_zone = zone;
1348 upper_left_corner = get_first_tile(zone);
1349 if (pos == upper_left_corner)
1350 break;
1351 }
1352 }
1353
1354 bool rectangular = is_rectangular(primary_zone);
1355 bool is_first_tile = pos == upper_left_corner;
1356 ostringstream keys;
1357
1358 if (!rectangular) {
1359 get_zone_keys(out, keys, primary_zone, true, is_first_tile);
1360 return cache(quotify_outer(keys));
1361 }
1362
1363 if (!is_first_tile)
1364 return if_pretty(ctx, "`");
1365
1366 get_zone_keys(out, keys, primary_zone, false, true);
1367 add_expansion_syntax(primary_zone, keys);
1368 return cache(quotify_outer(keys));
1369}
1370
1371static bool create_output_dir(color_ostream &out,
1372 const blueprint_options &opts) {

Callers

nothing calls this directly

Calls 8

get_first_tileFunction · 0.85
is_rectangularFunction · 0.85
get_zone_keysFunction · 0.85
cacheFunction · 0.85
quotify_outerFunction · 0.85
if_prettyFunction · 0.85
add_expansion_syntaxFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected