|
@@ -23,6 +23,14 @@
|
|
|
#include "../../lib/networkPacks/PacksForServer.h"
|
|
|
#include "../../lib/serializer/Cast.h"
|
|
|
|
|
|
+void CBattleQuery::notifyObjectAboutRemoval(const CObjectVisitQuery & objectVisit) const
|
|
|
+{
|
|
|
+ assert(result);
|
|
|
+
|
|
|
+ if(result && !isAiVsHuman)
|
|
|
+ objectVisit.visitedObject->battleFinished(objectVisit.visitingHero, *result);
|
|
|
+}
|
|
|
+
|
|
|
CBattleQuery::CBattleQuery(CGameHandler * owner, const IBattleInfo * bi):
|
|
|
CQuery(owner),
|
|
|
battleID(bi->getBattleID())
|
|
@@ -30,6 +38,8 @@ 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));
|
|
|
}
|
|
@@ -100,10 +110,11 @@ void CBattleDialogQuery::onRemoval(PlayerColor color)
|
|
|
{
|
|
|
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)
|
|
|
+
|
|
|
+ if(visitingObj && result && isAiVsHuman)
|
|
|
visitingObj->battleFinished(hero, *result);
|
|
|
}
|
|
|
}
|