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

Method describeUnit

library/RemoteTools.cpp:258–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256}
257
258void DFHack::describeUnit(BasicUnitInfo *info, df::unit *unit,
259 const BasicUnitInfoMask *mask)
260{
261 info->set_unit_id(unit->id);
262
263 info->set_pos_x(unit->pos.x);
264 info->set_pos_y(unit->pos.y);
265 info->set_pos_z(unit->pos.z);
266
267 auto name = Units::getVisibleName(unit);
268 if (name->has_name)
269 describeName(info->mutable_name(), name);
270
271 info->set_flags1(unit->flags1.whole);
272 info->set_flags2(unit->flags2.whole);
273 info->set_flags3(unit->flags3.whole);
274
275 info->set_race(unit->race);
276 info->set_caste(unit->caste);
277
278 if (unit->sex >= 0)
279 info->set_gender(unit->sex);
280 if (unit->civ_id >= 0)
281 info->set_civ_id(unit->civ_id);
282 if (unit->hist_figure_id >= 0)
283 info->set_histfig_id(unit->hist_figure_id);
284
285 if (unit->counters.death_id >= 0)
286 {
287 info->set_death_id(unit->counters.death_id);
288 if (auto death = df::incident::find(unit->counters.death_id))
289 info->set_death_flags(death->flags.whole);
290 }
291
292 if (mask && mask->profession())
293 {
294 if (unit->profession >= (df::profession)0)
295 info->set_profession(unit->profession);
296 if (!unit->custom_profession.empty())
297 info->set_custom_profession(unit->custom_profession);
298
299 if (unit->military.squad_id >= 0)
300 {
301 info->set_squad_id(unit->military.squad_id);
302 info->set_squad_position(unit->military.squad_position);
303 }
304 }
305
306 if (mask && mask->labors())
307 {
308 for (size_t i = 0; i < sizeof(unit->status.labors)/sizeof(bool); i++)
309 if (unit->status.labors[i])
310 info->add_labors(i);
311 }
312
313 if (mask && mask->skills() && unit->status.current_soul)
314 {
315 auto &vec = unit->status.current_soul->skills;

Callers

nothing calls this directly

Calls 4

findFunction · 0.50
mutable_nameMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected