diff --git a/src/rev.cpp.in b/src/rev.cpp.in index 4ccd03eca2..9b7cd17ccc 100644 --- a/src/rev.cpp.in +++ b/src/rev.cpp.in @@ -35,7 +35,7 @@ bool IsReleasedVersion() * * shows a "M", if the binary is made from modified source code. */ -const char _openttd_revision[] = "${REV_VERSION}"; +const std::string _openttd_revision = "${REV_VERSION}"; /** * The text version of OpenTTD's build date. @@ -43,17 +43,17 @@ const char _openttd_revision[] = "${REV_VERSION}"; * updated for each revision in contrary to most other files that only see * updates when they are actually changed themselves. */ -const char _openttd_build_date[] = __DATE__ " " __TIME__; +const std::string_view _openttd_build_date = __DATE__ " " __TIME__; /** * The git revision hash of this version. */ -const char _openttd_revision_hash[] = "${REV_HASH}"; +const std::string_view _openttd_revision_hash = "${REV_HASH}"; /** * The year of this version. */ -const char _openttd_revision_year[] = "${REV_YEAR}"; +const std::string_view _openttd_revision_year = "${REV_YEAR}"; /** * Let us know if current build was modified. This detection @@ -77,7 +77,7 @@ const uint8_t _openttd_revision_tagged = ${REV_ISTAG}; * It should never contain things like "beta", but only the release version * we are compatible with. */ -const char _openttd_content_version[] = "${REV_MAJOR}.${REV_MINOR}"; +const std::string_view _openttd_content_version = "${REV_MAJOR}.${REV_MINOR}"; /** * The NewGRF revision of OTTD: diff --git a/src/rev.h b/src/rev.h index 450a8984ba..cb4b7931f1 100644 --- a/src/rev.h +++ b/src/rev.h @@ -10,13 +10,13 @@ #ifndef REV_H #define REV_H -extern const char _openttd_revision[]; -extern const char _openttd_build_date[]; -extern const char _openttd_revision_hash[]; -extern const char _openttd_revision_year[]; +extern const std::string _openttd_revision; +extern const std::string_view _openttd_build_date; +extern const std::string_view _openttd_revision_hash; +extern const std::string_view _openttd_revision_year; extern const uint8_t _openttd_revision_modified; extern const uint8_t _openttd_revision_tagged; -extern const char _openttd_content_version[]; +extern const std::string_view _openttd_content_version; extern const uint32_t _openttd_newgrf_version; bool IsReleasedVersion(); diff --git a/src/screenshot_png.cpp b/src/screenshot_png.cpp index c3da01499e..a0418942cd 100644 --- a/src/screenshot_png.cpp +++ b/src/screenshot_png.cpp @@ -77,8 +77,8 @@ public: png_text_struct text[2]; memset(text, 0, sizeof(text)); text[0].key = const_cast("Software"); - text[0].text = const_cast(_openttd_revision); - text[0].text_length = strlen(_openttd_revision); + text[0].text = const_cast(_openttd_revision.c_str()); + text[0].text_length = _openttd_revision.size(); text[0].compression = PNG_TEXT_COMPRESSION_NONE; std::string message; diff --git a/src/social_integration.cpp b/src/social_integration.cpp index 4222a8d669..887335c22b 100644 --- a/src/social_integration.cpp +++ b/src/social_integration.cpp @@ -28,7 +28,7 @@ class InternalSocialIntegrationPlugin { public: InternalSocialIntegrationPlugin(const std::string &filename, const std::string &basepath) : library(nullptr), external(basepath) { - openttd_info.openttd_version = _openttd_revision; + openttd_info.openttd_version = _openttd_revision.c_str(); if (!ValidateSignatureFile(fmt::format("{}.sig", filename))) { external.state = SocialIntegrationPlugin::INVALID_SIGNATURE;