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");
NewsItem * _latest_news
tail of news items queue
Functions related to OTTD's strings.
void GamelogPrint(GamelogPrintProc *proc)
Prints active gamelog.
Definition of stuff that is very close to a company, like the company struct itself.
char _full_screenshot_name[MAX_PATH]
Pathname of the screenshot file.
bool _networking
are we in networking mode?
Base of all video drivers.
void GamelogEmergency()
Logs a emergency savegame.
bool WriteCrashLog(const char *buffer, char *filename, const char *filename_last) const
Write the crash log to a file.
void FioFCloseFile(FILE *f)
Close a file in a safe way.
Functions related to dates.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
static const char * gamelog_last
Temporary 'local' location of the end of the buffer.
Index of the monospaced font in the font tables.
Functions to be called to log possibly unsafe game events.
virtual char * LogError(char *buffer, const char *last, const char *message) const =0
Writes actually encountered error to the buffer.
Tile * _m
Tiles of the map.
const LanguageMetadata * _current_language
The currently loaded language.
Base for all sound drivers.
#define lastof(x)
Get the last element of an fixed size array.
Functions to make screenshots.
Functions related to maps.
static FontCache * Get(FontSize fs)
Get the font cache of a given font size.
virtual int WriteCrashDump(char *filename, const char *filename_last) const
Write the (crash) dump to a file.
Save game or scenario file.
Functions to read fonts from files and cache them.
Functions/types related to saving and loading games.
char * LogGamelog(char *buffer, const char *last) const
Writes the gamelog data to the buffer.
DateFract _date_fract
Fractional part of the day.
virtual void Stop()=0
Stop this driver.
char * LogOpenTTDVersion(char *buffer, const char *last) const
Writes OpenTTD's version to the buffer.
GUI functions related to the news.
static const char * message
Pointer to the error message.
#define TTD_LITTLE_ENDIAN
Little endian builds use this for TTD_ENDIAN.
const char * name
The name of the base set.
Functions related to the gfx engine.
FILE * FioFOpenFile(const char *filename, const char *mode, Subdirectory subdir, size_t *filesize)
Opens a OpenTTD file somewhere in a personal or global directory.
A path without any base directory.
Base for all music playback.
Definition of base types and functions in a cross-platform compatible way.
Data structure to convert between Date and triplet (year, month, and day).
A number of safeguards to prevent using unsafe methods.
static void AfterCrashLogCleanup()
Try to close the sound/video stuff so it doesn't keep lingering around incorrect video states or so...
bool MakeCrashLog() const
Makes the crash log, writes it to a file and then subsequently tries to make a crash dump and crash s...
Information about languages and their files.
static char * gamelog_buffer
Temporary 'local' location of the buffer.
const char * _personal_dir
custom directory for personal settings, saves, newgrf, etc.
NewsItem * prev
Previous news item.
bool WriteScreenshot(char *filename, const char *filename_last) const
Write the (crash) screenshot to a file.
static MusicDriver * GetInstance()
Get the currently active instance of the music driver.
Basic functions/variables used all over the place.
SaveOrLoadResult SaveOrLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded)
Main Save or Load function where the high-level saveload functions are handled.
virtual char * LogCompiler(char *buffer, const char *last) const
Writes compiler (and its version, if available) to the buffer.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
uint32 version
The version of this base set.
virtual const char * GetName() const =0
Get the name of this driver.
static class GameInfo * GetInfo()
Get the current GameInfo.
bool WriteSavegame(char *filename, const char *filename_last) const
Write the (crash) savegame to a file.
Functions to be called to log a crash.
bool MakeScreenshot(ScreenshotType t, const char *name)
Make an actual screenshot.
static SoundDriver * GetInstance()
Get the currently active instance of the sound driver.
GameInfo keeps track of all information of an Game, like Author, Description, ... ...
virtual char * LogStacktrace(char *buffer, const char *last) const =0
Writes the stack trace to the buffer, if there is information about it available. ...
Functions related to companies.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
virtual char * LogOSVersion(char *buffer, const char *last) const =0
Writes OS' version to the buffer.
char * LogLibraries(char *buffer, const char *last) const
Writes information (versions) of the used libraries.
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
Index of the normal font in the font tables.
char * LogRecentNews(char *buffer, const char *list) const
Writes up to 32 recent news messages to the buffer, with the most recent first.
Base functions for all Games.
bool _network_server
network-server is active
CompanyID _current_company
Company currently doing an action.
Index of the small font in the font tables.
Index of the large font in the font tables.
declaration of OTTD revision dependent variables
char * LogConfiguration(char *buffer, const char *last) const
Writes the (important) configuration settings to the buffer.
virtual char * LogRegisters(char *buffer, const char *last) const
Writes information about the data in the registers, if there is information about it available...
static void GamelogFillCrashLog(const char *s)
Helper function for printing the gamelog.
AIInfo keeps track of all information of an AI, like Author, Description, ...
char * FillCrashLog(char *buffer, const char *last) const
Fill the crash log buffer with all data of a crash log.
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...
Date _date
Current date in days (day counter)
Raw screenshot from blitter buffer.
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 void SetErrorMessage(const char *message)
Sets a message for the error message handler.
Factory to 'query' all available blitters.
Information about a single item of news.