mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Fix 1569 winning hero with no troops shall retreat
This commit is contained in:
@@ -712,7 +712,7 @@ void CGameHandler::battleAfterLevelUp( const BattleResult &result )
|
|||||||
|
|
||||||
setBattle(nullptr);
|
setBattle(nullptr);
|
||||||
|
|
||||||
if(visitObjectAfterVictory && result.winner==0)
|
if(visitObjectAfterVictory && result.winner==0 && !finishingBattle->winnerHero->stacks.empty())
|
||||||
{
|
{
|
||||||
logGlobal->traceStream() << "post-victory visit";
|
logGlobal->traceStream() << "post-victory visit";
|
||||||
visitObjectOnTile(*getTile(finishingBattle->winnerHero->getPosition()), finishingBattle->winnerHero);
|
visitObjectOnTile(*getTile(finishingBattle->winnerHero->getPosition()), finishingBattle->winnerHero);
|
||||||
@@ -741,6 +741,24 @@ void CGameHandler::battleAfterLevelUp( const BattleResult &result )
|
|||||||
|
|
||||||
sendAndApply(&sah);
|
sendAndApply(&sah);
|
||||||
}
|
}
|
||||||
|
if(finishingBattle->winnerHero->stacks.empty())
|
||||||
|
{
|
||||||
|
RemoveObject ro(finishingBattle->winnerHero->id);
|
||||||
|
sendAndApply(&ro);
|
||||||
|
|
||||||
|
SetAvailableHeroes sah;
|
||||||
|
sah.player = finishingBattle->victor;
|
||||||
|
sah.hid[0] = finishingBattle->winnerHero->subID;
|
||||||
|
sah.army[0].clear();
|
||||||
|
sah.army[0].setCreature(SlotID(0), finishingBattle->winnerHero->type->initialArmy.at(0).creature, 1);
|
||||||
|
|
||||||
|
if(const CGHeroInstance *another = getPlayer(finishingBattle->victor)->availableHeroes.at(1))
|
||||||
|
sah.hid[1] = another->subID;
|
||||||
|
else
|
||||||
|
sah.hid[1] = -1;
|
||||||
|
|
||||||
|
sendAndApply(&sah);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CStack *def, int distance, int targetHex)
|
void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CStack *def, int distance, int targetHex)
|
||||||
|
|||||||
Reference in New Issue
Block a user