mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-11 11:31:52 +02:00
3095 - fix campaign transition
This commit is contained in:
parent
b310f2e61e
commit
4a1e676399
@ -1079,7 +1079,7 @@ CGameState::CrossoverHeroesList CGameState::getCrossoverHeroesFromPreviousScenar
|
||||
|
||||
auto campaignState = scenarioOps->campState;
|
||||
auto bonus = campaignState->getBonusForCurrentMap();
|
||||
if (bonus && bonus->type == CScenarioTravel::STravelBonus::HEROES_FROM_PREVIOUS_SCENARIO)
|
||||
if(bonus && bonus->type == CScenarioTravel::STravelBonus::HEROES_FROM_PREVIOUS_SCENARIO)
|
||||
{
|
||||
std::vector<CGHeroInstance *> heroes;
|
||||
for(auto & node : campaignState->camp->scenarios[bonus->info2].crossoverHeroes)
|
||||
@ -1093,12 +1093,8 @@ CGameState::CrossoverHeroesList CGameState::getCrossoverHeroesFromPreviousScenar
|
||||
{
|
||||
if(!campaignState->mapsConquered.empty())
|
||||
{
|
||||
std::vector<CGHeroInstance *> heroes;
|
||||
for(auto & node : campaignState->camp->scenarios[campaignState->mapsConquered.back()].crossoverHeroes)
|
||||
{
|
||||
auto h = CCampaignState::crossoverDeserialize(node);
|
||||
heroes.push_back(h);
|
||||
}
|
||||
std::vector<CGHeroInstance *> heroes = {};
|
||||
|
||||
crossoverHeroes.heroesFromAnyPreviousScenarios = crossoverHeroes.heroesFromPreviousScenario = heroes;
|
||||
crossoverHeroes.heroesFromPreviousScenario = heroes;
|
||||
|
||||
@ -1111,7 +1107,7 @@ CGameState::CrossoverHeroesList CGameState::getCrossoverHeroesFromPreviousScenar
|
||||
// remove heroes which didn't reached the end of the scenario, but were available at the start
|
||||
for(auto hero : lostCrossoverHeroes)
|
||||
{
|
||||
// auto hero = CCampaignState::crossoverDeserialize(node);
|
||||
// auto hero = CCampaignState::crossoverDeserialize(node);
|
||||
vstd::erase_if(crossoverHeroes.heroesFromAnyPreviousScenarios, [hero](CGHeroInstance * h)
|
||||
{
|
||||
return hero->subID == h->subID;
|
||||
@ -1123,11 +1119,12 @@ CGameState::CrossoverHeroesList CGameState::getCrossoverHeroesFromPreviousScenar
|
||||
{
|
||||
auto hero = CCampaignState::crossoverDeserialize(node);
|
||||
// add new heroes and replace old heroes with newer ones
|
||||
auto it = range::find_if(crossoverHeroes.heroesFromAnyPreviousScenarios, [hero](CGHeroInstance * h)
|
||||
auto it = range::find_if(crossoverHeroes.heroesFromAnyPreviousScenarios, [hero](CGHeroInstance * h)
|
||||
{
|
||||
return hero->subID == h->subID;
|
||||
});
|
||||
if (it != crossoverHeroes.heroesFromAnyPreviousScenarios.end())
|
||||
|
||||
if(it != crossoverHeroes.heroesFromAnyPreviousScenarios.end())
|
||||
{
|
||||
// replace old hero with newer one
|
||||
crossoverHeroes.heroesFromAnyPreviousScenarios[it - crossoverHeroes.heroesFromAnyPreviousScenarios.begin()] = hero;
|
||||
@ -1137,6 +1134,11 @@ CGameState::CrossoverHeroesList CGameState::getCrossoverHeroesFromPreviousScenar
|
||||
// add new hero
|
||||
crossoverHeroes.heroesFromAnyPreviousScenarios.push_back(hero);
|
||||
}
|
||||
|
||||
if(mapNr == campaignState->mapsConquered.back())
|
||||
{
|
||||
crossoverHeroes.heroesFromPreviousScenario.push_back(hero);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user