mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Merge pull request #697 from vcmi/fix-campaign-transition
3095 - fix campaign transition
This commit is contained in:
@@ -1079,7 +1079,7 @@ CGameState::CrossoverHeroesList CGameState::getCrossoverHeroesFromPreviousScenar
|
|||||||
|
|
||||||
auto campaignState = scenarioOps->campState;
|
auto campaignState = scenarioOps->campState;
|
||||||
auto bonus = campaignState->getBonusForCurrentMap();
|
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;
|
std::vector<CGHeroInstance *> heroes;
|
||||||
for(auto & node : campaignState->camp->scenarios[bonus->info2].crossoverHeroes)
|
for(auto & node : campaignState->camp->scenarios[bonus->info2].crossoverHeroes)
|
||||||
@@ -1093,12 +1093,8 @@ CGameState::CrossoverHeroesList CGameState::getCrossoverHeroesFromPreviousScenar
|
|||||||
{
|
{
|
||||||
if(!campaignState->mapsConquered.empty())
|
if(!campaignState->mapsConquered.empty())
|
||||||
{
|
{
|
||||||
std::vector<CGHeroInstance *> heroes;
|
std::vector<CGHeroInstance *> heroes = {};
|
||||||
for(auto & node : campaignState->camp->scenarios[campaignState->mapsConquered.back()].crossoverHeroes)
|
|
||||||
{
|
|
||||||
auto h = CCampaignState::crossoverDeserialize(node);
|
|
||||||
heroes.push_back(h);
|
|
||||||
}
|
|
||||||
crossoverHeroes.heroesFromAnyPreviousScenarios = crossoverHeroes.heroesFromPreviousScenario = heroes;
|
crossoverHeroes.heroesFromAnyPreviousScenarios = crossoverHeroes.heroesFromPreviousScenario = heroes;
|
||||||
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
|
// remove heroes which didn't reached the end of the scenario, but were available at the start
|
||||||
for(auto hero : lostCrossoverHeroes)
|
for(auto hero : lostCrossoverHeroes)
|
||||||
{
|
{
|
||||||
// auto hero = CCampaignState::crossoverDeserialize(node);
|
// auto hero = CCampaignState::crossoverDeserialize(node);
|
||||||
vstd::erase_if(crossoverHeroes.heroesFromAnyPreviousScenarios, [hero](CGHeroInstance * h)
|
vstd::erase_if(crossoverHeroes.heroesFromAnyPreviousScenarios, [hero](CGHeroInstance * h)
|
||||||
{
|
{
|
||||||
return hero->subID == h->subID;
|
return hero->subID == h->subID;
|
||||||
@@ -1123,11 +1119,12 @@ CGameState::CrossoverHeroesList CGameState::getCrossoverHeroesFromPreviousScenar
|
|||||||
{
|
{
|
||||||
auto hero = CCampaignState::crossoverDeserialize(node);
|
auto hero = CCampaignState::crossoverDeserialize(node);
|
||||||
// add new heroes and replace old heroes with newer ones
|
// 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;
|
return hero->subID == h->subID;
|
||||||
});
|
});
|
||||||
if (it != crossoverHeroes.heroesFromAnyPreviousScenarios.end())
|
|
||||||
|
if(it != crossoverHeroes.heroesFromAnyPreviousScenarios.end())
|
||||||
{
|
{
|
||||||
// replace old hero with newer one
|
// replace old hero with newer one
|
||||||
crossoverHeroes.heroesFromAnyPreviousScenarios[it - crossoverHeroes.heroesFromAnyPreviousScenarios.begin()] = hero;
|
crossoverHeroes.heroesFromAnyPreviousScenarios[it - crossoverHeroes.heroesFromAnyPreviousScenarios.begin()] = hero;
|
||||||
@@ -1137,6 +1134,11 @@ CGameState::CrossoverHeroesList CGameState::getCrossoverHeroesFromPreviousScenar
|
|||||||
// add new hero
|
// add new hero
|
||||||
crossoverHeroes.heroesFromAnyPreviousScenarios.push_back(hero);
|
crossoverHeroes.heroesFromAnyPreviousScenarios.push_back(hero);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(mapNr == campaignState->mapsConquered.back())
|
||||||
|
{
|
||||||
|
crossoverHeroes.heroesFromPreviousScenario.push_back(hero);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user