mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-15 13:33:36 +02:00
BattleResultAccepted fixed
This commit is contained in:
parent
060aecc61c
commit
670999d40e
@ -1491,20 +1491,30 @@ struct DLL_LINKAGE BattleSetActiveStack : public CPackForClient
|
|||||||
struct DLL_LINKAGE BattleResultAccepted : public CPackForClient
|
struct DLL_LINKAGE BattleResultAccepted : public CPackForClient
|
||||||
{
|
{
|
||||||
void applyGs(CGameState * gs) const;
|
void applyGs(CGameState * gs) const;
|
||||||
|
|
||||||
CGHeroInstance * hero1 = nullptr;
|
|
||||||
CGHeroInstance * hero2 = nullptr;
|
|
||||||
CArmedInstance * army1 = nullptr;
|
|
||||||
CArmedInstance * army2 = nullptr;
|
|
||||||
TExpType exp[2];
|
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
struct HeroBattleResults
|
||||||
{
|
{
|
||||||
h & hero1;
|
HeroBattleResults()
|
||||||
h & hero2;
|
: hero(nullptr), army(nullptr), exp(0) {}
|
||||||
h & army1;
|
|
||||||
h & army2;
|
CGHeroInstance * hero;
|
||||||
h & exp;
|
CArmedInstance * army;
|
||||||
|
TExpType exp;
|
||||||
|
|
||||||
|
template <typename Handler> void serialize(Handler & h, const int version)
|
||||||
|
{
|
||||||
|
h & hero;
|
||||||
|
h & army;
|
||||||
|
h & exp;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
std::array<HeroBattleResults, 2> heroResult;
|
||||||
|
ui8 winnerSide;
|
||||||
|
|
||||||
|
template <typename Handler> void serialize(Handler & h, const int version)
|
||||||
|
{
|
||||||
|
h & heroResult;
|
||||||
|
h & winnerSide;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2214,36 +2214,32 @@ void BattleUpdateGateState::applyGs(CGameState * gs) const
|
|||||||
|
|
||||||
void BattleResultAccepted::applyGs(CGameState * gs) const
|
void BattleResultAccepted::applyGs(CGameState * gs) const
|
||||||
{
|
{
|
||||||
for(auto * h : {hero1, hero2})
|
// Remove any "until next battle" bonuses
|
||||||
|
for(auto & res : heroResult)
|
||||||
{
|
{
|
||||||
if(h)
|
if(res.hero)
|
||||||
{
|
res.hero->removeBonusesRecursive(Bonus::OneBattle);
|
||||||
h->removeBonusesRecursive(Bonus::OneBattle); //remove any "until next battle" bonuses
|
|
||||||
if (h->commander && h->commander->alive)
|
|
||||||
{
|
|
||||||
for (auto art : h->commander->artifactsWorn) //increment bonuses for commander artifacts
|
|
||||||
{
|
|
||||||
art.second.artifact->growingUp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(auto & art : h->artifactsWorn)
|
|
||||||
{
|
|
||||||
art.second.artifact->growingUp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Grow up growing artifacts
|
||||||
|
if(const auto hero = heroResult[winnerSide].hero)
|
||||||
|
{
|
||||||
|
if(hero->commander && hero->commander->alive)
|
||||||
|
{
|
||||||
|
for(auto & art : hero->commander->artifactsWorn)
|
||||||
|
art.second.artifact->growingUp();
|
||||||
|
}
|
||||||
|
for(auto & art : hero->artifactsWorn)
|
||||||
|
{
|
||||||
|
art.second.artifact->growingUp();
|
||||||
|
}
|
||||||
|
}
|
||||||
if(VLC->settings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE))
|
if(VLC->settings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE))
|
||||||
{
|
{
|
||||||
for(int i = 0; i < 2; i++)
|
if(heroResult[0].army)
|
||||||
{
|
heroResult[0].army->giveStackExp(heroResult[0].exp);
|
||||||
if(exp[i])
|
if(heroResult[1].army)
|
||||||
{
|
heroResult[1].army->giveStackExp(heroResult[1].exp);
|
||||||
if(auto * army = (i == 0 ? army1 : army2))
|
|
||||||
army->giveStackExp(exp[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CBonusSystemNode::treeHasChanged();
|
CBonusSystemNode::treeHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,12 +807,13 @@ void CGameHandler::endBattleConfirm(const BattleInfo * battleInfo)
|
|||||||
changePrimSkill(finishingBattle->winnerHero, PrimarySkill::EXPERIENCE, battleResult.data->exp[finishingBattle->winnerSide]);
|
changePrimSkill(finishingBattle->winnerHero, PrimarySkill::EXPERIENCE, battleResult.data->exp[finishingBattle->winnerSide]);
|
||||||
|
|
||||||
BattleResultAccepted raccepted;
|
BattleResultAccepted raccepted;
|
||||||
raccepted.army1 = const_cast<CArmedInstance*>(bEndArmy1);
|
raccepted.heroResult[0].army = const_cast<CArmedInstance*>(bEndArmy1);
|
||||||
raccepted.army2 = const_cast<CArmedInstance*>(bEndArmy2);
|
raccepted.heroResult[1].army = const_cast<CArmedInstance*>(bEndArmy2);
|
||||||
raccepted.hero1 = const_cast<CGHeroInstance*>(battleInfo->sides.at(0).hero);
|
raccepted.heroResult[0].hero = const_cast<CGHeroInstance*>(battleInfo->sides.at(0).hero);
|
||||||
raccepted.hero2 = const_cast<CGHeroInstance*>(battleInfo->sides.at(1).hero);
|
raccepted.heroResult[1].hero = const_cast<CGHeroInstance*>(battleInfo->sides.at(1).hero);
|
||||||
raccepted.exp[0] = battleResult.data->exp[0];
|
raccepted.heroResult[0].exp = battleResult.data->exp[0];
|
||||||
raccepted.exp[1] = battleResult.data->exp[1];
|
raccepted.heroResult[1].exp = battleResult.data->exp[1];
|
||||||
|
raccepted.winnerSide = finishingBattle->winnerSide;
|
||||||
sendAndApply(&raccepted);
|
sendAndApply(&raccepted);
|
||||||
|
|
||||||
queries.popIfTop(battleQuery);
|
queries.popIfTop(battleQuery);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user