1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-02 00:10:22 +02:00

Fix initialization of hero type in map editor

This commit is contained in:
Ivan Savenko 2024-10-11 15:01:43 +00:00
parent 115439f16a
commit e221cdccab
2 changed files with 17 additions and 1 deletions

View File

@ -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

View File

@ -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;