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

Function world_tile_match

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

Source from the content-addressed store, hash-verified

1429 //=======================================================================================
1430
1431 bool world_tile_match(embark_assist::defs::world_tile_data *survey_results,
1432 uint16_t x,
1433 uint16_t y,
1434 embark_assist::defs::finders *finder) {
1435
1436 bool trace = false;
1437 color_ostream_proxy out(Core::getInstance().getConsole());
1438 df::world_data *world_data = world->world_data;
1439 embark_assist::defs::region_tile_datum *tile = &survey_results->at(x).at(y);
1440 const uint16_t embark_size = finder->x_dim * finder->y_dim;
1441 bool found;
1442
1443 if (tile->surveyed) {
1444 // Savagery
1445 for (uint8_t i = 0; i < 3; i++)
1446 {
1447 switch (finder->savagery[i]) {
1448 case embark_assist::defs::evil_savagery_values::NA:
1449 break; // No restriction
1450
1451 case embark_assist::defs::evil_savagery_values::All:
1452 if (tile->savagery_count[i] < embark_size) {
1453 if (trace) out.print("matcher::world_tile_match: Savagery All ({}, {})\n", x, y);
1454 return false;
1455 }
1456 break;
1457
1458 case embark_assist::defs::evil_savagery_values::Present:
1459 if (tile->savagery_count[i] == 0 && !tile->neighboring_savagery[i]) {
1460 if (trace) out.print("matcher::world_tile_match: Savagery Present ({}, {})\n", x, y);
1461 return false;
1462 }
1463 break;
1464
1465 case embark_assist::defs::evil_savagery_values::Absent:
1466 if (tile->savagery_count[i] > 256 - embark_size) {
1467 if (trace) out.print("matcher::world_tile_match: Savagery Absent ({}, {})\n", x, y);
1468 return false;
1469 }
1470 break;
1471 }
1472 }
1473
1474 // Evilness
1475 for (uint8_t i = 0; i < 3; i++)
1476 {
1477 switch (finder->evilness[i]) {
1478 case embark_assist::defs::evil_savagery_values::NA:
1479 break; // No restriction
1480
1481 case embark_assist::defs::evil_savagery_values::All:
1482 if (tile->evilness_count[i] < embark_size) {
1483 if (trace) out.print("matcher::world_tile_match: Evil All ({}, {})\n", x, y);
1484 return false;
1485 }
1486 break;
1487
1488 case embark_assist::defs::evil_savagery_values::Present:

Callers 1

preliminary_world_matchFunction · 0.85

Calls 2

printMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected