Browse Source

Couple fixes

nordsoft 2 years ago
parent
commit
cb02e221f3
2 changed files with 15 additions and 4 deletions
  1. 10 4
      mapeditor/mapcontroller.cpp
  2. 5 0
      mapeditor/windownewmap.cpp

+ 10 - 4
mapeditor/mapcontroller.cpp

@@ -105,7 +105,9 @@ void MapController::repairMap()
 	}
 	
 	//fix owners for objects
-	for(auto obj : _map->objects)
+	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
 		if(obj->ID != Obj::HERO && obj->ID != Obj::PRISON && (obj->typeName.empty() || obj->subTypeName.empty()))
@@ -154,12 +156,16 @@ void MapController::repairMap()
 			if(nih->spellbookContainsSpell(SpellID::PRESET))
 			{
 				nih->removeSpellFromSpellbook(SpellID::PRESET);
-			}
-			else
-			{
 				for(auto spellID : type->spells)
 					nih->addSpellToSpellbook(spellID);
 			}
+			if(nih->spellbookContainsSpell(SpellID::SPELLBOOK_PRESET))
+			{
+				nih->removeSpellFromSpellbook(SpellID::SPELLBOOK_PRESET);
+				if(!nih->getArt(ArtifactPosition::SPELLBOOK) && type->haveSpellBook)
+					nih->putArtifact(ArtifactPosition::SPELLBOOK, ArtifactUtils::createNewArtifactInstance(ArtifactID::SPELLBOOK));
+			}
+			
 			//fix portrait
 			if(nih->portrait < 0 || nih->portrait == 255)
 				nih->portrait = type->imageIndex;

+ 5 - 0
mapeditor/windownewmap.cpp

@@ -90,6 +90,11 @@ void WindowNewMap::loadUserSettings()
 	{
 		ui->heightTxt->setText(height.toString());
 	}
+	for(auto & sz : mapSizes)
+	{
+		if(sz.second.first == width.toInt() && sz.second.second == height.toInt())
+			ui->sizeCombo->setCurrentIndex(sz.first);
+	}
 	auto twoLevel = s.value(newMapTwoLevel);
 	if (twoLevel.isValid())
 	{