Skip to content

Commit f756f5e

Browse files
committed
Pull version check into private method
1 parent 0ce6e50 commit f756f5e

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

System/DataModule.cpp

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,7 @@ namespace RTE {
5454
// If the module is a mod, read only its `index.ini` to validate its SupportedGameVersion.
5555
if (m_ModuleID >= g_PresetMan.GetOfficialModuleCount() && !m_IsUserdata && ReadModuleProperties(moduleName, progressCallback) >= 0) {
5656
if (progressCallback) { progressCallback(m_FileName + " " + static_cast<char>(-43) + " reading index:", true); }
57-
if (m_SupportedGameVersion != c_GameVersion) {
58-
59-
RTEAssert(m_SupportedGameVersion != version::Semver200_version(), m_FileName + " does not specify a supported Cortex Command version, so it is not compatible with this version of Cortex Command (" + c_GameVersion.str() + ").\n\nPlease contact the mod author or ask for help in the CCCP discord server.");
60-
61-
bool modulePrereleaseVersionMismatch = !m_SupportedGameVersion.prerelease().empty();
62-
bool moduleBuildVersionMismatch = !m_SupportedGameVersion.build().empty();
63-
RTEAssert(!modulePrereleaseVersionMismatch && !moduleBuildVersionMismatch, m_FileName + " was developed for prerelease build of Cortex Command v" + m_SupportedGameVersion.str() + ", this game version (v" + c_GameVersion.str() + ") is incompatible.\n\nMods developed on a prerelease must match the game version exactly.\nPlease contact the mod author or ask for help in the CCCP discord server.");
64-
65-
bool gamePrereleaseVersionMismatch = !c_GameVersion.prerelease().empty();
66-
bool gameBuildVersionMismatch = !c_GameVersion.build().empty();
67-
RTEAssert(!gamePrereleaseVersionMismatch && !gameBuildVersionMismatch, m_FileName + " was developed for Cortex Command v" + m_SupportedGameVersion.str() + ", this prerelease version of the game (v" + c_GameVersion.str() + ") may not support it.\n\nMods must match the game version exactly to use prerelease builds.\nPlease contact the mod author or ask for help in the CCCP discord server.");
68-
69-
70-
// Game engine is the same major version as the Module
71-
bool majorVersionMatch = c_GameVersion.major() == m_SupportedGameVersion.major();
72-
// Game engine is at least the minor version the Module requires (allow patch mismatch)
73-
bool minorVersionInRange = m_SupportedGameVersion.inc_minor() <= c_GameVersion.inc_minor();
74-
75-
RTEAssert(majorVersionMatch && minorVersionInRange, m_FileName + " was developed for Cortex Command v" + m_SupportedGameVersion.str() + ", so this version of Cortex Command (v" + c_GameVersion.str() + ") may not support it.\nPlease contact the mod author or ask for help in the CCCP discord server.");
76-
}
57+
CheckSupportedGameVersion();
7758
}
7859

7960
if (reader.Create(indexPath, true, progressCallback) >= 0) {
@@ -505,4 +486,29 @@ namespace RTE {
505486
}
506487
return true;
507488
}
489+
490+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
491+
492+
void DataModule::CheckSupportedGameVersion() const {
493+
if (m_SupportedGameVersion != c_GameVersion) {
494+
static const std::string contactAuthor = "Please contact the mod author or ask for help in the CCCP discord server.";
495+
496+
RTEAssert(m_SupportedGameVersion != version::Semver200_version(), m_FileName + " does not specify a supported Cortex Command version, so it is not compatible with this version of Cortex Command (" + c_GameVersion.str() + ").\n\n" + contactAuthor);
497+
498+
bool modulePrereleaseVersionMismatch = !m_SupportedGameVersion.prerelease().empty();
499+
bool moduleBuildVersionMismatch = !m_SupportedGameVersion.build().empty();
500+
RTEAssert(!modulePrereleaseVersionMismatch && !moduleBuildVersionMismatch, m_FileName + " was developed for pre-release build of Cortex Command v" + m_SupportedGameVersion.str() + ", this game version (v" + c_GameVersion.str() + ") is incompatible.\n\nMods developed on a pre-release must match the game version exactly.\n" + contactAuthor);
501+
502+
bool gamePrereleaseVersionMismatch = !c_GameVersion.prerelease().empty();
503+
bool gameBuildVersionMismatch = !c_GameVersion.build().empty();
504+
RTEAssert(!gamePrereleaseVersionMismatch && !gameBuildVersionMismatch, m_FileName + " was developed for Cortex Command v" + m_SupportedGameVersion.str() + ", this pre-release version of the game (v" + c_GameVersion.str() + ") may not support it.\n\nMods must match the game version exactly to use pre-release builds.\n" + contactAuthor);
505+
506+
// Game engine is the same major version as the Module
507+
bool majorVersionMatch = c_GameVersion.major() == m_SupportedGameVersion.major();
508+
// Game engine is at least the minor version the Module requires (allow patch mismatch)
509+
bool minorVersionInRange = m_SupportedGameVersion.inc_minor() <= c_GameVersion.inc_minor();
510+
511+
RTEAssert(majorVersionMatch && minorVersionInRange, m_FileName + " was developed for Cortex Command v" + m_SupportedGameVersion.str() + ", so this version of Cortex Command (v" + c_GameVersion.str() + ") may not support it.\n" + contactAuthor);
512+
}
513+
}
508514
}

System/DataModule.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,11 @@ namespace RTE {
356356
static const std::string c_ClassName; //!< A string with the friendly-formatted type name of this object.
357357

358358
#pragma region INI Handling
359+
/// <summary>
360+
/// Checks the module's supported game version against the current game version to ensure compatibility.
361+
/// </summary>
362+
void CheckSupportedGameVersion() const;
363+
359364
/// <summary>
360365
/// If ScanFolderContents is enabled in this DataModule's Index.ini, looks for any ini files in the top-level directory of the module and reads all of them in alphabetical order.
361366
/// </summary>

0 commit comments

Comments
 (0)