|
@@ -602,6 +602,10 @@ void CGameState::initHeroes()
|
|
|
auto hero = getHero(heroID);
|
|
|
assert(map->isInTheMap(hero->visitablePos()));
|
|
|
const auto & tile = map->getTile(hero->visitablePos());
|
|
|
+
|
|
|
+ if (hero->ID == Obj::PRISON)
|
|
|
+ continue;
|
|
|
+
|
|
|
if (tile.isWater())
|
|
|
{
|
|
|
auto handler = LIBRARY->objtypeh->getHandlerFor(Obj::BOAT, hero->getBoatType().getNum());
|
|
@@ -615,12 +619,6 @@ void CGameState::initHeroes()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- for(auto hero : map->getObjects<CGHeroInstance>()) //prisons
|
|
|
- {
|
|
|
- if(hero->ID == Obj::PRISON)
|
|
|
- hero->initHero(getRandomGenerator());
|
|
|
- }
|
|
|
-
|
|
|
std::set<HeroTypeID> heroesToCreate = getUnusedAllowedHeroes(); //ids of heroes to be created and put into the pool
|
|
|
|
|
|
for(const HeroTypeID & htype : heroesToCreate) //all not used allowed heroes go with default state into the pool
|
|
@@ -1562,19 +1560,21 @@ void CGameState::obtainPlayersStats(SThievesGuildInfo & tgi, int level)
|
|
|
void CGameState::buildBonusSystemTree()
|
|
|
{
|
|
|
buildGlobalTeamPlayerTree();
|
|
|
- attachArmedObjects();
|
|
|
+ for(auto & armed : map->getObjects<CArmedInstance>())
|
|
|
+ armed->attachToBonusSystem(this);
|
|
|
|
|
|
- for (const auto & townID : getMap().getAllTowns())
|
|
|
- {
|
|
|
- auto t = getTown(townID);
|
|
|
- t->deserializationFix();
|
|
|
- }
|
|
|
+ for(auto & art : map->getArtifacts())
|
|
|
+ art->attachToBonusSystem(this);
|
|
|
}
|
|
|
|
|
|
-void CGameState::deserializationFix()
|
|
|
+void CGameState::restoreBonusSystemTree()
|
|
|
{
|
|
|
buildGlobalTeamPlayerTree();
|
|
|
- attachArmedObjects();
|
|
|
+ for(auto & armed : map->getObjects<CArmedInstance>())
|
|
|
+ armed->restoreBonusSystem(this);
|
|
|
+
|
|
|
+ for(auto & art : map->getArtifacts())
|
|
|
+ art->attachToBonusSystem(this);
|
|
|
|
|
|
if (campaign)
|
|
|
campaign->setGamestate(this);
|
|
@@ -1596,14 +1596,6 @@ void CGameState::buildGlobalTeamPlayerTree()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void CGameState::attachArmedObjects()
|
|
|
-{
|
|
|
- for(auto & armed : map->getObjects<CArmedInstance>())
|
|
|
- {
|
|
|
- armed->whatShouldBeAttached().attachTo(armed->whereShouldBeAttached(this));
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
bool CGameState::giveHeroArtifact(CGHeroInstance * h, const ArtifactID & aid)
|
|
|
{
|
|
|
CArtifactInstance * ai = createArtifact(aid);
|
|
@@ -1632,12 +1624,6 @@ std::set<HeroTypeID> CGameState::getUnusedAllowedHeroes(bool alsoIncludeNotAllow
|
|
|
for (auto heroID : map->getHeroesOnMap())
|
|
|
ret -= getHero(heroID)->getHeroTypeID();
|
|
|
|
|
|
- for(auto hero : map->getObjects<CGHeroInstance>()) //prisons
|
|
|
- {
|
|
|
- if(hero && hero->ID == Obj::PRISON)
|
|
|
- ret -= hero->getHeroTypeID();
|
|
|
- }
|
|
|
-
|
|
|
return ret;
|
|
|
}
|
|
|
|