mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
Create heroes in pool via handler to properly initialize appearance
This commit is contained in:
@@ -554,6 +554,7 @@ void CGameState::placeStartingHero(const PlayerColor & playerColor, const HeroTy
|
||||
hero = std::dynamic_pointer_cast<CGHeroInstance>(object);
|
||||
hero->ID = Obj::HERO;
|
||||
hero->setHeroType(heroTypeId);
|
||||
assert(hero->appearance != nullptr);
|
||||
}
|
||||
|
||||
hero->tempOwner = playerColor;
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "../networkPacks/ArtifactLocation.h"
|
||||
#include "../spells/CSpellHandler.h"
|
||||
#include "../texts/TextOperations.h"
|
||||
#include "entities/hero/CHeroClass.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
@@ -843,8 +844,9 @@ void CMapLoaderH3M::readPredefinedHeroes()
|
||||
if(!custom)
|
||||
continue;
|
||||
|
||||
auto hero = std::make_shared<CGHeroInstance>(map->cb);
|
||||
hero->ID = Obj::HERO;
|
||||
auto handler = LIBRARY->objtypeh->getHandlerFor(Obj::HERO, HeroTypeID(heroID).toHeroType()->heroClass->getIndex());
|
||||
auto object = handler->create(map->cb, handler->getTemplates().front());
|
||||
auto hero = std::dynamic_pointer_cast<CGHeroInstance>(object);
|
||||
hero->subID = heroID;
|
||||
|
||||
bool hasExp = reader->readBool();
|
||||
|
||||
Reference in New Issue
Block a user