|
OpenTTD Source
14.0-beta3
|
Go to the documentation of this file.
42 #ifdef WITH_FONTCONFIG
43 # include <fontconfig/fontconfig.h>
51 # include <ft2build.h>
52 # include FT_FREETYPE_H
58 # include <unicode/uversion.h>
64 #include <lzo/lzo1x.h>
66 #if defined(WITH_SDL) || defined(WITH_SDL2)
73 # include <curl/curl.h>
87 {SocialIntegrationPlugin::State::RUNNING,
"running"},
88 {SocialIntegrationPlugin::State::FAILED,
"failed"},
89 {SocialIntegrationPlugin::State::PLATFORM_NOT_RUNNING,
"platform_not_running"},
90 {SocialIntegrationPlugin::State::UNLOADED,
"unloaded"},
91 {SocialIntegrationPlugin::State::DUPLICATE,
"duplicate"},
92 {SocialIntegrationPlugin::State::UNSUPPORTED_API,
"unsupported_api"},
93 {SocialIntegrationPlugin::State::INVALID_SIGNATURE,
"invalid_signature"},
117 static const SettingTable _generic_setting_tables[] = {
118 _difficulty_settings,
124 _multimedia_settings,
126 _news_display_settings,
127 _pathfinding_settings,
131 return _generic_setting_tables;
142 static void SurveySettingsTable(nlohmann::json &survey,
const SettingTable &table,
void *
object,
bool skip_if_default)
144 for (
auto &desc : table) {
163 #if defined(_WIN32) && !defined(DEDICATED)
180 #if defined(_MSC_VER)
181 survey[
"name"] =
"MSVC";
182 survey[
"version"] = _MSC_VER;
183 #elif defined(__ICC) && defined(__GNUC__)
184 survey[
"name"] =
"ICC";
185 survey[
"version"] = __ICC;
186 # if defined(__GNUC__)
187 survey[
"extra"] = fmt::format(
"GCC {}.{}.{} mode", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
189 #elif defined(__GNUC__)
190 survey[
"name"] =
"GCC";
191 survey[
"version"] = fmt::format(
"{}.{}.{}", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
193 survey[
"name"] =
"unknown";
196 #if defined(__VERSION__)
197 survey[
"extra"] = __VERSION__;
208 survey[
"version"][
"revision"] = std::string(_openttd_revision);
209 survey[
"version"][
"modified"] = _openttd_revision_modified;
210 survey[
"version"][
"tagged"] = _openttd_revision_tagged;
211 survey[
"version"][
"hash"] = std::string(_openttd_revision_hash);
212 survey[
"version"][
"newgrf"] = fmt::format(
"{:X}", _openttd_newgrf_version);
213 survey[
"version"][
"content"] = std::string(_openttd_content_version);
214 survey[
"build_date"] = std::string(_openttd_build_date);
216 #ifdef POINTER_IS_64BIT
223 #if (TTD_ENDIAN == TTD_LITTLE_ENDIAN)
229 survey[
"dedicated_build"] =
267 if (extra_cfg !=
nullptr && extra_cfg->
num_params > 0) {
268 survey[
"graphics_set_parameters"] = std::span<const uint32_t>(extra_cfg->
param.data(), extra_cfg->
num_params);
270 survey[
"graphics_set_parameters"] = std::span<const uint32_t>();
302 auto &company = survey[std::to_string(c->index)];
303 if (c->ai_info ==
nullptr) {
304 company[
"type"] =
"human";
306 company[
"type"] =
"ai";
307 company[
"script"] = fmt::format(
"{}.{}", c->ai_info->GetName(), c->ai_info->GetVersion());
311 uint amount = c->group_all[type].num_vehicle;
315 company[
"infrastructure"][
"road"] = c->infrastructure.GetRoadTotal();
316 company[
"infrastructure"][
"tram"] = c->infrastructure.GetTramTotal();
317 company[
"infrastructure"][
"rail"] = c->infrastructure.GetRailTotal();
318 company[
"infrastructure"][
"signal"] = c->infrastructure.signal;
319 company[
"infrastructure"][
"water"] = c->infrastructure.water;
320 company[
"infrastructure"][
"station"] = c->infrastructure.station;
321 company[
"infrastructure"][
"airport"] = c->infrastructure.airport;
333 survey[
"seconds"] = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() -
_switch_mode_time).count();
336 survey[
"economy"] = fmt::format(
"{:04}-{:02}-{:02} ({})", economy_ymd.year, economy_ymd.month + 1, economy_ymd.day,
TimerGameEconomy::date_fract);
350 auto grfid = fmt::format(
"{:08x}",
BSWAP32(c->ident.grfid));
351 auto &grf = survey[grfid];
354 grf[
"status"] = c->status;
365 grf[
"parameters"] = std::span<const uint32_t>(c->param.data(), c->num_params);
389 survey[
"allegro"] = std::string(allegro_id);
392 #ifdef WITH_FONTCONFIG
393 int version = FcGetVersion();
394 survey[
"fontconfig"] = fmt::format(
"{}.{}.{}", version / 10000, (version / 100) % 100, version % 100);
399 int major, minor, patch;
400 FT_Init_FreeType(&library);
401 FT_Library_Version(library, &major, &minor, &patch);
402 FT_Done_FreeType(library);
403 survey[
"freetype"] = fmt::format(
"{}.{}.{}", major, minor, patch);
406 #if defined(WITH_HARFBUZZ)
407 survey[
"harfbuzz"] = hb_version_string();
410 #if defined(WITH_ICU_I18N)
412 char buf[4 * 3 + 3 + 1];
415 u_versionToString(ver, buf);
416 survey[
"icu_i18n"] = buf;
420 survey[
"lzma"] = lzma_version_string();
424 survey[
"lzo"] = lzo_version_string();
428 survey[
"png"] = png_get_libpng_ver(
nullptr);
432 const SDL_version *sdl_v = SDL_Linked_Version();
433 survey[
"sdl"] = fmt::format(
"{}.{}.{}", sdl_v->major, sdl_v->minor, sdl_v->patch);
434 #elif defined(WITH_SDL2)
436 SDL_GetVersion(&sdl2_v);
437 survey[
"sdl2"] = fmt::format(
"{}.{}.{}", sdl2_v.major, sdl2_v.minor, sdl2_v.patch);
441 survey[
"zlib"] = zlibVersion();
445 auto *curl_v = curl_version_info(CURLVERSION_NOW);
446 survey[
"curl"] = curl_v->version;
447 survey[
"curl_ssl"] = curl_v->ssl_version ==
nullptr ?
"none" : curl_v->ssl_version;
461 auto &platform = survey[plugin->social_platform];
463 {
"name", plugin->name},
464 {
"version", plugin->version},
465 {
"basepath", plugin->basepath},
466 {
"state", plugin->state},
481 memory = memory / 1024;
482 memory =
CeilDiv(memory, 1024);
486 return fmt::format(
"{} GiB",
CeilDiv(memory, 1024));
491 return fmt::format(
"{} MiB",
Ceil(memory, 128));
495 return fmt::format(
"{} MiB",
Ceil(memory, 4));
void SurveyConfiguration(nlohmann::json &survey)
Convert generic game information to JSON.
SaveLoadVersion version_to
Save/load the variable before this savegame version.
std::string FormatArrayAsHex(std::span< const byte > data)
Format a byte array into a continuous hex string.
void SurveyLibraries(nlohmann::json &survey)
Convert compiled libraries information to JSON.
void SurveyTimers(nlohmann::json &survey)
Convert timer information to JSON.
static TickCounter counter
Monotonic counter, in ticks, since start of game.
virtual const char * GetName() const =0
Get the name of this driver.
virtual bool IsDefaultValue(void *object) const =0
Check whether the value is the same as the default value.
@ GCS_ACTIVATED
GRF file has been activated.
constexpr uint Ceil(uint a, uint b)
Computes ceil(a / b) * b for non-negative a and b.
static DateFract date_fract
Fractional part of the day.
bool _network_server
network-server is active
static class GameInfo * GetInfo()
Get the current GameInfo.
SaveLoad save
Internal structure (going to savegame, parts to config).
@ FS_LARGE
Index of the large font in the font tables.
std::string SurveyMemoryToText(uint64_t memory)
Change the bytes of memory into a textual version rounded up to the biggest unit.
@ GCS_NOT_FOUND
GRF file was not found in the local cache.
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
static DateFract date_fract
Fractional part of the day.
ClientSettings _settings_client
The current settings for this game.
@ GRFP_GRF_UNSET
The NewGRF provided no information.
@ GRFP_BLT_UNSET
The NewGRF provided no information or doesn't care about a 32 bpp blitter.
void SurveySettings(nlohmann::json &survey, bool skip_if_default)
Convert settings to JSON.
@ GRFP_GRF_DOS
The NewGRF says the DOS palette can be used.
static uint32_t BSWAP32(uint32_t x)
Perform a 32 bits endianness bitswap on x.
@ GCS_INITIALISED
GRF file has been initialised.
Information about GRF, used in the game and (part of it) in savegames.
static MusicDriver * GetInstance()
Get the currently active instance of the music driver.
@ FS_NORMAL
Index of the normal font in the font tables.
@ VEH_COMPANY_END
Last company-ownable type.
@ GRFP_GRF_ANY
The NewGRF says any palette can be used.
constexpr const std::string & GetName() const
Get the name of this setting.
@ FS_SMALL
Index of the small font in the font tables.
virtual std::string FormatValue(const void *object) const =0
Format the value of the setting associated with this object.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
void SurveyOpenTTD(nlohmann::json &survey)
Convert generic OpenTTD information to JSON.
void SurveyCompanies(nlohmann::json &survey)
Convert company information to JSON.
const LanguageMetadata * _current_language
The currently loaded language.
static YearMonthDay ConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
@ GRFP_BLT_32BPP
The NewGRF prefers a 32 bpp blitter.
std::chrono::steady_clock::time_point _switch_mode_time
The time when the switch mode was requested.
bool _networking
are we in networking mode?
static constexpr const SettingDesc * GetSettingDesc(const SettingVariant &desc)
Helper to convert the type of the iterated settings description to a pointer to it.
@ GRFP_GRF_MASK
Bitmask to get only the NewGRF supplied information.
void SurveyGrfs(nlohmann::json &survey)
Convert GRF information to JSON.
static YearMonthDay ConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
VehicleType
Available vehicle types.
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
@ GCS_UNKNOWN
The status of this grf file is unknown.
bool SlIsObjectCurrentlyValid(SaveLoadVersion version_from, SaveLoadVersion version_to)
Checks if some version from/to combination falls within the range of the active savegame version.
static auto & GenericSettingTables()
List of all the generic setting tables.
virtual const char * GetName()=0
Get the name of the blitter, the same as the Factory-instance returns.
@ GCS_DISABLED
GRF file is disabled.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
@ GRFP_GRF_WINDOWS
The NewGRF says the Windows palette can be used.
static std::vector< std::unique_ptr< InternalSocialIntegrationPlugin > > _plugins
List of loaded plugins.
virtual std::string GetFontName()=0
Get the name of this font.
std::array< uint32_t, 0x80 > param
GRF parameters.
Properties of config file settings.
void SurveyCompiler(nlohmann::json &survey)
Convert compiler information to JSON.
static const std::string _vehicle_type_to_string[]
Lookup table to convert a VehicleType to a string.
static void SurveySettingsTable(nlohmann::json &survey, const SettingTable &table, void *object, bool skip_if_default)
Convert a settings table to JSON.
struct GRFConfig * next
NOSAVE: Next item in the linked list.
SaveLoadVersion version_from
Save/load the variable starting from this savegame version.
GRFConfig * _grfconfig
First item in list of current GRF set up.
uint8_t num_params
Number of used parameters.
@ FS_MONO
Index of the monospaced font in the font tables.
static SoundDriver * GetInstance()
Get the currently active instance of the sound driver.
static Date date
Current date in days (day counter).
CompanySettings company
default values for per-company settings
void SurveyGameScript(nlohmann::json &survey)
Convert game-script information to JSON.
void SurveyFont(nlohmann::json &survey)
Convert font information to JSON.
void SurveyPlugins(nlohmann::json &survey)
Convert plugin information to JSON.
static std::vector< SocialIntegrationPlugin * > GetPlugins()
Get the list of loaded social integration plugins.
NLOHMANN_JSON_SERIALIZE_ENUM(NetworkSurveyHandler::Reason, { {NetworkSurveyHandler::Reason::PREVIEW, "preview"}, {NetworkSurveyHandler::Reason::LEAVE, "leave"}, {NetworkSurveyHandler::Reason::EXIT, "exit"}, {NetworkSurveyHandler::Reason::CRASH, "crash"}, }) std
Create the payload for the survey.
@ GCF_STATIC
GRF file is used statically (can be used in any MP game)
static FontCache * Get(FontSize fs)
Get the font cache of a given font size.
static Date date
Current date in days (day counter).
@ GRFP_BLT_MASK
Bitmask to only get the blitter information.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.