From c4e2417326416d1294cbe136c14af1a898622b90 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Fri, 8 Sep 2023 16:35:43 +0300 Subject: [PATCH] Fix crash on obstacle creation (e.g. moat) --- lib/battle/CBattleInfoCallback.cpp | 1 + lib/spells/effects/Moat.cpp | 1 + lib/spells/effects/Obstacle.cpp | 1 + lib/spells/effects/RemoveObstacle.cpp | 1 + 4 files changed, 4 insertions(+) diff --git a/lib/battle/CBattleInfoCallback.cpp b/lib/battle/CBattleInfoCallback.cpp index 5655c017d..c8714652d 100644 --- a/lib/battle/CBattleInfoCallback.cpp +++ b/lib/battle/CBattleInfoCallback.cpp @@ -874,6 +874,7 @@ bool CBattleInfoCallback::handleObstacleTriggersForUnit(SpellCastEnvironment & s changedObstacle.revealed = true; BattleObstaclesChanged bocp; + bocp.battleID = getBattle()->getBattleID(); bocp.changes.emplace_back(spellObstacle.uniqueID, operation); changedObstacle.toInfo(bocp.changes.back(), operation); spellEnv.apply(&bocp); diff --git a/lib/spells/effects/Moat.cpp b/lib/spells/effects/Moat.cpp index 0c8a6c93c..bb80b9d08 100644 --- a/lib/spells/effects/Moat.cpp +++ b/lib/spells/effects/Moat.cpp @@ -128,6 +128,7 @@ void Moat::placeObstacles(ServerCallback * server, const Mechanics * m, const Ef assert(m->casterSide == BattleSide::DEFENDER); // Moats are always cast by defender BattleObstaclesChanged pack; + pack.battleID = m->battle()->getBattle()->getBattleID(); auto all = m->battle()->battleGetAllObstacles(BattlePerspective::ALL_KNOWING); diff --git a/lib/spells/effects/Obstacle.cpp b/lib/spells/effects/Obstacle.cpp index 720bc1fa0..731bb736c 100644 --- a/lib/spells/effects/Obstacle.cpp +++ b/lib/spells/effects/Obstacle.cpp @@ -270,6 +270,7 @@ void Obstacle::placeObstacles(ServerCallback * server, const Mechanics * m, cons const ObstacleSideOptions & options = sideOptions.at(m->casterSide); BattleObstaclesChanged pack; + pack.battleID = m->battle()->getBattle()->getBattleID(); auto all = m->battle()->battleGetAllObstacles(BattlePerspective::ALL_KNOWING); diff --git a/lib/spells/effects/RemoveObstacle.cpp b/lib/spells/effects/RemoveObstacle.cpp index 112435dcb..10c5ca57f 100644 --- a/lib/spells/effects/RemoveObstacle.cpp +++ b/lib/spells/effects/RemoveObstacle.cpp @@ -44,6 +44,7 @@ bool RemoveObstacle::applicable(Problem & problem, const Mechanics * m, const Ef void RemoveObstacle::apply(ServerCallback * server, const Mechanics * m, const EffectTarget & target) const { BattleObstaclesChanged pack; + pack.battleID = m->battle()->getBattle()->getBattleID(); for(const auto & obstacle : getTargets(m, target, false)) {