mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
Always use ResourcePath for referencing images and animations
This commit is contained in:
@@ -30,9 +30,9 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
static JsonNode loadModSettings(const std::string & path)
|
||||
{
|
||||
if (CResourceHandler::get("local")->existsResource(ResourceID(path)))
|
||||
if (CResourceHandler::get("local")->existsResource(ResourcePath(path)))
|
||||
{
|
||||
return JsonNode(ResourceID(path, EResType::TEXT));
|
||||
return JsonNode(ResourcePath(path, EResType::TEXT));
|
||||
}
|
||||
// Probably new install. Create initial configuration
|
||||
CResourceHandler::get("local")->createResource(path);
|
||||
@@ -157,7 +157,7 @@ std::vector<std::string> CModHandler::getModList(const std::string & path) const
|
||||
std::string modDir = boost::to_upper_copy(path + "MODS/");
|
||||
size_t depth = boost::range::count(modDir, '/');
|
||||
|
||||
auto list = CResourceHandler::get("initial")->getFilteredFiles([&](const ResourceID & id) -> bool
|
||||
auto list = CResourceHandler::get("initial")->getFilteredFiles([&](const ResourcePath & id) -> bool
|
||||
{
|
||||
if (id.getType() != EResType::DIRECTORY)
|
||||
return false;
|
||||
@@ -200,9 +200,9 @@ void CModHandler::loadOneMod(std::string modName, const std::string & parent, co
|
||||
return;
|
||||
}
|
||||
|
||||
if(CResourceHandler::get("initial")->existsResource(ResourceID(CModInfo::getModFile(modFullName))))
|
||||
if(CResourceHandler::get("initial")->existsResource(ResourcePath(CModInfo::getModFile(modFullName))))
|
||||
{
|
||||
CModInfo mod(modFullName, modSettings[modName], JsonNode(ResourceID(CModInfo::getModFile(modFullName))));
|
||||
CModInfo mod(modFullName, modSettings[modName], JsonNode(ResourcePath(CModInfo::getModFile(modFullName))));
|
||||
if (!parent.empty()) // this is submod, add parent to dependencies
|
||||
mod.dependencies.insert(parent);
|
||||
|
||||
@@ -228,7 +228,7 @@ void CModHandler::loadMods(bool onlyEssential)
|
||||
loadMods("", "", modConfig["activeMods"], true);
|
||||
}
|
||||
|
||||
coreMod = std::make_unique<CModInfo>(ModScope::scopeBuiltin(), modConfig[ModScope::scopeBuiltin()], JsonNode(ResourceID("config/gameConfig.json")));
|
||||
coreMod = std::make_unique<CModInfo>(ModScope::scopeBuiltin(), modConfig[ModScope::scopeBuiltin()], JsonNode(ResourcePath("config/gameConfig.json")));
|
||||
coreMod->name = "Original game files";
|
||||
}
|
||||
|
||||
@@ -283,19 +283,19 @@ static ui32 calculateModChecksum(const std::string & modName, ISimpleResourceLoa
|
||||
// FIXME: remove workaround for core mod
|
||||
if (modName != ModScope::scopeBuiltin())
|
||||
{
|
||||
ResourceID modConfFile(CModInfo::getModFile(modName), EResType::TEXT);
|
||||
ResourcePath modConfFile(CModInfo::getModFile(modName), EResType::TEXT);
|
||||
ui32 configChecksum = CResourceHandler::get("initial")->load(modConfFile)->calculateCRC32();
|
||||
modChecksum.process_bytes(reinterpret_cast<const void *>(&configChecksum), sizeof(configChecksum));
|
||||
}
|
||||
// third - add all detected text files from this mod into checksum
|
||||
auto files = filesystem->getFilteredFiles([](const ResourceID & resID)
|
||||
auto files = filesystem->getFilteredFiles([](const ResourcePath & resID)
|
||||
{
|
||||
return resID.getType() == EResType::TEXT &&
|
||||
( boost::starts_with(resID.getName(), "DATA") ||
|
||||
boost::starts_with(resID.getName(), "CONFIG"));
|
||||
});
|
||||
|
||||
for (const ResourceID & file : files)
|
||||
for (const ResourcePath & file : files)
|
||||
{
|
||||
ui32 fileChecksum = filesystem->load(file)->calculateCRC32();
|
||||
modChecksum.process_bytes(reinterpret_cast<const void *>(&fileChecksum), sizeof(fileChecksum));
|
||||
@@ -318,7 +318,7 @@ void CModHandler::loadModFilesystems()
|
||||
}
|
||||
}
|
||||
|
||||
TModID CModHandler::findResourceOrigin(const ResourceID & name)
|
||||
TModID CModHandler::findResourceOrigin(const ResourcePath & name)
|
||||
{
|
||||
for(const auto & modID : boost::adaptors::reverse(activeMods))
|
||||
{
|
||||
@@ -483,7 +483,7 @@ void CModHandler::afterLoad(bool onlyEssential)
|
||||
|
||||
if(!onlyEssential)
|
||||
{
|
||||
std::fstream file(CResourceHandler::get()->getResourceName(ResourceID("config/modSettings.json"))->c_str(), std::ofstream::out | std::ofstream::trunc);
|
||||
std::fstream file(CResourceHandler::get()->getResourceName(ResourcePath("config/modSettings.json"))->c_str(), std::ofstream::out | std::ofstream::trunc);
|
||||
file << modSettings.toJson();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user