summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Pigott <charlespigott@googlemail.com>2018-04-12 21:31:35 +0100
committerfrosch <github@elsenhans.name>2018-04-13 22:08:13 +0200
commit62d79900ecd48eb26687ba3c17164896d656c8ba (patch)
tree8cd978e0f19f329455d6c36f03d32cf822ab698e /src
parent6ac079020b4545accc2b411fe0d4389845438ba5 (diff)
downloadopenttd-62d79900ecd48eb26687ba3c17164896d656c8ba.tar.xz
Add: List recent news messages in crashlog output
Diffstat (limited to 'src')
-rw-r--r--src/crashlog.cpp23
-rw-r--r--src/crashlog.h1
-rw-r--r--src/news_gui.cpp8
-rw-r--r--src/news_gui.h4
4 files changed, 32 insertions, 4 deletions
diff --git a/src/crashlog.cpp b/src/crashlog.cpp
index 53a85e442..78d9b1465 100644
--- a/src/crashlog.cpp
+++ b/src/crashlog.cpp
@@ -27,6 +27,7 @@
#include "network/network.h"
#include "language.h"
#include "fontcache.h"
+#include "news_gui.h"
#include "ai/ai_info.hpp"
#include "game/game.hpp"
@@ -309,6 +310,27 @@ char *CrashLog::LogGamelog(char *buffer, const char *last) const
}
/**
+ * Writes any recent news messages to the buffer.
+ * @param buffer The begin where to write at.
+ * @param last The last position in the buffer to write to.
+ * @return the position of the \c '\0' character after the buffer.
+ */
+char *CrashLog::LogRecentNews(char *buffer, const char *last) const
+{
+ buffer += seprintf(buffer, last, "Recent news messages:\n");
+
+ for (NewsItem *news = _oldest_news; news != NULL; news = news->next) {
+ YearMonthDay ymd;
+ ConvertDateToYMD(news->date, &ymd);
+ buffer += seprintf(buffer, last, "(%i-%02i-%02i) StringID: %u, Type: %u, Ref1: %u, %u, Ref2: %u, %u\n",
+ ymd.year, ymd.month + 1, ymd.day, news->string_id, news->type,
+ news->reftype1, news->ref1, news->reftype2, news->ref2);
+ }
+ buffer += seprintf(buffer, last, "\n");
+ return buffer;
+}
+
+/**
* Fill the crash log buffer with all data of a crash log.
* @param buffer The begin where to write at.
* @param last The last position in the buffer to write to.
@@ -334,6 +356,7 @@ char *CrashLog::FillCrashLog(char *buffer, const char *last) const
buffer = this->LogLibraries(buffer, last);
buffer = this->LogModules(buffer, last);
buffer = this->LogGamelog(buffer, last);
+ buffer = this->LogRecentNews(buffer, last);
buffer += seprintf(buffer, last, "*** End of OpenTTD Crash Report ***\n");
return buffer;
diff --git a/src/crashlog.h b/src/crashlog.h
index 6f7fb3c21..b9bc8afa2 100644
--- a/src/crashlog.h
+++ b/src/crashlog.h
@@ -85,6 +85,7 @@ protected:
char *LogConfiguration(char *buffer, const char *last) const;
char *LogLibraries(char *buffer, const char *last) const;
char *LogGamelog(char *buffer, const char *last) const;
+ char *LogRecentNews(char *buffer, const char *list) const;
public:
/** Stub destructor to silence some compilers. */
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index 6338b760b..94cfaccf9 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -42,10 +42,10 @@
const NewsItem *_statusbar_news_item = NULL;
-static uint MIN_NEWS_AMOUNT = 30; ///< preferred minimum amount of news messages
-static uint _total_news = 0; ///< current number of news items
-static NewsItem *_oldest_news = NULL; ///< head of news items queue
-static NewsItem *_latest_news = NULL; ///< tail of news items queue
+static uint MIN_NEWS_AMOUNT = 30; ///< preferred minimum amount of news messages
+static uint _total_news = 0; ///< current number of news items
+NewsItem *_oldest_news = NULL; ///< head of news items queue
+static NewsItem *_latest_news = NULL; ///< tail of news items queue
/**
* Forced news item.
diff --git a/src/news_gui.h b/src/news_gui.h
index f0b28a734..0f42c68c6 100644
--- a/src/news_gui.h
+++ b/src/news_gui.h
@@ -12,7 +12,11 @@
#ifndef NEWS_GUI_H
#define NEWS_GUI_H
+#include "news_type.h"
+
void ShowLastNewsMessage();
void ShowMessageHistory();
+extern NewsItem *_oldest_news;
+
#endif /* NEWS_GUI_H */