MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SurveyRecentNews

Function SurveyRecentNews

src/crashlog.cpp:55–68  ·  view source on GitHub ↗

* Writes up to 32 recent news messages to the buffer, with the most recent first. * @param output_iterator Iterator to write the output to. */

Source from the content-addressed store, hash-verified

53 * @param output_iterator Iterator to write the output to.
54 */
55static void SurveyRecentNews(nlohmann::json &json)
56{
57 json = nlohmann::json::array();
58
59 int i = 0;
60 for (const auto &news : GetNews()) {
61 TimerGameCalendar::YearMonthDay ymd = TimerGameCalendar::ConvertDateToYMD(news.date);
62 json.push_back(fmt::format("({}-{:02}-{:02}) String: {}, Type: {}, Ref1: {}, {}, Ref2: {}, {}",
63 ymd.year, ymd.month + 1, ymd.day, news.GetStatusText(), news.type,
64 news.ref1.index(), SerialiseNewsReference(news.ref1),
65 news.ref2.index(), SerialiseNewsReference(news.ref2)));
66 if (++i > 32) break;
67 }
68}
69
70/**
71 * Create a timestamped filename.

Callers 1

FillCrashLogMethod · 0.85

Calls 4

SerialiseNewsReferenceFunction · 0.85
push_backMethod · 0.80
GetStatusTextMethod · 0.80
formatFunction · 0.50

Tested by

no test coverage detected