OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
40 #ifdef WITH_FONTCONFIG
41 # include <fontconfig/fontconfig.h>
49 # include <ft2build.h>
50 # include FT_FREETYPE_H
52 #if defined(WITH_ICU_LX) || defined(WITH_ICU_I18N)
53 # include <unicode/uversion.h>
59 #include <lzo/lzo1x.h>
61 #if defined(WITH_SDL) || defined(WITH_SDL2)
76 buffer +=
seprintf(buffer, last,
" Compiler: "
79 #elif defined(__ICC) && defined(__GNUC__)
80 "ICC %d (GCC %d.%d.%d mode)", __ICC, __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__
83 #elif defined(__GNUC__)
84 "GCC %d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__
85 #elif defined(__WATCOMC__)
86 "WatcomC %d", __WATCOMC__
91 #if defined(__VERSION__)
92 return buffer +
seprintf(buffer, last,
" \"" __VERSION__
"\"\n\n");
94 return buffer +
seprintf(buffer, last,
"\n\n");
118 return buffer +
seprintf(buffer, last,
120 " Version: %s (%d)\n"
121 " NewGRF ver: %08x\n"
125 " Build date: %s\n\n",
127 _openttd_revision_modified,
128 _openttd_newgrf_version,
129 #ifdef POINTER_IS_64BIT
160 " Graphics set: %s (%u)\n"
162 " Music driver: %s\n"
163 " Music set: %s (%u)\n"
165 " Sound driver: %s\n"
166 " Sound set: %s (%u)\n"
167 " Video driver: %s\n\n",
196 if (c->ai_info ==
nullptr) {
197 buffer +=
seprintf(buffer, last,
" %2i: Human\n", (
int)c->index);
199 buffer +=
seprintf(buffer, last,
" %2i: %s (v%d)\n", (
int)c->index, c->ai_info->GetName(), c->ai_info->GetVersion());
206 buffer +=
seprintf(buffer, last,
"\n");
219 buffer +=
seprintf(buffer, last,
"Libraries:\n");
222 buffer +=
seprintf(buffer, last,
" Allegro: %s\n", allegro_id);
225 #ifdef WITH_FONTCONFIG
226 int version = FcGetVersion();
227 buffer +=
seprintf(buffer, last,
" FontConfig: %d.%d.%d\n", version / 10000, (version / 100) % 100, version % 100);
232 int major, minor, patch;
233 FT_Init_FreeType(&library);
234 FT_Library_Version(library, &major, &minor, &patch);
235 FT_Done_FreeType(library);
236 buffer +=
seprintf(buffer, last,
" FreeType: %d.%d.%d\n", major, minor, patch);
239 #if defined(WITH_ICU_LX) || defined(WITH_ICU_I18N)
241 char buf[4 * 3 + 3 + 1];
244 u_versionToString(ver, buf);
246 buffer +=
seprintf(buffer, last,
" ICU i18n: %s\n", buf);
249 buffer +=
seprintf(buffer, last,
" ICU lx: %s\n", buf);
254 buffer +=
seprintf(buffer, last,
" LZMA: %s\n", lzma_version_string());
258 buffer +=
seprintf(buffer, last,
" LZO: %s\n", lzo_version_string());
262 buffer +=
seprintf(buffer, last,
" PNG: %s\n", png_get_libpng_ver(
nullptr));
266 const SDL_version *sdl_v = SDL_Linked_Version();
267 buffer +=
seprintf(buffer, last,
" SDL1: %d.%d.%d\n", sdl_v->major, sdl_v->minor, sdl_v->patch);
268 #elif defined(WITH_SDL2)
270 SDL_GetVersion(&sdl2_v);
271 buffer +=
seprintf(buffer, last,
" SDL2: %d.%d.%d\n", sdl2_v.major, sdl2_v.minor, sdl2_v.patch);
275 buffer +=
seprintf(buffer, last,
" Zlib: %s\n", zlibVersion());
278 buffer +=
seprintf(buffer, last,
"\n");
313 buffer +=
seprintf(buffer, last,
"Recent news messages:\n");
319 buffer +=
seprintf(buffer, last,
"(%i-%02i-%02i) StringID: %u, Type: %u, Ref1: %u, %u, Ref2: %u, %u\n",
320 ymd.
year, ymd.
month + 1, ymd.
day, news->string_id, news->type,
321 news->reftype1, news->ref1, news->reftype2, news->ref2);
323 buffer +=
seprintf(buffer, last,
"\n");
335 buffer +=
seprintf(buffer, last,
"*** OpenTTD Crash Report ***\n\n");
336 buffer +=
UTCTime::Format(buffer, last,
"Crash at: %Y-%m-%d %H:%M:%S (UTC)\n");
354 buffer +=
seprintf(buffer, last,
"*** End of OpenTTD Crash Report ***\n");
372 if (file ==
nullptr)
return false;
374 size_t len = strlen(buffer);
375 size_t written = fwrite(buffer, 1, len, file);
378 return len == written;
399 if (
_m ==
nullptr)
return false;
424 if (_screen.width < 1 || _screen.height < 1 || _screen.dst_ptr ==
nullptr)
return false;
440 static bool crashlogged =
false;
441 if (crashlogged)
return false;
444 char filename[MAX_PATH];
448 printf(
"Crash encountered, generating crash log...\n");
450 printf(
"%s\n", buffer);
451 printf(
"Crash log generated.\n\n");
453 printf(
"Writing crash log to disk...\n");
456 printf(
"Crash log written to %s. Please add this file to any bug reports.\n\n", filename);
458 printf(
"Writing crash log failed. Please attach the output above to any bug reports.\n\n");
465 printf(
"Writing crash dump failed.\n\n");
467 }
else if (dret > 0) {
468 printf(
"Crash dump written to %s. Please add this file to any bug reports.\n\n", filename);
471 printf(
"Writing crash savegame...\n");
474 printf(
"Crash savegame written to %s. Please add this file and the last (auto)save to any bug reports.\n\n", filename);
477 printf(
"Writing crash savegame failed. Please attach the last (auto)save to any bug reports.\n\n");
480 printf(
"Writing crash screenshot...\n");
483 printf(
"Crash screenshot written to %s. Please add this file to any bug reports.\n\n", filename);
486 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.
static size_t Format(char *buffer, const char *last, const char *format) NOACCESS(2) WARN_TIME_FORMAT(3)
Format the current time with the given strftime format specifiers.
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.