Changeset - r22793:0c646694741d
[Not reviewed]
master
0 4 0
Charles Pigott - 7 years ago 2018-04-12 20:31:35
charlespigott@googlemail.com
Add: List recent news messages in crashlog output
4 files changed with 29 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/crashlog.cpp
Show inline comments
 
@@ -24,12 +24,13 @@
 
#include "saveload/saveload.h"
 
#include "screenshot.h"
 
#include "gfx_func.h"
 
#include "network/network.h"
 
#include "language.h"
 
#include "fontcache.h"
 
#include "news_gui.h"
 

	
 
#include "ai/ai_info.hpp"
 
#include "game/game.hpp"
 
#include "game/game_info.hpp"
 
#include "company_base.h"
 
#include "company_func.h"
 
@@ -306,12 +307,33 @@ char *CrashLog::LogGamelog(char *buffer,
 
	CrashLog::gamelog_last = last;
 
	GamelogPrint(&CrashLog::GamelogFillCrashLog);
 
	return CrashLog::gamelog_buffer + seprintf(CrashLog::gamelog_buffer, last, "\n");
 
}
 

	
 
/**
 
 * 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.
 
 * @return the position of the \c '\0' character after the buffer.
 
 */
 
char *CrashLog::FillCrashLog(char *buffer, const char *last) const
 
@@ -331,12 +353,13 @@ char *CrashLog::FillCrashLog(char *buffe
 
	buffer = this->LogOSVersion(buffer, last);
 
	buffer = this->LogCompiler(buffer, last);
 
	buffer = this->LogConfiguration(buffer, last);
 
	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;
 
}
 

	
 
/**
src/crashlog.h
Show inline comments
 
@@ -82,12 +82,13 @@ protected:
 

	
 

	
 
	char *LogOpenTTDVersion(char *buffer, const char *last) const;
 
	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. */
 
	virtual ~CrashLog() {}
 

	
 
	char *FillCrashLog(char *buffer, const char *last) const;
src/news_gui.cpp
Show inline comments
 
@@ -41,13 +41,13 @@
 
#include "safeguards.h"
 

	
 
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
 
NewsItem *_oldest_news = NULL;         ///< head of news items queue
 
static NewsItem *_latest_news = NULL;       ///< tail of news items queue
 

	
 
/**
 
 * Forced news item.
 
 * Users can force an item by accessing the history or "last message".
 
 * If the message being shown was forced by the user, a pointer is stored
src/news_gui.h
Show inline comments
 
@@ -9,10 +9,14 @@
 

	
 
/** @file news_gui.h GUI functions related to the news. */
 

	
 
#ifndef NEWS_GUI_H
 
#define NEWS_GUI_H
 

	
 
#include "news_type.h"
 

	
 
void ShowLastNewsMessage();
 
void ShowMessageHistory();
 

	
 
extern NewsItem *_oldest_news;
 

	
 
#endif /* NEWS_GUI_H */
0 comments (0 inline, 0 general)