From a84c5fa371a2638e4214f27714deb609ab70bd47 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Wed, 23 Aug 2023 22:46:42 +0300 Subject: [PATCH] Fix battle replaying --- server/battles/BattleProcessor.cpp | 1 + server/battles/BattleResultProcessor.cpp | 6 ++++++ server/battles/BattleResultProcessor.h | 1 + 3 files changed, 8 insertions(+) diff --git a/server/battles/BattleProcessor.cpp b/server/battles/BattleProcessor.cpp index 5d7be25ec..50f2a31b2 100644 --- a/server/battles/BattleProcessor.cpp +++ b/server/battles/BattleProcessor.cpp @@ -67,6 +67,7 @@ void BattleProcessor::startBattlePrimary(const CArmedInstance *army1, const CArm heroes[0] = hero1; heroes[1] = hero2; + resultProcessor->setupBattle(); setupBattle(tile, armies, heroes, creatureBank, town); //initializes stacks, places creatures on battlefield, blocks and informs player interfaces auto lastBattleQuery = std::dynamic_pointer_cast(gameHandler->queries->topQuery(gameHandler->gameState()->curB->sides[0].color)); diff --git a/server/battles/BattleResultProcessor.cpp b/server/battles/BattleResultProcessor.cpp index 6e23d3103..e6616fa38 100644 --- a/server/battles/BattleResultProcessor.cpp +++ b/server/battles/BattleResultProcessor.cpp @@ -539,6 +539,12 @@ void BattleResultProcessor::setBattleResult(EBattleResult resultType, int victor gameHandler->gameState()->curB->calculateCasualties(battleResult->casualties); } +void BattleResultProcessor::setupBattle() +{ + finishingBattle.reset(); + battleResult.reset(); +} + bool BattleResultProcessor::battleIsEnding() const { return battleResult != nullptr; diff --git a/server/battles/BattleResultProcessor.h b/server/battles/BattleResultProcessor.h index e758cadfe..9c85638ae 100644 --- a/server/battles/BattleResultProcessor.h +++ b/server/battles/BattleResultProcessor.h @@ -73,6 +73,7 @@ public: bool battleIsEnding() const; + void setupBattle(); void setBattleResult(EBattleResult resultType, int victoriusSide); void endBattle(int3 tile, const CGHeroInstance * hero1, const CGHeroInstance * hero2); //ends battle void endBattleConfirm(const BattleInfo * battleInfo);