Explorar el Código

Fix crash on obstacle creation (e.g. moat)

Ivan Savenko hace 2 años
padre
commit
c4e2417326

+ 1 - 0
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);

+ 1 - 0
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);
 

+ 1 - 0
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);
 

+ 1 - 0
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))
 	{