43 #ifdef WITH_FONTCONFIG 44 # include <fontconfig/fontconfig.h> 52 # include <ft2build.h> 53 # include FT_FREETYPE_H 55 #if defined(WITH_ICU_LX) || defined(WITH_ICU_I18N) 56 # include <unicode/uversion.h> 62 #include <lzo/lzo1x.h> 64 #if defined(WITH_SDL) || defined(WITH_SDL2) 79 buffer +=
seprintf(buffer, last,
" Compiler: " 82 #elif defined(__ICC) && defined(__GNUC__)
83 "ICC %d (GCC %d.%d.%d mode)", __ICC, __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__
86 #elif defined(__GNUC__)
87 "GCC %d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__
88 #elif defined(__WATCOMC__)
89 "WatcomC %d", __WATCOMC__
94 #if defined(__VERSION__) 95 return buffer +
seprintf(buffer, last,
" \"" __VERSION__
"\"\n\n");
97 return buffer +
seprintf(buffer, last,
"\n\n");
121 return buffer +
seprintf(buffer, last,
123 " Version: %s (%d)\n" 124 " NewGRF ver: %08x\n" 128 " Build date: %s\n\n",
130 _openttd_revision_modified,
131 _openttd_newgrf_version,
163 " Graphics set: %s (%u)\n" 165 " Music driver: %s\n" 166 " Music set: %s (%u)\n" 168 " Sound driver: %s\n" 169 " Sound set: %s (%u)\n" 170 " Video driver: %s\n\n",
199 FOR_ALL_COMPANIES(c) {
200 if (c->ai_info ==
nullptr) {
201 buffer +=
seprintf(buffer, last,
" %2i: Human\n", (
int)c->
index);
210 buffer +=
seprintf(buffer, last,
"\n");
223 buffer +=
seprintf(buffer, last,
"Libraries:\n");
226 buffer +=
seprintf(buffer, last,
" Allegro: %s\n", allegro_id);
229 #ifdef WITH_FONTCONFIG 230 int version = FcGetVersion();
231 buffer +=
seprintf(buffer, last,
" FontConfig: %d.%d.%d\n", version / 10000, (version / 100) % 100, version % 100);
236 int major, minor, patch;
237 FT_Init_FreeType(&library);
238 FT_Library_Version(library, &major, &minor, &patch);
239 FT_Done_FreeType(library);
240 buffer +=
seprintf(buffer, last,
" FreeType: %d.%d.%d\n", major, minor, patch);
243 #if defined(WITH_ICU_LX) || defined(WITH_ICU_I18N) 245 char buf[4 * 3 + 3 + 1];
248 u_versionToString(ver, buf);
250 buffer +=
seprintf(buffer, last,
" ICU i18n: %s\n", buf);
253 buffer +=
seprintf(buffer, last,
" ICU lx: %s\n", buf);
258 buffer +=
seprintf(buffer, last,
" LZMA: %s\n", lzma_version_string());
262 buffer +=
seprintf(buffer, last,
" LZO: %s\n", lzo_version_string());
266 buffer +=
seprintf(buffer, last,
" PNG: %s\n", png_get_libpng_ver(
nullptr));
270 const SDL_version *sdl_v = SDL_Linked_Version();
271 buffer +=
seprintf(buffer, last,
" SDL1: %d.%d.%d\n", sdl_v->major, sdl_v->minor, sdl_v->patch);
272 #elif defined(WITH_SDL2) 274 SDL_GetVersion(&sdl2_v);
275 buffer +=
seprintf(buffer, last,
" SDL2: %d.%d.%d\n", sdl2_v.major, sdl2_v.minor, sdl2_v.patch);
279 buffer +=
seprintf(buffer, last,
" Zlib: %s\n", zlibVersion());
282 buffer +=
seprintf(buffer, last,
"\n");
317 buffer +=
seprintf(buffer, last,
"Recent news messages:\n");
323 buffer +=
seprintf(buffer, last,
"(%i-%02i-%02i) StringID: %u, Type: %u, Ref1: %u, %u, Ref2: %u, %u\n",
324 ymd.
year, ymd.
month + 1, ymd.
day, news->string_id, news->type,
325 news->reftype1, news->ref1, news->reftype2, news->ref2);
327 buffer +=
seprintf(buffer, last,
"\n");
339 time_t cur_time = time(
nullptr);
340 buffer +=
seprintf(buffer, last,
"*** OpenTTD Crash Report ***\n\n");
341 buffer +=
seprintf(buffer, last,
"Crash at: %s", asctime(gmtime(&cur_time)));
359 buffer +=
seprintf(buffer, last,
"*** End of OpenTTD Crash Report ***\n");
377 if (file ==
nullptr)
return false;
379 size_t len = strlen(buffer);
380 size_t written = fwrite(buffer, 1, len, file);
383 return len == written;
404 if (
_m ==
nullptr)
return false;
429 if (_screen.width < 1 || _screen.height < 1 || _screen.dst_ptr ==
nullptr)
return false;
445 static bool crashlogged =
false;
446 if (crashlogged)
return false;
449 char filename[MAX_PATH];
453 printf(
"Crash encountered, generating crash log...\n");
455 printf(
"%s\n", buffer);
456 printf(
"Crash log generated.\n\n");
458 printf(
"Writing crash log to disk...\n");
461 printf(
"Crash log written to %s. Please add this file to any bug reports.\n\n", filename);
463 printf(
"Writing crash log failed. Please attach the output above to any bug reports.\n\n");
470 printf(
"Writing crash dump failed.\n\n");
472 }
else if (dret > 0) {
473 printf(
"Crash dump written to %s. Please add this file to any bug reports.\n\n", filename);
476 printf(
"Writing crash savegame...\n");
479 printf(
"Crash savegame written to %s. Please add this file and the last (auto)save to any bug reports.\n\n", filename);
482 printf(
"Writing crash savegame failed. Please attach the last (auto)save to any bug reports.\n\n");
485 printf(
"Writing crash screenshot...\n");
488 printf(
"Crash screenshot written to %s. Please add this file to any bug reports.\n\n", filename);
491 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.
int GetVersion() const
Get the version of the script.
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.
const char * GetName() const
Get the Name of the script.
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.
Tindex index
Index of this pool item.
#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 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.