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

Function isAssigned

plugins/autonestbox.cpp:189–200  ·  view source on GitHub ↗

check if assigned to pen, pit, (built) cage or chain note: BUILDING_CAGED is not set for animals (maybe it's used for dwarves who get caged as sentence) animals in cages (no matter if built or on stockpile) get the ref CONTAINED_IN_ITEM instead removing them from cages on stockpiles is no problem even without clearing the ref and usually it will be desired behavior to do so.

Source from the content-addressed store, hash-verified

187// removing them from cages on stockpiles is no problem even without clearing the ref
188// and usually it will be desired behavior to do so.
189static bool isAssigned(df::unit *unit) {
190 for (auto ref : unit->general_refs) {
191 auto rtype = ref->getType();
192 if(rtype == df::general_ref_type::BUILDING_CIVZONE_ASSIGNED
193 || rtype == df::general_ref_type::BUILDING_CAGED
194 || rtype == df::general_ref_type::BUILDING_CHAIN
195 || (rtype == df::general_ref_type::CONTAINED_IN_ITEM && isInBuiltCage(unit))) {
196 return true;
197 }
198 }
199 return false;
200}
201
202static bool unlikely_to_revert_to_wild(df::unit *unit) {
203 if (Units::isDomesticated(unit))

Callers 1

isFreeEgglayerFunction · 0.85

Calls 2

isInBuiltCageFunction · 0.85
getTypeMethod · 0.80

Tested by

no test coverage detected