diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp index 326995bd39..f32707d993 100644 --- a/Source/Android/jni/MainAndroid.cpp +++ b/Source/Android/jni/MainAndroid.cpp @@ -299,13 +299,13 @@ JNIEXPORT double JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetInputRa JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv* env, jclass) { - return ToJString(env, Common::scm_rev_str); + return ToJString(env, Common::GetScmRevStr()); } JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetGitRevision(JNIEnv* env, jclass) { - return ToJString(env, Common::scm_rev_git_str); + return ToJString(env, Common::GetScmRevGitStr()); } JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveScreenShot(JNIEnv*, jclass) diff --git a/Source/Core/Common/LinearDiskCache.h b/Source/Core/Common/LinearDiskCache.h index 5f9f7589d4..78982109b9 100644 --- a/Source/Core/Common/LinearDiskCache.h +++ b/Source/Core/Common/LinearDiskCache.h @@ -149,8 +149,8 @@ private: { // Null-terminator is intentionally not copied. std::memcpy(&id, "DCAC", sizeof(u32)); - std::memcpy(ver, Common::scm_rev_git_str.c_str(), - std::min(Common::scm_rev_git_str.size(), sizeof(ver))); + std::memcpy(ver, Common::GetScmRevGitStr().c_str(), + std::min(Common::GetScmRevGitStr().size(), sizeof(ver))); } u32 id = 0; diff --git a/Source/Core/Common/Version.cpp b/Source/Core/Common/Version.cpp index f6479c2158..7801aaae30 100644 --- a/Source/Core/Common/Version.cpp +++ b/Source/Core/Common/Version.cpp @@ -17,28 +17,61 @@ namespace Common #define BUILD_TYPE_STR "" #endif -const std::string scm_rev_str = "Dolphin " +const std::string& GetScmRevStr() +{ + static const std::string scm_rev_str = "Dolphin " #if !SCM_IS_MASTER - "[" SCM_BRANCH_STR "] " + "[" SCM_BRANCH_STR "] " #endif #ifdef __INTEL_COMPILER - BUILD_TYPE_STR SCM_DESC_STR "-ICC"; + BUILD_TYPE_STR SCM_DESC_STR "-ICC"; #else - BUILD_TYPE_STR SCM_DESC_STR; + BUILD_TYPE_STR SCM_DESC_STR; #endif + return scm_rev_str; +} -const std::string scm_rev_git_str = SCM_REV_STR; -const std::string scm_desc_str = SCM_DESC_STR; -const std::string scm_branch_str = SCM_BRANCH_STR; -const std::string scm_distributor_str = SCM_DISTRIBUTOR_STR; -const std::string scm_update_track_str = SCM_UPDATE_TRACK_STR; +const std::string& GetScmRevGitStr() +{ + static const std::string scm_rev_git_str = SCM_REV_STR; + return scm_rev_git_str; +} +const std::string& GetScmDescStr() +{ + static const std::string scm_desc_str = SCM_DESC_STR; + return scm_desc_str; +} + +const std::string& GetScmBranchStr() +{ + static const std::string scm_branch_str = SCM_BRANCH_STR; + return scm_branch_str; +} + +const std::string& GetScmDistributorStr() +{ + static const std::string scm_distributor_str = SCM_DISTRIBUTOR_STR; + return scm_distributor_str; +} + +const std::string& GetScmUpdateTrackStr() +{ + static const std::string scm_update_track_str = SCM_UPDATE_TRACK_STR; + return scm_update_track_str; +} + +const std::string& GetNetplayDolphinVer() +{ #ifdef _WIN32 -const std::string netplay_dolphin_ver = SCM_DESC_STR " Win"; + static const std::string netplay_dolphin_ver = SCM_DESC_STR " Win"; #elif __APPLE__ -const std::string netplay_dolphin_ver = SCM_DESC_STR " Mac"; + static const std::string netplay_dolphin_ver = SCM_DESC_STR " Mac"; #else -const std::string netplay_dolphin_ver = SCM_DESC_STR " Lin"; + static const std::string netplay_dolphin_ver = SCM_DESC_STR " Lin"; #endif + return netplay_dolphin_ver; +} + } // namespace Common diff --git a/Source/Core/Common/Version.h b/Source/Core/Common/Version.h index 7ca97af108..7aee07f84e 100644 --- a/Source/Core/Common/Version.h +++ b/Source/Core/Common/Version.h @@ -7,12 +7,11 @@ namespace Common { -// Git version number -extern const std::string scm_desc_str; -extern const std::string scm_branch_str; -extern const std::string scm_rev_str; -extern const std::string scm_rev_git_str; -extern const std::string scm_distributor_str; -extern const std::string scm_update_track_str; -extern const std::string netplay_dolphin_ver; +const std::string& GetScmDescStr(); +const std::string& GetScmBranchStr(); +const std::string& GetScmRevStr(); +const std::string& GetScmRevGitStr(); +const std::string& GetScmDistributorStr(); +const std::string& GetScmUpdateTrackStr(); +const std::string& GetNetplayDolphinVer(); } // namespace Common diff --git a/Source/Core/Core/Config/MainSettings.cpp b/Source/Core/Core/Config/MainSettings.cpp index 5ccd5bdfc7..e2b73ce846 100644 --- a/Source/Core/Core/Config/MainSettings.cpp +++ b/Source/Core/Core/Config/MainSettings.cpp @@ -381,7 +381,7 @@ const Info MAIN_FIFOPLAYER_EARLY_MEMORY_UPDATES{ // Main.AutoUpdate const Info MAIN_AUTOUPDATE_UPDATE_TRACK{{System::Main, "AutoUpdate", "UpdateTrack"}, - Common::scm_update_track_str}; + Common::GetScmUpdateTrackStr()}; const Info MAIN_AUTOUPDATE_HASH_OVERRIDE{{System::Main, "AutoUpdate", "HashOverride"}, ""}; diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 1687c9900f..a945d72276 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -982,7 +982,7 @@ void UpdateTitle(u32 ElapseTime) } } - std::string message = fmt::format("{} | {} | {}", Common::scm_rev_str, SSettings, SFPS); + std::string message = fmt::format("{} | {} | {}", Common::GetScmRevStr(), SSettings, SFPS); if (Config::Get(Config::MAIN_SHOW_ACTIVE_TITLE)) { const std::string& title = SConfig::GetInstance().GetTitleDescription(); diff --git a/Source/Core/Core/DolphinAnalytics.cpp b/Source/Core/Core/DolphinAnalytics.cpp index d03ee0f0f3..d55a5fba5e 100644 --- a/Source/Core/Core/DolphinAnalytics.cpp +++ b/Source/Core/Core/DolphinAnalytics.cpp @@ -248,10 +248,10 @@ void DolphinAnalytics::MakeBaseBuilder() Common::AnalyticsReportBuilder builder; // Version information. - builder.AddData("version-desc", Common::scm_desc_str); - builder.AddData("version-hash", Common::scm_rev_git_str); - builder.AddData("version-branch", Common::scm_branch_str); - builder.AddData("version-dist", Common::scm_distributor_str); + builder.AddData("version-desc", Common::GetScmDescStr()); + builder.AddData("version-hash", Common::GetScmRevGitStr()); + builder.AddData("version-branch", Common::GetScmBranchStr()); + builder.AddData("version-dist", Common::GetScmDistributorStr()); // Auto-Update information. builder.AddData("update-track", Config::Get(Config::MAIN_AUTOUPDATE_UPDATE_TRACK)); diff --git a/Source/Core/Core/IOS/DolphinDevice.cpp b/Source/Core/Core/IOS/DolphinDevice.cpp index 3c533f9ab0..db399c97a9 100644 --- a/Source/Core/Core/IOS/DolphinDevice.cpp +++ b/Source/Core/Core/IOS/DolphinDevice.cpp @@ -58,10 +58,10 @@ IPCReply GetVersion(const IOCtlVRequest& request) return IPCReply(IPC_EINVAL); } - const auto length = std::min(size_t(request.io_vectors[0].size), Common::scm_desc_str.size()); + const auto length = std::min(size_t(request.io_vectors[0].size), Common::GetScmDescStr().size()); Memory::Memset(request.io_vectors[0].address, 0, request.io_vectors[0].size); - Memory::CopyToEmu(request.io_vectors[0].address, Common::scm_desc_str.data(), length); + Memory::CopyToEmu(request.io_vectors[0].address, Common::GetScmDescStr().data(), length); return IPCReply(IPC_SUCCESS); } diff --git a/Source/Core/Core/Movie.cpp b/Source/Core/Core/Movie.cpp index 4f73226e60..78f36941c9 100644 --- a/Source/Core/Core/Movie.cpp +++ b/Source/Core/Core/Movie.cpp @@ -1471,7 +1471,7 @@ void GetSettings() s_memcards |= (slot_a_has_raw_memcard || slot_a_has_gci_folder) << 0; s_memcards |= (slot_b_has_raw_memcard || slot_b_has_gci_folder) << 1; - s_revision = ConvertGitRevisionToBytes(Common::scm_rev_git_str); + s_revision = ConvertGitRevisionToBytes(Common::GetScmRevGitStr()); if (!Config::Get(Config::MAIN_DSP_HLE)) { diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index 5497db41ac..dc2a56efdc 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -229,8 +229,8 @@ bool NetPlayClient::Connect() { // send connect message sf::Packet packet; - packet << Common::scm_rev_git_str; - packet << Common::netplay_dolphin_ver; + packet << Common::GetScmRevGitStr(); + packet << Common::GetNetplayDolphinVer(); packet << m_player_name; Send(packet); enet_host_flush(m_client); @@ -283,7 +283,7 @@ bool NetPlayClient::Connect() Player player; player.name = m_player_name; player.pid = m_pid; - player.revision = Common::netplay_dolphin_ver; + player.revision = Common::GetNetplayDolphinVer(); // add self to player list m_players[m_pid] = player; diff --git a/Source/Core/Core/NetPlayServer.cpp b/Source/Core/Core/NetPlayServer.cpp index be79d45739..6b00929373 100644 --- a/Source/Core/Core/NetPlayServer.cpp +++ b/Source/Core/Core/NetPlayServer.cpp @@ -393,7 +393,7 @@ ConnectionError NetPlayServer::OnConnect(ENetPeer* socket, sf::Packet& rpac) std::string npver; rpac >> npver; // Dolphin netplay version - if (npver != Common::scm_rev_git_str) + if (npver != Common::GetScmRevGitStr()) return ConnectionError::VersionMismatch; // game is currently running or game start is pending diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp index 86877ecb50..f89c1fc79e 100644 --- a/Source/Core/Core/State.cpp +++ b/Source/Core/Core/State.cpp @@ -116,7 +116,7 @@ static bool DoStateVersion(PointerWrap& p, std::string* version_created_by) version = cookie - COOKIE_BASE; } - *version_created_by = Common::scm_rev_str; + *version_created_by = Common::GetScmRevStr(); if (version > 42) p.Do(*version_created_by); else diff --git a/Source/Core/DiscIO/VolumeVerifier.cpp b/Source/Core/DiscIO/VolumeVerifier.cpp index 0a17864290..252cf427b6 100644 --- a/Source/Core/DiscIO/VolumeVerifier.cpp +++ b/Source/Core/DiscIO/VolumeVerifier.cpp @@ -125,7 +125,7 @@ RedumpVerifier::DownloadStatus RedumpVerifier::DownloadDatfile(const std::string const std::optional> result = request.Get("http://redump.org/datfile/" + system + "/serial,version", - {{"User-Agent", Common::scm_rev_str}}); + {{"User-Agent", Common::GetScmRevStr()}}); const std::string output_path = GetPathForSystem(system); diff --git a/Source/Core/DolphinQt/AboutDialog.cpp b/Source/Core/DolphinQt/AboutDialog.cpp index b5ee68a07c..e1dce12766 100644 --- a/Source/Core/DolphinQt/AboutDialog.cpp +++ b/Source/Core/DolphinQt/AboutDialog.cpp @@ -47,12 +47,12 @@ AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent) %SUPPORT% )") .replace(QStringLiteral("%VERSION_STRING%"), - QString::fromUtf8(Common::scm_desc_str.c_str())) + QString::fromUtf8(Common::GetScmDescStr().c_str())) .replace(QStringLiteral("%BRANCH%"), // i18n: "Branch" means the version control term, not a literal tree branch. - tr("Branch: %1").arg(QString::fromUtf8(Common::scm_branch_str.c_str()))) + tr("Branch: %1").arg(QString::fromUtf8(Common::GetScmBranchStr().c_str()))) .replace(QStringLiteral("%REVISION%"), - tr("Revision: %1").arg(QString::fromUtf8(Common::scm_rev_git_str.c_str()))) + tr("Revision: %1").arg(QString::fromUtf8(Common::GetScmRevGitStr().c_str()))) .replace(QStringLiteral("%QT_VERSION%"), tr("Using Qt %1").arg(QStringLiteral(QT_VERSION_STR))) .replace(QStringLiteral("%CHECK_FOR_UPDATES%"), tr("Check for updates")) diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 4585209ba3..7fc42cc44a 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -206,7 +206,7 @@ MainWindow::MainWindow(std::unique_ptr boot_parameters, const std::string& movie_path) : QMainWindow(nullptr) { - setWindowTitle(QString::fromStdString(Common::scm_rev_str)); + setWindowTitle(QString::fromStdString(Common::GetScmRevStr())); setWindowIcon(Resources::GetAppIcon()); setUnifiedTitleAndToolBarOnMac(true); setAcceptDrops(true); @@ -1145,7 +1145,7 @@ void MainWindow::HideRenderWidget(bool reinit, bool is_exit) m_rendering_to_main = false; m_stack->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); disconnect(Host::GetInstance(), &Host::RequestTitle, this, &MainWindow::setWindowTitle); - setWindowTitle(QString::fromStdString(Common::scm_rev_str)); + setWindowTitle(QString::fromStdString(Common::GetScmRevStr())); } // The following code works around a driver bug that would lead to Dolphin crashing when changing diff --git a/Source/Core/DolphinQt/NetPlay/NetPlayBrowser.cpp b/Source/Core/DolphinQt/NetPlay/NetPlayBrowser.cpp index d87f61c67c..348f6de047 100644 --- a/Source/Core/DolphinQt/NetPlay/NetPlayBrowser.cpp +++ b/Source/Core/DolphinQt/NetPlay/NetPlayBrowser.cpp @@ -158,7 +158,7 @@ void NetPlayBrowser::Refresh() std::map filters; if (m_check_hide_incompatible->isChecked()) - filters["version"] = Common::scm_desc_str; + filters["version"] = Common::GetScmDescStr(); if (!m_edit_name->text().isEmpty()) filters["name"] = m_edit_name->text().toStdString(); @@ -246,7 +246,7 @@ void NetPlayBrowser::UpdateList() auto* player_count = new QTableWidgetItem(QStringLiteral("%1").arg(entry.player_count)); auto* version = new QTableWidgetItem(QString::fromStdString(entry.version)); - const bool enabled = Common::scm_desc_str == entry.version; + const bool enabled = Common::GetScmDescStr() == entry.version; for (const auto& item : {region, name, password, in_game, game_id, player_count, version}) item->setFlags(enabled ? Qt::ItemIsEnabled | Qt::ItemIsSelectable : Qt::NoItemFlags); diff --git a/Source/Core/DolphinQt/Updater.cpp b/Source/Core/DolphinQt/Updater.cpp index 9388175a65..256a8f59c1 100644 --- a/Source/Core/DolphinQt/Updater.cpp +++ b/Source/Core/DolphinQt/Updater.cpp @@ -55,7 +55,7 @@ void Updater::OnUpdateAvailable(const NewVersionInformation& info) "download. " "You are running %2.
Would you like to update?

Release Notes:

") .arg(QString::fromStdString(info.new_shortrev)) - .arg(QString::fromStdString(Common::scm_desc_str))); + .arg(QString::fromStdString(Common::GetScmDescStr()))); label->setTextFormat(Qt::RichText); auto* changelog = new QTextBrowser; diff --git a/Source/Core/UICommon/AutoUpdate.cpp b/Source/Core/UICommon/AutoUpdate.cpp index ce316758b0..e423b9ec86 100644 --- a/Source/Core/UICommon/AutoUpdate.cpp +++ b/Source/Core/UICommon/AutoUpdate.cpp @@ -161,7 +161,7 @@ void AutoUpdateChecker::CheckForUpdate(std::string_view update_track, CleanupFromPreviousUpdate(); #endif - std::string_view version_hash = hash_override.empty() ? Common::scm_rev_git_str : hash_override; + std::string_view version_hash = hash_override.empty() ? Common::GetScmRevGitStr() : hash_override; std::string url = fmt::format("https://dolphin-emu.org/update/check/v1/{}/{}/{}", update_track, version_hash, GetPlatformID()); diff --git a/Source/Core/UICommon/CommandLineParse.cpp b/Source/Core/UICommon/CommandLineParse.cpp index 7ac1bafe36..54093f219a 100644 --- a/Source/Core/UICommon/CommandLineParse.cpp +++ b/Source/Core/UICommon/CommandLineParse.cpp @@ -78,7 +78,7 @@ private: std::unique_ptr CreateParser(ParserOptions options) { auto parser = std::make_unique(); - parser->usage("usage: %prog [options]... [FILE]...").version(Common::scm_rev_str); + parser->usage("usage: %prog [options]... [FILE]...").version(Common::GetScmRevStr()); parser->add_option("-u", "--user").action("store").help("User folder path"); parser->add_option("-m", "--movie").action("store").help("Play a movie file"); diff --git a/Source/Core/UICommon/NetPlayIndex.cpp b/Source/Core/UICommon/NetPlayIndex.cpp index 925f209052..aaaa4549a8 100644 --- a/Source/Core/UICommon/NetPlayIndex.cpp +++ b/Source/Core/UICommon/NetPlayIndex.cpp @@ -170,7 +170,7 @@ bool NetPlayIndex::Add(const NetPlaySession& session) "&password=" + std::to_string(session.has_password) + "&method=" + session.method + "&server_id=" + session.server_id + "&in_game=" + std::to_string(session.in_game) + "&port=" + std::to_string(session.port) + "&player_count=" + - std::to_string(session.player_count) + "&version=" + Common::scm_desc_str, + std::to_string(session.player_count) + "&version=" + Common::GetScmDescStr(), {{"X-Is-Dolphin", "1"}}, Common::HttpRequest::AllowedReturnCodes::All); if (!response.has_value()) diff --git a/Source/Core/VideoBackends/D3DCommon/Shader.cpp b/Source/Core/VideoBackends/D3DCommon/Shader.cpp index c05d3d65bc..0d7c84b8e0 100644 --- a/Source/Core/VideoBackends/D3DCommon/Shader.cpp +++ b/Source/Core/VideoBackends/D3DCommon/Shader.cpp @@ -115,7 +115,7 @@ std::optional Shader::CompileShader(D3D_FEATURE_LEVEL featur file << "\n"; file.write(static_cast(errors->GetBufferPointer()), errors->GetBufferSize()); file << "\n"; - file << "Dolphin Version: " + Common::scm_rev_str + "\n"; + file << "Dolphin Version: " + Common::GetScmRevStr() + "\n"; file << "Video Backend: " + g_video_backend->GetDisplayName(); file.close(); diff --git a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp index 83761271d4..659882d015 100644 --- a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp +++ b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp @@ -363,7 +363,7 @@ bool ProgramShaderCache::CheckShaderCompileResult(GLuint id, GLenum type, std::s File::OpenFStream(file, filename, std::ios_base::out); file << s_glsl_header << code << info_log; file << "\n"; - file << "Dolphin Version: " + Common::scm_rev_str + "\n"; + file << "Dolphin Version: " + Common::GetScmRevStr() + "\n"; file << "Video Backend: " + g_video_backend->GetDisplayName(); file.close(); @@ -408,7 +408,7 @@ bool ProgramShaderCache::CheckProgramLinkResult(GLuint id, std::string_view vcod file << info_log; file << "\n"; - file << "Dolphin Version: " + Common::scm_rev_str + "\n"; + file << "Dolphin Version: " + Common::GetScmRevStr() + "\n"; file << "Video Backend: " + g_video_backend->GetDisplayName(); file.close(); diff --git a/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp b/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp index ec38d58009..7da5f827d4 100644 --- a/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp +++ b/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp @@ -169,7 +169,7 @@ static std::optional CompileShaderToSPV(EShLanguage stage, } stream << "\n"; - stream << "Dolphin Version: " + Common::scm_rev_str + "\n"; + stream << "Dolphin Version: " + Common::GetScmRevStr() + "\n"; stream << "Video Backend: " + g_video_backend->GetDisplayName(); PanicAlertFmt("{} (written to {})", msg, filename);