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

Method addCombatReport

library/modules/Gui.cpp:1932–1966  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1930}
1931
1932bool Gui::addCombatReport(df::unit *unit, df::unit_report_type slot, df::report *report, bool update_alert)
1933{
1934 CHECK_INVALID_ARGUMENT(is_valid_enum_item(slot));
1935
1936 if (!unit || !report)
1937 return false;
1938
1939 unit->reports.log[slot].push_back(report->id);
1940 unit->reports.last_year[slot] = report->year;
1941 unit->reports.last_year_tick[slot] = report->time;
1942
1943 auto alert_type = announcement_alert_type::NONE;
1944 switch (slot)
1945 {
1946 case unit_report_type::NONE: /* should never happen? */
1947 return false;
1948 case unit_report_type::Combat:
1949 world->status.flags.bits.combat = true;
1950 alert_type = announcement_alert_type::COMBAT;
1951 break;
1952 case unit_report_type::Hunting:
1953 world->status.flags.bits.hunting = true;
1954 alert_type = announcement_alert_type::HUNTING;
1955 break;
1956 case unit_report_type::Sparring:
1957 world->status.flags.bits.sparring = true;
1958 alert_type = announcement_alert_type::SPARRING;
1959 break;
1960 }
1961
1962 if (update_alert)
1963 update_ucr_alert(unit, alert_type);
1964
1965 return true;
1966}
1967
1968
1969bool Gui::addCombatReport(df::unit *unit, df::unit_report_type slot, int report_index, bool update_alert)

Callers

nothing calls this directly

Calls 3

is_valid_enum_itemFunction · 0.85
update_ucr_alertFunction · 0.85
vector_getFunction · 0.85

Tested by

no test coverage detected