1
0
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:
Laserlicht 2024-01-27 01:57:28 +01:00 committed by GitHub
parent 7f58333ef9
commit e48e8e0f01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View File

@ -64,6 +64,8 @@ void BattleProcessor::restartBattlePrimary(const BattleID & battleID, const CArm
auto battle = gameHandler->gameState()->getBattle(battleID); auto battle = gameHandler->gameState()->getBattle(battleID);
auto lastBattleQuery = std::dynamic_pointer_cast<CBattleQuery>(gameHandler->queries->topQuery(battle->sides[0].color)); 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); 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)); 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) if (lastBattleQuery)
{ {
@ -184,6 +188,8 @@ BattleID BattleProcessor::setupBattle(int3 tile, const CArmedInstance *armies[2]
engageIntoBattle(bs.info->sides[1].color); engageIntoBattle(bs.info->sides[1].color);
auto lastBattleQuery = std::dynamic_pointer_cast<CBattleQuery>(gameHandler->queries->topQuery(bs.info->sides[0].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 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(); bool isAttackerHuman = gameHandler->getPlayerState(bs.info->sides[0].color)->isHuman();

View File

@ -257,6 +257,8 @@ void BattleResultProcessor::endBattle(const CBattleInfoCallback & battle)
battleResult->exp[1] = heroDefender->calculateXp(battleResult->exp[1]); battleResult->exp[1] = heroDefender->calculateXp(battleResult->exp[1]);
auto battleQuery = std::dynamic_pointer_cast<CBattleQuery>(gameHandler->queries->topQuery(battle.sideToPlayer(0))); 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) if (!battleQuery)
{ {
logGlobal->error("Cannot find battle query!"); logGlobal->error("Cannot find battle query!");
@ -306,6 +308,8 @@ void BattleResultProcessor::endBattle(const CBattleInfoCallback & battle)
void BattleResultProcessor::endBattleConfirm(const CBattleInfoCallback & battle) void BattleResultProcessor::endBattleConfirm(const CBattleInfoCallback & battle)
{ {
auto battleQuery = std::dynamic_pointer_cast<CBattleQuery>(gameHandler->queries->topQuery(battle.sideToPlayer(0))); 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) if(!battleQuery)
{ {
logGlobal->trace("No battle query, battle end was confirmed by another player"); logGlobal->trace("No battle query, battle end was confirmed by another player");