mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-05 22:04:57 +00:00
(svn r18156) -Add: crash screenshot, created from blitter buffer
This commit is contained in:
parent
4eaa558ca1
commit
5924863a49
@ -68,7 +68,8 @@ When you are sure it is not already reported you should:
|
||||
forum thread related to that patch pack.
|
||||
* Make it reproducible for the developers. In other words, create a savegame
|
||||
in which you can reproduce the issue once loaded. It is very useful to give
|
||||
us the crash.dmp, crash.sav and crash.log which are created on crashes.
|
||||
us the crash.dmp, crash.sav, crash.log and crash screenshot which are
|
||||
created on crashes.
|
||||
* Check whether the bug is already reported on our bug tracker. This includes
|
||||
searching for recently closed bug reports as the bug might already be fixed.
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include "sound/sound_driver.hpp"
|
||||
#include "video/video_driver.hpp"
|
||||
#include "saveload/saveload.h"
|
||||
#include "screenshot.h"
|
||||
#include "gfx_func.h"
|
||||
|
||||
#include <squirrel.h>
|
||||
#include "ai/ai_info.hpp"
|
||||
@ -249,6 +251,17 @@ bool CrashLog::WriteSavegame(char *filename, const char *filename_last) const
|
||||
}
|
||||
}
|
||||
|
||||
bool CrashLog::WriteScreenshot(char *filename, const char *filename_last) const
|
||||
{
|
||||
/* Don't draw when we have invalid screen size */
|
||||
if (_screen.width < 1 || _screen.height < 1 || _screen.dst_ptr == NULL) return false;
|
||||
|
||||
RequestScreenshot(SC_RAW, "crash");
|
||||
bool res = MakeScreenshot();
|
||||
if (res) strecpy(filename, _full_screenshot_name, filename_last);
|
||||
return res;
|
||||
}
|
||||
|
||||
bool CrashLog::MakeCrashLog() const
|
||||
{
|
||||
/* Don't keep looping logging crashes. */
|
||||
@ -292,6 +305,15 @@ bool CrashLog::MakeCrashLog() const
|
||||
printf("Writing crash savegame failed. Please attach the last (auto)save to any bug reports.\n\n");
|
||||
}
|
||||
|
||||
printf("Writing crash screenshot...\n");
|
||||
bret = this->WriteScreenshot(filename, lastof(filename));
|
||||
if (bret) {
|
||||
printf("Crash screenshot written to %s. Please add this file to any bug reports.\n\n", filename);
|
||||
} else {
|
||||
ret = false;
|
||||
printf("Writing crash screenshot failed.\n\n");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -154,6 +154,16 @@ public:
|
||||
*/
|
||||
bool WriteSavegame(char *filename, const char *filename_last) const;
|
||||
|
||||
/**
|
||||
* Write the (crash) screenshot to a file.
|
||||
* @note On success the filename will be filled with the full path of the
|
||||
* screenshot. Make sure filename is at least \c MAX_PATH big.
|
||||
* @param filename Output for the filename of the written file.
|
||||
* @param filename_last The last position in the filename buffer.
|
||||
* @return true when the crash screenshot was successfully made.
|
||||
*/
|
||||
bool WriteScreenshot(char *filename, const char *filename_last) const;
|
||||
|
||||
/**
|
||||
* Makes the crash log, writes it to a file and then subsequently tries
|
||||
* to make a crash dump and crash savegame. It uses DEBUG to write
|
||||
|
@ -123,7 +123,6 @@ void CDECL error(const char *s, ...)
|
||||
va_end(va);
|
||||
|
||||
ShowOSErrorBox(buf, true);
|
||||
if (_video_driver != NULL) _video_driver->Stop();
|
||||
|
||||
/* Set the error message for the crash log and then invoke it. */
|
||||
CrashLog::SetErrorMessage(buf);
|
||||
|
@ -644,6 +644,8 @@ bool MakeScreenshot()
|
||||
case SC_VIEWPORT:
|
||||
UndrawMouseCursor();
|
||||
DrawDirtyBlocks();
|
||||
/* FALL THROUGH */
|
||||
case SC_RAW:
|
||||
_screenshot_type = SC_NONE;
|
||||
return MakeSmallScreenshot();
|
||||
case SC_WORLD:
|
||||
|
@ -21,6 +21,7 @@ void SetScreenshotFormat(int i);
|
||||
enum ScreenshotType {
|
||||
SC_NONE, ///< No screenshot requested
|
||||
SC_VIEWPORT, ///< Screenshot of viewport
|
||||
SC_RAW, ///< Raw screenshot from blitter buffer
|
||||
SC_WORLD, ///< World screenshot
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user