Pass battle pointer along with clone for battleside.
continuous-integration/drone/push Build is passing Details

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
Deukhoofd 2021-04-13 22:45:48 +02:00
parent 8baa647940
commit 8a9a6af0af
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
3 changed files with 5 additions and 4 deletions

View File

@ -178,7 +178,7 @@ Battle* Battle::Clone() const {
auto* battle = new Battle(_library, parties, _canFlee, _numberOfSides, _creaturesPerSide); auto* battle = new Battle(_library, parties, _canFlee, _numberOfSides, _creaturesPerSide);
for (int i = 0; i < _numberOfSides; ++i) { 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 // 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. // new battle. This needs to be cleaned up, as it's ugly and slow.
for (int creatureIndex = 0; creatureIndex < _creaturesPerSide; ++creatureIndex) { for (int creatureIndex = 0; creatureIndex < _creaturesPerSide; ++creatureIndex) {

View File

@ -123,8 +123,9 @@ bool BattleSide::SwapPositions(u8 a, u8 b) {
_battle->TriggerEventListener<SwapEvent>(_index, a, b); _battle->TriggerEventListener<SwapEvent>(_index, a, b);
return true; return true;
} }
BattleSide* BattleSide::CloneWithoutCreatures() const {
auto* side = new BattleSide(_index, _battle, _creaturesPerSide); BattleSide *BattleSide::CloneWithoutCreatures(ArbUt::BorrowedPtr<Battle> battle) const {
auto *side = new BattleSide(_index, battle, _creaturesPerSide);
side->_choicesSet = _choicesSet; side->_choicesSet = _choicesSet;
_volatile.Clone(side->_volatile); _volatile.Clone(side->_volatile);
side->_hasFled = _hasFled; side->_hasFled = _hasFled;

View File

@ -88,7 +88,7 @@ namespace CreatureLib::Battling {
bool SwapPositions(u8 a, u8 b); bool SwapPositions(u8 a, u8 b);
BattleSide* CloneWithoutCreatures() const; BattleSide *CloneWithoutCreatures(ArbUt::BorrowedPtr<Battle> battle) const;
}; };
} }