diff --git a/AI/FuzzyLite/fuzzylite/fl/norm/SNorm.h b/AI/FuzzyLite/fuzzylite/fl/norm/SNorm.h index 235035d17..a281f526e 100644 --- a/AI/FuzzyLite/fuzzylite/fl/norm/SNorm.h +++ b/AI/FuzzyLite/fuzzylite/fl/norm/SNorm.h @@ -40,7 +40,7 @@ namespace fl { FL_DEFAULT_COPY_AND_MOVE(SNorm) - virtual SNorm* clone() const = 0; + virtual SNorm* clone() const FL_IOVERRIDE = 0; }; } #endif /* FL_SNORM_H */ diff --git a/AI/FuzzyLite/fuzzylite/fl/norm/TNorm.h b/AI/FuzzyLite/fuzzylite/fl/norm/TNorm.h index 790f10f2e..8ba8538d3 100644 --- a/AI/FuzzyLite/fuzzylite/fl/norm/TNorm.h +++ b/AI/FuzzyLite/fuzzylite/fl/norm/TNorm.h @@ -40,7 +40,7 @@ namespace fl { FL_DEFAULT_COPY_AND_MOVE(TNorm) - virtual TNorm* clone() const = 0; + virtual TNorm* clone() const FL_IOVERRIDE = 0; }; } #endif /* TNORM_H */ diff --git a/CMakeLists.txt b/CMakeLists.txt index 1624418ec..ac53967e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,13 +105,10 @@ if(NOT WIN32) if(HAVE_RT_LIB) set(SYSTEM_LIBS ${SYSTEM_LIBS} rt) endif() - - CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_DL_LIB) - if(HAVE_DL_LIB) - set(SYSTEM_LIBS ${SYSTEM_LIBS} dl) - endif() endif() +set(SYSTEM_LIBS ${SYSTEM_LIBS} ${CMAKE_DL_LIBS}) + set(FFmpeg_FIND_COMPONENTS AVFORMAT SWSCALE) find_package(Boost 1.48.0 COMPONENTS filesystem locale program_options system thread REQUIRED) find_package(ZLIB REQUIRED) diff --git a/client/battle/CBattleInterface.cpp b/client/battle/CBattleInterface.cpp index 85e7ee537..7e89444da 100644 --- a/client/battle/CBattleInterface.cpp +++ b/client/battle/CBattleInterface.cpp @@ -2153,9 +2153,9 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType) case WALK_AND_ATTACK: case ATTACK_AND_RETURN: { - if (shere && !ourStack && shere->alive()) + if (curInt->cb->battleCanAttack(sactive, shere, myNumber)) { - if (isTileAttackable(myNumber)) + if (isTileAttackable(myNumber)) // move isTileAttackable to be part of battleCanAttack? { setBattleCursor(myNumber); // temporary - needed for following function :( BattleHex attackFromHex = fromWhichHexAttack(myNumber); diff --git a/lib/CBattleCallback.cpp b/lib/CBattleCallback.cpp index 03dfe0dc5..0948c4a85 100644 --- a/lib/CBattleCallback.cpp +++ b/lib/CBattleCallback.cpp @@ -775,6 +775,29 @@ std::vector CBattleInfoCallback::battleGetAvailableHexes(const CStack return ret; } +bool CBattleInfoCallback::battleCanAttack(const CStack * stack, const CStack * target, BattleHex dest) const +{ + RETURN_IF_NOT_BATTLE(false); + + if(battleTacticDist()) + return false; + + if (!stack || !target) + return false; + + if (stack->owner == target->owner) + return false; + + auto &id = stack->getCreature()->idNumber; + if (id == CreatureID::FIRST_AID_TENT || id == CreatureID::CATAPULT) + return false; + + if (!target->alive()) + return false; + + return true; +} + bool CBattleInfoCallback::battleCanShoot(const CStack * stack, BattleHex dest) const { RETURN_IF_NOT_BATTLE(false); diff --git a/lib/CBattleCallback.h b/lib/CBattleCallback.h index de1bed9f6..62e6eb160 100644 --- a/lib/CBattleCallback.h +++ b/lib/CBattleCallback.h @@ -252,6 +252,8 @@ public: int battleGetSurrenderCost(PlayerColor Player) const; //returns cost of surrendering battle, -1 if surrendering is not possible ReachabilityInfo::TDistances battleGetDistances(const CStack * stack, BattleHex hex = BattleHex::INVALID, BattleHex * predecessors = nullptr) const; //returns vector of distances to [dest hex number] std::set battleGetAttackedHexes(const CStack* attacker, BattleHex destinationTile, BattleHex attackerPos = BattleHex::INVALID) const; + + bool battleCanAttack(const CStack * stack, const CStack * target, BattleHex dest) const; //determines if stack with given ID can attack target at the selected destination bool battleCanShoot(const CStack * stack, BattleHex dest) const; //determines if stack with given ID shoot at the selected destination bool battleIsStackBlocked(const CStack * stack) const; //returns true if there is neighboring enemy stack std::set batteAdjacentCreatures (const CStack * stack) const; diff --git a/lib/CCreatureSet.cpp b/lib/CCreatureSet.cpp index c42fb5c22..954669e7a 100644 --- a/lib/CCreatureSet.cpp +++ b/lib/CCreatureSet.cpp @@ -712,7 +712,7 @@ void CCommanderInstance::setAlive (bool Alive) alive = Alive; if (!alive) { - getBonusList().remove_if (Bonus::UntilCommanderKilled); + popBonuses(Bonus::UntilCommanderKilled); } } diff --git a/lib/HeroBonus.cpp b/lib/HeroBonus.cpp index fffe8bafe..43ce5b0d4 100644 --- a/lib/HeroBonus.cpp +++ b/lib/HeroBonus.cpp @@ -273,13 +273,13 @@ void BonusList::push_back(Bonus* const &x) bonuses.push_back(x); if (belongsToTree) - CBonusSystemNode::incrementTreeChangedNum(); + CBonusSystemNode::treeHasChanged(); } std::vector::iterator BonusList::erase(const int position) { if (belongsToTree) - CBonusSystemNode::incrementTreeChangedNum(); + CBonusSystemNode::treeHasChanged(); return bonuses.erase(bonuses.begin() + position); } @@ -288,7 +288,7 @@ void BonusList::clear() bonuses.clear(); if (belongsToTree) - CBonusSystemNode::incrementTreeChangedNum(); + CBonusSystemNode::treeHasChanged(); } std::vector::size_type BonusList::operator-=(Bonus* const &i) @@ -299,7 +299,7 @@ std::vector::size_type BonusList::operator-=(Bonus* const &i) bonuses.erase(itr); if (belongsToTree) - CBonusSystemNode::incrementTreeChangedNum(); + CBonusSystemNode::treeHasChanged(); return true; } @@ -308,7 +308,7 @@ void BonusList::resize(std::vector::size_type sz, Bonus* c ) bonuses.resize(sz, c); if (belongsToTree) - CBonusSystemNode::incrementTreeChangedNum(); + CBonusSystemNode::treeHasChanged(); } void BonusList::insert(std::vector::iterator position, std::vector::size_type n, Bonus* const &x) @@ -316,7 +316,7 @@ void BonusList::insert(std::vector::iterator position, std::vectornewChildAttached(this); - CBonusSystemNode::treeChanged++; + CBonusSystemNode::treeHasChanged(); } void CBonusSystemNode::detachFrom(CBonusSystemNode *parent) @@ -768,7 +768,7 @@ void CBonusSystemNode::detachFrom(CBonusSystemNode *parent) parents -= parent; parent->childDetached(this); - CBonusSystemNode::treeChanged++; + CBonusSystemNode::treeHasChanged(); } void CBonusSystemNode::popBonuses(const CSelector &s) @@ -792,7 +792,7 @@ void CBonusSystemNode::addNewBonus(Bonus *b) assert(!vstd::contains(exportedBonuses,b)); exportedBonuses.push_back(b); exportBonus(b); - CBonusSystemNode::treeChanged++; + CBonusSystemNode::treeHasChanged(); } void CBonusSystemNode::accumulateBonus(Bonus &b) @@ -812,7 +812,7 @@ void CBonusSystemNode::removeBonus(Bonus *b) else bonuses -= b; vstd::clear_pointer(b); - CBonusSystemNode::treeChanged++; + CBonusSystemNode::treeHasChanged(); } bool CBonusSystemNode::actsAsBonusSourceOnly() const @@ -995,7 +995,7 @@ void CBonusSystemNode::exportBonus(Bonus * b) else bonuses.push_back(b); - CBonusSystemNode::treeChanged++; + CBonusSystemNode::treeHasChanged(); } void CBonusSystemNode::exportBonuses() @@ -1049,11 +1049,6 @@ void CBonusSystemNode::setDescription(const std::string &description) this->description = description; } -void CBonusSystemNode::incrementTreeChangedNum() -{ - treeChanged++; -} - void CBonusSystemNode::limitBonuses(const BonusList &allBonuses, BonusList &out) const { assert(&allBonuses != &out); //todo should it work in-place? diff --git a/lib/HeroBonus.h b/lib/HeroBonus.h index 962563a2e..6c194173f 100644 --- a/lib/HeroBonus.h +++ b/lib/HeroBonus.h @@ -683,7 +683,6 @@ public: void exportBonus(Bonus * b); void exportBonuses(); - static void incrementTreeChangedNum(); BonusList &getBonusList(); const BonusList &getBonusList() const; BonusList &getExportedBonusList(); @@ -981,7 +980,7 @@ void BonusList::insert(const int position, InputIterator first, InputIterator la bonuses.insert(bonuses.begin() + position, first, last); if (belongsToTree) - CBonusSystemNode::incrementTreeChangedNum(); + CBonusSystemNode::treeHasChanged(); } // Extensions for BOOST_FOREACH to enable iterating of BonusList objects diff --git a/lib/NetPacksLib.cpp b/lib/NetPacksLib.cpp index 1031432ad..9483cac51 100644 --- a/lib/NetPacksLib.cpp +++ b/lib/NetPacksLib.cpp @@ -1175,7 +1175,7 @@ void BattleResult::applyGs( CGameState *gs ) { if(auto h = gs->curB->battleGetFightingHero(i)) { - h->getBonusList().remove_if(Bonus::OneBattle); //remove any "until next battle" bonuses + h->popBonuses(Bonus::OneBattle); //remove any "until next battle" bonuses if (h->commander && h->commander->alive) { for (auto art : h->commander->artifactsWorn) //increment bonuses for commander artifacts