Skip to content

Commit bea2868

Browse files
authored
Merge pull request #164 from cortex-command-community/supported-version-crash
Fix embarrassing SupportedGameVersion crash
2 parents 85a3937 + 879ab5e commit bea2868

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Source/System/DataModule.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -492,26 +492,30 @@ bool DataModule::AddToTypeMap(Entity* entityToAdd) {
492492
}
493493

494494
void DataModule::CheckSupportedGameVersion() const {
495+
static const std::string contactAuthor = "Please contact the mod author or ask for help in the CCCP discord server.";
496+
497+
RTEAssert(m_SupportedGameVersion, 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);
498+
499+
if (!m_SupportedGameVersion) {
500+
return;
501+
}
502+
495503
if (*m_SupportedGameVersion == c_GameVersion) {
496504
return;
497505
}
498506

499-
static const std::string contactAuthor = "Please contact the mod author or ask for help in the CCCP discord server.";
500-
501-
RTEAssert(m_SupportedGameVersion, 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);
502-
503507
bool modulePrereleaseVersionMismatch = !m_SupportedGameVersion->prerelease().empty();
504508
bool moduleBuildVersionMismatch = !m_SupportedGameVersion->build().empty();
505-
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);
509+
RTEAssert(!modulePrereleaseVersionMismatch && !moduleBuildVersionMismatch, m_FileName + " was developed for pre-release build of Cortex Command v" + m_SupportedGameVersion->str() + ", so this game version (v" + c_GameVersion.str() + ") may not support it.\n\n" + contactAuthor);
506510

507511
bool gamePrereleaseVersionMismatch = !c_GameVersion.prerelease().empty();
508512
bool gameBuildVersionMismatch = !c_GameVersion.build().empty();
509-
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);
513+
RTEAssert(!gamePrereleaseVersionMismatch && !gameBuildVersionMismatch, m_FileName + " was developed for Cortex Command v" + m_SupportedGameVersion->str() + ", so this pre-release version of the game (v" + c_GameVersion.str() + ") may not support it.\n\n" + contactAuthor);
510514

511515
// Game engine is the same major version as the Module
512516
bool majorVersionMatch = c_GameVersion.major() == m_SupportedGameVersion->major();
513517
// Game engine is at least the minor version the Module requires (allow patch mismatch)
514518
bool minorVersionInRange = m_SupportedGameVersion->inc_minor() <= c_GameVersion.inc_minor();
515519

516-
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);
520+
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\n" + contactAuthor);
517521
}

0 commit comments

Comments
 (0)