mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
fix if attacked
This commit is contained in:
parent
7f58333ef9
commit
e48e8e0f01
@ -64,6 +64,8 @@ void BattleProcessor::restartBattlePrimary(const BattleID & battleID, const CArm
|
||||
auto battle = gameHandler->gameState()->getBattle(battleID);
|
||||
|
||||
auto lastBattleQuery = std::dynamic_pointer_cast<CBattleQuery>(gameHandler->queries->topQuery(battle->sides[0].color));
|
||||
if(!lastBattleQuery)
|
||||
lastBattleQuery = std::dynamic_pointer_cast<CBattleQuery>(gameHandler->queries->topQuery(battle->sides[1].color));
|
||||
|
||||
assert(lastBattleQuery);
|
||||
|
||||
@ -131,6 +133,8 @@ void BattleProcessor::startBattlePrimary(const CArmedInstance *army1, const CArm
|
||||
}
|
||||
|
||||
auto lastBattleQuery = std::dynamic_pointer_cast<CBattleQuery>(gameHandler->queries->topQuery(battle->sides[0].color));
|
||||
if(!lastBattleQuery)
|
||||
lastBattleQuery = std::dynamic_pointer_cast<CBattleQuery>(gameHandler->queries->topQuery(battle->sides[1].color));
|
||||
|
||||
if (lastBattleQuery)
|
||||
{
|
||||
@ -184,6 +188,8 @@ BattleID BattleProcessor::setupBattle(int3 tile, const CArmedInstance *armies[2]
|
||||
engageIntoBattle(bs.info->sides[1].color);
|
||||
|
||||
auto lastBattleQuery = std::dynamic_pointer_cast<CBattleQuery>(gameHandler->queries->topQuery(bs.info->sides[0].color));
|
||||
if(!lastBattleQuery)
|
||||
lastBattleQuery = std::dynamic_pointer_cast<CBattleQuery>(gameHandler->queries->topQuery(bs.info->sides[1].color));
|
||||
bool isDefenderHuman = bs.info->sides[1].color.isValidPlayer() && gameHandler->getPlayerState(bs.info->sides[1].color)->isHuman();
|
||||
bool isAttackerHuman = gameHandler->getPlayerState(bs.info->sides[0].color)->isHuman();
|
||||
|
||||
|
@ -257,6 +257,8 @@ void BattleResultProcessor::endBattle(const CBattleInfoCallback & battle)
|
||||
battleResult->exp[1] = heroDefender->calculateXp(battleResult->exp[1]);
|
||||
|
||||
auto battleQuery = std::dynamic_pointer_cast<CBattleQuery>(gameHandler->queries->topQuery(battle.sideToPlayer(0)));
|
||||
if(!battleQuery)
|
||||
battleQuery = std::dynamic_pointer_cast<CBattleQuery>(gameHandler->queries->topQuery(battle.sideToPlayer(1)));
|
||||
if (!battleQuery)
|
||||
{
|
||||
logGlobal->error("Cannot find battle query!");
|
||||
@ -306,6 +308,8 @@ void BattleResultProcessor::endBattle(const CBattleInfoCallback & battle)
|
||||
void BattleResultProcessor::endBattleConfirm(const CBattleInfoCallback & battle)
|
||||
{
|
||||
auto battleQuery = std::dynamic_pointer_cast<CBattleQuery>(gameHandler->queries->topQuery(battle.sideToPlayer(0)));
|
||||
if(!battleQuery)
|
||||
battleQuery = std::dynamic_pointer_cast<CBattleQuery>(gameHandler->queries->topQuery(battle.sideToPlayer(1)));
|
||||
if(!battleQuery)
|
||||
{
|
||||
logGlobal->trace("No battle query, battle end was confirmed by another player");
|
||||
|
Loading…
Reference in New Issue
Block a user