mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-01 00:45:26 +02:00
Fixed mod dependencies check on save loading to prevent crashes:
- mods that don't affect game objects can be ignored when loading save - gameplay-affecting mods that were present in save must be active - gameplay-affecting mods that were not in save must not be active
This commit is contained in:
@ -649,6 +649,48 @@ void CModInfo::updateChecksum(ui32 newChecksum)
|
||||
}
|
||||
}
|
||||
|
||||
bool CModInfo::checkModGameplayAffecting() const
|
||||
{
|
||||
if (modGameplayAffecting.has_value())
|
||||
return *modGameplayAffecting;
|
||||
|
||||
static const std::vector<std::string> keysToTest = {
|
||||
"heroClasses",
|
||||
"artifacts",
|
||||
"creatures",
|
||||
"factions",
|
||||
"objects",
|
||||
"heroes",
|
||||
"spells",
|
||||
"skills",
|
||||
"templates",
|
||||
"scripts",
|
||||
"battlefields",
|
||||
"terrains",
|
||||
"rivers",
|
||||
"roads",
|
||||
"obstacles"
|
||||
};
|
||||
|
||||
ResourceID modFileResource(CModInfo::getModFile(identifier));
|
||||
|
||||
if(CResourceHandler::get("initial")->existsResource(modFileResource))
|
||||
{
|
||||
const JsonNode modConfig(modFileResource);
|
||||
|
||||
for (auto const & key : keysToTest)
|
||||
{
|
||||
if (!modConfig[key].isNull())
|
||||
{
|
||||
modGameplayAffecting = true;
|
||||
return *modGameplayAffecting;
|
||||
}
|
||||
}
|
||||
}
|
||||
modGameplayAffecting = false;
|
||||
return *modGameplayAffecting;
|
||||
}
|
||||
|
||||
void CModInfo::loadLocalData(const JsonNode & data)
|
||||
{
|
||||
bool validated = false;
|
||||
|
Reference in New Issue
Block a user