1
0
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:
Ivan Savenko 2023-09-11 15:56:33 +03:00 committed by GitHub
commit f13f213d8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 0 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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))
{