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

Function detect_caravans

plugins/timestream.cpp:382–398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

380}
381
382static bool detect_caravans()
383{
384 auto& caravans = df::global::plotinfo->caravans;
385 return std::any_of(caravans.begin(), caravans.end(), [](auto caravan) {
386 if (caravan->trade_state != df::caravan_state::T_trade_state::AtDepot)
387 return false;
388 auto car_civ = caravan->entity;
389 auto& units = world->units.active;
390 return std::any_of(units.begin(), units.end(), [car_civ] (auto un) {
391 return (un->civ_id == car_civ
392 && DFHack::Units::isMerchant(un)
393 && std::any_of(un->inventory.begin(), un->inventory.end(), [] (auto inv_item) {
394 return inv_item->item && inv_item->item->flags.bits.trader;
395 }));
396 });
397 });
398}
399
400static int32_t clamp_timeskip(int32_t timeskip) {
401 if (timeskip <= 0)

Callers 1

clamp_timeskipFunction · 0.85

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected