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

Function get_zone_keys

plugins/blueprint.cpp:1235–1321  ·  view source on GitHub ↗

TODO: handle locations

Source from the content-addressed store, hash-verified

1233
1234// TODO: handle locations
1235static void get_zone_keys(color_ostream &out, ostringstream &keys, df::building_civzonest *zone, bool add_label, bool add_properties) {
1236 vector<string> properties;
1237
1238 if (!zone->name.empty())
1239 properties.push_back(quotify_inner("name=" + zone->name));
1240 if (!zone->spec_sub_flag.bits.active)
1241 properties.push_back("active=false");
1242 if (auto reserved_for = get_reservation(out, zone); !reserved_for.empty()) {
1243 properties.push_back("assigned_unit=" + reserved_for);
1244 }
1245
1246 // in DFHack docs order
1247 switch (zone->type) {
1248 using namespace df::enums::civzone_type;
1249 case MeetingHall: keys << "m"; break;
1250 case Bedroom: keys << "b"; break;
1251 case DiningHall: keys << "h"; break;
1252 case Pen: keys << "n"; break;
1253 case Pond:
1254 keys << "p";
1255 {
1256 if (zone->zone_settings.pond.flag.bits.keep_filled)
1257 properties.push_back("pond=true");
1258 }
1259 break;
1260 case WaterSource: keys << "w"; break;
1261 case Dungeon: keys << "j"; break;
1262 case FishingArea: keys << "f"; break;
1263 case SandCollection: keys << "s"; break;
1264 case Office: keys << "o"; break;
1265 case Dormitory: keys << "D"; break;
1266 case Barracks: keys << "B"; break;
1267 case ArcheryRange:
1268 keys << "a";
1269 {
1270 auto & archery = zone->zone_settings.archery;
1271 if (archery.dir_x == 1 && archery.dir_y == 0)
1272 properties.push_back("shoot_from=west");
1273 else if (archery.dir_x == -1 && archery.dir_y == 0)
1274 properties.push_back("shoot_from=east");
1275 else if (archery.dir_x == 0 && archery.dir_y == 1)
1276 properties.push_back("shoot_from=north");
1277 else if (archery.dir_x == 0 && archery.dir_y == -1)
1278 properties.push_back("shoot_from=south");
1279 else {
1280 keys.clear();
1281 return; // invalid direction
1282 }
1283 }
1284 break;
1285 case Dump: keys << "d"; break;
1286 case AnimalTraining: keys << "t"; break;
1287 case Tomb:
1288 keys << "T";
1289 {
1290 auto & tomb = zone->zone_settings.tomb;
1291 if (!tomb.flags.bits.no_pets)
1292 properties.push_back("pets=true");

Callers 1

get_tile_zoneFunction · 0.85

Calls 5

quotify_innerFunction · 0.85
get_reservationFunction · 0.85
join_stringsFunction · 0.50
emptyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected