mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
CGameHandler: do not open-code toInfo
There is an obstacle function which is doing exactly this.
This commit is contained in:
parent
f704a17e1a
commit
53a6fb2836
@ -5247,27 +5247,20 @@ bool CGameHandler::handleDamageFromObstacle(const CStack * curStack, bool stackI
|
||||
|
||||
if(spellObstacle->triggersEffects())
|
||||
{
|
||||
const bool oneTimeObstacle = spellObstacle->removeOnTrigger;
|
||||
auto revealObstacles = [&](const SpellCreatedObstacle & spellObstacle) -> void
|
||||
{
|
||||
// For the hidden spell created obstacles, e.g. QuickSand, it should be revealed after taking damage
|
||||
ObstacleChanges changeInfo;
|
||||
changeInfo.id = spellObstacle.uniqueID;
|
||||
if (oneTimeObstacle)
|
||||
changeInfo.operation = ObstacleChanges::EOperation::REMOVE;
|
||||
else
|
||||
changeInfo.operation = ObstacleChanges::EOperation::UPDATE;
|
||||
auto operation = ObstacleChanges::EOperation::UPDATE;
|
||||
if (spellObstacle.removeOnTrigger)
|
||||
operation = ObstacleChanges::EOperation::REMOVE;
|
||||
|
||||
SpellCreatedObstacle changedObstacle;
|
||||
changedObstacle.uniqueID = changeInfo.id;
|
||||
changedObstacle.uniqueID = spellObstacle.uniqueID;
|
||||
changedObstacle.revealed = true;
|
||||
|
||||
changeInfo.data.clear();
|
||||
JsonSerializer ser(nullptr, changeInfo.data);
|
||||
ser.serializeStruct("obstacle", changedObstacle);
|
||||
|
||||
BattleObstaclesChanged bocp;
|
||||
bocp.changes.emplace_back(changeInfo);
|
||||
bocp.changes.emplace_back(spellObstacle.uniqueID, operation);
|
||||
changedObstacle.toInfo(bocp.changes.back(), operation);
|
||||
sendAndApply(&bocp);
|
||||
};
|
||||
auto shouldReveal = !spellObstacle->hidden || !gs->curB->battleIsObstacleVisibleForSide(*obstacle, (BattlePerspective::BattlePerspective)side);
|
||||
|
Loading…
Reference in New Issue
Block a user