|
|
|
@ -1368,9 +1368,8 @@ DFHACK_EXPORT void Gui::writeToGamelog(std::string message)
|
|
|
|
|
fseed.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
|
{ // Utility functions for reports
|
|
|
|
|
bool parseReportString(std::vector<std::string> *out, const std::string &str, size_t line_length = 73)
|
|
|
|
|
// Utility functions for reports
|
|
|
|
|
static bool parseReportString(std::vector<std::string> *out, const std::string &str, size_t line_length = 73)
|
|
|
|
|
{ // parse a string into output strings like DF does for reports
|
|
|
|
|
if (str.empty() || line_length == 0)
|
|
|
|
|
return false;
|
|
|
|
@ -1388,7 +1387,7 @@ namespace
|
|
|
|
|
|
|
|
|
|
if (str[i] == 'r') // "&r" adds a blank line
|
|
|
|
|
{
|
|
|
|
|
word_wrap(out, parsed, line_length, false/*, true*/);
|
|
|
|
|
word_wrap(out, parsed, line_length/*, WSMODE_TRIM_LEADING*/);
|
|
|
|
|
out->push_back(" "); // DF adds a line with a space for some reason
|
|
|
|
|
parsed.clear();
|
|
|
|
|
}
|
|
|
|
@ -1402,23 +1401,19 @@ namespace
|
|
|
|
|
while (++i < str.length());
|
|
|
|
|
|
|
|
|
|
if (parsed.length())
|
|
|
|
|
word_wrap(out, parsed, line_length, false/*, true*/);
|
|
|
|
|
word_wrap(out, parsed, line_length/*, WSMODE_TRIM_LEADING*/);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool recent_report(df::unit *unit, df::unit_report_type slot)
|
|
|
|
|
static bool recent_report(df::unit *unit, df::unit_report_type slot)
|
|
|
|
|
{
|
|
|
|
|
if (unit && !unit->reports.log[slot].empty() &&
|
|
|
|
|
return unit && !unit->reports.log[slot].empty() &&
|
|
|
|
|
*df::global::cur_year == unit->reports.last_year[slot] &&
|
|
|
|
|
(*df::global::cur_year_tick - unit->reports.last_year_tick[slot]) <= 500)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
(*df::global::cur_year_tick - unit->reports.last_year_tick[slot]) <= 500;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool recent_report_any(df::unit *unit)
|
|
|
|
|
static bool recent_report_any(df::unit *unit)
|
|
|
|
|
{
|
|
|
|
|
FOR_ENUM_ITEMS(unit_report_type, slot)
|
|
|
|
|
{
|
|
|
|
@ -1428,7 +1423,7 @@ namespace
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void delete_old_reports()
|
|
|
|
|
static void delete_old_reports()
|
|
|
|
|
{
|
|
|
|
|
auto &reports = world->status.reports;
|
|
|
|
|
while (reports.size() > 3000)
|
|
|
|
@ -1443,7 +1438,7 @@ namespace
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t check_repeat_report(vector<string> &results)
|
|
|
|
|
static int32_t check_repeat_report(vector<string> &results)
|
|
|
|
|
{ // returns the new repeat count, else 0
|
|
|
|
|
if (*gamemode == game_mode::DWARF && !results.empty() && world->status.reports.size() >= results.size())
|
|
|
|
|
{
|
|
|
|
@ -1460,7 +1455,7 @@ namespace
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// End of utility functions for reports
|
|
|
|
|
|
|
|
|
|
DFHACK_EXPORT int Gui::makeAnnouncement(df::announcement_type type, df::announcement_flags flags, df::coord pos, std::string message, int color, bool bright)
|
|
|
|
|
{
|
|
|
|
@ -1592,9 +1587,8 @@ bool Gui::addCombatReport(df::unit *unit, df::unit_report_type slot, int report_
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
|
{ // An additional utility function for reports
|
|
|
|
|
bool add_proper_report(df::unit *unit, bool is_sparring, int report_index)
|
|
|
|
|
// An additional utility function for reports
|
|
|
|
|
static bool add_proper_report(df::unit *unit, bool is_sparring, int report_index)
|
|
|
|
|
{
|
|
|
|
|
if (is_sparring)
|
|
|
|
|
return Gui::addCombatReport(unit, unit_report_type::Sparring, report_index);
|
|
|
|
@ -1603,7 +1597,6 @@ namespace
|
|
|
|
|
else
|
|
|
|
|
return Gui::addCombatReport(unit, unit_report_type::Combat, report_index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Gui::addCombatReportAuto(df::unit *unit, df::announcement_flags mode, int report_index)
|
|
|
|
|
{
|
|
|
|
|