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

Function mid_level_tile_match

plugins/embark-assistant/matcher.cpp:1359–1427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1357 //=======================================================================================
1358
1359 void mid_level_tile_match(embark_assist::defs::world_tile_data *survey_results,
1360 embark_assist::defs::mid_level_tiles *mlt,
1361 uint16_t x,
1362 uint16_t y,
1363 embark_assist::defs::finders *finder,
1364 embark_assist::defs::match_results *match_results) {
1365
1366// color_ostream_proxy out(Core::getInstance().getConsole());
1367 bool match = false;
1368 bool world_tile_match = true;
1369 embark_assist::defs::region_tile_datum *world_tile = &survey_results->at(x).at(y);
1370
1371 // These world tile checks require that the MLTs have been surveyed to update the world tile data
1372 // Necro Neighbors
1373 if (finder->min_necro_neighbors > world_tile->necro_neighbors) world_tile_match = false;
1374 if (finder->max_necro_neighbors != -1 && finder->max_necro_neighbors < world_tile->necro_neighbors) world_tile_match = false;
1375
1376 // Civ Neighbors
1377 if (finder->min_civ_neighbors > (int16_t)world_tile->neighbors.size()) world_tile_match = false;
1378 if (finder->max_civ_neighbors != -1 && finder->max_civ_neighbors < (int8_t)world_tile->neighbors.size()) world_tile_match = false;
1379
1380 // Specific Neighbors
1381 for (uint16_t i = 0; i < finder->neighbors.size(); i++) {
1382 switch (finder->neighbors[i].present) {
1383 case embark_assist::defs::present_absent_ranges::NA:
1384 break;
1385
1386 case embark_assist::defs::present_absent_ranges::Present:
1387 {
1388 bool found = false;
1389
1390 for (uint16_t k = 0; k < world_tile->neighbors.size(); k++) {
1391 if (finder->neighbors[i].entity_raw == world_tile->neighbors[k]) {
1392 found = true;
1393 break;
1394 }
1395 }
1396
1397 if (!found) world_tile_match = false;
1398
1399 break;
1400 }
1401
1402 case embark_assist::defs::present_absent_ranges::Absent:
1403 for (uint16_t k = 0; k < world_tile->neighbors.size(); k++) {
1404 if (finder->neighbors[i].entity_raw == world_tile->neighbors[k]) {
1405 world_tile_match = false;
1406 break;
1407 }
1408 }
1409
1410 break;
1411 }
1412 }
1413
1414 for (uint16_t i = 0; i < 16; i++) {
1415 for (uint16_t k = 0; k < 16; k++) {
1416 if (world_tile_match && i < 16 - finder->x_dim + 1 && k < 16 - finder->y_dim + 1) {

Callers 1

match_world_tileFunction · 0.85

Calls 2

embark_matchFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected