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

Function process_rooms

plugins/preserve-rooms.cpp:495–528  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

493}
494
495static void process_rooms(color_ostream &out,
496 const unordered_set<int32_t> & active_unit_ids,
497 ZoneAssignments & last_known,
498 const vector<df::building_civzonest *> & vec,
499 bool share_with_spouse=true)
500{
501 ZoneAssignments assignments;
502 auto it = last_known.begin();
503 auto it_end = last_known.end();
504 for (auto zone : vec) {
505 auto idx = linear_index(df::global::world->buildings.all, (df::building*)(zone));
506 if (idx == -1) {
507 WARN(cycle, out).print("invalid building pointer {} in building vector\n", static_cast<void*>(zone));
508 continue;
509 }
510 if (zone->assigned_unit_id == -1) {
511 handle_missing_assignments(out, active_unit_ids, &it, it_end, share_with_spouse, zone->id);
512 continue;
513 }
514 auto owner = Buildings::getOwner(zone);
515 if (!owner) {
516 DEBUG(cycle, out).print("building {} has owner id {} but no such unit exists\n", zone->id, zone->assigned_unit_id);
517 continue;
518 }
519 auto hf = df::historical_figure::find(owner->hist_figure_id);
520 if (!hf)
521 continue;
522 int32_t spouse_hfid = share_with_spouse ? get_spouse_hfid(out, hf) : -1;
523 assignments.emplace_back(zone->id, std::make_pair(hf->id, spouse_hfid));
524 }
525 handle_missing_assignments(out, active_unit_ids, &it, it_end, share_with_spouse, -1);
526
527 last_known = assignments;
528}
529
530static void do_cycle(color_ostream &out) {
531 cycle_timestamp = world->frame_counter;

Callers 1

do_cycleFunction · 0.85

Calls 7

get_spouse_hfidFunction · 0.85
linear_indexFunction · 0.50
findFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected