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

Function gatherRelevantUnits

library/modules/EventManager.cpp:1393–1417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1391}
1392
1393static vector<df::unit*> gatherRelevantUnits(color_ostream& out, df::report* r1, df::report* r2) {
1394 vector<df::report*> reports;
1395 if ( r1 == r2 ) r2 = nullptr;
1396 if ( r1 ) reports.push_back(r1);
1397 if ( r2 ) reports.push_back(r2);
1398 vector<df::unit*> result;
1399 unordered_set<int32_t> ids;
1400//out.print("%s,%d\n",__FILE__,__LINE__);
1401 for (auto report : reports) {
1402//out.print("%s,%d\n",__FILE__,__LINE__);
1403 vector<int32_t>& units = reportToRelevantUnits[report->id];
1404 if ( units.size() > 2 ) {
1405 if ( Once::doOnce("EventManager interaction too many relevant units") ) {
1406 out.print("{},{}: too many relevant units. On report\n \'{}\'\n", __FILE__, __LINE__, report->text);
1407 }
1408 }
1409 for (int & unit_id : units)
1410 if (ids.find(unit_id) == ids.end() ) {
1411 ids.insert(unit_id);
1412 result.push_back(df::unit::find(unit_id));
1413 }
1414 }
1415//out.print("%s,%d\n",__FILE__,__LINE__);
1416 return result;
1417}
1418
1419static void manageInteractionEvent(color_ostream& out) {
1420 if (!df::global::world)

Callers 1

manageInteractionEventFunction · 0.85

Calls 6

findFunction · 0.50
sizeMethod · 0.45
printMethod · 0.45
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected