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