From 8a9a6af0af10feab1056def9933b62f6ee237231 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Tue, 13 Apr 2021 22:45:48 +0200 Subject: [PATCH] Pass battle pointer along with clone for battleside. Signed-off-by: Deukhoofd --- src/Battling/Models/Battle.cpp | 2 +- src/Battling/Models/BattleSide.cpp | 5 +++-- src/Battling/Models/BattleSide.hpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Battling/Models/Battle.cpp b/src/Battling/Models/Battle.cpp index ce2d1c3..8074d52 100644 --- a/src/Battling/Models/Battle.cpp +++ b/src/Battling/Models/Battle.cpp @@ -178,7 +178,7 @@ Battle* Battle::Clone() const { auto* battle = new Battle(_library, parties, _canFlee, _numberOfSides, _creaturesPerSide); for (int i = 0; i < _numberOfSides; ++i) { - battle->_sides.Set(i, _sides[i]->CloneWithoutCreatures()); + battle->_sides.Set(i, _sides[i]->CloneWithoutCreatures(battle)); // FIXME: This is horrible code to translate the creature from the old battle into the same creature in the // new battle. This needs to be cleaned up, as it's ugly and slow. for (int creatureIndex = 0; creatureIndex < _creaturesPerSide; ++creatureIndex) { diff --git a/src/Battling/Models/BattleSide.cpp b/src/Battling/Models/BattleSide.cpp index 44b9d41..894712f 100644 --- a/src/Battling/Models/BattleSide.cpp +++ b/src/Battling/Models/BattleSide.cpp @@ -123,8 +123,9 @@ bool BattleSide::SwapPositions(u8 a, u8 b) { _battle->TriggerEventListener(_index, a, b); return true; } -BattleSide* BattleSide::CloneWithoutCreatures() const { - auto* side = new BattleSide(_index, _battle, _creaturesPerSide); + +BattleSide *BattleSide::CloneWithoutCreatures(ArbUt::BorrowedPtr battle) const { + auto *side = new BattleSide(_index, battle, _creaturesPerSide); side->_choicesSet = _choicesSet; _volatile.Clone(side->_volatile); side->_hasFled = _hasFled; diff --git a/src/Battling/Models/BattleSide.hpp b/src/Battling/Models/BattleSide.hpp index 883d26a..164a4a0 100644 --- a/src/Battling/Models/BattleSide.hpp +++ b/src/Battling/Models/BattleSide.hpp @@ -88,7 +88,7 @@ namespace CreatureLib::Battling { bool SwapPositions(u8 a, u8 b); - BattleSide* CloneWithoutCreatures() const; + BattleSide *CloneWithoutCreatures(ArbUt::BorrowedPtr battle) const; }; }