1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Fix processing of VCMI_Tests map

This commit is contained in:
Ivan Savenko
2023-03-14 21:48:39 +02:00
parent 06e5d37fbd
commit d2152d387f
2 changed files with 20 additions and 4 deletions

View File

@@ -156,6 +156,7 @@ void ClientCommandManager::processCommand(const std::string &message, bool calle
// }
else if(message=="convert txt")
{
logGlobal->info("Searching for available maps");
std::unordered_set<ResourceID> mapList = CResourceHandler::get()->getFilteredFiles([&](const ResourceID & ident)
{
return ident.getType() == EResType::MAP;
@@ -168,9 +169,21 @@ void ClientCommandManager::processCommand(const std::string &message, bool calle
CMapService mapService;
logGlobal->info("Loading maps for export");
for (auto const & mapName : mapList)
mapService.loadMap(mapName); // load and drop loaded map - we only need loader to run over all maps
{
try
{
// load and drop loaded map - we only need loader to run over all maps
mapService.loadMap(mapName);
}
catch(std::exception & e)
{
logGlobal->error("Map %s is invalid. Message: %s", mapName.getName(), e.what());
}
}
logGlobal->info("Loading campaigns for export");
for (auto const & campaignName : campaignList)
{
CCampaignState state(CCampaignHandler::getCampaign(campaignName.getName()));

View File

@@ -339,11 +339,14 @@ std::set<si32> CObjectClassesHandler::knownObjects() const
std::set<si32> CObjectClassesHandler::knownSubObjects(si32 primaryID) const
{
assert(primaryID < objects.size());
assert(objects[primaryID]);
std::set<si32> ret;
if (!objects.at(primaryID))
{
logGlobal->error("Failed to find object %d", primaryID);
return ret;
}
for(const auto & entry : objects.at(primaryID)->objects)
if (entry)
ret.insert(entry->subtype);