1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

After-battle object visitation will now occur after levelups

This commit is contained in:
Ivan Savenko 2024-06-01 10:06:16 +00:00
parent b638b0b679
commit f39aaf2495
2 changed files with 6 additions and 12 deletions

View File

@ -27,7 +27,7 @@ void CBattleQuery::notifyObjectAboutRemoval(const CObjectVisitQuery & objectVisi
{
assert(result);
if(result && !isAiVsHuman)
if(result)
objectVisit.visitedObject->battleFinished(objectVisit.visitingHero, *result);
}
@ -38,8 +38,6 @@ CBattleQuery::CBattleQuery(CGameHandler * owner, const IBattleInfo * bi):
belligerents[0] = bi->getSideArmy(0);
belligerents[1] = bi->getSideArmy(1);
isAiVsHuman = bi->getSidePlayer(1).isValidPlayer() && gh->getPlayerState(bi->getSidePlayer(0))->isHuman() != gh->getPlayerState(bi->getSidePlayer(1))->isHuman();
addPlayer(bi->getSidePlayer(0));
addPlayer(bi->getSidePlayer(1));
}
@ -89,7 +87,9 @@ CBattleDialogQuery::CBattleDialogQuery(CGameHandler * owner, const IBattleInfo *
void CBattleDialogQuery::onRemoval(PlayerColor color)
{
if (!gh->getPlayerState(color)->isHuman())
// answer to this query was already processed when handling 1st player
// this removal call for 2nd player which can be safely ignored
if (resultProcessed)
return;
assert(answer);
@ -108,13 +108,7 @@ void CBattleDialogQuery::onRemoval(PlayerColor color)
}
else
{
auto hero = bi->getSideHero(BattleSide::ATTACKER);
auto visitingObj = bi->getDefendedTown() ? bi->getDefendedTown() : gh->getVisitingObject(hero);
bool isAiVsHuman = bi->getSidePlayer(1).isValidPlayer() && gh->getPlayerState(bi->getSidePlayer(0))->isHuman() != gh->getPlayerState(bi->getSidePlayer(1))->isHuman();
gh->battles->endBattleConfirm(bi->getBattleID());
if(visitingObj && result && isAiVsHuman)
visitingObj->battleFinished(hero, *result);
}
resultProcessed = true;
}

View File

@ -23,7 +23,6 @@ public:
std::array<const CArmedInstance *,2> belligerents;
std::array<int, 2> initialHeroMana;
bool isAiVsHuman;
BattleID battleID;
std::optional<BattleResult> result;
@ -37,6 +36,7 @@ public:
class CBattleDialogQuery : public CDialogQuery
{
bool resultProcessed = false;
public:
CBattleDialogQuery(CGameHandler * owner, const IBattleInfo * Bi, std::optional<BattleResult> Br);