mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-14 02:33:51 +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();
|
initPlayerStates();
|
||||||
if (campaign)
|
if (campaign)
|
||||||
campaign->placeCampaignHeroes();
|
campaign->placeCampaignHeroes();
|
||||||
|
removeHeroPlaceholders();
|
||||||
initGrailPosition();
|
initGrailPosition();
|
||||||
initRandomFactionsForPlayers();
|
initRandomFactionsForPlayers();
|
||||||
randomizeMapObjects();
|
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()
|
void CGameState::initStartingResources()
|
||||||
{
|
{
|
||||||
logGlobal->debug("\tSetting up resources");
|
logGlobal->debug("\tSetting up resources");
|
||||||
|
@ -220,6 +220,7 @@ private:
|
|||||||
void initPlayerStates();
|
void initPlayerStates();
|
||||||
void placeStartingHeroes();
|
void placeStartingHeroes();
|
||||||
void placeStartingHero(const PlayerColor & playerColor, const HeroTypeID & heroTypeId, int3 townPos);
|
void placeStartingHero(const PlayerColor & playerColor, const HeroTypeID & heroTypeId, int3 townPos);
|
||||||
|
void removeHeroPlaceholders();
|
||||||
void initStartingResources();
|
void initStartingResources();
|
||||||
void initHeroes();
|
void initHeroes();
|
||||||
void placeHeroesInTowns();
|
void placeHeroesInTowns();
|
||||||
|
@ -333,19 +333,6 @@ void CGameStateCampaign::placeCampaignHeroes()
|
|||||||
gameState->map->getEditManager()->insertObject(hero);
|
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)
|
void CGameStateCampaign::giveCampaignBonusToHero(CGHeroInstance * hero)
|
||||||
|
Loading…
Reference in New Issue
Block a user