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

Function df_showmood

plugins/showmood.cpp:31–293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29REQUIRE_GLOBAL(world);
30
31command_result df_showmood (color_ostream &out, vector <string> & parameters)
32{
33 if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) {
34 out.printerr("Cannot enable {} without a loaded fort.\n", plugin_name);
35 return CR_FAILURE;
36 }
37
38 if (!parameters.empty())
39 return CR_WRONG_USAGE;
40
41 bool found = false;
42 for (df::job_list_link *cur = world->jobs.list.next; cur != NULL; cur = cur->next)
43 {
44 df::job *job = cur->item;
45 if ((job->job_type < job_type::StrangeMoodCrafter) || (job->job_type > job_type::StrangeMoodMechanics))
46 continue;
47 found = true;
48 df::unit *unit = NULL;
49 df::building *building = NULL;
50 for (size_t i = 0; i < job->general_refs.size(); i++)
51 {
52 df::general_ref *ref = job->general_refs[i];
53 if (ref->getType() == general_ref_type::UNIT_WORKER)
54 unit = ref->getUnit();
55 if (ref->getType() == general_ref_type::BUILDING_HOLDER)
56 building = ref->getBuilding();
57 }
58 if (!unit)
59 {
60 out.printerr("Found strange mood not attached to any dwarf!\n");
61 continue;
62 }
63 if (unit->mood == mood_type::None)
64 {
65 out.printerr("Dwarf with strange mood does not have a mood type!\n");
66 continue;
67 }
68 out.print("{} is currently ", DF2CONSOLE(out, Units::getReadableName(unit)));
69 switch (unit->mood)
70 {
71 case mood_type::Macabre:
72 out.print("in a macabre mood");
73 if (job->job_type != job_type::StrangeMoodBrooding)
74 out.print(" (but isn't actually in a macabre mood?)");
75 break;
76
77 case mood_type::Fell:
78 out.print("in a fell mood");
79 if (job->job_type != job_type::StrangeMoodFell)
80 out.print(" (but isn't actually in a fell mood?)");
81 break;
82
83 case mood_type::Fey:
84 case mood_type::Secretive:
85 case mood_type::Possessed:
86 switch (unit->mood)
87 {
88 case mood_type::Fey:

Callers

nothing calls this directly

Calls 9

getTypeMethod · 0.80
c_strMethod · 0.80
is_setMethod · 0.80
bitfield_to_stringFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
printMethod · 0.45
getNameMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected