mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
Remove heroes placeholders even in single scenarios
This commit is contained in:
parent
2882e2d248
commit
453d441562
@ -512,6 +512,7 @@ void CGameState::init(const IMapService * mapService, StartInfo * si, bool allow
|
||||
initPlayerStates();
|
||||
if (campaign)
|
||||
campaign->placeCampaignHeroes();
|
||||
removeHeroPlaceholders();
|
||||
initGrailPosition();
|
||||
initRandomFactionsForPlayers();
|
||||
randomizeMapObjects();
|
||||
@ -858,6 +859,22 @@ void CGameState::placeStartingHeroes()
|
||||
}
|
||||
}
|
||||
|
||||
void CGameState::removeHeroPlaceholders()
|
||||
{
|
||||
// remove any hero placeholders that remain on map after (potential) campaign heroes placement
|
||||
for(auto obj : map->objects)
|
||||
{
|
||||
if(obj && obj->ID == Obj::HERO_PLACEHOLDER)
|
||||
{
|
||||
auto heroPlaceholder = dynamic_cast<CGHeroPlaceholder *>(obj.get());
|
||||
map->removeBlockVisTiles(heroPlaceholder, true);
|
||||
map->instanceNames.erase(obj->instanceName);
|
||||
map->objects[heroPlaceholder->id.getNum()] = nullptr;
|
||||
delete heroPlaceholder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGameState::initStartingResources()
|
||||
{
|
||||
logGlobal->debug("\tSetting up resources");
|
||||
|
@ -220,6 +220,7 @@ private:
|
||||
void initPlayerStates();
|
||||
void placeStartingHeroes();
|
||||
void placeStartingHero(const PlayerColor & playerColor, const HeroTypeID & heroTypeId, int3 townPos);
|
||||
void removeHeroPlaceholders();
|
||||
void initStartingResources();
|
||||
void initHeroes();
|
||||
void placeHeroesInTowns();
|
||||
|
@ -333,19 +333,6 @@ void CGameStateCampaign::placeCampaignHeroes()
|
||||
gameState->map->getEditManager()->insertObject(hero);
|
||||
}
|
||||
}
|
||||
|
||||
// remove hero placeholders on map
|
||||
for(auto obj : gameState->map->objects)
|
||||
{
|
||||
if(obj && obj->ID == Obj::HERO_PLACEHOLDER)
|
||||
{
|
||||
auto heroPlaceholder = dynamic_cast<CGHeroPlaceholder *>(obj.get());
|
||||
gameState->map->removeBlockVisTiles(heroPlaceholder, true);
|
||||
gameState->map->instanceNames.erase(obj->instanceName);
|
||||
gameState->map->objects[heroPlaceholder->id.getNum()] = nullptr;
|
||||
delete heroPlaceholder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGameStateCampaign::giveCampaignBonusToHero(CGHeroInstance * hero)
|
||||
|
Loading…
Reference in New Issue
Block a user