| 364 | typedef multimap<int, df::plant *, std::greater<int>> TreesBySize; |
| 365 | |
| 366 | static int32_t scan_tree(color_ostream & out, df::plant *plant, int32_t *expected_yield, |
| 367 | TreesBySize *designatable_trees_by_size, bool designate_clearcut, |
| 368 | const vector<df::unit *> &citizens, int32_t *accessible_trees, |
| 369 | int32_t *inaccessible_trees, int32_t *designated_trees, int32_t *accessible_yield, |
| 370 | map<int32_t, int32_t> *tree_counts, |
| 371 | map<int32_t, int32_t> *designated_tree_counts, |
| 372 | map<int, PersistentDataItem *> &clearcut_burrows, |
| 373 | map<int, PersistentDataItem *> &chop_burrows) { |
| 374 | TRACE(cycle,out).print(" scanning tree at {},{},{}\n", |
| 375 | plant->pos.x, plant->pos.y, plant->pos.z); |
| 376 | |
| 377 | if (!is_valid_tree(plant)) |
| 378 | return 0; |
| 379 | |
| 380 | bool accessible = is_accessible_tree(plant->pos, citizens); |
| 381 | int32_t yield = estimate_logs(plant); |
| 382 | |
| 383 | if (accessible) { |
| 384 | if (accessible_trees) |
| 385 | ++*accessible_trees; |
| 386 | if (accessible_yield) |
| 387 | *accessible_yield += yield; |
| 388 | } else { |
| 389 | if (inaccessible_trees) |
| 390 | ++*inaccessible_trees; |
| 391 | } |
| 392 | |
| 393 | bool can_chop = false; |
| 394 | bool designated = Designations::isPlantMarked(plant); |
| 395 | bool was_designated = designated; |
| 396 | bucket_tree(plant, designate_clearcut, &designated, &can_chop, tree_counts, |
| 397 | designated_tree_counts, clearcut_burrows, chop_burrows); |
| 398 | |
| 399 | int32_t ret = 0; |
| 400 | if (designated) { |
| 401 | if (!was_designated) |
| 402 | ret = 1; |
| 403 | if (designated_trees) |
| 404 | ++*designated_trees; |
| 405 | if (expected_yield) |
| 406 | *expected_yield += yield; |
| 407 | } else if (can_chop && accessible) { |
| 408 | if (designatable_trees_by_size) |
| 409 | designatable_trees_by_size->emplace(yield, plant); |
| 410 | } |
| 411 | |
| 412 | return ret; |
| 413 | } |
| 414 | |
| 415 | // returns the number of trees that were newly marked |
| 416 | static int32_t scan_trees(color_ostream & out, int32_t *expected_yield, |
no test coverage detected