Procházet zdrojové kódy

Fix initialization of hero type in map editor

Ivan Savenko před 1 rokem
rodič
revize
e221cdccab

+ 5 - 1
lib/mapObjects/CGHeroInstance.cpp

@@ -309,7 +309,11 @@ const CHeroClass * CGHeroInstance::getHeroClass() const
 
 HeroClassID CGHeroInstance::getHeroClassID() const
 {
-	return getHeroType()->heroClass->getId();
+	auto heroType = getHeroTypeID();
+	if (heroType.hasValue())
+		return getHeroType()->heroClass->getId();
+	else
+		return HeroClassID();
 }
 
 const CHero * CGHeroInstance::getHeroType() const

+ 12 - 0
mapeditor/inspector/inspector.cpp

@@ -139,6 +139,18 @@ void Initializer::initialize(CGHeroInstance * o)
 		o->tempOwner = PlayerColor::NEUTRAL;
 	}
 
+	if(o->ID == Obj::HERO)
+	{
+		for(auto const & t : VLC->heroh->objects)
+		{
+			if(t->heroClass->getId() == HeroClassID(o->subID))
+			{
+				o->subID = t->getId();
+				break;
+			}
+		}
+	}
+
 	if(o->getHeroTypeID().hasValue())
 	{
 		o->gender = o->getHeroType()->gender;