From ec814a6b741d9e4e6335c6af367d8b02127f5fec Mon Sep 17 00:00:00 2001 From: Crash Cringle <30600688+CrashCringle12@users.noreply.github.com> Date: Wed, 26 Feb 2025 03:15:58 -0500 Subject: [PATCH] Add version to Pack.ini, auto populate this value in the Pack.ini if it isn't manually provided --- src/Group.cpp | 21 ++++++++++++++++++++- src/Group.h | 10 ++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/Group.cpp b/src/Group.cpp index e1d3a1c0b9..37291a63d0 100644 --- a/src/Group.cpp +++ b/src/Group.cpp @@ -20,7 +20,8 @@ * with the Waiei Group.ini-lua project still actively * being developed. */ -const RString INI_FILE = "Pack.ini"; +const RString INI_FILE = "Pack.ini"; +const int INI_VERSION = 1; Group::Group() { m_sDisplayTitle = ""; @@ -82,8 +83,26 @@ Group::Group(const RString& sDir, const RString& sGroupDirName) { } } ini.GetValue("Group", "Year", m_iYearReleased); + + RString sVersion = ""; + ini.GetValue("Group", "Version", sVersion); + Trim(sVersion); + if (!sVersion.empty()) { + m_iVersion = StringToInt(sVersion); + } else { + // If the version is not set, set it to the current version + // and write it to the file. + m_iVersion = INI_VERSION; + ini.SetValue("Group", "Version", INI_VERSION); + if( !ini.WriteFile(sPackIniPath)) { + RString sError = ssprintf( "Error writing pack.ini ", sPackIniPath.c_str(), ini.GetError().c_str() ); + Dialog::OK( sError ); + } + } + } else { m_bHasPackIni = false; + m_iVersion = INI_VERSION; fOffset = PREFSMAN->m_fMachineSyncBias; } diff --git a/src/Group.h b/src/Group.h index c7a2ea384f..6bb27c6def 100644 --- a/src/Group.h +++ b/src/Group.h @@ -103,6 +103,13 @@ public: */ int GetYearReleased() const { return m_iYearReleased; }; + + /** + * @brief The version of the Pack.ini info + * + */ + int GetVersion() const { return m_iVersion; }; + private: /** * @brief This is the title of the group as its displayed to the user @@ -136,6 +143,9 @@ public: /** @brief The year the group was released */ int m_iYearReleased; + /** @brief The version of the Pack.ini info */ + int m_iVersion; + }; #endif