Include crash/desync log contents in PNG screenshots
This commit is contained in:
@@ -586,6 +586,8 @@ bool CrashLog::MakeCrashLog() const
|
|||||||
printf("Crash dump written to %s. Please add this file to any bug reports.\n\n", filename);
|
printf("Crash dump written to %s. Please add this file to any bug reports.\n\n", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetScreenshotAuxiliaryText("Crash Log", buffer);
|
||||||
|
|
||||||
if (IsNonMainThread()) {
|
if (IsNonMainThread()) {
|
||||||
printf("Asking main thread to write crash savegame and screenshot...\n\n");
|
printf("Asking main thread to write crash savegame and screenshot...\n\n");
|
||||||
CrashLog::main_thread_pending_crashlog = this;
|
CrashLog::main_thread_pending_crashlog = this;
|
||||||
@@ -640,6 +642,7 @@ bool CrashLog::MakeDesyncCrashLog() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(_screen.width < 1 || _screen.height < 1 || _screen.dst_ptr == nullptr)) {
|
if (!(_screen.width < 1 || _screen.height < 1 || _screen.dst_ptr == nullptr)) {
|
||||||
|
SetScreenshotAuxiliaryText("Desync Log", buffer);
|
||||||
bret = this->WriteScreenshot(filename, lastof(filename), name_buffer);
|
bret = this->WriteScreenshot(filename, lastof(filename), name_buffer);
|
||||||
if (bret) {
|
if (bret) {
|
||||||
printf("Desync screenshot written to %s. Please add this file to any bug reports.\n\n", filename);
|
printf("Desync screenshot written to %s. Please add this file to any bug reports.\n\n", filename);
|
||||||
@@ -647,6 +650,7 @@ bool CrashLog::MakeDesyncCrashLog() const
|
|||||||
ret = false;
|
ret = false;
|
||||||
printf("Writing desync screenshot failed.\n\n");
|
printf("Writing desync screenshot failed.\n\n");
|
||||||
}
|
}
|
||||||
|
ClearScreenshotAuxiliaryText();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
#include "../../gamelog.h"
|
#include "../../gamelog.h"
|
||||||
#include "../../saveload/saveload.h"
|
#include "../../saveload/saveload.h"
|
||||||
#include "../../thread.h"
|
#include "../../thread.h"
|
||||||
|
#include "../../screenshot.h"
|
||||||
#include "macos.h"
|
#include "macos.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -431,7 +432,8 @@ public:
|
|||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Writing crash savegame...\n");
|
printf("Writing crash screenshot...\n");
|
||||||
|
SetScreenshotAuxiliaryText("Crash Log", buffer);
|
||||||
if (!this->WriteScreenshot(filename_screenshot, lastof(filename_screenshot))) {
|
if (!this->WriteScreenshot(filename_screenshot, lastof(filename_screenshot))) {
|
||||||
filename_screenshot[0] = '\0';
|
filename_screenshot[0] = '\0';
|
||||||
ret = false;
|
ret = false;
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#include "../../saveload/saveload.h"
|
#include "../../saveload/saveload.h"
|
||||||
#include "../../video/video_driver.hpp"
|
#include "../../video/video_driver.hpp"
|
||||||
#include "../../openttd.h"
|
#include "../../openttd.h"
|
||||||
|
#include "../../screenshot.h"
|
||||||
#if defined(WITH_DEMANGLE)
|
#if defined(WITH_DEMANGLE)
|
||||||
#include <cxxabi.h>
|
#include <cxxabi.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -554,6 +555,7 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
|
|||||||
log->WriteCrashDump(log->crashdump_filename, lastof(log->crashdump_filename));
|
log->WriteCrashDump(log->crashdump_filename, lastof(log->crashdump_filename));
|
||||||
log->AppendDecodedStacktrace(buf, lastof(log->crashlog));
|
log->AppendDecodedStacktrace(buf, lastof(log->crashlog));
|
||||||
log->WriteCrashLog(log->crashlog, log->crashlog_filename, lastof(log->crashlog_filename));
|
log->WriteCrashLog(log->crashlog, log->crashlog_filename, lastof(log->crashlog_filename));
|
||||||
|
SetScreenshotAuxiliaryText("Crash Log", log->crashlog);
|
||||||
log->WriteScreenshot(log->screenshot_filename, lastof(log->screenshot_filename));
|
log->WriteScreenshot(log->screenshot_filename, lastof(log->screenshot_filename));
|
||||||
|
|
||||||
/* Close any possible log files */
|
/* Close any possible log files */
|
||||||
|
@@ -40,6 +40,15 @@ uint _cur_screenshot_format; ///< Index of the currently selected scree
|
|||||||
static char _screenshot_name[128]; ///< Filename of the screenshot file.
|
static char _screenshot_name[128]; ///< Filename of the screenshot file.
|
||||||
char _full_screenshot_name[MAX_PATH]; ///< Pathname of the screenshot file.
|
char _full_screenshot_name[MAX_PATH]; ///< Pathname of the screenshot file.
|
||||||
|
|
||||||
|
static const char *_screenshot_aux_text_key = nullptr;
|
||||||
|
static const char *_screenshot_aux_text_value = nullptr;
|
||||||
|
|
||||||
|
void SetScreenshotAuxiliaryText(const char *key, const char *value)
|
||||||
|
{
|
||||||
|
_screenshot_aux_text_key = key;
|
||||||
|
_screenshot_aux_text_value = value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback function signature for generating lines of pixel data to be written to the screenshot file.
|
* Callback function signature for generating lines of pixel data to be written to the screenshot file.
|
||||||
* @param userdata Pointer to user data.
|
* @param userdata Pointer to user data.
|
||||||
@@ -303,7 +312,7 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user
|
|||||||
#ifdef PNG_TEXT_SUPPORTED
|
#ifdef PNG_TEXT_SUPPORTED
|
||||||
/* Try to add some game metadata to the PNG screenshot so
|
/* Try to add some game metadata to the PNG screenshot so
|
||||||
* it's more useful for debugging and archival purposes. */
|
* it's more useful for debugging and archival purposes. */
|
||||||
png_text_struct text[2];
|
png_text_struct text[3];
|
||||||
memset(text, 0, sizeof(text));
|
memset(text, 0, sizeof(text));
|
||||||
text[0].key = const_cast<char *>("Software");
|
text[0].key = const_cast<char *>("Software");
|
||||||
text[0].text = const_cast<char *>(_openttd_revision);
|
text[0].text = const_cast<char *>(_openttd_revision);
|
||||||
@@ -332,7 +341,13 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user
|
|||||||
text[1].text = buf;
|
text[1].text = buf;
|
||||||
text[1].text_length = p - buf;
|
text[1].text_length = p - buf;
|
||||||
text[1].compression = PNG_TEXT_COMPRESSION_zTXt;
|
text[1].compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||||
png_set_text(png_ptr, info_ptr, text, 2);
|
if (_screenshot_aux_text_key && _screenshot_aux_text_value) {
|
||||||
|
text[2].key = const_cast<char *>(_screenshot_aux_text_key);
|
||||||
|
text[2].text = const_cast<char *>(_screenshot_aux_text_value);
|
||||||
|
text[2].text_length = strlen(_screenshot_aux_text_value);
|
||||||
|
text[2].compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||||
|
}
|
||||||
|
png_set_text(png_ptr, info_ptr, text, _screenshot_aux_text_key && _screenshot_aux_text_value ? 3 : 2);
|
||||||
#endif /* PNG_TEXT_SUPPORTED */
|
#endif /* PNG_TEXT_SUPPORTED */
|
||||||
|
|
||||||
if (pixelformat == 8) {
|
if (pixelformat == 8) {
|
||||||
|
@@ -33,6 +33,8 @@ bool MakeHeightmapScreenshot(const char *filename);
|
|||||||
bool MakeSmallMapScreenshot(unsigned int width, unsigned int height, SmallMapWindow *window);
|
bool MakeSmallMapScreenshot(unsigned int width, unsigned int height, SmallMapWindow *window);
|
||||||
bool MakeScreenshot(ScreenshotType t, const char *name);
|
bool MakeScreenshot(ScreenshotType t, const char *name);
|
||||||
void SaveMinimap(const char *name);
|
void SaveMinimap(const char *name);
|
||||||
|
void SetScreenshotAuxiliaryText(const char *key, const char *value);
|
||||||
|
inline void ClearScreenshotAuxiliaryText() { SetScreenshotAuxiliaryText(nullptr, nullptr); }
|
||||||
|
|
||||||
extern char _screenshot_format_name[8];
|
extern char _screenshot_format_name[8];
|
||||||
extern uint _num_screenshot_formats;
|
extern uint _num_screenshot_formats;
|
||||||
|
Reference in New Issue
Block a user