mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Merge pull request #2780 from IvanSavenko/fix_siege_regression
Fix crash on obstacle creation (e.g. moat)
This commit is contained in:
commit
f13f213d8c
@ -395,6 +395,7 @@ void CStack::spendMana(ServerCallback * server, const int spellCost) const
|
||||
logGlobal->warn("Unexpected spell cost %d for creature", spellCost);
|
||||
|
||||
BattleSetStackProperty ssp;
|
||||
ssp.battleID = battle->battleID;
|
||||
ssp.stackID = unitId();
|
||||
ssp.which = BattleSetStackProperty::CASTS;
|
||||
ssp.val = -spellCost;
|
||||
|
@ -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);
|
||||
|
@ -116,6 +116,7 @@ void Moat::apply(ServerCallback * server, const Mechanics * m, const EffectTarge
|
||||
for(auto & b : converted)
|
||||
{
|
||||
GiveBonus gb(GiveBonus::ETarget::BATTLE);
|
||||
gb.id = m->battle()->getBattle()->getBattleID().getNum();
|
||||
gb.bonus = b;
|
||||
server->apply(&gb);
|
||||
}
|
||||
@ -128,6 +129,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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user