Pārlūkot izejas kodu

Merge pull request #1194 from Nordsoft91/editor-crash

Fix hero-related problems in editor [1.1]
Andrii Danylchenko 2 gadi atpakaļ
vecāks
revīzija
35e8b794cd

+ 1 - 1
lib/mapObjects/CGHeroInstance.cpp

@@ -1434,7 +1434,7 @@ void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler)
 	handler.serializeString("biography", biography);
 	handler.serializeInt("experience", exp, 0);
 
-	if (!handler.saving)
+	if(!handler.saving && exp != 0xffffffff) //do not gain levels if experience is not initialized
 	{
 		while (gainsLevel())
 		{

+ 3 - 0
mapeditor/inspector/inspector.cpp

@@ -555,6 +555,9 @@ void Inspector::setProperty(CGHeroInstance * o, const QString & key, const QVari
 	if(key == "Name")
 		o->name = value.toString().toStdString();
 	
+	if(key == "Experience")
+		o->exp = value.toInt();
+	
 	if(key == "Hero type")
 	{
 		for(auto t : VLC->heroh->objects)

+ 6 - 1
mapeditor/mapcontroller.cpp

@@ -128,10 +128,15 @@ void MapController::repairMap()
 			assert(type->heroClass);
 			//TODO: find a way to get proper type name
 			if(obj->ID == Obj::HERO)
+			{
 				nih->typeName = "hero";
+				nih->subTypeName = type->heroClass->identifier;
+			}
 			if(obj->ID == Obj::PRISON)
+			{
 				nih->typeName = "prison";
-			nih->subTypeName = type->heroClass->identifier;
+				nih->subTypeName = "prison";
+			}
 			
 			nih->type = type;
 			if(nih->name.empty())

+ 5 - 2
mapeditor/scenelayer.cpp

@@ -460,8 +460,11 @@ void SelectionObjectsLayer::selectObjects(int x1, int y1, int x2, int y2)
 	{
 		for(int i = x1; i < x2; ++i)
 		{
-			for(auto & o : handler->getObjects(i, j, scene->level))
-				selectObject(o.obj, false); //do not inform about each object added
+			if(map->isInTheMap(int3(i, j, scene->level)))
+			{
+				for(auto & o : handler->getObjects(i, j, scene->level))
+					selectObject(o.obj, false); //do not inform about each object added
+			}
 		}
 	}
 	onSelection();