Go to the documentation of this file.
41 #ifdef WITH_FONTCONFIG
42 # include <fontconfig/fontconfig.h>
50 # include <ft2build.h>
51 # include FT_FREETYPE_H
53 #if defined(WITH_ICU_LX) || defined(WITH_ICU_I18N)
54 # include <unicode/uversion.h>
60 #include <lzo/lzo1x.h>
62 #if defined(WITH_SDL) || defined(WITH_SDL2)
77 buffer +=
seprintf(buffer, last,
" Compiler: "
80 #elif defined(__ICC) && defined(__GNUC__)
81 "ICC %d (GCC %d.%d.%d mode)", __ICC, __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__
84 #elif defined(__GNUC__)
85 "GCC %d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__
86 #elif defined(__WATCOMC__)
87 "WatcomC %d", __WATCOMC__
92 #if defined(__VERSION__)
93 return buffer +
seprintf(buffer, last,
" \"" __VERSION__
"\"\n\n");
95 return buffer +
seprintf(buffer, last,
"\n\n");
119 return buffer +
seprintf(buffer, last,
121 " Version: %s (%d)\n"
122 " NewGRF ver: %08x\n"
126 " Build date: %s\n\n",
128 _openttd_revision_modified,
129 _openttd_newgrf_version,
161 " Graphics set: %s (%u)\n"
163 " Music driver: %s\n"
164 " Music set: %s (%u)\n"
166 " Sound driver: %s\n"
167 " Sound set: %s (%u)\n"
168 " Video driver: %s\n\n",
197 if (c->ai_info ==
nullptr) {
198 buffer +=
seprintf(buffer, last,
" %2i: Human\n", (
int)c->index);
200 buffer +=
seprintf(buffer, last,
" %2i: %s (v%d)\n", (
int)c->index, c->ai_info->GetName(), c->ai_info->GetVersion());
207 buffer +=
seprintf(buffer, last,
"\n");
220 buffer +=
seprintf(buffer, last,
"Libraries:\n");
223 buffer +=
seprintf(buffer, last,
" Allegro: %s\n", allegro_id);
226 #ifdef WITH_FONTCONFIG
227 int version = FcGetVersion();
228 buffer +=
seprintf(buffer, last,
" FontConfig: %d.%d.%d\n", version / 10000, (version / 100) % 100, version % 100);
233 int major, minor, patch;
234 FT_Init_FreeType(&library);
235 FT_Library_Version(library, &major, &minor, &patch);
236 FT_Done_FreeType(library);
237 buffer +=
seprintf(buffer, last,
" FreeType: %d.%d.%d\n", major, minor, patch);
240 #if defined(WITH_ICU_LX) || defined(WITH_ICU_I18N)
242 char buf[4 * 3 + 3 + 1];
245 u_versionToString(ver, buf);
247 buffer +=
seprintf(buffer, last,
" ICU i18n: %s\n", buf);
250 buffer +=
seprintf(buffer, last,
" ICU lx: %s\n", buf);
255 buffer +=
seprintf(buffer, last,
" LZMA: %s\n", lzma_version_string());
259 buffer +=
seprintf(buffer, last,
" LZO: %s\n", lzo_version_string());
263 buffer +=
seprintf(buffer, last,
" PNG: %s\n", png_get_libpng_ver(
nullptr));
267 const SDL_version *sdl_v = SDL_Linked_Version();
268 buffer +=
seprintf(buffer, last,
" SDL1: %d.%d.%d\n", sdl_v->major, sdl_v->minor, sdl_v->patch);
269 #elif defined(WITH_SDL2)
271 SDL_GetVersion(&sdl2_v);
272 buffer +=
seprintf(buffer, last,
" SDL2: %d.%d.%d\n", sdl2_v.major, sdl2_v.minor, sdl2_v.patch);
276 buffer +=
seprintf(buffer, last,
" Zlib: %s\n", zlibVersion());
279 buffer +=
seprintf(buffer, last,
"\n");
314 buffer +=
seprintf(buffer, last,
"Recent news messages:\n");
320 buffer +=
seprintf(buffer, last,
"(%i-%02i-%02i) StringID: %u, Type: %u, Ref1: %u, %u, Ref2: %u, %u\n",
321 ymd.
year, ymd.
month + 1, ymd.
day, news->string_id, news->type,
322 news->reftype1, news->ref1, news->reftype2, news->ref2);
324 buffer +=
seprintf(buffer, last,
"\n");
336 time_t cur_time = time(
nullptr);
337 buffer +=
seprintf(buffer, last,
"*** OpenTTD Crash Report ***\n\n");
338 buffer +=
seprintf(buffer, last,
"Crash at: %s", asctime(gmtime(&cur_time)));
356 buffer +=
seprintf(buffer, last,
"*** End of OpenTTD Crash Report ***\n");
374 if (file ==
nullptr)
return false;
376 size_t len = strlen(buffer);
377 size_t written = fwrite(buffer, 1, len, file);
380 return len == written;
401 if (
_m ==
nullptr)
return false;
426 if (_screen.width < 1 || _screen.height < 1 || _screen.dst_ptr ==
nullptr)
return false;
442 static bool crashlogged =
false;
443 if (crashlogged)
return false;
446 char filename[MAX_PATH];
450 printf(
"Crash encountered, generating crash log...\n");
452 printf(
"%s\n", buffer);
453 printf(
"Crash log generated.\n\n");
455 printf(
"Writing crash log to disk...\n");
458 printf(
"Crash log written to %s. Please add this file to any bug reports.\n\n", filename);
460 printf(
"Writing crash log failed. Please attach the output above to any bug reports.\n\n");
467 printf(
"Writing crash dump failed.\n\n");
469 }
else if (dret > 0) {
470 printf(
"Crash dump written to %s. Please add this file to any bug reports.\n\n", filename);
473 printf(
"Writing crash savegame...\n");
476 printf(
"Crash savegame written to %s. Please add this file and the last (auto)save to any bug reports.\n\n", filename);
479 printf(
"Writing crash savegame failed. Please attach the last (auto)save to any bug reports.\n\n");
482 printf(
"Writing crash screenshot...\n");
485 printf(
"Crash screenshot written to %s. Please add this file to any bug reports.\n\n", filename);
488 printf(
"Writing crash screenshot failed.\n\n");
char * LogLibraries(char *buffer, const char *last) const
Writes information (versions) of the used libraries.
virtual const char * GetName() const =0
Get the name of this driver.
bool MakeCrashLog() const
Makes the crash log, writes it to a file and then subsequently tries to make a crash dump and crash s...
std::string _personal_dir
custom directory for personal settings, saves, newgrf, etc.
static void AfterCrashLogCleanup()
Try to close the sound/video stuff so it doesn't keep lingering around incorrect video states or so,...
Information about a single item of news.
bool WriteScreenshot(char *filename, const char *filename_last) const
Write the (crash) screenshot to a file.
SaveOrLoadResult SaveOrLoad(const std::string &filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded)
Main Save or Load function where the high-level saveload functions are handled.
DateFract _date_fract
Fractional part of the day.
bool _network_server
network-server is active
std::string name
The name of the base set.
char * LogConfiguration(char *buffer, const char *last) const
Writes the (important) configuration settings to the buffer.
static class GameInfo * GetInfo()
Get the current GameInfo.
char * LogOpenTTDVersion(char *buffer, const char *last) const
Writes OpenTTD's version to the buffer.
@ FS_LARGE
Index of the large font in the font tables.
@ DFT_GAME_FILE
Save game or scenario file.
uint32 version
The version of this base set.
virtual char * LogOSVersion(char *buffer, const char *last) const =0
Writes OS' version to the buffer.
static char * gamelog_buffer
Temporary 'local' location of the buffer.
#define TTD_LITTLE_ENDIAN
Little endian builds use this for TTD_ENDIAN.
char * LogGamelog(char *buffer, const char *last) const
Writes the gamelog data to the buffer.
void GamelogPrint(GamelogPrintProc *proc)
Prints active gamelog.
Date _date
Current date in days (day counter)
@ SLO_SAVE
File is being saved.
static MusicDriver * GetInstance()
Get the currently active instance of the music driver.
@ FS_NORMAL
Index of the normal font in the font tables.
virtual char * LogModules(char *buffer, const char *last) const
Writes the dynamically linked libraries/modules to the buffer, if there is information about it avail...
char * LogRecentNews(char *buffer, const char *list) const
Writes up to 32 recent news messages to the buffer, with the most recent first.
FILE * FioFOpenFile(const std::string &filename, const char *mode, Subdirectory subdir, size_t *filesize)
Opens a OpenTTD file somewhere in a personal or global directory.
@ FS_SMALL
Index of the small font in the font tables.
static void SetErrorMessage(const char *message)
Sets a message for the error message handler.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
void GamelogEmergency()
Logs a emergency savegame.
void ConvertDateToYMD(Date date, YearMonthDay *ymd)
Converts a Date to a Year, Month & Day.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
static const char * message
Pointer to the error message.
const LanguageMetadata * _current_language
The currently loaded language.
virtual char * LogRegisters(char *buffer, const char *last) const
Writes information about the data in the registers, if there is information about it available.
bool _networking
are we in networking mode?
NewsItem * prev
Previous news item.
virtual int WriteCrashDump(char *filename, const char *filename_last) const
Write the (crash) dump to a file.
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
virtual char * LogError(char *buffer, const char *last, const char *message) const =0
Writes actually encountered error to the buffer.
virtual char * LogCompiler(char *buffer, const char *last) const
Writes compiler (and its version, if available) to the buffer.
CompanyID _current_company
Company currently doing an action.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static void GamelogFillCrashLog(const char *s)
Helper function for printing the gamelog.
bool WriteSavegame(char *filename, const char *filename_last) const
Write the (crash) savegame to a file.
@ NO_DIRECTORY
A path without any base directory.
static const char * gamelog_last
Temporary 'local' location of the end of the buffer.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
char _full_screenshot_name[MAX_PATH]
Pathname of the screenshot file.
bool MakeScreenshot(ScreenshotType t, std::string name, uint32 width, uint32 height)
Schedule making a screenshot.
NewsItem * _latest_news
tail of news items queue
Data structure to convert between Date and triplet (year, month, and day).
@ FS_MONO
Index of the monospaced font in the font tables.
static SoundDriver * GetInstance()
Get the currently active instance of the sound driver.
char * FillCrashLog(char *buffer, const char *last) const
Fill the crash log buffer with all data of a crash log.
bool WriteCrashLog(const char *buffer, char *filename, const char *filename_last) const
Write the crash log to a file.
@ SC_CRASHLOG
Raw screenshot from blitter buffer.
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
virtual void Stop()=0
Stop this driver.
#define lastof(x)
Get the last element of an fixed size array.
@ SL_OK
completed successfully
Tile * _m
Tiles of the map.
virtual char * LogStacktrace(char *buffer, const char *last) const =0
Writes the stack trace to the buffer, if there is information about it available.
void FioFCloseFile(FILE *f)
Close a file in a safe way.
static FontCache * Get(FontSize fs)
Get the font cache of a given font size.