mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Convertion finished
This commit is contained in:
parent
4e5580f3d9
commit
9c5725da66
@ -1265,8 +1265,11 @@ void MainWindow::on_actionh3m_converter_triggered()
|
||||
for(auto & m : mapFiles)
|
||||
{
|
||||
CMapService mapService;
|
||||
mapService.saveMap(openMapInternal(m), (saveDirectory + QFileInfo(m).fileName()).toStdString());
|
||||
auto map = openMapInternal(m);
|
||||
controller.repairMap(map.get());
|
||||
mapService.saveMap(map, (saveDirectory + '/' + QFileInfo(m).completeBaseName() + ".vmap").toStdString());
|
||||
}
|
||||
QMessageBox::information(this, tr("Operation completed"), tr("Successfully converted %1 maps").arg(mapFiles.size()));
|
||||
}
|
||||
catch(const std::exception & e)
|
||||
{
|
||||
|
@ -86,27 +86,35 @@ MinimapScene * MapController::miniScene(int level)
|
||||
|
||||
void MapController::repairMap()
|
||||
{
|
||||
repairMap(map());
|
||||
}
|
||||
|
||||
void MapController::repairMap(CMap * map) const
|
||||
{
|
||||
if(!map)
|
||||
return;
|
||||
|
||||
//there might be extra skills, arts and spells not imported from map
|
||||
if(VLC->skillh->getDefaultAllowed().size() > map()->allowedAbilities.size())
|
||||
if(VLC->skillh->getDefaultAllowed().size() > map->allowedAbilities.size())
|
||||
{
|
||||
map()->allowedAbilities.resize(VLC->skillh->getDefaultAllowed().size());
|
||||
map->allowedAbilities.resize(VLC->skillh->getDefaultAllowed().size());
|
||||
}
|
||||
if(VLC->arth->getDefaultAllowed().size() > map()->allowedArtifact.size())
|
||||
if(VLC->arth->getDefaultAllowed().size() > map->allowedArtifact.size())
|
||||
{
|
||||
map()->allowedArtifact.resize(VLC->arth->getDefaultAllowed().size());
|
||||
map->allowedArtifact.resize(VLC->arth->getDefaultAllowed().size());
|
||||
}
|
||||
if(VLC->spellh->getDefaultAllowed().size() > map()->allowedSpells.size())
|
||||
if(VLC->spellh->getDefaultAllowed().size() > map->allowedSpells.size())
|
||||
{
|
||||
map()->allowedSpells.resize(VLC->spellh->getDefaultAllowed().size());
|
||||
map->allowedSpells.resize(VLC->spellh->getDefaultAllowed().size());
|
||||
}
|
||||
if(VLC->heroh->getDefaultAllowed().size() > map()->allowedHeroes.size())
|
||||
if(VLC->heroh->getDefaultAllowed().size() > map->allowedHeroes.size())
|
||||
{
|
||||
map()->allowedHeroes.resize(VLC->heroh->getDefaultAllowed().size());
|
||||
map->allowedHeroes.resize(VLC->heroh->getDefaultAllowed().size());
|
||||
}
|
||||
|
||||
//fix owners for objects
|
||||
auto allImpactedObjects(_map->objects);
|
||||
allImpactedObjects.insert(allImpactedObjects.end(), _map->predefinedHeroes.begin(), _map->predefinedHeroes.end());
|
||||
auto allImpactedObjects(map->objects);
|
||||
allImpactedObjects.insert(allImpactedObjects.end(), map->predefinedHeroes.begin(), map->predefinedHeroes.end());
|
||||
for(auto obj : allImpactedObjects)
|
||||
{
|
||||
//setup proper names (hero name will be fixed later
|
||||
@ -131,7 +139,7 @@ void MapController::repairMap()
|
||||
//fix hero instance
|
||||
if(auto * nih = dynamic_cast<CGHeroInstance*>(obj.get()))
|
||||
{
|
||||
map()->allowedHeroes.at(nih->subID) = true;
|
||||
map->allowedHeroes.at(nih->subID) = true;
|
||||
auto type = VLC->heroh->objects[nih->subID];
|
||||
assert(type->heroClass);
|
||||
//TODO: find a way to get proper type name
|
||||
@ -202,7 +210,7 @@ void MapController::repairMap()
|
||||
art->storedArtifact = a;
|
||||
}
|
||||
else
|
||||
map()->allowedArtifact.at(art->subID) = true;
|
||||
map->allowedArtifact.at(art->subID) = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,8 +30,9 @@ public:
|
||||
~MapController();
|
||||
|
||||
void setMap(std::unique_ptr<CMap>);
|
||||
void initObstaclePainters(CMap* map);
|
||||
void initObstaclePainters(CMap * map);
|
||||
|
||||
void repairMap(CMap * map) const;
|
||||
void repairMap();
|
||||
|
||||
const std::unique_ptr<CMap> & getMapUniquePtr() const; //to be used for map saving
|
||||
|
Loading…
Reference in New Issue
Block a user