Merge pull request #5476 from IvanSavenko/hotfix

[1.6.7] Fixes for reported issues
This commit is contained in:
Ivan Savenko
2025-02-25 19:38:16 +02:00
committed by GitHub
5 changed files with 58 additions and 26 deletions
+30 -23
View File
@@ -961,31 +961,38 @@ void SelectionTab::parseCampaigns(const std::unordered_set<ResourcePath> & files
allItems.reserve(files.size()); allItems.reserve(files.size());
for(auto & file : files) for(auto & file : files)
{ {
auto info = std::make_shared<ElementInfo>(); try
info->fileURI = file.getOriginalName();
info->campaignInit();
info->name = info->getNameForList();
if(info->campaign)
{ {
// skip campaigns organized in sets auto info = std::make_shared<ElementInfo>();
std::string foundInSet = ""; info->fileURI = file.getOriginalName();
for (auto const & set : campaignSets.Struct()) info->campaignInit();
for (auto const & item : set.second["items"].Vector()) info->name = info->getNameForList();
if(file.getName() == ResourcePath(item["file"].String()).getName())
foundInSet = set.first;
// set has to be used in main menu
bool setInMainmenu = false;
if(!foundInSet.empty())
for (auto const & item : mainmenu["window"]["items"].Vector())
if(item["name"].String() == "campaign")
for (auto const & button : item["buttons"].Vector())
if(boost::algorithm::ends_with(boost::algorithm::to_lower_copy(button["command"].String()), boost::algorithm::to_lower_copy(foundInSet)))
setInMainmenu = true;
if(!setInMainmenu) if(info->campaign)
allItems.push_back(info); {
// skip campaigns organized in sets
std::string foundInSet = "";
for (auto const & set : campaignSets.Struct())
for (auto const & item : set.second["items"].Vector())
if(file.getName() == ResourcePath(item["file"].String()).getName())
foundInSet = set.first;
// set has to be used in main menu
bool setInMainmenu = false;
if(!foundInSet.empty())
for (auto const & item : mainmenu["window"]["items"].Vector())
if(item["name"].String() == "campaign")
for (auto const & button : item["buttons"].Vector())
if(boost::algorithm::ends_with(boost::algorithm::to_lower_copy(button["command"].String()), boost::algorithm::to_lower_copy(foundInSet)))
setInMainmenu = true;
if(!setInMainmenu)
allItems.push_back(info);
}
}
catch(const std::exception & e)
{
logGlobal->error("Error: Failed to process campaign %s: %s", file.getName(), e.what());
} }
} }
} }
+2 -1
View File
@@ -442,7 +442,8 @@ void CShowableAnim::blitImage(size_t frame, size_t group, Canvas & to)
if(img) if(img)
{ {
img->setAlpha(alpha); img->setAlpha(alpha);
img->setOverlayColor(Colors::TRANSPARENCY); if (getModeForFlags(flags) == EImageBlitMode::WITH_SHADOW_AND_SELECTION)
img->setOverlayColor(Colors::TRANSPARENCY);
to.draw(img, pos.topLeft(), src); to.draw(img, pos.topLeft(), src);
} }
} }
+11
View File
@@ -224,7 +224,18 @@ bool ZipArchive::extract(const boost::filesystem::path & where, const std::strin
std::fstream destFile(fullName.c_str(), std::ios::out | std::ios::binary); std::fstream destFile(fullName.c_str(), std::ios::out | std::ios::binary);
if (!destFile.good()) if (!destFile.good())
{
#ifdef VCMI_WINDOWS
if (fullName.size() < 260)
logGlobal->error("Failed to open file '%s'", fullName.c_str());
else
logGlobal->error("Failed to open file with long path '%s' (%d characters)", fullName.c_str(), fullName.size());
#else
logGlobal->error("Failed to open file '%s'", fullName.c_str());
#endif
return false; return false;
}
if (!extractCurrent(archive, destFile)) if (!extractCurrent(archive, destFile))
return false; return false;
@@ -177,7 +177,12 @@ void CObjectClassesHandler::loadSubObject(const std::string & scope, const std::
registerObject(scope, baseObject->getJsonKey(), subObject->getSubTypeName(), subObject->subtype); registerObject(scope, baseObject->getJsonKey(), subObject->getSubTypeName(), subObject->subtype);
for(const auto & compatID : entry["compatibilityIdentifiers"].Vector()) for(const auto & compatID : entry["compatibilityIdentifiers"].Vector())
registerObject(scope, baseObject->getJsonKey(), compatID.String(), subObject->subtype); {
if (identifier != compatID.String())
registerObject(scope, baseObject->getJsonKey(), compatID.String(), subObject->subtype);
else
logMod->warn("Mod '%s' map object '%s': compatibility identifier has same name as object itself!");
}
} }
void CObjectClassesHandler::loadSubObject(const std::string & scope, const std::string & identifier, const JsonNode & entry, ObjectClass * baseObject, size_t index) void CObjectClassesHandler::loadSubObject(const std::string & scope, const std::string & identifier, const JsonNode & entry, ObjectClass * baseObject, size_t index)
@@ -192,7 +197,12 @@ void CObjectClassesHandler::loadSubObject(const std::string & scope, const std::
registerObject(scope, baseObject->getJsonKey(), subObject->getSubTypeName(), subObject->subtype); registerObject(scope, baseObject->getJsonKey(), subObject->getSubTypeName(), subObject->subtype);
for(const auto & compatID : entry["compatibilityIdentifiers"].Vector()) for(const auto & compatID : entry["compatibilityIdentifiers"].Vector())
registerObject(scope, baseObject->getJsonKey(), compatID.String(), subObject->subtype); {
if (identifier != compatID.String())
registerObject(scope, baseObject->getJsonKey(), compatID.String(), subObject->subtype);
else
logMod->warn("Mod '%s' map object '%s': compatibility identifier has same name as object itself!");
}
} }
TObjectTypeHandler CObjectClassesHandler::loadSubObjectFromJson(const std::string & scope, const std::string & identifier, const JsonNode & entry, ObjectClass * baseObject, size_t index) TObjectTypeHandler CObjectClassesHandler::loadSubObjectFromJson(const std::string & scope, const std::string & identifier, const JsonNode & entry, ObjectClass * baseObject, size_t index)
+3
View File
@@ -763,6 +763,9 @@ void ModDependenciesResolver::tryAddMods(TModList modsToResolve, const ModsStora
if (mod.isTranslation() && CGeneralTextHandler::getPreferredLanguage() != mod.getBaseLanguage()) if (mod.isTranslation() && CGeneralTextHandler::getPreferredLanguage() != mod.getBaseLanguage())
return false; return false;
if(!mod.isCompatible())
return false;
if(mod.getDependencies().size() > resolvedModIDs.size()) if(mod.getDependencies().size() > resolvedModIDs.size())
return false; return false;