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

Function assignUnitToZone

plugins/autonestbox.cpp:227–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225}
226
227static bool assignUnitToZone(color_ostream &out, df::unit *unit, df::building_civzonest *zone) {
228 auto ref = createCivzoneRef();
229 if (!ref) {
230 ERR(cycle,out).print("Could not create activity zone reference!\n");
231 return false;
232 }
233
234 ref->building_id = zone->id;
235 unit->general_refs.push_back(ref);
236 zone->assigned_units.push_back(unit->id);
237
238 INFO(cycle,out).print("Unit {} ({}) assigned to nestbox zone {} ({})\n",
239 unit->id, Units::getRaceName(unit),
240 zone->id, zone->name);
241
242 return true;
243}
244
245// also assigns units to zone if they have already claimed the nestbox
246// and are not assigned elsewhere; returns number assigned

Callers 2

getFreeNestboxZonesFunction · 0.85
assign_nestboxesFunction · 0.85

Calls 2

createCivzoneRefFunction · 0.85
printMethod · 0.45

Tested by

no test coverage detected