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

Method getCasteProfessionColor

library/modules/Units.cpp:1958–1974  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1956}
1957
1958int8_t Units::getCasteProfessionColor(int race, int casteid, df::profession pid) {
1959 if (!is_valid_enum_item(pid) || pid == profession::NONE)
1960 return 3;
1961 // If it's not a Peasant, it's hardcoded
1962 if (pid != profession::STANDARD)
1963 return ENUM_ATTR(profession, color, pid);
1964
1965 if (auto creature = df::creature_raw::find(race)) {
1966 if (auto caste = vector_get(creature->caste, casteid)) {
1967 if (caste->flags.is_set(caste_raw_flags::HAS_COLOR))
1968 return caste->caste_color[0] + caste->caste_color[2] * 8;
1969 }
1970 return creature->color[0] + creature->color[2] * 8;
1971 }
1972 // Default to dwarven peasant color
1973 return 3;
1974}
1975
1976df::goal_type Units::getGoalType(df::unit *unit, size_t goalIndex) {
1977 CHECK_NULL_POINTER(unit);

Callers

nothing calls this directly

Calls 4

is_valid_enum_itemFunction · 0.85
vector_getFunction · 0.85
is_setMethod · 0.80
findFunction · 0.50

Tested by

no test coverage detected