From 7618e294c270fd4013ccf0ad7c2fff92cb6c6a59 Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Sat, 24 Sep 2016 04:55:48 +0300 Subject: [PATCH] More fixes to not place obstacles on wall parts --- lib/CBattleCallback.cpp | 3 ++- lib/spells/BattleSpellMechanics.cpp | 16 ++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/CBattleCallback.cpp b/lib/CBattleCallback.cpp index b2a915a4c..8ddc1d3ed 100644 --- a/lib/CBattleCallback.cpp +++ b/lib/CBattleCallback.cpp @@ -70,7 +70,8 @@ namespace SiegeStuffThatShouldBeMovedToHandlers // <=== TODO std::make_pair(45, EWallPart::INDESTRUCTIBLE_PART), std::make_pair(62, EWallPart::INDESTRUCTIBLE_PART), std::make_pair(112, EWallPart::INDESTRUCTIBLE_PART), - std::make_pair(147, EWallPart::INDESTRUCTIBLE_PART) + std::make_pair(147, EWallPart::INDESTRUCTIBLE_PART), + std::make_pair(165, EWallPart::INDESTRUCTIBLE_PART) }; static EWallPart::EWallPart hexToWallPart(BattleHex hex) diff --git a/lib/spells/BattleSpellMechanics.cpp b/lib/spells/BattleSpellMechanics.cpp index 3cac1b245..fc0618476 100644 --- a/lib/spells/BattleSpellMechanics.cpp +++ b/lib/spells/BattleSpellMechanics.cpp @@ -430,14 +430,14 @@ bool ObstacleMechanics::isHexAviable(const CBattleInfoCallback * cb, const Battl { EWallPart::EWallPart part = cb->battleHexToWallPart(hex); - if(part != EWallPart::INVALID) - { - if(static_cast(part) < 0) - return false;//indestuctible part, cant be checked by battleGetWallState - - if(cb->battleGetWallState(part) != EWallState::DESTROYED && cb->battleGetWallState(part) != EWallState::NONE) - return false; - } + if(part == EWallPart::INVALID) + return true;//no fortification here + else if(static_cast(part) < 0) + return false;//indestuctible part (cant be checked by battleGetWallState) + else if(part == EWallPart::BOTTOM_TOWER || part == EWallPart::UPPER_TOWER) + return false;//destructible, but should not be available + else if(cb->battleGetWallState(part) != EWallState::DESTROYED && cb->battleGetWallState(part) != EWallState::NONE) + return false; } return true;