Fixes invalid pointers to a battle dangling when a battle is removed.
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
2020-12-28 13:40:39 +01:00
parent 69476b6f9d
commit a284641b5a
7 changed files with 26 additions and 11 deletions

View File

@@ -79,7 +79,7 @@ void Battle::CheckChoicesSetAndRun() {
this->_currentTurnQueue = std::make_unique<ChoiceQueue>(choices);
TriggerEventListener<TurnStartEvent>();
try {
TurnHandler::RunTurn(this->_currentTurnQueue);
TurnHandler::RunTurn(this->_currentTurnQueue, this);
} catch (const ArbUt::Exception& e) {
throw e;
} catch (const std::exception& e) {
@@ -133,7 +133,7 @@ void Battle::ValidateBattleState() {
auto side = _sides[i];
if (side->HasFled()) {
this->_battleResult = BattleResult::Inconclusive();
this->_hasEnded = true;
EndBattle();
return;
}
if (!side->IsDefeated()) {
@@ -146,11 +146,11 @@ void Battle::ValidateBattleState() {
}
if (!survivingSideExists) {
this->_battleResult = BattleResult::Inconclusive();
this->_hasEnded = true;
EndBattle();
return;
}
this->_battleResult = BattleResult::Conclusive(winningSide);
this->_hasEnded = true;
EndBattle();
}
void Battle::AddVolatileScript(const ArbUt::StringView& key) {
auto script = _volatile.Get(key);