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

Function scan_trees

plugins/autochop.cpp:416–458  ·  view source on GitHub ↗

returns the number of trees that were newly marked

Source from the content-addressed store, hash-verified

414
415// returns the number of trees that were newly marked
416static int32_t scan_trees(color_ostream & out, int32_t *expected_yield,
417 TreesBySize *designatable_trees_by_size, bool designate_clearcut,
418 const vector<df::unit *> &citizens, int32_t *accessible_trees = NULL,
419 int32_t *inaccessible_trees = NULL, int32_t *designated_trees = NULL,
420 int32_t *accessible_yield = NULL,
421 map<int32_t, int32_t> *tree_counts = NULL,
422 map<int32_t, int32_t> *designated_tree_counts = NULL) {
423 TRACE(cycle,out).print("scanning trees\n");
424 int32_t newly_marked = 0;
425
426 if (accessible_trees)
427 *accessible_trees = 0;
428 if (inaccessible_trees)
429 *inaccessible_trees = 0;
430 if (designated_trees)
431 *designated_trees = 0;
432 if (expected_yield)
433 *expected_yield = 0;
434 if (accessible_yield)
435 *accessible_yield = 0;
436 if (tree_counts)
437 tree_counts->clear();
438 if (designated_tree_counts)
439 designated_tree_counts->clear();
440
441 map<int, PersistentDataItem *> clearcut_burrows, chop_burrows;
442 bucket_watched_burrows(out, clearcut_burrows, chop_burrows);
443
444 for (auto plant : world->plants.tree_dry)
445 newly_marked += scan_tree(out, plant, expected_yield, designatable_trees_by_size,
446 designate_clearcut, citizens, accessible_trees,
447 inaccessible_trees, designated_trees, accessible_yield,
448 tree_counts, designated_tree_counts,
449 clearcut_burrows, chop_burrows);
450 for (auto plant : world->plants.tree_wet)
451 newly_marked += scan_tree(out, plant, expected_yield, designatable_trees_by_size,
452 designate_clearcut, citizens, accessible_trees,
453 inaccessible_trees, designated_trees, accessible_yield,
454 tree_counts, designated_tree_counts,
455 clearcut_burrows, chop_burrows);
456
457 return newly_marked;
458}
459
460// TODO: does this actually catch anything above the bad_flag check?
461static bool is_valid_item(df::item *item) {

Callers 3

do_cycleFunction · 0.85
autochop_printStatusFunction · 0.85

Calls 4

bucket_watched_burrowsFunction · 0.85
scan_treeFunction · 0.85
printMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected